|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
17 #include <arpa/inet.h>
56 m.
as_u64[0] = 0xffffffff00000000;
58 m.
as_u64[0] |= 0x00000000ffffffff;
59 m.
as_u64[1] = 0xffffffff00000000;
61 m.
as_u64[1] |= 0x00000000ffff0000;
63 m.
as_u64[1] |= 0x000000000000ffff;
91 nodename =
"pnat-input";
92 arcname =
"ip4-unicast";
97 nodename =
"pnat-output";
98 arcname =
"ip4-output";
105 if (!interface->enabled[attachment]) {
124 interface->lookup_mask[attachment] =
mask;
126 interface->enabled[attachment] =
true;
129 pnat_mask_t current_mask = interface->lookup_mask[attachment];
130 if (current_mask !=
mask) {
132 "PNAT lookup mask must be consistent per "
133 "interface/direction %u",
138 interface->refcount++;
153 if (interface->refcount == 0)
156 if (interface->enabled[attachment] && attachment ==
PNAT_IP4_INPUT) {
172 interface->enabled[attachment] =
false;
174 interface->refcount--;
175 if (interface->refcount == 0) {
194 htons(match->sport), htons(match->dport),
mask, kv);
228 clib_bihash_init_16_8(&pm->
flowhash,
"PNAT flow hash",
242 clib_bihash_free_16_8(&pm->
flowhash);
256 if (!interface->enabled[attachment])
258 if (interface->lookup_mask[attachment] !=
mask)
278 if (match->mask == 0 ||
rewrite->mask == 0)
282 if ((match->dport || match->sport) &&
315 if (clib_bihash_search_16_8(&pm->
flowhash, &kv, &
value) == 0) {
347 if (clib_bihash_search_16_8(&pm->
flowhash, &kv, &
value) == 0) {
352 kv.
value = binding_index;
353 if (clib_bihash_add_del_16_8(&pm->
flowhash, &kv, 1)) {
377 if (clib_bihash_add_del_16_8(&pm->
flowhash, &kv, 0)) {
vl_api_pnat_match_tuple_t pnat_match_tuple_t
int pnat_binding_attach(u32 sw_if_index, pnat_attachment_point_t attachment, u32 binding_index)
#define clib_memcpy(d, s, n)
static void pnat_enable(void)
int pnat_binding_del(u32 index)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define clib_error_return(e, args...)
pnat_rewrite_tuple_t rewrite
static int pnat_disable_interface(u32 sw_if_index, pnat_attachment_point_t attachment)
#define pool_put(P, E)
Free an object E in pool P.
vl_api_pnat_mask_t pnat_mask_t
int ip4_sv_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
u32 * interface_by_sw_if_index
static clib_error_t * pnat_enable_interface(u32 sw_if_index, pnat_attachment_point_t attachment, pnat_mask_t mask)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
pnat_mask_t lookup_mask[PNAT_ATTACHMENT_POINT_MAX]
u32 pnat_flow_lookup(u32 sw_if_index, pnat_attachment_point_t attachment, pnat_match_tuple_t *match)
vl_api_pnat_rewrite_tuple_t pnat_rewrite_tuple_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
IPv4 shallow virtual reassembly.
@ PNAT_INSTR_DESTINATION_PORT
int pnat_binding_detach(u32 sw_if_index, pnat_attachment_point_t attachment, u32 binding_index)
pnat_translation_t * translations
static int pnat_interface_check_mask(u32 sw_if_index, pnat_attachment_point_t attachment, pnat_mask_t mask)
int ip4_sv_reass_output_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
pnat_interface_t * pnat_interface_by_sw_if_index(u32 sw_if_index)
static void pnat_calc_key_from_5tuple(u32 sw_if_index, pnat_attachment_point_t attachment, pnat_match_tuple_t *match, clib_bihash_kv_16_8_t *kv)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
pnat_instructions_t instructions
#define PNAT_FLOW_HASH_BUCKETS
clib_bihash_16_8_t flowhash
static uword pool_elts(void *v)
Number of active elements in a pool.
static pnat_mask_fast_t pnat_mask2fast(pnat_mask_t lookup_mask)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
static void pnat_disable(void)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
@ PNAT_INSTR_DESTINATION_ADDRESS
#define clib_warning(format, args...)
static void pnat_calc_key(u32 sw_if_index, pnat_attachment_point_t attachment, ip4_address_t src, ip4_address_t dst, u8 protocol, u16 sport, u16 dport, pnat_mask_fast_t mask, clib_bihash_kv_16_8_t *kv)
pnat_interface_t * interfaces
@ PNAT_INSTR_SOURCE_ADDRESS
vl_api_interface_index_t sw_if_index
int pnat_binding_add(pnat_match_tuple_t *match, pnat_rewrite_tuple_t *rewrite, u32 *index)
pnat_instructions_t pnat_instructions_from_mask(pnat_mask_t m)
vl_api_pnat_attachment_point_t pnat_attachment_point_t