From 7c7b50546107d4e1a5b71a1f55dbf4e1d85126ad Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Mon, 4 Oct 2021 12:03:20 +0200 Subject: ip: fix punt for ipv6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Type: fix Change-Id: I583c30e9b63c0b0b6cd5fef0b2cb9ed7ec9856e2 Signed-off-by: Benoît Ganne --- src/vnet/ip/punt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/vnet/ip/punt.c b/src/vnet/ip/punt.c index fb0cc221950..eb191da1394 100644 --- a/src/vnet/ip/punt.c +++ b/src/vnet/ip/punt.c @@ -369,6 +369,8 @@ punt_l4_add_del (vlib_main_t * vm, ip_address_family_t af, ip_protocol_t protocol, u16 port, bool is_add) { + int is_ip4 = af == AF_IP4; + /* For now we only support TCP and UDP punt */ if (protocol != IP_PROTOCOL_UDP && protocol != IP_PROTOCOL_TCP) return clib_error_return (0, @@ -378,19 +380,22 @@ punt_l4_add_del (vlib_main_t * vm, if (port == (u16) ~ 0) { if (protocol == IP_PROTOCOL_UDP) - udp_punt_unknown (vm, af == AF_IP4, is_add); + udp_punt_unknown (vm, is_ip4, is_add); else if (protocol == IP_PROTOCOL_TCP) - tcp_punt_unknown (vm, af == AF_IP4, is_add); + tcp_punt_unknown (vm, is_ip4, is_add); return 0; } else if (is_add) { + const vlib_node_registration_t *punt_node = + is_ip4 ? &udp4_punt_node : &udp6_punt_node; + if (protocol == IP_PROTOCOL_TCP) return clib_error_return (0, "punt TCP ports is not supported yet"); - udp_register_dst_port (vm, port, udp4_punt_node.index, af == AF_IP4); + udp_register_dst_port (vm, port, punt_node->index, is_ip4); return 0; } @@ -399,7 +404,7 @@ punt_l4_add_del (vlib_main_t * vm, if (protocol == IP_PROTOCOL_TCP) return clib_error_return (0, "punt TCP ports is not supported yet"); - udp_unregister_dst_port (vm, port, af == AF_IP4); + udp_unregister_dst_port (vm, port, is_ip4); return 0; } -- cgit 1.2.3-korg