- /*
- * ip[46] lookup in the configured FIB
- * nsh-vxlan-gpe-encap, here's the encap tunnel sw_if_index
- */
- vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->decap_fib_index;
+ if (next0 == NSH_VXLAN_GPE_INPUT_NEXT_NSH_VXLAN_GPE_ENCAP)
+ {
+ /*
+ * Functioning as SFF (ie "half NSH tunnel mode")
+ * If ingress (we are in decap.c) with NSH header, and 'decap next nsh-vxlan-gpe' then "NSH switch"
+ * 1. Take DST, remap to SRC, remap other keys in place
+ * 2. Look up new t0 as per above
+ * 3. Set sw_if_index[VLIB_TX] to be t0->sw_if_index
+ */
+ uword * next_p0;
+ nsh_vxlan_gpe_tunnel_t * next_t0;
+ nsh_vxlan_gpe_tunnel_key_t next_key0;
+
+ next_key0.src = iuvn0->ip4.dst_address.as_u32;
+ next_key0.vni = iuvn0->vxlan.vni_res;
+ next_key0.spi_si = iuvn0->nsh.spi_si;
+ next_key0.pad = 0;
+
+ next_p0 = hash_get_mem (ngm->nsh_vxlan_gpe_tunnel_by_key, &next_key0);
+
+ if (next_p0 == 0)
+ {
+ error0 = NSH_VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
+ goto trace0;
+ }
+ next_t0 = pool_elt_at_index (ngm->tunnels, next_p0[0]);
+ vnet_buffer(b0)->sw_if_index[VLIB_TX] = next_t0->sw_if_index;
+
+ }
+ else
+ {
+ /*
+ * ip[46] lookup in the configured FIB
+ * nsh-vxlan-gpe-encap, here's the encap tunnel sw_if_index
+ */
+ vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->decap_fib_index;
+ }
+