FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
udp_encap.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __UDP_ENCAP_H__
17 #define __UDP_ENCAP_H__
18 
19 #include <vnet/ip/ip.h>
20 #include <vnet/udp/udp_packet.h>
21 #include <vnet/fib/fib_node.h>
22 
23 /**
24  * UDP encapsulation.
25  * A representation of the encapsulation of packets in UDP-over-IP.
26  * This is encapsulation only, there is no tunnel interface, hence
27  * it is uni-directional. For decap register a handler with the UDP port
28  * dispatcher.
29  */
30 
31 /**
32  * Fixup behaviour. Actions performed on the encap in the data-plane
33  */
35 {
37  /**
38  * UDP source port contains an entropy/hash value for load-balancing by downstream peers.
39  */
42 
43 /**
44  * The UDP encap representation
45  */
46 typedef struct udp_encap_t_
47 {
48  /**
49  * The first cacheline contains the data used in the data-plane
50  */
51  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
52 
53  /**
54  * The headers to paint, in packet painting order
55  */
56  union
57  {
58  struct
59  {
62  } __attribute__ ((packed)) ip4;
63  struct
64  {
67  } __attribute__ ((packed)) ip6;
68  } __attribute__ ((packed)) ue_hdrs;
69 
70  /**
71  * The DPO used to forward to the next node in the VLIB graph
72  */
74 
75  /**
76  * Flags controlling fixup behaviour
77  */
79 
80  /**
81  * the protocol of the IP header imposed
82  */
84 
85  /**
86  * The second cacheline contains control-plane data
87  */
88  CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
89 
90  /**
91  * linkage into the FIB graph
92  */
94 
95  /**
96  * Tracking information for the IP destination
97  */
100 
101  /**
102  * The FIB index in which the encap destination resides
103  */
105 } udp_encap_t;
106 
108  index_t fib_index,
109  const ip46_address_t * src_ip,
110  const ip46_address_t * dst_ip,
111  u16 src_port,
112  u16 dst_port,
114 
115 extern void udp_encap_lock (index_t uei);
116 extern void udp_encap_unlock (index_t uei);
117 extern u8 *format_udp_encap (u8 * s, va_list * args);
120  dpo_id_t * dpo);
121 
122 extern void udp_encap_get_stats (index_t uei, u64 * packets, u64 * bytes);
123 
124 /**
125  * Callback function invoked when walking all encap objects.
126  * Return non-zero to continue the walk.
127  */
128 typedef walk_rc_t (*udp_encap_walk_cb_t) (index_t uei, void *ctx);
129 
130 /**
131  * Walk each of the encap objects
132  */
133 extern void udp_encap_walk (udp_encap_walk_cb_t cb, void *ctx);
134 
135 /**
136  * Pool of encaps
137  */
139 
140 static inline udp_encap_t *
142 {
143  return (pool_elt_at_index (udp_encap_pool, uei));
144 }
145 
146 /*
147  * fd.io coding-style-patch-verification: ON
148  *
149  * Local Variables:
150  * eval: (c-set-style "gnu")
151  * End:
152  */
153 
154 #endif
udp_encap_t_::ue_ip4
ip4_header_t ue_ip4
Definition: udp_encap.h:60
dst_port
vl_api_ip_port_and_mask_t dst_port
Definition: flow_types.api:92
udp_encap_t_::ue_fib_index
index_t ue_fib_index
The FIB index in which the encap destination resides.
Definition: udp_encap.h:104
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
udp_encap_unlock
void udp_encap_unlock(index_t uei)
Definition: udp_encap.c:162
udp_encap_walk_cb_t
walk_rc_t(* udp_encap_walk_cb_t)(index_t uei, void *ctx)
Callback function invoked when walking all encap objects.
Definition: udp_encap.h:128
u16
unsigned short u16
Definition: types.h:57
udp_encap_t_::ip4
struct udp_encap_t_::@565::@566 ip4
udp_encap_t_::ip6
struct udp_encap_t_::@565::@567 ip6
udp_encap_t_::ue_udp
udp_header_t ue_udp
Definition: udp_encap.h:61
udp_encap_t_
The UDP encap representation.
Definition: udp_encap.h:46
fib_node.h
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
udp_encap_get_stats
void udp_encap_get_stats(index_t uei, u64 *packets, u64 *bytes)
Definition: udp_encap.c:247
udp_encap_t_::ue_flags
udp_encap_fixup_flags_t ue_flags
Flags controlling fixup behaviour.
Definition: udp_encap.h:78
dst_ip
vl_api_address_t dst_ip
Definition: udp.api:44
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
UDP_ENCAP_FIXUP_UDP_SRC_PORT_ENTROPY
@ UDP_ENCAP_FIXUP_UDP_SRC_PORT_ENTROPY
UDP source port contains an entropy/hash value for load-balancing by downstream peers.
Definition: udp_encap.h:40
udp_packet.h
format_udp_encap
u8 * format_udp_encap(u8 *s, va_list *args)
Definition: udp_encap.c:267
udp_encap_fixup_flags_t
enum udp_encap_fixup_flags_t_ udp_encap_fixup_flags_t
UDP encapsulation.
src_port
vl_api_ip_port_and_mask_t src_port
Definition: flow_types.api:91
udp_encap_t_::CLIB_CACHE_LINE_ALIGN_MARK
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
The first cacheline contains the data used in the data-plane.
UDP_ENCAP_FIXUP_NONE
@ UDP_ENCAP_FIXUP_NONE
Definition: udp_encap.h:36
udp_encap_get
static udp_encap_t * udp_encap_get(index_t uei)
Definition: udp_encap.h:141
udp_encap_t
struct udp_encap_t_ udp_encap_t
The UDP encap representation.
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
udp_encap_t_::ue_ip_proto
fib_protocol_t ue_ip_proto
the protocol of the IP header imposed
Definition: udp_encap.h:83
udp_encap_t_::ue_fib_sibling
u32 ue_fib_sibling
Definition: udp_encap.h:99
udp_encap_fixup_flags_t_
udp_encap_fixup_flags_t_
UDP encapsulation.
Definition: udp_encap.h:34
udp_encap_t_::ue_fib_entry_index
fib_node_index_t ue_fib_entry_index
Tracking information for the IP destination.
Definition: udp_encap.h:98
udp_encap_pool
udp_encap_t * udp_encap_pool
Pool of encaps.
Definition: udp_encap.c:30
udp_encap_contribute_forwarding
void udp_encap_contribute_forwarding(index_t uei, dpo_proto_t proto, dpo_id_t *dpo)
Definition: udp_encap.c:131
u64
unsigned long u64
Definition: types.h:89
ip.h
u32
unsigned int u32
Definition: types.h:88
udp_encap_add_and_lock
index_t udp_encap_add_and_lock(fib_protocol_t proto, index_t fib_index, const ip46_address_t *src_ip, const ip46_address_t *dst_ip, u16 src_port, u16 dst_port, udp_encap_fixup_flags_t flags)
Definition: udp_encap.c:56
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
udp_encap_t_::ue_dpo
dpo_id_t ue_dpo
The DPO used to forward to the next node in the VLIB graph.
Definition: udp_encap.h:73
src_ip
vl_api_address_t src_ip
Definition: wireguard.api:38
ip6_header_t
Definition: ip6_packet.h:294
udp_encap_t_::ue_fib_node
fib_node_t ue_fib_node
linkage into the FIB graph
Definition: udp_encap.h:93
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
udp_encap_t_::ue_hdrs
union udp_encap_t_::@565 ue_hdrs
The headers to paint, in packet painting order.
udp_encap_walk
void udp_encap_walk(udp_encap_walk_cb_t cb, void *ctx)
Walk each of the encap objects.
Definition: udp_encap.c:506
udp_encap_lock
void udp_encap_lock(index_t uei)
Definition: udp_encap.c:149
u8
unsigned char u8
Definition: types.h:56
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
udp_encap_t_::ue_ip6
ip6_header_t ue_ip6
Definition: udp_encap.h:65
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
packets
units packets
Definition: map.api:366
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105