42 .stat_segment_name =
"/net/udp-encap",
57 const ip46_address_t *
src_ip,
58 const ip46_address_t *
dst_ip,
82 ue->
ue_hdrs.
ip4.ue_ip4.ip_version_and_header_length = 0x45;
84 ue->
ue_hdrs.
ip4.ue_ip4.protocol = IP_PROTOCOL_UDP;
85 ue->
ue_hdrs.
ip4.ue_ip4.src_address.as_u32 = src_ip->ip4.as_u32;
86 ue->
ue_hdrs.
ip4.ue_ip4.dst_address.as_u32 = dst_ip->ip4.as_u32;
89 ue->
ue_hdrs.
ip4.ue_udp.src_port = clib_host_to_net_u16 (src_port);
90 ue->
ue_hdrs.
ip4.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
95 ue->
ue_hdrs.
ip6.ue_ip6.ip_version_traffic_class_and_flow_label =
96 clib_host_to_net_u32 (6 << 28);
98 ue->
ue_hdrs.
ip6.ue_ip6.protocol = IP_PROTOCOL_UDP;
99 ue->
ue_hdrs.
ip6.ue_ip6.src_address.as_u64[0] = src_ip->ip6.as_u64[0];
100 ue->
ue_hdrs.
ip6.ue_ip6.src_address.as_u64[1] = src_ip->ip6.as_u64[1];
101 ue->
ue_hdrs.
ip6.ue_ip6.dst_address.as_u64[0] = dst_ip->ip6.as_u64[0];
102 ue->
ue_hdrs.
ip6.ue_ip6.dst_address.as_u64[1] = dst_ip->ip6.as_u64[1];
103 ue->
ue_hdrs.
ip6.ue_udp.src_port = clib_host_to_net_u16 (src_port);
104 ue->
ue_hdrs.
ip6.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
206 u32 indent = va_arg (*args,
u32);
207 u32 details = va_arg (*args,
u32);
217 s =
format (s,
"ip:[src:%U, dst:%U] udp:[src:%d, dst:%d]",
222 clib_net_to_host_u16 (ue->
ue_hdrs.
ip4.ue_udp.src_port),
223 clib_net_to_host_u16 (ue->
ue_hdrs.
ip4.ue_udp.dst_port));
227 s =
format (s,
"ip:[src:%U, dst:%U] udp:[src:%d dst:%d]",
232 clib_net_to_host_u16 (ue->
ue_hdrs.
ip6.ue_udp.src_port),
233 clib_net_to_host_u16 (ue->
ue_hdrs.
ip6.ue_udp.dst_port));
264 u32 indent = va_arg (*args,
u32);
273 u32 details = va_arg (*args,
u32);
443 if (
unformat (line_input,
"index %d", &uei))
445 else if (
unformat (line_input,
"add"))
447 else if (
unformat (line_input,
"del"))
449 else if (
unformat (line_input,
"%U %U",
453 else if (
unformat (line_input,
"%U %U",
457 else if (
unformat (line_input,
"%d %d", &src_port, &dst_port))
459 else if (
unformat (line_input,
"%d", &dst_port))
461 else if (
unformat (line_input,
"table-id %d", &table_id))
463 else if (
unformat (line_input,
"src-port-is-entropy"))
487 src_port, dst_port, flags);
562 .short_help =
"udp encap [add|del] <id ID> <src-ip> <dst-ip> [<src-port>] <dst-port> [src-port-is-entropy] [table-id <table>]",
567 .path =
"show udp encap",
568 .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.
Recursive resolution source.
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
void fib_node_init(fib_node_t *node, fib_node_type_t type)
u32 fib_entry_child_add(fib_node_index_t fib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
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)
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 fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
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
union udp_encap_t_::@357 ue_hdrs
The headers to paint, in packet painting order.
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() ...
#define VLIB_INIT_FUNCTION(x)
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
struct udp_encap_t_::@357::@358 ip4
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)
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a 'special' entry to the FIB.
index_t ue_fib_index
The FIB index in which the encap destination resides.
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 fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
void udp_encap_lock(index_t uei)
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.
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
struct udp_encap_t_::@357::@359 ip6
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.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
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[]