summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/ip/punt.c22
-rw-r--r--test/test_ip4.py21
2 files changed, 31 insertions, 12 deletions
diff --git a/src/vnet/ip/punt.c b/src/vnet/ip/punt.c
index 296df59b615..6f321507efe 100644
--- a/src/vnet/ip/punt.c
+++ b/src/vnet/ip/punt.c
@@ -397,9 +397,6 @@ punt_l4_add_del (vlib_main_t * vm,
return clib_error_return (0,
"punt TCP/SCTP ports is not supported yet");
- if (!udp_is_valid_dst_port (port, af == AF_IP4))
- return clib_error_return (0, "invalid port: %d", port);
-
udp_register_dst_port (vm, port, udp4_punt_node.index, af == AF_IP4);
return 0;
@@ -438,16 +435,19 @@ punt_cli (vlib_main_t * vm,
{
clib_error_t *error = NULL;
bool is_add = true;
+ /* *INDENT-OFF* */
punt_reg_t pr = {
.punt = {
- .l4 = {
- .af = AF_IP4,
- .port = ~0,
- .protocol = ~0,
- },
- },
+ .l4 = {
+ .af = AF_IP4,
+ .port = ~0,
+ .protocol = ~0,
+ },
+ },
.type = PUNT_TYPE_L4,
};
+ u32 port;
+ /* *INDENT-ON* */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@ -457,8 +457,8 @@ punt_cli (vlib_main_t * vm,
pr.punt.l4.af = AF_IP6;
else if (unformat (input, "ip6"))
pr.punt.l4.af = AF_IP6;
- else if (unformat (input, "%d", &pr.punt.l4.port))
- ;
+ else if (unformat (input, "%d", &port))
+ pr.punt.l4.port = port;
else if (unformat (input, "udp"))
pr.punt.l4.protocol = IP_PROTOCOL_UDP;
else if (unformat (input, "tcp"))
diff --git a/test/test_ip4.py b/test/test_ip4.py
index 346904ab981..6d6aeb0a5d9 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -17,6 +17,7 @@ from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \
VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
VppMplsTable, VppIpTable
from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint
+from vpp_papi import VppEnum
NUM_PKTS = 67
@@ -1281,10 +1282,28 @@ class TestIPPunt(VppTestCase):
def test_ip_punt(self):
""" IP punt police and redirect """
+ # use UDP packet that have a port we need to explicitly
+ # register to get punted.
+ pt_l4 = VppEnum.vl_api_punt_type_t.PUNT_API_TYPE_L4
+ af_ip4 = VppEnum.vl_api_address_family_t.ADDRESS_IP4
+ udp_proto = VppEnum.vl_api_ip_proto_t.IP_API_PROTO_UDP
+ punt_udp = {
+ 'type': pt_l4,
+ 'punt': {
+ 'l4': {
+ 'af': af_ip4,
+ 'protocol': udp_proto,
+ 'port': 1234,
+ }
+ }
+ }
+
+ self.vapi.set_punt(is_add=1, punt=punt_udp)
+
p = (Ether(src=self.pg0.remote_mac,
dst=self.pg0.local_mac) /
IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
- TCP(sport=1234, dport=1234) /
+ UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
pkts = p * 1025