ip: refactor reassembly

this is a preparation step for introducing other reassembly types

Type: refactor

Change-Id: I197e299dbd729b00eead31667913b8ceff915d63
Signed-off-by: Klement Sekera <ksekera@cisco.com>
This commit is contained in:
Klement Sekera
2019-06-24 11:52:49 +00:00
committed by Ole Trøan
parent 5e2f84d2cf
commit 896c896a3c
11 changed files with 894 additions and 849 deletions

View File

@ -431,7 +431,7 @@ list(APPEND VNET_SOURCES
ip/ip4_pg.c
ip/ip4_source_and_port_range_check.c
ip/ip4_source_check.c
ip/ip4_reassembly.c
ip/reass/ip4_full_reass.c
ip/ip6_format.c
ip/ip6_forward.c
ip/ip6_ll_table.c
@ -441,7 +441,7 @@ list(APPEND VNET_SOURCES
ip/ip6_input.c
ip/ip6_neighbor.c
ip/ip6_pg.c
ip/ip6_reassembly.c
ip/reass/ip6_full_reass.c
ip/rd_cp.c
ip/ip_neighbor.c
ip/ip_api.c
@ -461,9 +461,9 @@ list(APPEND VNET_SOURCES
list(APPEND VNET_MULTIARCH_SOURCES
ip/ip4_source_check.c
ip/ip4_punt_drop.c
ip/ip4_reassembly.c
ip/reass/ip4_full_reass.c
ip/ip6_hop_by_hop.c
ip/ip6_reassembly.c
ip/reass/ip6_full_reass.c
ip/ip6_input.c
ip/ip6_punt_drop.c
ip/punt_node.c

View File

@ -38,8 +38,8 @@
*/
#include <vnet/ip/ip.h>
#include <vnet/ip/ip4_reassembly.h>
#include <vnet/ip/ip6_reassembly.h>
#include <vnet/ip/reass/ip4_full_reass.h>
#include <vnet/ip/reass/ip6_full_reass.h>
/**
* @file
@ -269,26 +269,26 @@ set_reassembly_command_fn (vlib_main_t * vm,
}
vnet_api_error_t rv4 = ip4_reass_enable_disable (sw_if_index, ip4_on);
vnet_api_error_t rv6 = ip6_reass_enable_disable (sw_if_index, ip6_on);
vnet_api_error_t rv4 = ip4_full_reass_enable_disable (sw_if_index, ip4_on);
vnet_api_error_t rv6 = ip6_full_reass_enable_disable (sw_if_index, ip6_on);
if (rv4 && rv6)
{
return clib_error_return (0,
"`ip4_reass_enable_disable' API call failed, rv=%d:%U, "
"`ip6_reass_enable_disable' API call failed, rv=%d:%U",
"`ip4_full_reass_enable_disable' API call failed, rv=%d:%U, "
"`ip6_full_reass_enable_disable' API call failed, rv=%d:%U",
(int) rv4, format_vnet_api_errno, rv4,
(int) rv6, format_vnet_api_errno, rv6);
}
else if (rv4)
{
return clib_error_return (0,
"`ip4_reass_enable_disable' API call failed, rv=%d:%U",
"`ip4_full_reass_enable_disable' API call failed, rv=%d:%U",
(int) rv4, format_vnet_api_errno, rv4);
}
else if (rv6)
{
return clib_error_return (0,
"`ip6_reass_enable_disable' API call failed, rv=%d:%U",
"`ip6_full_reass_enable_disable' API call failed, rv=%d:%U",
(int) rv6, format_vnet_api_errno, rv6);
}
return NULL;

View File

@ -1871,7 +1871,7 @@ VLIB_REGISTER_NODE (ip4_local_node) =
[IP_LOCAL_NEXT_PUNT] = "ip4-punt",
[IP_LOCAL_NEXT_UDP_LOOKUP] = "ip4-udp-lookup",
[IP_LOCAL_NEXT_ICMP] = "ip4-icmp-input",
[IP_LOCAL_NEXT_REASSEMBLY] = "ip4-reassembly",
[IP_LOCAL_NEXT_REASSEMBLY] = "ip4-full-reassembly",
},
};
/* *INDENT-ON* */

View File

@ -398,7 +398,7 @@ VLIB_REGISTER_NODE (ip4_input_node) = {
[IP4_INPUT_NEXT_LOOKUP] = "ip4-lookup",
[IP4_INPUT_NEXT_LOOKUP_MULTICAST] = "ip4-mfib-forward-lookup",
[IP4_INPUT_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[IP4_INPUT_NEXT_REASSEMBLY] = "ip4-reassembly",
[IP4_INPUT_NEXT_REASSEMBLY] = "ip4-full-reassembly",
},
.format_buffer = format_ip4_header,

View File

@ -1517,7 +1517,7 @@ VLIB_REGISTER_NODE (ip6_local_node) =
[IP_LOCAL_NEXT_PUNT] = "ip6-punt",
[IP_LOCAL_NEXT_UDP_LOOKUP] = "ip6-udp-lookup",
[IP_LOCAL_NEXT_ICMP] = "ip6-icmp-input",
[IP_LOCAL_NEXT_REASSEMBLY] = "ip6-reassembly",
[IP_LOCAL_NEXT_REASSEMBLY] = "ip6-full-reassembly",
},
};
/* *INDENT-ON* */

View File

@ -43,8 +43,8 @@
#include <vnet/fib/ip6_fib.h>
#include <vnet/fib/fib_path_list.h>
#include <vnet/ip/ip6_hop_by_hop.h>
#include <vnet/ip/ip4_reassembly.h>
#include <vnet/ip/ip6_reassembly.h>
#include <vnet/ip/reass/ip4_full_reass.h>
#include <vnet/ip/reass/ip6_full_reass.h>
#include <vnet/ethernet/arp.h>
#include <vnet/ip/ip_types_api.h>
@ -2738,17 +2738,21 @@ vl_api_ip_reassembly_set_t_handler (vl_api_ip_reassembly_set_t * mp)
int rv = 0;
if (mp->is_ip6)
{
rv = ip6_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
clib_net_to_host_u32 (mp->max_reassemblies),
clib_net_to_host_u32 (mp->max_reassembly_length),
clib_net_to_host_u32 (mp->expire_walk_interval_ms));
rv = ip6_full_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
clib_net_to_host_u32 (mp->max_reassemblies),
clib_net_to_host_u32
(mp->max_reassembly_length),
clib_net_to_host_u32
(mp->expire_walk_interval_ms));
}
else
{
rv = ip4_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
clib_net_to_host_u32 (mp->max_reassemblies),
clib_net_to_host_u32 (mp->max_reassembly_length),
clib_net_to_host_u32 (mp->expire_walk_interval_ms));
rv = ip4_full_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
clib_net_to_host_u32 (mp->max_reassemblies),
clib_net_to_host_u32
(mp->max_reassembly_length),
clib_net_to_host_u32
(mp->expire_walk_interval_ms));
}
REPLY_MACRO (VL_API_IP_REASSEMBLY_SET_REPLY);
@ -2771,15 +2775,16 @@ vl_api_ip_reassembly_get_t_handler (vl_api_ip_reassembly_get_t * mp)
if (mp->is_ip6)
{
rmp->is_ip6 = 1;
ip6_reass_get (&rmp->timeout_ms, &rmp->max_reassemblies,
&rmp->expire_walk_interval_ms);
ip6_full_reass_get (&rmp->timeout_ms, &rmp->max_reassemblies,
&rmp->max_reassembly_length,
&rmp->expire_walk_interval_ms);
}
else
{
rmp->is_ip6 = 0;
ip4_reass_get (&rmp->timeout_ms, &rmp->max_reassemblies,
&rmp->max_reassembly_length,
&rmp->expire_walk_interval_ms);
ip4_full_reass_get (&rmp->timeout_ms, &rmp->max_reassemblies,
&rmp->max_reassembly_length,
&rmp->expire_walk_interval_ms);
}
rmp->timeout_ms = clib_host_to_net_u32 (rmp->timeout_ms);
rmp->max_reassemblies = clib_host_to_net_u32 (rmp->max_reassemblies);
@ -2794,12 +2799,13 @@ void
{
vl_api_ip_reassembly_enable_disable_reply_t *rmp;
int rv = 0;
rv = ip4_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
mp->enable_ip4);
rv = ip4_full_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
mp->enable_ip4);
if (0 == rv)
{
rv = ip6_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
mp->enable_ip6);
rv =
ip6_full_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
mp->enable_ip6);
}
REPLY_MACRO (VL_API_IP_REASSEMBLY_ENABLE_DISABLE_REPLY);

