- common header files and structs used in both GRE and VXLAN-GPE
Change-Id: I06d0b773e936fb011408817237059f24a4beb412
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
+########################################
+# NSH Map: nsh
+########################################
+
+nobase_include_HEADERS += \
+ vnet/nsh/nsh_packet.h \
+ vnet/nsh/nsh_error.def
+
+
########################################
# Tunnel protocol: nsh-gre
########################################
########################################
# Tunnel protocol: nsh-gre
########################################
vnet/nsh-gre/decap.c
nobase_include_HEADERS += \
vnet/nsh-gre/decap.c
nobase_include_HEADERS += \
- vnet/nsh-gre/nsh_gre.h \
- vnet/nsh-gre/nsh_gre_packet.h \
- vnet/nsh-gre/nsh_gre_error.def
########################################
# Tunnel protocol: nsh-vxlan-gpe
########################################
# Tunnel protocol: nsh-vxlan-gpe
#include <vlib/vlib.h>
#include <vnet/pg/pg.h>
#include <vnet/nsh-gre/nsh_gre.h>
#include <vlib/vlib.h>
#include <vnet/pg/pg.h>
#include <vnet/nsh-gre/nsh_gre.h>
-#include <vnet/nsh-gre/nsh_gre_packet.h>
+#include <vnet/nsh/nsh_packet.h>
vlib_node_registration_t nsh_input_node;
vlib_node_registration_t nsh_input_node;
s = format (s, "ver %d ", h->ver_o_c>>6);
s = format (s, "ver %d ", h->ver_o_c>>6);
- if (h->ver_o_c & NSH_GRE_O_BIT)
+ if (h->ver_o_c & NSH_O_BIT)
s = format (s, "O-set ");
s = format (s, "O-set ");
- if (h->ver_o_c & NSH_GRE_C_BIT)
+ if (h->ver_o_c & NSH_C_BIT)
s = format (s, "C-set ");
s = format (s, "len %d (%d bytes) md_type %d next_protocol %d\n",
s = format (s, "C-set ");
s = format (s, "len %d (%d bytes) md_type %d next_protocol %d\n",
tmp = clib_net_to_host_u32 (h->spi_si);
s = format (s, " spi %d si %d ",
tmp = clib_net_to_host_u32 (h->spi_si);
s = format (s, " spi %d si %d ",
- (tmp>>NSH_GRE_SPI_SHIFT) & NSH_GRE_SPI_MASK,
- tmp & NSH_GRE_SINDEX_MASK);
+ (tmp>>NSH_SPI_SHIFT) & NSH_SPI_MASK,
+ tmp & NSH_SINDEX_MASK);
s = format (s, "c1 %u c2 %u c3 %u c4 %u",
clib_net_to_host_u32 (h->c1),
s = format (s, "c1 %u c2 %u c3 %u c4 %u",
clib_net_to_host_u32 (h->c1),
tunnel_index1 = ~0;
error0 = 0;
error1 = 0;
tunnel_index1 = ~0;
error0 = 0;
error1 = 0;
- next0 = NSH_INPUT_NEXT_DROP;
- next1 = NSH_INPUT_NEXT_DROP;
+ next0 = NSH_GRE_INPUT_NEXT_DROP;
+ next1 = NSH_GRE_INPUT_NEXT_DROP;
if (PREDICT_FALSE(key0 != last_key))
{
if (PREDICT_FALSE(key0 != last_key))
{
tunnel_index0 = ~0;
error0 = 0;
tunnel_index0 = ~0;
error0 = 0;
- next0 = NSH_INPUT_NEXT_DROP;
+ next0 = NSH_GRE_INPUT_NEXT_DROP;
if (PREDICT_FALSE(key0 != last_key))
{
if (PREDICT_FALSE(key0 != last_key))
{
static char * nsh_error_strings[] = {
#define nsh_gre_error(n,s) s,
static char * nsh_error_strings[] = {
#define nsh_gre_error(n,s) s,
-#include <vnet/nsh-gre/nsh_gre_error.def>
+#include <vnet/nsh/nsh_error.def>
#undef nsh_gre_error
#undef _
};
#undef nsh_gre_error
#undef _
};
.n_errors = NSH_GRE_N_ERROR,
.error_strings = nsh_error_strings,
.n_errors = NSH_GRE_N_ERROR,
.error_strings = nsh_error_strings,
- .n_next_nodes = NSH_INPUT_N_NEXT,
+ .n_next_nodes = NSH_GRE_INPUT_N_NEXT,
-#define _(s,n) [NSH_INPUT_NEXT_##s] = n,
+#define _(s,n) [NSH_GRE_INPUT_NEXT_##s] = n,
foreach_nsh_gre_input_next
#undef _
},
foreach_nsh_gre_input_next
#undef _
},
- case NSH_INPUT_NEXT_DROP:
+ case NSH_GRE_INPUT_NEXT_DROP:
return format (s, "drop");
return format (s, "drop");
- case NSH_INPUT_NEXT_IP4_INPUT:
+ case NSH_GRE_INPUT_NEXT_IP4_INPUT:
return format (s, "ip4");
return format (s, "ip4");
- case NSH_INPUT_NEXT_IP6_INPUT:
+ case NSH_GRE_INPUT_NEXT_IP6_INPUT:
return format (s, "ip6");
return format (s, "ip6");
- case NSH_INPUT_NEXT_ETHERNET_INPUT:
+ case NSH_GRE_INPUT_NEXT_ETHERNET_INPUT:
return format (s, "ethernet");
default:
return format (s, "index %d", next_index);
return format (s, "ethernet");
default:
return format (s, "index %d", next_index);
s = format (s, " decap-next %U\n", format_decap_next, t->decap_next_index);
s = format (s, " decap-next %U\n", format_decap_next, t->decap_next_index);
- s = format (s, " ver %d ", (t->ver_o_c>>6));
- if (t->ver_o_c & NSH_GRE_O_BIT)
+ s = format (s, " ver %d ", (t->nsh_hdr.ver_o_c>>6));
+ if (t->nsh_hdr.ver_o_c & NSH_O_BIT)
s = format (s, "O-set ");
s = format (s, "O-set ");
- if (t->ver_o_c & NSH_GRE_C_BIT)
+ if (t->nsh_hdr.ver_o_c & NSH_C_BIT)
s = format (s, "C-set ");
s = format (s, "len %d (%d bytes) md_type %d next_protocol %d\n",
s = format (s, "C-set ");
s = format (s, "len %d (%d bytes) md_type %d next_protocol %d\n",
- t->length, t->length * 4, t->md_type, t->next_protocol);
+ t->nsh_hdr.length, t->nsh_hdr.length * 4, t->nsh_hdr.md_type, t->nsh_hdr.next_protocol);
s = format (s, " service path %d service index %d\n",
s = format (s, " service path %d service index %d\n",
- (t->spi_si>>NSH_GRE_SPI_SHIFT) & NSH_GRE_SPI_MASK,
- t->spi_si & NSH_GRE_SINDEX_MASK);
+ (t->nsh_hdr.spi_si>>NSH_SPI_SHIFT) & NSH_SPI_MASK,
+ t->nsh_hdr.spi_si & NSH_SINDEX_MASK);
s = format (s, " c1 %d c2 %d c3 %d c4 %d\n",
s = format (s, " c1 %d c2 %d c3 %d c4 %d\n",
- t->c1, t->c2, t->c3, t->c4);
+ t->nsh_hdr.c1, t->nsh_hdr.c2, t->nsh_hdr.c3, t->nsh_hdr.c4);
_(dst.as_u32) \
_(encap_fib_index) \
_(decap_fib_index) \
_(dst.as_u32) \
_(encap_fib_index) \
_(decap_fib_index) \
-_(decap_next_index) \
-_(ver_o_c) \
-_(length) \
-_(md_type) \
-_(next_protocol) \
-_(spi_si) \
-_(c1) \
-_(c2) \
-_(c3) \
-_(c4) \
+_(decap_next_index)
+
+
+#define foreach_copy_nshhdr_field \
+_(ver_o_c) \
+_(length) \
+_(md_type) \
+_(next_protocol) \
+_(spi_si) \
+_(c1) \
+_(c2) \
+_(c3) \
+_(c4) \
-#define foreach_32bit_field \
+#define foreach_32bit_field \
_(spi_si) \
_(c1) \
_(c2) \
_(spi_si) \
_(c1) \
_(c2) \
ip4_gre_and_nsh_header_t * h0;
int len;
ip4_gre_and_nsh_header_t * h0;
int len;
- len = sizeof (*h0) + vec_len(t->tlvs)*4;
+ len = sizeof (*h0) + vec_len(t->nsh_hdr.tlvs)*4;
vec_validate_aligned (rw, len-1, CLIB_CACHE_LINE_BYTES);
vec_validate_aligned (rw, len-1, CLIB_CACHE_LINE_BYTES);
/* NSH header */
nsh0 = &h0->nsh;
/* NSH header */
nsh0 = &h0->nsh;
- nsh0->ver_o_c = t->ver_o_c;
- nsh0->md_type = t->md_type;
- nsh0->next_protocol = t->next_protocol;
- nsh0->spi_si = t->spi_si;
- nsh0->c1 = t->c1;
- nsh0->c2 = t->c2;
- nsh0->c3 = t->c3;
- nsh0->c4 = t->c4;
+ nsh0->ver_o_c = t->nsh_hdr.ver_o_c;
+ nsh0->md_type = t->nsh_hdr.md_type;
+ nsh0->next_protocol = t->nsh_hdr.next_protocol;
+ nsh0->spi_si = t->nsh_hdr.spi_si;
+ nsh0->c1 = t->nsh_hdr.c1;
+ nsh0->c2 = t->nsh_hdr.c2;
+ nsh0->c3 = t->nsh_hdr.c3;
+ nsh0->c4 = t->nsh_hdr.c4;
/* Endian swap 32-bit fields */
#define _(x) nsh0->x = clib_host_to_net_u32(nsh0->x);
/* Endian swap 32-bit fields */
#define _(x) nsh0->x = clib_host_to_net_u32(nsh0->x);
#undef _
/* fix nsh header length */
#undef _
/* fix nsh header length */
- t->length = 6 + vec_len(t->tlvs);
- nsh0->length = t->length;
+ t->nsh_hdr.length = 6 + vec_len(t->nsh_hdr.tlvs);
+ nsh0->length = t->nsh_hdr.length;
- if (vec_len(t->tlvs))
- clib_memcpy (nsh0->tlvs, t->tlvs, 4*vec_len(t->tlvs));
+ if (vec_len(t->nsh_hdr.tlvs))
+ clib_memcpy (nsh0->tlvs, t->nsh_hdr.tlvs, 4*vec_len(t->nsh_hdr.tlvs));
t->rewrite = rw;
return (0);
t->rewrite = rw;
return (0);
u64 key;
u32 spi_si_net_byte_order;
u64 key;
u32 spi_si_net_byte_order;
- spi_si_net_byte_order = clib_host_to_net_u32(a->spi_si);
+ spi_si_net_byte_order = clib_host_to_net_u32(a->nsh_hdr.spi_si);
key = (((u64)(a->src.as_u32))<<32) | spi_si_net_byte_order;
key = (((u64)(a->src.as_u32))<<32) | spi_si_net_byte_order;
if (p)
return VNET_API_ERROR_INVALID_VALUE;
if (p)
return VNET_API_ERROR_INVALID_VALUE;
- if (a->decap_next_index >= NSH_INPUT_N_NEXT)
+ if (a->decap_next_index >= NSH_GRE_INPUT_N_NEXT)
return VNET_API_ERROR_INVALID_DECAP_NEXT;
pool_get_aligned (ngm->tunnels, t, CLIB_CACHE_LINE_BYTES);
return VNET_API_ERROR_INVALID_DECAP_NEXT;
pool_get_aligned (ngm->tunnels, t, CLIB_CACHE_LINE_BYTES);
foreach_copy_field;
#undef _
foreach_copy_field;
#undef _
+ /* copy from arg structure */
+#define _(x) t->nsh_hdr.x = a->nsh_hdr.x;
+ foreach_copy_nshhdr_field;
+#undef _
+
rv = nsh_gre_rewrite (t);
if (rv)
rv = nsh_gre_rewrite (t);
if (rv)
u32 tmp;
if (unformat (input, "drop"))
u32 tmp;
if (unformat (input, "drop"))
- *result = NSH_INPUT_NEXT_DROP;
+ *result = NSH_GRE_INPUT_NEXT_DROP;
else if (unformat (input, "ip4"))
else if (unformat (input, "ip4"))
- *result = NSH_INPUT_NEXT_IP4_INPUT;
+ *result = NSH_GRE_INPUT_NEXT_IP4_INPUT;
else if (unformat (input, "ip6"))
else if (unformat (input, "ip6"))
- *result = NSH_INPUT_NEXT_IP6_INPUT;
+ *result = NSH_GRE_INPUT_NEXT_IP6_INPUT;
else if (unformat (input, "ethernet"))
else if (unformat (input, "ethernet"))
- *result = NSH_INPUT_NEXT_ETHERNET_INPUT;
+ *result = NSH_GRE_INPUT_NEXT_ETHERNET_INPUT;
else if (unformat (input, "%d", &tmp))
*result = tmp;
else
else if (unformat (input, "%d", &tmp))
*result = tmp;
else
#define _(x) a->x = x;
foreach_copy_field;
#undef _
#define _(x) a->x = x;
foreach_copy_field;
#undef _
+
+ /* copy from arg structure */
+#define _(x) a->nsh_hdr.x = x;
+ foreach_copy_nshhdr_field;
+#undef _
+
rv = vnet_nsh_gre_add_del_tunnel (a, 0 /* hw_if_indexp */);
switch(rv)
rv = vnet_nsh_gre_add_del_tunnel (a, 0 /* hw_if_indexp */);
switch(rv)
#include <vnet/vnet.h>
#include <vnet/gre/gre.h>
#include <vnet/vnet.h>
#include <vnet/gre/gre.h>
-#include <vnet/nsh-gre/nsh_gre_packet.h>
+#include <vnet/nsh/nsh_packet.h>
#include <vnet/ip/ip4_packet.h>
typedef CLIB_PACKED (struct {
#include <vnet/ip/ip4_packet.h>
typedef CLIB_PACKED (struct {
u32 sw_if_index;
/* NSH header fields in HOST byte order */
u32 sw_if_index;
/* NSH header fields in HOST byte order */
- u8 ver_o_c;
- u8 length;
- u8 md_type;
- u8 next_protocol;
- u32 spi_si;
-
- /* Context headers, always present, in HOST byte order */
- u32 c1, c2, c3, c4;
- u32 * tlvs;
+ nsh_header_t nsh_hdr;
+
} nsh_gre_tunnel_t;
#define foreach_nsh_gre_input_next \
} nsh_gre_tunnel_t;
#define foreach_nsh_gre_input_next \
_ (ETHERNET_INPUT, "ethernet-input")
typedef enum {
_ (ETHERNET_INPUT, "ethernet-input")
typedef enum {
-#define _(s,n) NSH_INPUT_NEXT_##s,
+#define _(s,n) NSH_GRE_INPUT_NEXT_##s,
foreach_nsh_gre_input_next
#undef _
foreach_nsh_gre_input_next
#undef _
} nsh_gre_input_next_t;
typedef enum {
#define nsh_gre_error(n,s) NSH_GRE_ERROR_##n,
} nsh_gre_input_next_t;
typedef enum {
#define nsh_gre_error(n,s) NSH_GRE_ERROR_##n,
-#include <vnet/nsh-gre/nsh_gre_error.def>
+#include <vnet/nsh/nsh_error.def>
#undef nsh_gre_error
NSH_GRE_N_ERROR,
} nsh_gre_input_error_t;
#undef nsh_gre_error
NSH_GRE_N_ERROR,
} nsh_gre_input_error_t;
u32 encap_fib_index;
u32 decap_fib_index;
u32 decap_next_index;
u32 encap_fib_index;
u32 decap_fib_index;
u32 decap_next_index;
- u8 ver_o_c;
- u8 length;
- u8 md_type;
- u8 next_protocol;
- u32 spi_si;
- u32 c1, c2, c3, c4;
- u32 * tlvs;
} vnet_nsh_gre_add_del_tunnel_args_t;
int vnet_nsh_gre_add_del_tunnel (vnet_nsh_gre_add_del_tunnel_args_t *a,
} vnet_nsh_gre_add_del_tunnel_args_t;
int vnet_nsh_gre_add_del_tunnel (vnet_nsh_gre_add_del_tunnel_args_t *a,
t->decap_fib_index);
s = format (s, " decap next %U\n", format_decap_next, t->decap_next_index);
s = format (s, " vxlan VNI %d ", t->vni);
t->decap_fib_index);
s = format (s, " decap next %U\n", format_decap_next, t->decap_next_index);
s = format (s, " vxlan VNI %d ", t->vni);
- s = format (s, "nsh ver %d ", (t->ver_o_c>>6));
- if (t->ver_o_c & NSH_GRE_O_BIT)
+ s = format (s, "nsh ver %d ", (t->nsh_hdr.ver_o_c>>6));
+ if (t->nsh_hdr.ver_o_c & NSH_O_BIT)
s = format (s, "O-set ");
s = format (s, "O-set ");
- if (t->ver_o_c & NSH_GRE_C_BIT)
+ if (t->nsh_hdr.ver_o_c & NSH_C_BIT)
s = format (s, "C-set ");
s = format (s, "len %d (%d bytes) md_type %d next_protocol %d\n",
s = format (s, "C-set ");
s = format (s, "len %d (%d bytes) md_type %d next_protocol %d\n",
- t->length, t->length * 4, t->md_type, t->next_protocol);
+ t->nsh_hdr.length, t->nsh_hdr.length * 4, t->nsh_hdr.md_type, t->nsh_hdr.next_protocol);
s = format (s, " service path %d service index %d\n",
s = format (s, " service path %d service index %d\n",
- (t->spi_si>>NSH_GRE_SPI_SHIFT) & NSH_GRE_SPI_MASK,
- t->spi_si & NSH_GRE_SINDEX_MASK);
+ (t->nsh_hdr.spi_si>>NSH_SPI_SHIFT) & NSH_SPI_MASK,
+ t->nsh_hdr.spi_si & NSH_SINDEX_MASK);
s = format (s, " c1 %d c2 %d c3 %d c4 %d\n",
s = format (s, " c1 %d c2 %d c3 %d c4 %d\n",
- t->c1, t->c2, t->c3, t->c4);
+ t->nsh_hdr.c1, t->nsh_hdr.c2, t->nsh_hdr.c3, t->nsh_hdr.c4);
_(vni) \
_(encap_fib_index) \
_(decap_fib_index) \
_(vni) \
_(encap_fib_index) \
_(decap_fib_index) \
-_(decap_next_index) \
-_(ver_o_c) \
-_(length) \
-_(md_type) \
-_(next_protocol) \
-_(spi_si) \
-_(c1) \
-_(c2) \
-_(c3) \
-_(c4) \
+_(decap_next_index)
+
+
+#define foreach_copy_nshhdr_field \
+_(ver_o_c) \
+_(length) \
+_(md_type) \
+_(next_protocol) \
+_(spi_si) \
+_(c1) \
+_(c2) \
+_(c3) \
+_(c4) \
-#define foreach_32bit_field \
+#define foreach_32bit_field \
_(spi_si) \
_(c1) \
_(c2) \
_(spi_si) \
_(c1) \
_(c2) \
ip4_vxlan_gpe_and_nsh_header_t * h0;
int len;
ip4_vxlan_gpe_and_nsh_header_t * h0;
int len;
- len = sizeof (*h0) + vec_len(t->tlvs)*4;
+ len = sizeof (*h0) + vec_len(t->nsh_hdr.tlvs)*4;
vec_validate_aligned (rw, len-1, CLIB_CACHE_LINE_BYTES);
vec_validate_aligned (rw, len-1, CLIB_CACHE_LINE_BYTES);
/* NSH header */
nsh0 = &h0->nsh;
/* NSH header */
nsh0 = &h0->nsh;
- nsh0->ver_o_c = t->ver_o_c;
- nsh0->md_type = t->md_type;
- nsh0->next_protocol = t->next_protocol;
- nsh0->spi_si = t->spi_si;
- nsh0->c1 = t->c1;
- nsh0->c2 = t->c2;
- nsh0->c3 = t->c3;
- nsh0->c4 = t->c4;
+ nsh0->ver_o_c = t->nsh_hdr.ver_o_c;
+ nsh0->md_type = t->nsh_hdr.md_type;
+ nsh0->next_protocol = t->nsh_hdr.next_protocol;
+ nsh0->spi_si = t->nsh_hdr.spi_si;
+ nsh0->c1 = t->nsh_hdr.c1;
+ nsh0->c2 = t->nsh_hdr.c2;
+ nsh0->c3 = t->nsh_hdr.c3;
+ nsh0->c4 = t->nsh_hdr.c4;
/* Endian swap 32-bit fields */
#define _(x) nsh0->x = clib_host_to_net_u32(nsh0->x);
/* Endian swap 32-bit fields */
#define _(x) nsh0->x = clib_host_to_net_u32(nsh0->x);
#undef _
/* fix nsh header length */
#undef _
/* fix nsh header length */
- t->length = 6 + vec_len(t->tlvs);
- nsh0->length = t->length;
+ t->nsh_hdr.length = 6 + vec_len(t->nsh_hdr.tlvs);
+ nsh0->length = t->nsh_hdr.length;
- if (vec_len(t->tlvs))
- clib_memcpy (nsh0->tlvs, t->tlvs, 4*vec_len(t->tlvs));
+ if (vec_len(t->nsh_hdr.tlvs))
+ clib_memcpy (nsh0->tlvs, t->nsh_hdr.tlvs, 4*vec_len(t->nsh_hdr.tlvs));
t->rewrite = rw;
return (0);
t->rewrite = rw;
return (0);
key.src = a->dst.as_u32; /* decap src in key is encap dst in config */
key.vni = clib_host_to_net_u32 (a->vni << 8);
key.src = a->dst.as_u32; /* decap src in key is encap dst in config */
key.vni = clib_host_to_net_u32 (a->vni << 8);
- key.spi_si = clib_host_to_net_u32(a->spi_si);
+ key.spi_si = clib_host_to_net_u32(a->nsh_hdr.spi_si);
key.pad = 0;
p = hash_get_mem (ngm->nsh_vxlan_gpe_tunnel_by_key, &key);
key.pad = 0;
p = hash_get_mem (ngm->nsh_vxlan_gpe_tunnel_by_key, &key);
#define _(x) t->x = a->x;
foreach_copy_field;
#undef _
#define _(x) t->x = a->x;
foreach_copy_field;
#undef _
+
+ /* copy from arg structure */
+#define _(x) t->nsh_hdr.x = a->nsh_hdr.x;
+ foreach_copy_nshhdr_field;
+#undef _
rv = nsh_vxlan_gpe_rewrite (t);
rv = nsh_vxlan_gpe_rewrite (t);
#define _(x) a->x = x;
foreach_copy_field;
#undef _
#define _(x) a->x = x;
foreach_copy_field;
#undef _
+
+#define _(x) a->nsh_hdr.x = x;
+ foreach_copy_nshhdr_field;
+#undef _
rv = vnet_nsh_vxlan_gpe_add_del_tunnel (a, 0 /* hw_if_indexp */);
rv = vnet_nsh_vxlan_gpe_add_del_tunnel (a, 0 /* hw_if_indexp */);
#include <vnet/l2/l2_input.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/gre/gre.h>
#include <vnet/l2/l2_input.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/gre/gre.h>
-#include <vnet/nsh-gre/nsh_gre_packet.h>
+#include <vnet/nsh/nsh_packet.h>
#include <vnet/nsh-vxlan-gpe/vxlan_gpe_packet.h>
#include <vnet/ip/ip4_packet.h>
#include <vnet/ip/udp.h>
#include <vnet/nsh-vxlan-gpe/vxlan_gpe_packet.h>
#include <vnet/ip/ip4_packet.h>
#include <vnet/ip/udp.h>
u32 sw_if_index;
/* NSH header fields in HOST byte order */
u32 sw_if_index;
/* NSH header fields in HOST byte order */
- u8 ver_o_c;
- u8 length;
- u8 md_type;
- u8 next_protocol;
- u32 spi_si;
-
- /* Context headers, always present, in HOST byte order */
- u32 c1, c2, c3, c4;
- u32 * tlvs;
} nsh_vxlan_gpe_tunnel_t;
#define foreach_nsh_vxlan_gpe_input_next \
} nsh_vxlan_gpe_tunnel_t;
#define foreach_nsh_vxlan_gpe_input_next \
u32 decap_fib_index;
u32 decap_next_index;
u32 vni;
u32 decap_fib_index;
u32 decap_next_index;
u32 vni;
- u8 ver_o_c;
- u8 length;
- u8 md_type;
- u8 next_protocol;
- u32 spi_si;
- u32 c1, c2, c3, c4;
- u32 * tlvs;
} vnet_nsh_vxlan_gpe_add_del_tunnel_args_t;
int vnet_nsh_vxlan_gpe_add_del_tunnel
} vnet_nsh_vxlan_gpe_add_del_tunnel_args_t;
int vnet_nsh_vxlan_gpe_add_del_tunnel
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef included_vnet_nsh_gre_packet_h
-#define included_vnet_nsh_gre_packet_h
+#ifndef included_vnet_nsh_packet_h
+#define included_vnet_nsh_packet_h
- * NSH_GRE packet format from draft-quinn-sfc-nsh-03.txt
+ * NSH packet format from draft-quinn-sfc-nsh-03.txt
*
* NSH Base Header
* 0 1 2 3
*
* NSH Base Header
* 0 1 2 3
u32 c1; u32 c2; u32 c3; u32 c4;
/* Optional variable length metadata */
u32 c1; u32 c2; u32 c3; u32 c4;
/* Optional variable length metadata */
-#define NSH_GRE_VERSION (0<<6)
-#define NSH_GRE_O_BIT (1<<5)
-#define NSH_GRE_C_BIT (1<<4)
+#define NSH_O_BIT (1<<5)
+#define NSH_C_BIT (1<<4)
/* Network byte order shift / mask */
/* Network byte order shift / mask */
-#define NSH_GRE_SINDEX_MASK 0xFF
-#define NSH_GRE_SPI_MASK (0x00FFFFFF)
-#define NSH_GRE_SPI_SHIFT 8
+#define NSH_SINDEX_MASK 0xFF
+#define NSH_SPI_MASK (0x00FFFFFF)
+#define NSH_SPI_SHIFT 8
-#endif /* included_vnet_nsh_gre_packet_h */
+#endif /* included_vnet_nsh_packet_h */
u32 tmp;
if (unformat (input, "drop"))
u32 tmp;
if (unformat (input, "drop"))
- *result = NSH_INPUT_NEXT_DROP;
+ *result = NSH_GRE_INPUT_NEXT_DROP;
else if (unformat (input, "ip4"))
else if (unformat (input, "ip4"))
- *result = NSH_INPUT_NEXT_IP4_INPUT;
+ *result = NSH_GRE_INPUT_NEXT_IP4_INPUT;
else if (unformat (input, "ip6"))
else if (unformat (input, "ip6"))
- *result = NSH_INPUT_NEXT_IP6_INPUT;
+ *result = NSH_GRE_INPUT_NEXT_IP6_INPUT;
else if (unformat (input, "ethernet"))
else if (unformat (input, "ethernet"))
- *result = NSH_INPUT_NEXT_ETHERNET_INPUT;
+ *result = NSH_GRE_INPUT_NEXT_ETHERNET_INPUT;
else if (unformat (input, "%d", &tmp))
*result = tmp;
else
else if (unformat (input, "%d", &tmp))
*result = tmp;
else
u32 c3 = 0;
u32 c4 = 0;
u32 *tlvs = 0;
u32 c3 = 0;
u32 c4 = 0;
u32 *tlvs = 0;
- u32 decap_next_index = NSH_INPUT_NEXT_IP4_INPUT;
+ u32 decap_next_index = NSH_GRE_INPUT_NEXT_IP4_INPUT;
u32 c3 = 0;
u32 c4 = 0;
u32 *tlvs = 0;
u32 c3 = 0;
u32 c4 = 0;
u32 *tlvs = 0;
- u32 decap_next_index = NSH_INPUT_NEXT_IP4_INPUT;
+ u32 decap_next_index = NSH_GRE_INPUT_NEXT_IP4_INPUT;
u32 vni;
u8 vni_set = 0;
u32 tmp;
u32 vni;
u8 vni_set = 0;
u32 tmp;
decap_next_index = ntohl(mp->decap_next_index);
/* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
decap_next_index = ntohl(mp->decap_next_index);
/* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
- if (decap_next_index == NSH_INPUT_NEXT_IP4_INPUT) {
+ if (decap_next_index == NSH_GRE_INPUT_NEXT_IP4_INPUT) {
p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
if (! p) {
rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
if (! p) {
rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
a->encap_fib_index = encap_fib_index;
a->decap_fib_index = decap_fib_index;
a->decap_next_index = decap_next_index;
a->encap_fib_index = encap_fib_index;
a->decap_fib_index = decap_fib_index;
a->decap_next_index = decap_next_index;
- a->ver_o_c = mp->ver_o_c;
- a->length = mp->length;
- a->md_type = mp->md_type;
- a->next_protocol = mp->next_protocol;
- a->spi_si = ntohl(mp->spi_si);
- a->c1 = ntohl(mp->c1);
- a->c2 = ntohl(mp->c2);
- a->c3 = ntohl(mp->c3);
- a->c4 = ntohl(mp->c4);
+ a->nsh_hdr.ver_o_c = mp->ver_o_c;
+ a->nsh_hdr.length = mp->length;
+ a->nsh_hdr.md_type = mp->md_type;
+ a->nsh_hdr.next_protocol = mp->next_protocol;
+ a->nsh_hdr.spi_si = ntohl(mp->spi_si);
+ a->nsh_hdr.c1 = ntohl(mp->c1);
+ a->nsh_hdr.c2 = ntohl(mp->c2);
+ a->nsh_hdr.c3 = ntohl(mp->c3);
+ a->nsh_hdr.c4 = ntohl(mp->c4);
for (i = 0; i < mp->tlv_len_in_words; i++)
vec_add1 (tlvs, ntohl(mp->tlvs[i]));
for (i = 0; i < mp->tlv_len_in_words; i++)
vec_add1 (tlvs, ntohl(mp->tlvs[i]));
+ a->nsh_hdr.tlvs = tlvs;
rv = vnet_nsh_gre_add_del_tunnel (a, &sw_if_index);
rv = vnet_nsh_gre_add_del_tunnel (a, &sw_if_index);
decap_next_index = ntohl(mp->decap_next_index);
/* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
decap_next_index = ntohl(mp->decap_next_index);
/* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
- if (decap_next_index == NSH_INPUT_NEXT_IP4_INPUT) {
+ if (decap_next_index == NSH_GRE_INPUT_NEXT_IP4_INPUT) {
p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
if (! p) {
rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
if (! p) {
rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
a->decap_fib_index = decap_fib_index;
a->decap_next_index = decap_next_index;
a->vni = ntohl(mp->vni);
a->decap_fib_index = decap_fib_index;
a->decap_next_index = decap_next_index;
a->vni = ntohl(mp->vni);
- a->ver_o_c = mp->ver_o_c;
- a->length = mp->length;
- a->md_type = mp->md_type;
- a->next_protocol = mp->next_protocol;
- a->spi_si = ntohl(mp->spi_si);
- a->c1 = ntohl(mp->c1);
- a->c2 = ntohl(mp->c2);
- a->c3 = ntohl(mp->c3);
- a->c4 = ntohl(mp->c4);
+ a->nsh_hdr.ver_o_c = mp->ver_o_c;
+ a->nsh_hdr.length = mp->length;
+ a->nsh_hdr.md_type = mp->md_type;
+ a->nsh_hdr.next_protocol = mp->next_protocol;
+ a->nsh_hdr.spi_si = ntohl(mp->spi_si);
+ a->nsh_hdr.c1 = ntohl(mp->c1);
+ a->nsh_hdr.c2 = ntohl(mp->c2);
+ a->nsh_hdr.c3 = ntohl(mp->c3);
+ a->nsh_hdr.c4 = ntohl(mp->c4);
for (i = 0; i < mp->tlv_len_in_words; i++)
vec_add1 (tlvs, ntohl(mp->tlvs[i]));
for (i = 0; i < mp->tlv_len_in_words; i++)
vec_add1 (tlvs, ntohl(mp->tlvs[i]));
+ a->nsh_hdr.tlvs = tlvs;
rv = vnet_nsh_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
rv = vnet_nsh_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
decap_next_index = ntohl(mp->decap_next_index);
/* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
decap_next_index = ntohl(mp->decap_next_index);
/* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
- if (decap_next_index == NSH_INPUT_NEXT_IP4_INPUT) {
+ if (decap_next_index == NSH_GRE_INPUT_NEXT_IP4_INPUT) {
p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
if (! p) {
rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
if (! p) {
rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
if (mp->ver_o_c & 0xc)
s = format (s, "version %d ", mp->ver_o_c>>6);
if (mp->ver_o_c & 0xc)
s = format (s, "version %d ", mp->ver_o_c>>6);
- if (mp->ver_o_c & NSH_GRE_O_BIT)
+ if (mp->ver_o_c & NSH_O_BIT)
s = format (s, "o-bit 1 ");
s = format (s, "o-bit 1 ");
- if (mp->ver_o_c & NSH_GRE_C_BIT)
+ if (mp->ver_o_c & NSH_C_BIT)
s = format (s, "c-bit 1 ");
if (mp->md_type)
s = format (s, "md-type %d ", mp->md_type);
s = format (s, "c-bit 1 ");
if (mp->md_type)
s = format (s, "md-type %d ", mp->md_type);
if (mp->ver_o_c & 0xc)
s = format (s, "version %d ", mp->ver_o_c>>6);
if (mp->ver_o_c & 0xc)
s = format (s, "version %d ", mp->ver_o_c>>6);
- if (mp->ver_o_c & NSH_GRE_O_BIT)
+ if (mp->ver_o_c & NSH_O_BIT)
s = format (s, "o-bit 1 ");
s = format (s, "o-bit 1 ");
- if (mp->ver_o_c & NSH_GRE_C_BIT)
+ if (mp->ver_o_c & NSH_C_BIT)
s = format (s, "c-bit 1 ");
if (mp->md_type)
s = format (s, "md-type %d ", mp->md_type);
s = format (s, "c-bit 1 ");
if (mp->md_type)
s = format (s, "md-type %d ", mp->md_type);