From b1895cf231a03f221e41048f84864619ef5f9fe0 Mon Sep 17 00:00:00 2001 From: Hongjun Ni Date: Mon, 17 Apr 2017 22:40:13 +0800 Subject: Extend nsh map to support gre4 and gre6 tunnel Change-Id: I8c2384082b54a013209c325573edd3775f5eda78 Signed-off-by: Hongjun Ni --- nsh-plugin/nsh/nsh.c | 18 +++++++++++++----- nsh-plugin/nsh/nsh.h | 3 ++- nsh-plugin/nsh/nsh_test.c | 6 ++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/nsh-plugin/nsh/nsh.c b/nsh-plugin/nsh/nsh.c index a59609a..603570b 100644 --- a/nsh-plugin/nsh/nsh.c +++ b/nsh-plugin/nsh/nsh.c @@ -342,9 +342,14 @@ u8 * format_nsh_map (u8 * s, va_list * args) switch (map->next_node) { - case NSH_NODE_NEXT_ENCAP_GRE: + case NSH_NODE_NEXT_ENCAP_GRE4: { - s = format (s, "encapped by GRE intf: %d", map->sw_if_index); + s = format (s, "encapped by GRE4 intf: %d", map->sw_if_index); + break; + } + case NSH_NODE_NEXT_ENCAP_GRE6: + { + s = format (s, "encapped by GRE6 intf: %d", map->sw_if_index); break; } case NSH_NODE_NEXT_ENCAP_VXLANGPE: @@ -686,8 +691,10 @@ nsh_add_del_map_command_fn (vlib_main_t * vm, else if (unformat (line_input, "nsh_action %U", unformat_nsh_action, &nsh_action)) nsh_action_set = 1; - else if (unformat (line_input, "encap-gre-intf %d", &sw_if_index)) - next_node = NSH_NODE_NEXT_ENCAP_GRE; + else if (unformat (line_input, "encap-gre4-intf %d", &sw_if_index)) + next_node = NSH_NODE_NEXT_ENCAP_GRE4; + else if (unformat (line_input, "encap-gre6-intf %d", &sw_if_index)) + next_node = NSH_NODE_NEXT_ENCAP_GRE6; else if (unformat (line_input, "encap-vxlan-gpe-intf %d", &sw_if_index)) next_node = NSH_NODE_NEXT_ENCAP_VXLANGPE; else if (unformat (line_input, "encap-lisp-gpe-intf %d", &sw_if_index)) @@ -773,7 +780,8 @@ VLIB_CLI_COMMAND (create_nsh_map_command, static) = { .path = "create nsh map", .short_help = "create nsh map nsp nsi [del] mapped-nsp mapped-nsi nsh_action [swap|push|pop] " - "[encap-gre-intf | encap-vxlan-gpe-intf | encap-lisp-gpe-intf | encap-none]\n", + "[encap-gre4-intf | encap-gre4-intf | encap-vxlan-gpe-intf | encap-lisp-gpe-intf " + " encap-vxlan4-intf | encap-vxlan6-intf | encap-none]\n", .function = nsh_add_del_map_command_fn, }; diff --git a/nsh-plugin/nsh/nsh.h b/nsh-plugin/nsh/nsh.h index b03c8e7..4efad8d 100644 --- a/nsh-plugin/nsh/nsh.h +++ b/nsh-plugin/nsh/nsh.h @@ -190,7 +190,8 @@ typedef enum { #define foreach_nsh_node_next \ _(DROP, "error-drop") \ - _(ENCAP_GRE, "gre-input" ) \ + _(ENCAP_GRE4, "gre4-input" ) \ + _(ENCAP_GRE6, "gre6-input" ) \ _(ENCAP_VXLANGPE, "vxlan-gpe-encap" ) \ _(ENCAP_VXLAN4, "vxlan4-encap" ) \ _(ENCAP_VXLAN6, "vxlan6-encap" ) \ diff --git a/nsh-plugin/nsh/nsh_test.c b/nsh-plugin/nsh/nsh_test.c index 1d0a16c..6171b58 100644 --- a/nsh-plugin/nsh/nsh_test.c +++ b/nsh-plugin/nsh/nsh_test.c @@ -273,8 +273,10 @@ static int api_nsh_add_del_map (vat_main_t * vam) mapped_nsp_set = 1; else if (unformat (line_input, "mapped-nsi %d", &mapped_nsi)) mapped_nsi_set = 1; - else if (unformat (line_input, "encap-gre-intf %d", &sw_if_index)) - next_node = NSH_NODE_NEXT_ENCAP_GRE; + else if (unformat (line_input, "encap-gre4-intf %d", &sw_if_index)) + next_node = NSH_NODE_NEXT_ENCAP_GRE4; + else if (unformat (line_input, "encap-gre6-intf %d", &sw_if_index)) + next_node = NSH_NODE_NEXT_ENCAP_GRE6; else if (unformat (line_input, "encap-vxlan-gpe-intf %d", &sw_if_index)) next_node = NSH_NODE_NEXT_ENCAP_VXLANGPE; else if (unformat (line_input, "encap-none")) -- cgit 1.2.3-korg