From c59a668da538c902bd49e5900e3fbf4ae36f5a4b Mon Sep 17 00:00:00 2001 From: Andrew Yourtchenko Date: Tue, 21 Nov 2017 14:37:43 +0100 Subject: [PATCH] stn-plugin: do not assume all punted packets start with L3 header. Some punt scenarios (notably, involving DNS traffic) do not have the current_data set to the L3 header - as a result, chaos ensues. To tackle this, approach the parsing from the other side, and look at the hopefully remaining ethernet header to see whether the packet is IPv4 or IPv6. Verified the STN'ed TCP traffic continues to work, and that the STN'ed DNS traffic starts to work as well. Change-Id: I0aa2ad1df2fb23dd4e54a564714103b19114d636 Signed-off-by: Andrew Yourtchenko --- src/plugins/stn/stn.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/stn/stn.c b/src/plugins/stn/stn.c index a9e6a98ebed..b05883b239d 100644 --- a/src/plugins/stn/stn.c +++ b/src/plugins/stn/stn.c @@ -109,8 +109,20 @@ stn_punt_fn (vlib_main_t * vm, p0 = vlib_get_buffer (vm, pi0); +/* + * We are not guaranteed any particular layer here. + * So we need to reparse from the beginning of the packet. + * which may not start from zero with some DPDK drivers. + ip4_header_t *ip = vlib_buffer_get_current(p0); if ((ip->ip_version_and_header_length & 0xf0) == 0x40) +* +*/ + int ethernet_header_offset = 0; /* to be filled by DPDK */ + ethernet_header_t *eth = (ethernet_header_t *)(p0->data + ethernet_header_offset); + /* ensure the block current data starts at L3 boundary now for the subsequent nodes */ + vlib_buffer_advance(p0, ethernet_header_offset + sizeof(ethernet_header_t) - p0->current_data); + if (clib_net_to_host_u16(eth->type) == ETHERNET_TYPE_IP4) next0 = stn->punt_to_stn_ip4_next_index; else next0 = stn->punt_to_stn_ip6_next_index; -- 2.16.6