diff options
-rw-r--r-- | vnet/Makefile.am | 13 | ||||
-rw-r--r-- | vnet/vnet/nsh-gre/decap.c | 22 | ||||
-rw-r--r-- | vnet/vnet/nsh-gre/nsh_gre.c | 97 | ||||
-rw-r--r-- | vnet/vnet/nsh-gre/nsh_gre.h | 27 | ||||
-rw-r--r-- | vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.c | 76 | ||||
-rw-r--r-- | vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.h | 20 | ||||
-rw-r--r-- | vnet/vnet/nsh/nsh_error.def (renamed from vnet/vnet/nsh-gre/nsh_gre_error.def) | 0 | ||||
-rw-r--r-- | vnet/vnet/nsh/nsh_packet.h (renamed from vnet/vnet/nsh-gre/nsh_gre_packet.h) | 21 | ||||
-rw-r--r-- | vpp-api-test/vat/api_format.c | 12 | ||||
-rw-r--r-- | vpp/api/api.c | 46 | ||||
-rw-r--r-- | vpp/api/custom_dump.c | 8 |
11 files changed, 173 insertions, 169 deletions
diff --git a/vnet/Makefile.am b/vnet/Makefile.am index a69734d1530..9393c1a8772 100644 --- a/vnet/Makefile.am +++ b/vnet/Makefile.am @@ -397,6 +397,15 @@ nobase_include_HEADERS += \ ######################################## +# NSH Map: nsh +######################################## + +nobase_include_HEADERS += \ + vnet/nsh/nsh_packet.h \ + vnet/nsh/nsh_error.def + + +######################################## # Tunnel protocol: nsh-gre ######################################## @@ -406,9 +415,7 @@ libvnet_la_SOURCES += \ 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 + vnet/nsh-gre/nsh_gre.h ######################################## # Tunnel protocol: nsh-vxlan-gpe diff --git a/vnet/vnet/nsh-gre/decap.c b/vnet/vnet/nsh-gre/decap.c index 2b6ae9a7d4c..c10b11b3070 100644 --- a/vnet/vnet/nsh-gre/decap.c +++ b/vnet/vnet/nsh-gre/decap.c @@ -18,7 +18,7 @@ #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; @@ -42,10 +42,10 @@ u8 * format_nsh_header_with_length (u8 * s, va_list * args) 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 "); - 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", @@ -54,8 +54,8 @@ u8 * format_nsh_header_with_length (u8 * s, va_list * args) 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), @@ -171,8 +171,8 @@ nsh_gre_input (vlib_main_t * vm, 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)) { @@ -332,7 +332,7 @@ nsh_gre_input (vlib_main_t * vm, tunnel_index0 = ~0; error0 = 0; - next0 = NSH_INPUT_NEXT_DROP; + next0 = NSH_GRE_INPUT_NEXT_DROP; if (PREDICT_FALSE(key0 != last_key)) { @@ -418,7 +418,7 @@ nsh_gre_input (vlib_main_t * vm, 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 _ }; @@ -432,9 +432,9 @@ VLIB_REGISTER_NODE (nsh_gre_input_node) = { .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, .next_nodes = { -#define _(s,n) [NSH_INPUT_NEXT_##s] = n, +#define _(s,n) [NSH_GRE_INPUT_NEXT_##s] = n, foreach_nsh_gre_input_next #undef _ }, diff --git a/vnet/vnet/nsh-gre/nsh_gre.c b/vnet/vnet/nsh-gre/nsh_gre.c index be49e86bca3..e75ed9dd862 100644 --- a/vnet/vnet/nsh-gre/nsh_gre.c +++ b/vnet/vnet/nsh-gre/nsh_gre.c @@ -28,13 +28,13 @@ static u8 * format_decap_next (u8 * s, va_list * args) switch (next_index) { - case NSH_INPUT_NEXT_DROP: + case NSH_GRE_INPUT_NEXT_DROP: return format (s, "drop"); - case NSH_INPUT_NEXT_IP4_INPUT: + case NSH_GRE_INPUT_NEXT_IP4_INPUT: return format (s, "ip4"); - case NSH_INPUT_NEXT_IP6_INPUT: + case NSH_GRE_INPUT_NEXT_IP6_INPUT: 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); @@ -57,22 +57,22 @@ u8 * format_nsh_gre_tunnel (u8 * s, va_list * args) 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 "); - 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", - 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", - (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", - t->c1, t->c2, t->c3, t->c4); + t->nsh_hdr.c1, t->nsh_hdr.c2, t->nsh_hdr.c3, t->nsh_hdr.c4); return s; } @@ -148,19 +148,22 @@ _(src.as_u32) \ _(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) \ _(tlvs) -#define foreach_32bit_field \ +#define foreach_32bit_field \ _(spi_si) \ _(c1) \ _(c2) \ @@ -175,7 +178,7 @@ static int nsh_gre_rewrite (nsh_gre_tunnel_t * t) 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); @@ -196,14 +199,14 @@ static int nsh_gre_rewrite (nsh_gre_tunnel_t * t) /* 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); @@ -211,12 +214,12 @@ static int nsh_gre_rewrite (nsh_gre_tunnel_t * t) #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; /* Copy any TLVs */ - 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); @@ -236,7 +239,7 @@ int vnet_nsh_gre_add_del_tunnel (vnet_nsh_gre_add_del_tunnel_args_t *a, 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; @@ -248,7 +251,7 @@ int vnet_nsh_gre_add_del_tunnel (vnet_nsh_gre_add_del_tunnel_args_t *a, 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); @@ -259,6 +262,11 @@ int vnet_nsh_gre_add_del_tunnel (vnet_nsh_gre_add_del_tunnel_args_t *a, 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) @@ -334,13 +342,13 @@ static uword unformat_decap_next (unformat_input_t * input, va_list * args) u32 tmp; if (unformat (input, "drop")) - *result = NSH_INPUT_NEXT_DROP; + *result = NSH_GRE_INPUT_NEXT_DROP; else if (unformat (input, "ip4")) - *result = NSH_INPUT_NEXT_IP4_INPUT; + *result = NSH_GRE_INPUT_NEXT_IP4_INPUT; else if (unformat (input, "ip6")) - *result = NSH_INPUT_NEXT_IP6_INPUT; + *result = NSH_GRE_INPUT_NEXT_IP6_INPUT; 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 @@ -463,7 +471,12 @@ nsh_gre_add_del_tunnel_command_fn (vlib_main_t * vm, #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) diff --git a/vnet/vnet/nsh-gre/nsh_gre.h b/vnet/vnet/nsh-gre/nsh_gre.h index 580942f0f19..abe115580cb 100644 --- a/vnet/vnet/nsh-gre/nsh_gre.h +++ b/vnet/vnet/nsh-gre/nsh_gre.h @@ -17,7 +17,7 @@ #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 { @@ -46,15 +46,8 @@ typedef struct { 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 \ @@ -64,15 +57,15 @@ typedef struct { _ (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 _ - NSH_INPUT_N_NEXT, + NSH_GRE_INPUT_N_NEXT, } 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; @@ -108,13 +101,7 @@ typedef struct { 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; + nsh_header_t nsh_hdr; } vnet_nsh_gre_add_del_tunnel_args_t; int vnet_nsh_gre_add_del_tunnel (vnet_nsh_gre_add_del_tunnel_args_t *a, diff --git a/vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.c b/vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.c index d96ba57b1cf..88945cd8762 100644 --- a/vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.c +++ b/vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.c @@ -52,22 +52,22 @@ u8 * format_nsh_vxlan_gpe_tunnel (u8 * s, va_list * args) 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 "); - 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", - 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", - (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", - t->c1, t->c2, t->c3, t->c4); + t->nsh_hdr.c1, t->nsh_hdr.c2, t->nsh_hdr.c3, t->nsh_hdr.c4); return s; } @@ -144,19 +144,22 @@ _(dst.as_u32) \ _(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) \ _(tlvs) -#define foreach_32bit_field \ +#define foreach_32bit_field \ _(spi_si) \ _(c1) \ _(c2) \ @@ -171,7 +174,7 @@ static int nsh_vxlan_gpe_rewrite (nsh_vxlan_gpe_tunnel_t * t) 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); @@ -200,14 +203,14 @@ static int nsh_vxlan_gpe_rewrite (nsh_vxlan_gpe_tunnel_t * t) /* 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); @@ -215,12 +218,12 @@ static int nsh_vxlan_gpe_rewrite (nsh_vxlan_gpe_tunnel_t * t) #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; /* Copy any TLVs */ - 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); @@ -242,7 +245,7 @@ int vnet_nsh_vxlan_gpe_add_del_tunnel 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); @@ -263,6 +266,11 @@ int vnet_nsh_vxlan_gpe_add_del_tunnel #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); @@ -487,6 +495,10 @@ nsh_vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm, #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 */); diff --git a/vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.h b/vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.h index 99dc60001f6..3effd3318cb 100644 --- a/vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.h +++ b/vnet/vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.h @@ -22,7 +22,7 @@ #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> @@ -73,15 +73,7 @@ typedef struct { 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_vxlan_gpe_tunnel_t; #define foreach_nsh_vxlan_gpe_input_next \ @@ -137,13 +129,7 @@ typedef struct { 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; + nsh_header_t nsh_hdr; } vnet_nsh_vxlan_gpe_add_del_tunnel_args_t; int vnet_nsh_vxlan_gpe_add_del_tunnel diff --git a/vnet/vnet/nsh-gre/nsh_gre_error.def b/vnet/vnet/nsh/nsh_error.def index 532b02a6e89..532b02a6e89 100644 --- a/vnet/vnet/nsh-gre/nsh_gre_error.def +++ b/vnet/vnet/nsh/nsh_error.def diff --git a/vnet/vnet/nsh-gre/nsh_gre_packet.h b/vnet/vnet/nsh/nsh_packet.h index 0620f227b9f..87d46a93b6d 100644 --- a/vnet/vnet/nsh-gre/nsh_gre_packet.h +++ b/vnet/vnet/nsh/nsh_packet.h @@ -12,11 +12,11 @@ * 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 @@ -78,16 +78,15 @@ typedef CLIB_PACKED(struct { u32 c1; u32 c2; u32 c3; u32 c4; /* Optional variable length metadata */ - u32 tlvs[0]; + u32 * tlvs; }) nsh_header_t; -#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 */ -#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 */ diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c index 4a57d4cb018..548959edb3b 100644 --- a/vpp-api-test/vat/api_format.c +++ b/vpp-api-test/vat/api_format.c @@ -7894,13 +7894,13 @@ static uword unformat_nsh_gre_decap_next u32 tmp; if (unformat (input, "drop")) - *result = NSH_INPUT_NEXT_DROP; + *result = NSH_GRE_INPUT_NEXT_DROP; else if (unformat (input, "ip4")) - *result = NSH_INPUT_NEXT_IP4_INPUT; + *result = NSH_GRE_INPUT_NEXT_IP4_INPUT; else if (unformat (input, "ip6")) - *result = NSH_INPUT_NEXT_IP6_INPUT; + *result = NSH_GRE_INPUT_NEXT_IP6_INPUT; 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 @@ -7932,7 +7932,7 @@ static int api_nsh_gre_add_del_tunnel (vat_main_t * vam) 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 tmp; int i; @@ -8084,7 +8084,7 @@ static int api_nsh_vxlan_gpe_add_del_tunnel (vat_main_t * vam) 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; diff --git a/vpp/api/api.c b/vpp/api/api.c index 724bcf91018..e33e24d25ea 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -4543,7 +4543,7 @@ vl_api_nsh_gre_add_del_tunnel_t_handler 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; @@ -4563,20 +4563,20 @@ vl_api_nsh_gre_add_del_tunnel_t_handler 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])); - a->tlvs = tlvs; + a->nsh_hdr.tlvs = tlvs; rv = vnet_nsh_gre_add_del_tunnel (a, &sw_if_index); @@ -4612,7 +4612,7 @@ vl_api_nsh_vxlan_gpe_add_del_tunnel_t_handler 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; @@ -4633,20 +4633,20 @@ vl_api_nsh_vxlan_gpe_add_del_tunnel_t_handler 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])); - a->tlvs = tlvs; + a->nsh_hdr.tlvs = tlvs; rv = vnet_nsh_vxlan_gpe_add_del_tunnel (a, &sw_if_index); @@ -4680,7 +4680,7 @@ vl_api_lisp_gpe_add_del_tunnel_t_handler 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; diff --git a/vpp/api/custom_dump.c b/vpp/api/custom_dump.c index 6ae8c76dd82..574e102fc46 100644 --- a/vpp/api/custom_dump.c +++ b/vpp/api/custom_dump.c @@ -1603,9 +1603,9 @@ static void *vl_api_nsh_gre_add_del_tunnel_t_print 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 "); - 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); @@ -1659,9 +1659,9 @@ static void *vl_api_nsh_vxlan_gpe_add_del_tunnel_t_print 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 "); - 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); |