65 const ip46_address_t * src_ip,
66 const ip46_address_t * dst_ip,
95 ue->
ue_hdrs.
ip4.ue_ip4.ip_version_and_header_length = 0x45;
97 ue->
ue_hdrs.
ip4.ue_ip4.protocol = IP_PROTOCOL_UDP;
98 ue->
ue_hdrs.
ip4.ue_ip4.src_address.as_u32 = src_ip->ip4.as_u32;
99 ue->
ue_hdrs.
ip4.ue_ip4.dst_address.as_u32 = dst_ip->ip4.as_u32;
102 ue->
ue_hdrs.
ip4.ue_udp.src_port = clib_host_to_net_u16 (src_port);
103 ue->
ue_hdrs.
ip4.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
108 ue->
ue_hdrs.
ip6.ue_ip6.ip_version_traffic_class_and_flow_label =
109 clib_host_to_net_u32 (6 << 28);
111 ue->
ue_hdrs.
ip6.ue_ip6.protocol = IP_PROTOCOL_UDP;
112 ue->
ue_hdrs.
ip6.ue_ip6.src_address.as_u64[0] =
113 src_ip->ip6.as_u64[0];
114 ue->
ue_hdrs.
ip6.ue_ip6.src_address.as_u64[1] =
115 src_ip->ip6.as_u64[1];
116 ue->
ue_hdrs.
ip6.ue_ip6.dst_address.as_u64[0] =
117 dst_ip->ip6.as_u64[0];
118 ue->
ue_hdrs.
ip6.ue_ip6.dst_address.as_u64[1] =
119 dst_ip->ip6.as_u64[1];
120 ue->
ue_hdrs.
ip6.ue_udp.src_port = clib_host_to_net_u16 (src_port);
121 ue->
ue_hdrs.
ip6.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
259 u32 indent = va_arg (*args,
u32);
260 u32 details = va_arg (*args,
u32);
266 s =
format (s,
"udp-ecap:[%d]: id:%d ip-fib-index:%d",
270 s =
format (s,
"ip:[src:%U, dst:%U] udp:[src:%d, dst:%d]",
275 clib_net_to_host_u16 (ue->
ue_hdrs.
ip4.ue_udp.src_port),
276 clib_net_to_host_u16 (ue->
ue_hdrs.
ip4.ue_udp.dst_port));
280 s =
format (s,
"ip:[src:%U, dst:%U] udp:[src:%d dst:%d]",
285 clib_net_to_host_u16 (ue->
ue_hdrs.
ip6.ue_udp.src_port),
286 clib_net_to_host_u16 (ue->
ue_hdrs.
ip6.ue_udp.dst_port));
303 u32 indent = va_arg (*args,
u32);
311 u32 id = va_arg (*args,
u32);
312 u32 details = va_arg (*args,
u32);
319 return (
format (s,
"Invalid udp-encap ID: %d",
id));
473 ip46_address_t src_ip, dst_ip;
475 u32 src_port, dst_port;
493 if (
unformat (line_input,
"id %d", &ue_id))
495 else if (
unformat (line_input,
"add"))
497 else if (
unformat (line_input,
"del"))
499 else if (
unformat (line_input,
"%U %U",
503 else if (
unformat (line_input,
"%U %U",
507 else if (
unformat (line_input,
"%d %d", &src_port, &dst_port))
509 else if (
unformat (line_input,
"%d", &dst_port))
511 else if (
unformat (line_input,
"table-id %d", &table_id))
513 else if (
unformat (line_input,
"src-port-is-entropy"))
544 src_port, dst_port, flags);
562 "Some IP addresses would be usefull, don't you think?",
611 .short_help =
"udp encap [add|del] <id ID> <src-ip> <dst-ip> [<src-port>] <dst-port> [src-port-is-entropy] [table-id <table>]",
616 .path =
"show udp encap",
617 .short_help =
"show udp encap [ID]",
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.
#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...
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
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
struct udp_encap_t_::@293::@295 ip6
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[]
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.
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)
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.
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
struct udp_encap_t_::@293::@294 ip4
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[]
union udp_encap_t_::@293 ue_hdrs
The headers to paint, in packet painting order.
static fib_node_t * udp_encap_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
#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.
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)
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[]