70 const ip46_address_t * src_ip,
71 const ip46_address_t * dst_ip,
103 ue->
ue_hdrs.
ip4.ue_ip4.ip_version_and_header_length = 0x45;
105 ue->
ue_hdrs.
ip4.ue_ip4.protocol = IP_PROTOCOL_UDP;
106 ue->
ue_hdrs.
ip4.ue_ip4.src_address.as_u32 = src_ip->ip4.as_u32;
107 ue->
ue_hdrs.
ip4.ue_ip4.dst_address.as_u32 = dst_ip->ip4.as_u32;
110 ue->
ue_hdrs.
ip4.ue_udp.src_port = clib_host_to_net_u16 (src_port);
111 ue->
ue_hdrs.
ip4.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
116 ue->
ue_hdrs.
ip6.ue_ip6.ip_version_traffic_class_and_flow_label =
117 clib_host_to_net_u32 (6 << 28);
119 ue->
ue_hdrs.
ip6.ue_ip6.protocol = IP_PROTOCOL_UDP;
120 ue->
ue_hdrs.
ip6.ue_ip6.src_address.as_u64[0] =
121 src_ip->ip6.as_u64[0];
122 ue->
ue_hdrs.
ip6.ue_ip6.src_address.as_u64[1] =
123 src_ip->ip6.as_u64[1];
124 ue->
ue_hdrs.
ip6.ue_ip6.dst_address.as_u64[0] =
125 dst_ip->ip6.as_u64[0];
126 ue->
ue_hdrs.
ip6.ue_ip6.dst_address.as_u64[1] =
127 dst_ip->ip6.as_u64[1];
128 ue->
ue_hdrs.
ip6.ue_udp.src_port = clib_host_to_net_u16 (src_port);
129 ue->
ue_hdrs.
ip6.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
267 u32 indent = va_arg (*args,
u32);
268 u32 details = va_arg (*args,
u32);
275 s =
format (s,
"udp-ecap:[%d]: id:%d ip-fib-index:%d ",
279 s =
format (s,
"ip:[src:%U, dst:%U] udp:[src:%d, dst:%d]",
284 clib_net_to_host_u16 (ue->
ue_hdrs.
ip4.ue_udp.src_port),
285 clib_net_to_host_u16 (ue->
ue_hdrs.
ip4.ue_udp.dst_port));
289 s =
format (s,
"ip:[src:%U, dst:%U] udp:[src:%d dst:%d]",
294 clib_net_to_host_u16 (ue->
ue_hdrs.
ip6.ue_udp.src_port),
295 clib_net_to_host_u16 (ue->
ue_hdrs.
ip6.ue_udp.dst_port));
326 u32 indent = va_arg (*args,
u32);
334 u32 id = va_arg (*args,
u32);
335 u32 details = va_arg (*args,
u32);
342 return (
format (s,
"Invalid udp-encap ID: %d",
id));
496 ip46_address_t src_ip, dst_ip;
498 u32 src_port, dst_port;
516 if (
unformat (line_input,
"id %d", &ue_id))
518 else if (
unformat (line_input,
"add"))
520 else if (
unformat (line_input,
"del"))
522 else if (
unformat (line_input,
"%U %U",
526 else if (
unformat (line_input,
"%U %U",
530 else if (
unformat (line_input,
"%d %d", &src_port, &dst_port))
532 else if (
unformat (line_input,
"%d", &dst_port))
534 else if (
unformat (line_input,
"table-id %d", &table_id))
536 else if (
unformat (line_input,
"src-port-is-entropy"))
567 src_port, dst_port, flags);
585 "Some IP addresses would be usefull, don't you think?",
648 .short_help =
"udp encap [add|del] <id ID> <src-ip> <dst-ip> [<src-port>] <dst-port> [src-port-is-entropy] [table-id <table>]",
653 .path =
"show udp encap",
654 .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.
#define hash_set(h, key, value)
dpo_type_t udp_encap_dpo_types[FIB_PROTOCOL_MAX]
Registered DPO types for the IP header encapsulated, v4 or v6.
The UDP encap represenation.
A virtual function table regisitered for a DPO type.
udp_encap_t * udp_encap_pool
Pool of encaps.
vlib_combined_counter_main_t udp_encap_counters
Stats for each UDP encap object.
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
#define hash_unset(h, key)
index_t udp_encap_find(u32 id)
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)
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.
static udp_encap_t * udp_encap_get_w_id(u32 id)
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
void udp_encap_lock(u32 id)
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.
union udp_encap_t_::@330 ue_hdrs
The headers to paint, in packet painting order.
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.
uword * udp_encap_db
Hash DB to map from client ID to VPP index.
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
u32 ue_id
The ID given by the user/client.
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 pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
Aggregrate 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.
void udp_encap_unlock(u32 id)
static const char *const *const udp4_encap_nodes[DPO_PROTO_NUM]
enum udp_encap_fixup_flags_t_ udp_encap_fixup_flags_t
UDP encapsualtion.
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[]
int(* udp_encap_walk_cb_t)(index_t uei, void *ctx)
Callback function invoked when walking all encap objects.
index_t udp_encap_add_and_lock(u32 id, 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)
#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[]
struct udp_encap_t_::@330::@332 ip6
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 (general version).
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.
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,...)
#define hash_create(elts, value_bytes)
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
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[]
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.
struct udp_encap_t_::@330::@331 ip4
void udp_encap_unlock_w_index(index_t uei)
clib_error_t * udp_encap_cli(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmd)
#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)
void udp_encap_contribute_forwarding(u32 id, dpo_proto_t proto, dpo_id_t *dpo)
static udp_encap_t * udp_encap_get(index_t uei)
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[]