diff options
author | Andrew Yourtchenko <ayourtch@gmail.com> | 2017-10-25 05:50:37 -0700 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2017-10-25 16:28:03 +0000 |
commit | 5f3fcb96296a4769f55f60270e10c6294c604db9 (patch) | |
tree | 028293ba04f669187b8d41cd72f34f195e12e81b /src/vnet/ip/lookup.c | |
parent | 36ea2d6d3a67a60534a7c2b58551688858a1ce7f (diff) |
L3 proxy FIB source for container networking
Change-Id: I4164c4c19c8dbfd73e6ddf94a12056325cc093b9
Signed-off-by: Neale Ranns <nranns@cisco.com>
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src/vnet/ip/lookup.c')
-rw-r--r-- | src/vnet/ip/lookup.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c index 856c4942ea4..61350b4f0d8 100644 --- a/src/vnet/ip/lookup.c +++ b/src/vnet/ip/lookup.c @@ -49,6 +49,7 @@ #include <vnet/dpo/punt_dpo.h> #include <vnet/dpo/receive_dpo.h> #include <vnet/dpo/ip_null_dpo.h> +#include <vnet/dpo/l3_proxy_dpo.h> #include <vnet/ip/ip6_neighbor.h> /** @@ -1433,6 +1434,84 @@ VLIB_CLI_COMMAND (ip_probe_neighbor_command, static) = { }; /* *INDENT-ON* */ +clib_error_t * +ip_container_cmd (vlib_main_t * vm, + unformat_input_t * main_input, vlib_cli_command_t * cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + fib_prefix_t pfx; + + u32 is_del; + vnet_main_t *vnm; + u32 fib_index; + u32 sw_if_index; + + vnm = vnet_get_main (); + is_del = 0; + sw_if_index = ~0; + + /* Get a line of input. */ + if (!unformat_user (main_input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "%U", unformat_ip4_address, &pfx.fp_addr.ip4)) + { + pfx.fp_proto = FIB_PROTOCOL_IP4; + pfx.fp_len = 32; + } + else if (unformat (line_input, "%U", + unformat_ip6_address, &pfx.fp_addr.ip6)) + { + pfx.fp_proto = FIB_PROTOCOL_IP6; + pfx.fp_len = 128; + } + else if (unformat (line_input, "%U", + unformat_vnet_sw_interface, vnm, &sw_if_index)) + ; + else if (unformat (line_input, "del")) + is_del = 1; + else + return (clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input)); + } + + if (~0 == sw_if_index) + { + return (clib_error_return (0, "no interface")); + } + + fib_index = fib_table_get_table_id_for_sw_if_index (pfx.fp_proto, + sw_if_index); + + if (is_del) + fib_table_entry_special_remove (fib_index, &pfx, FIB_SOURCE_PROXY); + else + { + dpo_id_t proxy_dpo = DPO_INVALID; + + l3_proxy_dpo_add_or_lock (fib_proto_to_dpo (pfx.fp_proto), + sw_if_index, &proxy_dpo); + + fib_table_entry_special_dpo_add (fib_index, + &pfx, + FIB_SOURCE_PROXY, + FIB_ENTRY_FLAG_EXCLUSIVE, &proxy_dpo); + } + + return (NULL); +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (ip_container_command_node, static) = { + .path = "ip container", + .function = ip_container_cmd, + .short_help = "ip container <address> <interface>", + .is_mp_safe = 1, +}; +/* *INDENT-ON* */ + /* * fd.io coding-style-patch-verification: ON * |