43 .stat_segment_name =
"/net/udp-encap",
58 const ip46_address_t *
src_ip,
59 const ip46_address_t *
dst_ip,
83 ue->
ue_hdrs.
ip4.ue_ip4.ip_version_and_header_length = 0x45;
85 ue->
ue_hdrs.
ip4.ue_ip4.protocol = IP_PROTOCOL_UDP;
86 ue->
ue_hdrs.
ip4.ue_ip4.src_address.as_u32 = src_ip->ip4.as_u32;
87 ue->
ue_hdrs.
ip4.ue_ip4.dst_address.as_u32 = dst_ip->ip4.as_u32;
90 ue->
ue_hdrs.
ip4.ue_udp.src_port = clib_host_to_net_u16 (src_port);
91 ue->
ue_hdrs.
ip4.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
96 ue->
ue_hdrs.
ip6.ue_ip6.ip_version_traffic_class_and_flow_label =
97 clib_host_to_net_u32 (6 << 28);
99 ue->
ue_hdrs.
ip6.ue_ip6.protocol = IP_PROTOCOL_UDP;
100 ue->
ue_hdrs.
ip6.ue_ip6.src_address.as_u64[0] = src_ip->ip6.as_u64[0];
101 ue->
ue_hdrs.
ip6.ue_ip6.src_address.as_u64[1] = src_ip->ip6.as_u64[1];
102 ue->
ue_hdrs.
ip6.ue_ip6.dst_address.as_u64[0] = dst_ip->ip6.as_u64[0];
103 ue->
ue_hdrs.
ip6.ue_ip6.dst_address.as_u64[1] = dst_ip->ip6.as_u64[1];
104 ue->
ue_hdrs.
ip6.ue_udp.src_port = clib_host_to_net_u16 (src_port);
105 ue->
ue_hdrs.
ip6.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
203 u32 indent = va_arg (*args,
u32);
204 u32 details = va_arg (*args,
u32);
214 s =
format (s,
"ip:[src:%U, dst:%U] udp:[src:%d, dst:%d]",
219 clib_net_to_host_u16 (ue->
ue_hdrs.
ip4.ue_udp.src_port),
220 clib_net_to_host_u16 (ue->
ue_hdrs.
ip4.ue_udp.dst_port));
224 s =
format (s,
"ip:[src:%U, dst:%U] udp:[src:%d dst:%d]",
229 clib_net_to_host_u16 (ue->
ue_hdrs.
ip6.ue_udp.src_port),
230 clib_net_to_host_u16 (ue->
ue_hdrs.
ip6.ue_udp.dst_port));
261 u32 indent = va_arg (*args,
u32);
270 u32 details = va_arg (*args,
u32);
438 if (
unformat (line_input,
"index %d", &uei))
440 else if (
unformat (line_input,
"add"))
442 else if (
unformat (line_input,
"del"))
444 else if (
unformat (line_input,
"%U %U",
448 else if (
unformat (line_input,
"%U %U",
452 else if (
unformat (line_input,
"%d %d", &src_port, &dst_port))
454 else if (
unformat (line_input,
"%d", &dst_port))
456 else if (
unformat (line_input,
"table-id %d", &table_id))
458 else if (
unformat (line_input,
"src-port-is-entropy"))
482 src_port, dst_port, flags);
557 .short_help =
"udp encap [add|del] <id ID> <src-ip> <dst-ip> [<src-port>] <dst-port> [src-port-is-entropy] [table-id <table>]",
562 .path =
"show udp encap",
563 .short_help =
"show udp encap [ID]",
void udp_encap_walk(udp_encap_walk_cb_t cb, void *ctx)
Walk each of the encap objects.
fib_protocol_t ue_ip_proto
the protocol of the IP header imposed
fib_protocol_t fp_proto
protocol type
dpo_lock_fn_t dv_lock
A reference counting lock function.
struct udp_encap_t_::@562::@564 ip6
fib_node_index_t fib_entry_track(u32 fib_index, const fib_prefix_t *prefix, fib_node_type_t child_type, index_t child_index, u32 *sibling)
Trackers are used on FIB entries by objects that which to track the changing state of the entry...
dpo_type_t udp_encap_dpo_types[FIB_PROTOCOL_MAX]
Registered DPO types for the IP header encapsulated, v4 or v6.
The UDP encap representation.
A virtual function table regisitered for a DPO type.
udp_encap_t * udp_encap_pool
Pool of encaps.
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
vl_api_wireguard_peer_flags_t flags
void fib_node_init(fib_node_t *node, fib_node_type_t type)
static u8 * format_udp_encap_i(u8 *s, va_list *args)
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)
vl_api_ip_port_and_mask_t dst_port
static const char *const udp6_encap_mpls_nodes[]
fib_node_index_t ue_fib_entry_index
Tracking information for the IP destination.
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
static void udp_encap_dpo_lock(dpo_id_t *dpo)
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Combined counter to hold both packets and byte differences.
dpo_id_t ue_dpo
The DPO used to forward to the next node in the VLIB graph.
#define STRUCT_OFFSET_OF(t, f)
clib_error_t * udp_encap_init(vlib_main_t *vm)
fib_node_t ue_fib_node
linkage into the FIB graph
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
union udp_encap_t_::@562 ue_hdrs
The headers to paint, in packet painting order.
#define VLIB_INIT_FUNCTION(x)
Aggregate type for a prefix.
#define clib_error_return(e, args...)
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
static const char *const *const udp4_encap_nodes[DPO_PROTO_NUM]
enum udp_encap_fixup_flags_t_ udp_encap_fixup_flags_t
UDP encapsulation.
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
static const char *const udp6_encap_ip6_nodes[]
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
counter_t packets
packet counter
UDP source port contains an entropy/hash value for load-balancing by downstream peers.
clib_error_t * udp_encap_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void fib_node_lock(fib_node_t *node)
static void udp_encap_dpo_unlock(dpo_id_t *dpo)
u8 * format_udp_encap(u8 *s, va_list *args)
#define pool_put(P, E)
Free an object E in pool P.
static void udp_encap_restack(udp_encap_t *ue)
static const char *const udp4_encap_bier_nodes[]
fib_node_type_t fn_type
The node's type.
An node in the FIB graph.
void fib_node_unlock(fib_node_t *node)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
static u8 * format_udp_encap_dpo(u8 *s, va_list *args)
index_t ue_fib_index
The FIB index in which the encap destination resides.
vl_api_ip_port_and_mask_t src_port
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
void udp_encap_lock(index_t uei)
struct udp_encap_t_::@562::@563 ip4
u32 fib_node_index_t
A typedef of a node index.
static fib_node_back_walk_rc_t udp_encap_fib_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Function definition to backwalk a FIB node.
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
vlib_main_t vlib_node_runtime_t * node
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
void fib_entry_untrack(fib_node_index_t fei, u32 sibling)
Stop tracking a FIB entry.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static const char *const udp6_encap_bier_nodes[]
static const char *const udp4_encap_ip4_nodes[]
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject.
void udp_encap_get_stats(index_t uei, u64 *packets, u64 *bytes)
counter_t bytes
byte counter
static udp_encap_t * udp_encap_from_fib_node(fib_node_t *node)
index_t dpoi_index
the index of objects of that type
walk_rc_t(* udp_encap_walk_cb_t)(index_t uei, void *ctx)
Callback function invoked when walking all encap objects.
u32 fn_locks
Number of dependents on this node.
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
static const char *const udp4_encap_mpls_nodes[]
char * name
The counter collection's name.
static fib_node_t * udp_encap_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
A collection of combined counters.
#define FIB_PROTOCOL_MAX
Definition outside of enum so it does not need to be included in non-defaulted switch statements...
A FIB graph nodes virtual function table.
static const char *const udp6_encap_ip4_nodes[]
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
udp_encap_fixup_flags_t ue_flags
Flags controlling fixup behaviour.
clib_error_t * udp_encap_cli(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmd)
void udp_encap_unlock(index_t uei)
#define pool_foreach_index(i, v, body)
Iterate pool by index.
#define CLIB_CACHE_LINE_BYTES
static const char *const *const udp6_encap_nodes[DPO_PROTO_NUM]
static void udp_encap_fib_last_lock_gone(fib_node_t *node)
Function definition to inform the FIB node that its last lock has gone.
static u16 ip4_header_checksum(ip4_header_t *i)
static udp_encap_t * udp_encap_get(index_t uei)
void udp_encap_contribute_forwarding(index_t uei, dpo_proto_t proto, dpo_id_t *dpo)
void dpo_stack(dpo_type_t child_type, dpo_proto_t child_proto, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child-parent relationship.
static const char *const udp4_encap_ip6_nodes[]