View File

@ -20,8 +20,8 @@
* This file contains the source code for IPv4 reassembly.
*/
#ifndef __included_ip4_reassembly_h__
#define __included_ip4_reassembly_h__
#ifndef __included_ip4_full_reass_h__
#define __included_ip4_full_reass_h__
#include <vnet/api_errno.h>
#include <vnet/vnet.h>
@ -29,21 +29,21 @@
/**
* @brief set ip4 reassembly configuration
*/
vnet_api_error_t ip4_reass_set (u32 timeout_ms, u32 max_reassemblies,
u32 max_reassembly_length,
u32 expire_walk_interval_ms);
vnet_api_error_t ip4_full_reass_set (u32 timeout_ms, u32 max_reassemblies,
u32 max_reassembly_length,
u32 expire_walk_interval_ms);
/**
* @brief get ip4 reassembly configuration
*/
vnet_api_error_t ip4_reass_get (u32 * timeout_ms, u32 * max_reassemblies,
u32 * max_reassembly_length,
u32 * expire_walk_interval_ms);
vnet_api_error_t ip4_full_reass_get (u32 * timeout_ms, u32 * max_reassemblies,
u32 * max_reassembly_length,
u32 * expire_walk_interval_ms);
vnet_api_error_t ip4_reass_enable_disable (u32 sw_if_index,
u8 enable_disable);
vnet_api_error_t ip4_full_reass_enable_disable (u32 sw_if_index,
u8 enable_disable);
#endif /* __included_ip4_reassembly_h */
#endif /* __included_ip4_full_reass_h__ */
/*
* fd.io coding-style-patch-verification: ON

View File

@ -20,8 +20,8 @@
* This file contains the source code for IPv6 reassembly.
*/
#ifndef __included_ip6_reassembly_h__
#define __included_ip6_reassembly_h__
#ifndef __included_ip6_full_reass_h__
#define __included_ip6_full_reass_h__
#include <vnet/api_errno.h>
#include <vnet/vnet.h>
@ -29,20 +29,21 @@
/**
* @brief set ip6 reassembly configuration
*/
vnet_api_error_t ip6_reass_set (u32 timeout_ms, u32 max_reassemblies,
u32 max_reassembly_length,
u32 expire_walk_interval_ms);
vnet_api_error_t ip6_full_reass_set (u32 timeout_ms, u32 max_reassemblies,
u32 max_reassembly_length,
u32 expire_walk_interval_ms);
/**
* @brief get ip6 reassembly configuration
*/
vnet_api_error_t ip6_reass_get (u32 * timeout_ms, u32 * max_reassemblies,
u32 * expire_walk_interval_ms);
vnet_api_error_t ip6_full_reass_get (u32 * timeout_ms, u32 * max_reassemblies,
u32 * max_reassembly_length,
u32 * expire_walk_interval_ms);
vnet_api_error_t ip6_reass_enable_disable (u32 sw_if_index,
u8 enable_disable);
vnet_api_error_t ip6_full_reass_enable_disable (u32 sw_if_index,
u8 enable_disable);
#endif /* __included_ip6_reassembly_h */
#endif /* __included_ip6_full_reass_h */
/*
* fd.io coding-style-patch-verification: ON

View File

@ -17,6 +17,7 @@ from util import ppp, ppc, fragment_rfc791, fragment_rfc8200
from vpp_gre_interface import VppGreInterface
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathProto
from vpp_papi import VppEnum
# 35 is enough to have >257 400-byte fragments
test_packet_count = 35
@ -69,7 +70,7 @@ class TestIPv4Reassembly(VppTestCase):
super(TestIPv4Reassembly, self).tearDown()
def show_commands_at_teardown(self):
self.logger.debug(self.vapi.ppcli("show ip4-reassembly details"))
self.logger.debug(self.vapi.ppcli("show ip4-full-reassembly details"))
self.logger.debug(self.vapi.ppcli("show buffers"))
@classmethod
@ -197,7 +198,7 @@ class TestIPv4Reassembly(VppTestCase):
""" long fragment chain """
error_cnt_str = \
"/err/ip4-reassembly-feature/fragment chain too long (drop)"
"/err/ip4-full-reassembly-feature/fragment chain too long (drop)"
error_cnt = self.statistics.get_err_counter(error_cnt_str)
@ -247,11 +248,12 @@ class TestIPv4Reassembly(VppTestCase):
self.pg_start()
self.dst_if.get_capture(1)
self.assert_packet_counter_equal("ip4-reassembly-feature", 1)
self.logger.debug(self.vapi.ppcli("show error"))
self.assert_packet_counter_equal("ip4-full-reassembly-feature", 1)
# TODO remove above, uncomment below once clearing of counters
# is supported
# self.assert_packet_counter_equal(
# "/err/ip4-reassembly-feature/malformed packets", 1)
# "/err/ip4-full-reassembly-feature/malformed packets", 1)
def test_44924(self):
""" compress tiny fragments """
@ -314,11 +316,11 @@ class TestIPv4Reassembly(VppTestCase):
self.dst_if.get_capture(1)
self.assert_packet_counter_equal("ip4-reassembly-feature", 1)
self.assert_packet_counter_equal("ip4-full-reassembly-feature", 1)
# TODO remove above, uncomment below once clearing of counters
# is supported
# self.assert_packet_counter_equal(
# "/err/ip4-reassembly-feature/malformed packets", 1)
# "/err/ip4-full-reassembly-feature/malformed packets", 1)
def test_random(self):
""" random order reassembly """
@ -551,7 +553,7 @@ class TestIPv4MWReassembly(VppTestCase):
super(TestIPv4MWReassembly, self).tearDown()
def show_commands_at_teardown(self):
self.logger.debug(self.vapi.ppcli("show ip4-reassembly details"))
self.logger.debug(self.vapi.ppcli("show ip4-full-reassembly details"))
self.logger.debug(self.vapi.ppcli("show buffers"))
@classmethod
@ -713,14 +715,14 @@ class TestIPv6Reassembly(VppTestCase):
self.vapi.ip_reassembly_set(timeout_ms=1000000, max_reassemblies=1000,
max_reassembly_length=1000,
expire_walk_interval_ms=10000, is_ip6=1)
self.logger.debug(self.vapi.ppcli("show ip6-reassembly details"))
self.logger.debug(self.vapi.ppcli("show ip6-full-reassembly details"))
self.logger.debug(self.vapi.ppcli("show buffers"))
def tearDown(self):
super(TestIPv6Reassembly, self).tearDown()
def show_commands_at_teardown(self):
self.logger.debug(self.vapi.ppcli("show ip6-reassembly details"))
self.logger.debug(self.vapi.ppcli("show ip6-full-reassembly details"))
self.logger.debug(self.vapi.ppcli("show buffers"))
@classmethod
@ -883,7 +885,7 @@ class TestIPv6Reassembly(VppTestCase):
""" long fragment chain """
error_cnt_str = \
"/err/ip6-reassembly-feature/fragment chain too long (drop)"
"/err/ip6-full-reassembly-feature/fragment chain too long (drop)"
error_cnt = self.statistics.get_err_counter(error_cnt_str)
@ -1162,7 +1164,7 @@ class TestIPv6MWReassembly(VppTestCase):
super(TestIPv6MWReassembly, self).tearDown()
def show_commands_at_teardown(self):
self.logger.debug(self.vapi.ppcli("show ip6-reassembly details"))
self.logger.debug(self.vapi.ppcli("show ip6-full-reassembly details"))
self.logger.debug(self.vapi.ppcli("show buffers"))
@classmethod
@ -1324,7 +1326,7 @@ class TestIPv4ReassemblyLocalNode(VppTestCase):
super(TestIPv4ReassemblyLocalNode, self).tearDown()
def show_commands_at_teardown(self):
self.logger.debug(self.vapi.ppcli("show ip4-reassembly details"))
self.logger.debug(self.vapi.ppcli("show ip4-full-reassembly details"))
self.logger.debug(self.vapi.ppcli("show buffers"))
@classmethod
@ -1463,8 +1465,8 @@ class TestFIFReassembly(VppTestCase):
super(TestFIFReassembly, self).tearDown()
def show_commands_at_teardown(self):
self.logger.debug(self.vapi.ppcli("show ip4-reassembly details"))
self.logger.debug(self.vapi.ppcli("show ip6-reassembly details"))
self.logger.debug(self.vapi.ppcli("show ip4-full-reassembly details"))
self.logger.debug(self.vapi.ppcli("show ip6-full-reassembly details"))
self.logger.debug(self.vapi.ppcli("show buffers"))
def verify_capture(self, capture, ip_class, dropped_packet_indexes=[]):