From d74de22904687af10de9dbea04a282afb42fb326 Mon Sep 17 00:00:00 2001 From: Hongjun Ni Date: Mon, 24 Apr 2017 20:18:10 +0800 Subject: Fix dual-loop issue of NSH-SNAT. NSHSFC-30 Change-Id: I000f617e554c55da2629503da415350e139eceba Signed-off-by: Hongjun Ni --- nsh-plugin/nsh/nsh.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/nsh-plugin/nsh/nsh.c b/nsh-plugin/nsh/nsh.c index f2d4685..34aa9ab 100644 --- a/nsh-plugin/nsh/nsh.c +++ b/nsh-plugin/nsh/nsh.c @@ -1617,6 +1617,8 @@ nsh_input_map (vlib_main_t * vm, nsh_proxy_session_by_key_t key0, key1; uword *p0, *p1; nsh_proxy_session_t *proxy0, *proxy1; + u32 sw_if_index0 = 0, sw_if_index1 = 0; + ethernet_header_t dummy_eth0, dummy_eth1; /* Prefetch next iteration. */ { @@ -1656,6 +1658,21 @@ nsh_input_map (vlib_main_t * vm, { nsp_nsi0 = clib_host_to_net_u32(vnet_buffer(b0)->l2_classify.opaque_index); } + else if(node_type == NSH_AWARE_VNF_PROXY_TYPE) + { + /* Push dummy Eth header */ + memset(&dummy_eth0.dst_address[0], 0x11223344, 4); + memset(&dummy_eth0.dst_address[4], 0x5566, 2); + memset(&dummy_eth0.src_address[0], 0x778899aa, 4); + memset(&dummy_eth0.src_address[4], 0xbbcc, 2); + dummy_eth0.type = 0x0800; + vlib_buffer_advance(b0, -(word)sizeof(ethernet_header_t)); + hdr0 = vlib_buffer_get_current(b0); + clib_memcpy(hdr0, &dummy_eth0, (word)sizeof(ethernet_header_t)); + + sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_TX]; + nsp_nsi0 = nm->tunnel_index_by_sw_if_index[sw_if_index0]; + } else { memset (&key0, 0, sizeof(key0)); @@ -1688,6 +1705,21 @@ nsh_input_map (vlib_main_t * vm, { nsp_nsi1 = clib_host_to_net_u32(vnet_buffer(b1)->l2_classify.opaque_index); } + else if(node_type == NSH_AWARE_VNF_PROXY_TYPE) + { + /* Push dummy Eth header */ + memset(&dummy_eth1.dst_address[0], 0x11223344, 4); + memset(&dummy_eth1.dst_address[4], 0x5566, 2); + memset(&dummy_eth1.src_address[0], 0x778899aa, 4); + memset(&dummy_eth1.src_address[4], 0xbbcc, 2); + dummy_eth1.type = 0x0800; + vlib_buffer_advance(b1, -(word)sizeof(ethernet_header_t)); + hdr1 = vlib_buffer_get_current(b1); + clib_memcpy(hdr1, &dummy_eth1, (word)sizeof(ethernet_header_t)); + + sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_TX]; + nsp_nsi1 = nm->tunnel_index_by_sw_if_index[sw_if_index1]; + } else { memset (&key1, 0, sizeof(key1)); -- cgit 1.2.3-korg