SNAT: Port allocation per protocol
Ports are allocated per protocol (UDP, TCP, ICMP) 1:1 NAT with port is configured for specific protocol Change-Id: I37ae5eed3715b223d0620d4fdaed7a482bb7a834 Signed-off-by: Matus Fabian <matfabia@cisco.com>
This commit is contained in:
@@ -224,7 +224,7 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0,
|
||||
u32 address_index = ~0;
|
||||
u32 outside_fib_index;
|
||||
uword * p;
|
||||
snat_static_mapping_key_t worker_by_out_key;
|
||||
snat_worker_key_t worker_by_out_key;
|
||||
|
||||
p = hash_get (sm->ip4_main->fib_index_by_table_id, sm->outside_vrf_id);
|
||||
if (! p)
|
||||
@@ -234,6 +234,7 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0,
|
||||
}
|
||||
outside_fib_index = p[0];
|
||||
|
||||
key1.protocol = key0->protocol;
|
||||
user_key.addr = ip0->src_address;
|
||||
user_key.fib_index = rx_fib_index0;
|
||||
kv0.key = user_key.as_u64;
|
||||
@@ -520,7 +521,7 @@ snat_hairpinning (snat_main_t *sm,
|
||||
u32 proto0)
|
||||
{
|
||||
snat_session_key_t key0, sm0;
|
||||
snat_static_mapping_key_t k0;
|
||||
snat_worker_key_t k0;
|
||||
snat_session_t * s0;
|
||||
clib_bihash_kv_8_8_t kv0, value0;
|
||||
ip_csum_t sum0;
|
||||
@@ -682,13 +683,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
|
||||
|
||||
next0 = next1 = SNAT_IN2OUT_NEXT_LOOKUP;
|
||||
|
||||
proto0 = ~0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_UDP)
|
||||
? SNAT_PROTOCOL_UDP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_TCP)
|
||||
? SNAT_PROTOCOL_TCP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_ICMP)
|
||||
? SNAT_PROTOCOL_ICMP : proto0;
|
||||
proto0 = ip_proto_to_snat_proto (ip0->protocol);
|
||||
|
||||
/* Next configured feature, probably ip4-lookup */
|
||||
if (is_slow_path)
|
||||
@@ -818,13 +813,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
|
||||
rx_fib_index1 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index,
|
||||
sw_if_index1);
|
||||
|
||||
proto1 = ~0;
|
||||
proto1 = (ip1->protocol == IP_PROTOCOL_UDP)
|
||||
? SNAT_PROTOCOL_UDP : proto1;
|
||||
proto1 = (ip1->protocol == IP_PROTOCOL_TCP)
|
||||
? SNAT_PROTOCOL_TCP : proto1;
|
||||
proto1 = (ip1->protocol == IP_PROTOCOL_ICMP)
|
||||
? SNAT_PROTOCOL_ICMP : proto1;
|
||||
proto1 = ip_proto_to_snat_proto (ip1->protocol);
|
||||
|
||||
/* Next configured feature, probably ip4-lookup */
|
||||
if (is_slow_path)
|
||||
@@ -989,13 +978,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
|
||||
rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index,
|
||||
sw_if_index0);
|
||||
|
||||
proto0 = ~0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_UDP)
|
||||
? SNAT_PROTOCOL_UDP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_TCP)
|
||||
? SNAT_PROTOCOL_TCP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_ICMP)
|
||||
? SNAT_PROTOCOL_ICMP : proto0;
|
||||
proto0 = ip_proto_to_snat_proto (ip0->protocol);
|
||||
|
||||
/* Next configured feature, probably ip4-lookup */
|
||||
if (is_slow_path)
|
||||
@@ -1497,13 +1480,7 @@ snat_in2out_fast_static_map_fn (vlib_main_t * vm,
|
||||
sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
|
||||
rx_fib_index0 = ip4_fib_table_get_index_for_sw_if_index(sw_if_index0);
|
||||
|
||||
proto0 = ~0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_UDP)
|
||||
? SNAT_PROTOCOL_UDP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_TCP)
|
||||
? SNAT_PROTOCOL_TCP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_ICMP)
|
||||
? SNAT_PROTOCOL_ICMP : proto0;
|
||||
proto0 = ip_proto_to_snat_proto (ip0->protocol);
|
||||
|
||||
if (PREDICT_FALSE (proto0 == ~0))
|
||||
goto trace0;
|
||||
|
||||
@@ -405,13 +405,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
|
||||
rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index,
|
||||
sw_if_index0);
|
||||
|
||||
proto0 = ~0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_UDP)
|
||||
? SNAT_PROTOCOL_UDP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_TCP)
|
||||
? SNAT_PROTOCOL_TCP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_ICMP)
|
||||
? SNAT_PROTOCOL_ICMP : proto0;
|
||||
proto0 = ip_proto_to_snat_proto (ip0->protocol);
|
||||
|
||||
if (PREDICT_FALSE (proto0 == ~0))
|
||||
goto trace0;
|
||||
@@ -536,13 +530,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
|
||||
rx_fib_index1 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index,
|
||||
sw_if_index1);
|
||||
|
||||
proto1 = ~0;
|
||||
proto1 = (ip1->protocol == IP_PROTOCOL_UDP)
|
||||
? SNAT_PROTOCOL_UDP : proto1;
|
||||
proto1 = (ip1->protocol == IP_PROTOCOL_TCP)
|
||||
? SNAT_PROTOCOL_TCP : proto1;
|
||||
proto1 = (ip1->protocol == IP_PROTOCOL_ICMP)
|
||||
? SNAT_PROTOCOL_ICMP : proto1;
|
||||
proto1 = ip_proto_to_snat_proto (ip1->protocol);
|
||||
|
||||
if (PREDICT_FALSE (proto1 == ~0))
|
||||
goto trace1;
|
||||
@@ -701,13 +689,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
|
||||
rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index,
|
||||
sw_if_index0);
|
||||
|
||||
proto0 = ~0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_UDP)
|
||||
? SNAT_PROTOCOL_UDP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_TCP)
|
||||
? SNAT_PROTOCOL_TCP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_ICMP)
|
||||
? SNAT_PROTOCOL_ICMP : proto0;
|
||||
proto0 = ip_proto_to_snat_proto (ip0->protocol);
|
||||
|
||||
if (PREDICT_FALSE (proto0 == ~0))
|
||||
goto trace00;
|
||||
@@ -901,7 +883,7 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm,
|
||||
u32 rx_fib_index0;
|
||||
ip4_header_t * ip0;
|
||||
udp_header_t * udp0;
|
||||
snat_static_mapping_key_t key0;
|
||||
snat_worker_key_t key0;
|
||||
clib_bihash_kv_8_8_t kv0, value0;
|
||||
u8 do_handoff;
|
||||
|
||||
@@ -1196,13 +1178,7 @@ snat_out2in_fast_node_fn (vlib_main_t * vm,
|
||||
|
||||
vnet_feature_next (sw_if_index0, &next0, b0);
|
||||
|
||||
proto0 = ~0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_UDP)
|
||||
? SNAT_PROTOCOL_UDP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_TCP)
|
||||
? SNAT_PROTOCOL_TCP : proto0;
|
||||
proto0 = (ip0->protocol == IP_PROTOCOL_ICMP)
|
||||
? SNAT_PROTOCOL_ICMP : proto0;
|
||||
proto0 = ip_proto_to_snat_proto (ip0->protocol);
|
||||
|
||||
if (PREDICT_FALSE (proto0 == ~0))
|
||||
goto trace00;
|
||||
|
||||
@@ -118,6 +118,7 @@ define snat_interface_details {
|
||||
@param addr_only - 1 if address only mapping
|
||||
@param local_ip_address - local IP address
|
||||
@param external_ip_address - external IP address
|
||||
@param protocol - IP protocol
|
||||
@param local_port - local port number
|
||||
@param external_port - external port number
|
||||
@param external_sw_if_index - external interface (if set
|
||||
@@ -132,6 +133,7 @@ define snat_add_static_mapping {
|
||||
u8 addr_only;
|
||||
u8 local_ip_address[16];
|
||||
u8 external_ip_address[16];
|
||||
u8 protocol;
|
||||
u16 local_port;
|
||||
u16 external_port;
|
||||
u32 external_sw_if_index;
|
||||
@@ -162,6 +164,7 @@ define snat_static_mapping_dump {
|
||||
@param addr_only - 1 if address only mapping
|
||||
@param local_ip_address - local IP address
|
||||
@param external_ip_address - external IP address
|
||||
@param protocol - IP protocol
|
||||
@param local_port - local port number
|
||||
@param external_port - external port number
|
||||
@param vfr_id - VRF ID
|
||||
@@ -172,6 +175,7 @@ define snat_static_mapping_details {
|
||||
u8 addr_only;
|
||||
u8 local_ip_address[16];
|
||||
u8 external_ip_address[16];
|
||||
u8 protocol;
|
||||
u16 local_port;
|
||||
u16 external_port;
|
||||
u32 vrf_id;
|
||||
|
||||
+144
-52
File diff suppressed because it is too large
Load Diff
+40
-6
@@ -66,13 +66,18 @@ typedef struct {
|
||||
};
|
||||
u64 as_u64;
|
||||
};
|
||||
} snat_static_mapping_key_t;
|
||||
} snat_worker_key_t;
|
||||
|
||||
|
||||
#define foreach_snat_protocol \
|
||||
_(UDP, 0, udp, "udp") \
|
||||
_(TCP, 1, tcp, "tcp") \
|
||||
_(ICMP, 2, icmp, "icmp")
|
||||
|
||||
typedef enum {
|
||||
SNAT_PROTOCOL_UDP = 0,
|
||||
SNAT_PROTOCOL_TCP,
|
||||
SNAT_PROTOCOL_ICMP,
|
||||
#define _(N, i, n, s) SNAT_PROTOCOL_##N = i,
|
||||
foreach_snat_protocol
|
||||
#undef _
|
||||
} snat_protocol_t;
|
||||
|
||||
|
||||
@@ -112,8 +117,11 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
ip4_address_t addr;
|
||||
u32 busy_ports;
|
||||
uword * busy_port_bitmap;
|
||||
#define _(N, i, n, s) \
|
||||
u32 busy_##n##_ports; \
|
||||
uword * busy_##n##_port_bitmap;
|
||||
foreach_snat_protocol
|
||||
#undef _
|
||||
} snat_address_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -124,6 +132,7 @@ typedef struct {
|
||||
u8 addr_only;
|
||||
u32 vrf_id;
|
||||
u32 fib_index;
|
||||
snat_protocol_t proto;
|
||||
} snat_static_mapping_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -137,6 +146,7 @@ typedef struct {
|
||||
u16 e_port;
|
||||
u32 sw_if_index;
|
||||
u32 vrf_id;
|
||||
snat_protocol_t proto;
|
||||
int addr_only;
|
||||
int is_add;
|
||||
} snat_static_map_resolve_t;
|
||||
@@ -272,4 +282,28 @@ typedef struct {
|
||||
u16 sequence;
|
||||
} icmp_echo_header_t;
|
||||
|
||||
always_inline snat_protocol_t
|
||||
ip_proto_to_snat_proto (u8 ip_proto)
|
||||
{
|
||||
snat_protocol_t snat_proto = ~0;
|
||||
|
||||
snat_proto = (ip_proto == IP_PROTOCOL_UDP) ? SNAT_PROTOCOL_UDP : snat_proto;
|
||||
snat_proto = (ip_proto == IP_PROTOCOL_TCP) ? SNAT_PROTOCOL_TCP : snat_proto;
|
||||
snat_proto = (ip_proto == IP_PROTOCOL_ICMP) ? SNAT_PROTOCOL_ICMP : snat_proto;
|
||||
|
||||
return snat_proto;
|
||||
}
|
||||
|
||||
always_inline u8
|
||||
snat_proto_to_ip_proto (snat_protocol_t snat_proto)
|
||||
{
|
||||
u8 ip_proto = ~0;
|
||||
|
||||
ip_proto = (snat_proto == SNAT_PROTOCOL_UDP) ? IP_PROTOCOL_UDP : ip_proto;
|
||||
ip_proto = (snat_proto == SNAT_PROTOCOL_TCP) ? IP_PROTOCOL_TCP : ip_proto;
|
||||
ip_proto = (snat_proto == SNAT_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP : ip_proto;
|
||||
|
||||
return ip_proto;
|
||||
}
|
||||
|
||||
#endif /* __included_snat_h__ */
|
||||
|
||||
@@ -295,9 +295,7 @@ snat_ipfix_logging_nat44_ses (u8 nat_event, u32 src_ip, u32 nat_src_ip,
|
||||
if (!silm->enabled)
|
||||
return;
|
||||
|
||||
proto = (snat_proto == SNAT_PROTOCOL_UDP) ? IP_PROTOCOL_UDP : proto;
|
||||
proto = (snat_proto == SNAT_PROTOCOL_TCP) ? IP_PROTOCOL_TCP : proto;
|
||||
proto = (snat_proto == SNAT_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP : proto;
|
||||
proto = snat_proto_to_ip_proto (snat_proto);
|
||||
|
||||
now = (u64) ((vlib_time_now (vm) - silm->vlib_time_0) * 1e3);
|
||||
now += silm->milisecond_time_0;
|
||||
|
||||
@@ -214,13 +214,14 @@ static int api_snat_add_static_mapping(vat_main_t * vam)
|
||||
unformat_input_t * i = vam->input;
|
||||
vl_api_snat_add_static_mapping_t * mp;
|
||||
u8 external_addr_set = 0;
|
||||
u8 local_addr_set;
|
||||
u8 local_addr_set = 0;
|
||||
u8 is_add = 1;
|
||||
u8 addr_only = 1;
|
||||
ip4_address_t local_addr, external_addr;
|
||||
u32 local_port = 0, external_port = 0, vrf_id = ~0;
|
||||
u32 sw_if_index = ~0;
|
||||
u8 sw_if_index_set = 0;
|
||||
u32 proto = ~0;
|
||||
int ret;
|
||||
|
||||
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
|
||||
@@ -239,7 +240,9 @@ static int api_snat_add_static_mapping(vat_main_t * vam)
|
||||
sw_if_index_set = 1;
|
||||
else if (unformat (i, "external_sw_if_index %d", &sw_if_index))
|
||||
sw_if_index_set = 1;
|
||||
else if (unformat (i, "vrf %u", &vrf_id))
|
||||
else if (unformat (i, "vrf %u", &vrf_id))
|
||||
;
|
||||
else if (unformat (i, "protocol %u", &proto))
|
||||
;
|
||||
else if (unformat (i, "del"))
|
||||
is_add = 0;
|
||||
@@ -269,6 +272,7 @@ static int api_snat_add_static_mapping(vat_main_t * vam)
|
||||
mp->external_port = ntohs ((u16) external_port);
|
||||
mp->external_sw_if_index = ntohl (sw_if_index);
|
||||
mp->vrf_id = ntohl (vrf_id);
|
||||
mp->protocol = (u8) proto;
|
||||
memcpy (mp->local_ip_address, &local_addr, 4);
|
||||
memcpy (mp->external_ip_address, &external_addr, 4);
|
||||
|
||||
@@ -300,17 +304,19 @@ static void vl_api_snat_static_mapping_details_t_handler
|
||||
vat_main_t *vam = sm->vat_main;
|
||||
|
||||
if (mp->addr_only)
|
||||
fformat (vam->ofp, "%15U%6s%15U%6s%11d\n",
|
||||
fformat (vam->ofp, "%15U%6s%15U%6s%11d%6d\n",
|
||||
format_ip4_address, &mp->local_ip_address, "",
|
||||
format_ip4_address, &mp->external_ip_address, "",
|
||||
ntohl (mp->vrf_id));
|
||||
ntohl (mp->vrf_id),
|
||||
mp->protocol);
|
||||
else
|
||||
fformat (vam->ofp, "%15U%6d%15U%6d%11d\n",
|
||||
fformat (vam->ofp, "%15U%6d%15U%6d%11d%6d\n",
|
||||
format_ip4_address, &mp->local_ip_address,
|
||||
ntohs (mp->local_port),
|
||||
format_ip4_address, &mp->external_ip_address,
|
||||
ntohs (mp->external_port),
|
||||
ntohl (mp->vrf_id));
|
||||
ntohl (mp->vrf_id),
|
||||
mp->protocol);
|
||||
|
||||
}
|
||||
|
||||
@@ -327,8 +333,8 @@ static int api_snat_static_mapping_dump(vat_main_t * vam)
|
||||
}
|
||||
|
||||
fformat (vam->ofp, "%21s%21s\n", "local", "external");
|
||||
fformat (vam->ofp, "%15s%6s%15s%6s%11s\n", "address", "port", "address",
|
||||
"port", "vrf");
|
||||
fformat (vam->ofp, "%15s%6s%15s%6s%11s%6s\n", "address", "port", "address",
|
||||
"port", "vrf", "proto");
|
||||
|
||||
M(SNAT_STATIC_MAPPING_DUMP, mp);
|
||||
S(mp);
|
||||
@@ -626,9 +632,10 @@ static int api_snat_add_del_interface_addr (vat_main_t * vam)
|
||||
_(snat_add_address_range, "<start-addr> [- <end-addr] [del]") \
|
||||
_(snat_interface_add_del_feature, \
|
||||
"<intfc> | sw_if_index <id> [in] [out] [del]") \
|
||||
_(snat_add_static_mapping, "local_addr <ip> external_addr <ip> " \
|
||||
"| external_if <intfc> | external_sw_if_ndex <id>) " \
|
||||
"[local_port <n>] [external_port <n>] [vrf <table-id>] [del]") \
|
||||
_(snat_add_static_mapping, "local_addr <ip> (external_addr <ip>" \
|
||||
" | external_if <intfc> | external_sw_if_ndex <id>) " \
|
||||
"[local_port <n>] [external_port <n>] [vrf <table-id>] [del] " \
|
||||
"protocol <n>") \
|
||||
_(snat_set_workers, "<wokrers_bitmap>") \
|
||||
_(snat_static_mapping_dump, "") \
|
||||
_(snat_show_config, "") \
|
||||
|
||||
+19
-8
@@ -292,6 +292,7 @@ class TestSNAT(VppTestCase):
|
||||
external_port=sm.external_port,
|
||||
addr_only=sm.addr_only,
|
||||
vrf_id=sm.vrf_id,
|
||||
protocol=sm.protocol,
|
||||
is_add=0)
|
||||
|
||||
adresses = self.vapi.snat_address_dump()
|
||||
@@ -302,7 +303,8 @@ class TestSNAT(VppTestCase):
|
||||
|
||||
def snat_add_static_mapping(self, local_ip, external_ip='0.0.0.0',
|
||||
local_port=0, external_port=0, vrf_id=0,
|
||||
is_add=1, external_sw_if_index=0xFFFFFFFF):
|
||||
is_add=1, external_sw_if_index=0xFFFFFFFF,
|
||||
proto=0):
|
||||
"""
|
||||
Add/delete S-NAT static mapping
|
||||
|
||||
@@ -313,6 +315,7 @@ class TestSNAT(VppTestCase):
|
||||
:param vrf_id: VRF ID (Default 0)
|
||||
:param is_add: 1 if add, 0 if delete (Default add)
|
||||
:param external_sw_if_index: External interface instead of IP address
|
||||
:param proto: IP protocol (Mandatory if port specified)
|
||||
"""
|
||||
addr_only = 1
|
||||
if local_port and external_port:
|
||||
@@ -327,6 +330,7 @@ class TestSNAT(VppTestCase):
|
||||
external_port,
|
||||
addr_only,
|
||||
vrf_id,
|
||||
proto,
|
||||
is_add)
|
||||
|
||||
def snat_add_address(self, ip, is_add=1):
|
||||
@@ -430,11 +434,14 @@ class TestSNAT(VppTestCase):
|
||||
|
||||
self.snat_add_address(self.snat_addr)
|
||||
self.snat_add_static_mapping(self.pg0.remote_ip4, self.snat_addr,
|
||||
self.tcp_port_in, self.tcp_port_out)
|
||||
self.tcp_port_in, self.tcp_port_out,
|
||||
proto=IP_PROTOS.tcp)
|
||||
self.snat_add_static_mapping(self.pg0.remote_ip4, self.snat_addr,
|
||||
self.udp_port_in, self.udp_port_out)
|
||||
self.udp_port_in, self.udp_port_out,
|
||||
proto=IP_PROTOS.udp)
|
||||
self.snat_add_static_mapping(self.pg0.remote_ip4, self.snat_addr,
|
||||
self.icmp_id_in, self.icmp_id_out)
|
||||
self.icmp_id_in, self.icmp_id_out,
|
||||
proto=IP_PROTOS.icmp)
|
||||
self.vapi.snat_interface_add_del_feature(self.pg0.sw_if_index)
|
||||
self.vapi.snat_interface_add_del_feature(self.pg1.sw_if_index,
|
||||
is_inside=0)
|
||||
@@ -464,11 +471,14 @@ class TestSNAT(VppTestCase):
|
||||
|
||||
self.snat_add_address(self.snat_addr)
|
||||
self.snat_add_static_mapping(self.pg0.remote_ip4, self.snat_addr,
|
||||
self.tcp_port_in, self.tcp_port_out)
|
||||
self.tcp_port_in, self.tcp_port_out,
|
||||
proto=IP_PROTOS.tcp)
|
||||
self.snat_add_static_mapping(self.pg0.remote_ip4, self.snat_addr,
|
||||
self.udp_port_in, self.udp_port_out)
|
||||
self.udp_port_in, self.udp_port_out,
|
||||
proto=IP_PROTOS.udp)
|
||||
self.snat_add_static_mapping(self.pg0.remote_ip4, self.snat_addr,
|
||||
self.icmp_id_in, self.icmp_id_out)
|
||||
self.icmp_id_in, self.icmp_id_out,
|
||||
proto=IP_PROTOS.icmp)
|
||||
self.vapi.snat_interface_add_del_feature(self.pg0.sw_if_index)
|
||||
self.vapi.snat_interface_add_del_feature(self.pg1.sw_if_index,
|
||||
is_inside=0)
|
||||
@@ -685,7 +695,8 @@ class TestSNAT(VppTestCase):
|
||||
is_inside=0)
|
||||
# add static mapping for server
|
||||
self.snat_add_static_mapping(server.ip4, self.snat_addr,
|
||||
server_in_port, server_out_port)
|
||||
server_in_port, server_out_port,
|
||||
proto=IP_PROTOS.tcp)
|
||||
|
||||
# send packet from host to server
|
||||
p = (Ether(src=host.mac, dst=self.pg0.local_mac) /
|
||||
|
||||
@@ -883,6 +883,7 @@ class VppPapiProvider(object):
|
||||
external_port=0,
|
||||
addr_only=1,
|
||||
vrf_id=0,
|
||||
protocol=0,
|
||||
is_add=1,
|
||||
is_ip4=1):
|
||||
"""Add/delete S-NAT static mapping
|
||||
@@ -894,6 +895,7 @@ class VppPapiProvider(object):
|
||||
:param external_port: External port number (Default value = 0)
|
||||
:param addr_only: 1 if address only mapping, 0 if address and port
|
||||
:param vrf_id: VRF ID
|
||||
:param protocol: IP protocol (Default value = 0)
|
||||
:param is_add: 1 if add, 0 if delete (Default value = 1)
|
||||
:param is_ip4: 1 if address type is IPv4 (Default value = 1)
|
||||
"""
|
||||
@@ -907,7 +909,8 @@ class VppPapiProvider(object):
|
||||
'local_port': local_port,
|
||||
'external_port': external_port,
|
||||
'external_sw_if_index': external_sw_if_index,
|
||||
'vrf_id': vrf_id})
|
||||
'vrf_id': vrf_id,
|
||||
'protocol': protocol})
|
||||
|
||||
def snat_add_address_range(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user