X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip-neighbor%2Fip_neighbor.c;h=6ba191abaf6bcc893841922b035d12113d13328d;hb=3bad8b62d87513c5f4004c3172551c8785c78e65;hp=78b45a27c9d8a806638dbbe33c4b9700dd67f6be;hpb=b2c31b685fd2cf28436ca32bc93e23eb24c74878;p=vpp.git diff --git a/src/vnet/ip-neighbor/ip_neighbor.c b/src/vnet/ip-neighbor/ip_neighbor.c index 78b45a27c9d..6ba191abaf6 100644 --- a/src/vnet/ip-neighbor/ip_neighbor.c +++ b/src/vnet/ip-neighbor/ip_neighbor.c @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -691,13 +692,18 @@ ip_neighbor_update (vnet_main_t * vnm, adj_index_t ai) ip_neighbor_probe (adj); } break; + case IP_LOOKUP_NEXT_REWRITE: + /* Update of an existing rewrite adjacency happens e.g. when the + * interface's MAC address changes */ + if (NULL != ipn) + ip_neighbor_mk_complete (ai, ipn); + break; case IP_LOOKUP_NEXT_GLEAN: case IP_LOOKUP_NEXT_BCAST: case IP_LOOKUP_NEXT_MCAST: case IP_LOOKUP_NEXT_DROP: case IP_LOOKUP_NEXT_PUNT: case IP_LOOKUP_NEXT_LOCAL: - case IP_LOOKUP_NEXT_REWRITE: case IP_LOOKUP_NEXT_MCAST_MIDCHAIN: case IP_LOOKUP_NEXT_MIDCHAIN: case IP_LOOKUP_NEXT_ICMP_ERROR: @@ -1141,31 +1147,6 @@ ip6_neighbor_proxy_del (u32 sw_if_index, const ip6_address_t * addr) return -1; } -static void -ip_neighbor_ethernet_change_mac (ethernet_main_t * em, - u32 sw_if_index, uword opaque) -{ - ip_neighbor_t *ipn; - - IP_NEIGHBOR_DBG ("mac-change: %U", - format_vnet_sw_if_index_name, vnet_get_main (), - sw_if_index); - - /* *INDENT-OFF* */ - pool_foreach (ipn, ip_neighbor_pool) - { - if (ipn->ipn_key->ipnk_sw_if_index == sw_if_index) - adj_nbr_walk_nh (ipn->ipn_key->ipnk_sw_if_index, - ip_address_family_to_fib_proto(ip_neighbor_get_af(ipn)), - &ip_addr_46(&ipn->ipn_key->ipnk_ip), - ip_neighbor_mk_complete_walk, - ipn); - } - /* *INDENT-ON* */ - - adj_glean_update_rewrite_itf (sw_if_index); -} - void ip_neighbor_populate (ip_address_family_t af, u32 sw_if_index) { @@ -1223,7 +1204,7 @@ ip_neighbor_flush (ip_address_family_t af, u32 sw_if_index) vec_free (ipnis); } -static walk_rc_t +walk_rc_t ip_neighbor_mark_one (index_t ipni, void *ctx) { ip_neighbor_t *ipn; @@ -1717,12 +1698,65 @@ ip_neighbor_config_show (vlib_main_t * vm, return (NULL); } +static clib_error_t * +ip_neighbor_config_set (vlib_main_t *vm, unformat_input_t *input, + vlib_cli_command_t *cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + clib_error_t *error = NULL; + ip_address_family_t af; + u32 limit, age; + bool recycle; + + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + if (!unformat (line_input, "%U", unformat_ip_address_family, &af)) + { + error = unformat_parse_error (line_input); + goto done; + } + + limit = ip_neighbor_db[af].ipndb_limit; + age = ip_neighbor_db[af].ipndb_age; + recycle = ip_neighbor_db[af].ipndb_recycle; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "limit %u", &limit)) + ; + else if (unformat (line_input, "age %u", &age)) + ; + else if (unformat (line_input, "recycle")) + recycle = true; + else if (unformat (line_input, "norecycle")) + recycle = false; + else + { + error = unformat_parse_error (line_input); + goto done; + } + } + + ip_neighbor_config (af, limit, age, recycle); + +done: + unformat_free (line_input); + return error; +} + /* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_ip_neighbor_cfg_cmd_node, static) = { .path = "show ip neighbor-config", .function = ip_neighbor_config_show, .short_help = "show ip neighbor-config", }; +VLIB_CLI_COMMAND (set_ip_neighbor_cfg_cmd_node, static) = { + .path = "set ip neighbor-config", + .function = ip_neighbor_config_set, + .short_help = "set ip neighbor-config ip4|ip6 [limit ] [age ] " + "[recycle|norecycle]", +}; /* *INDENT-ON* */ static clib_error_t * @@ -1752,14 +1786,6 @@ ip_neighbor_init (vlib_main_t * vm) }; vec_add1 (ip6_main.table_bind_callbacks, cb); } - { - ethernet_address_change_ctx_t ctx = { - .function = ip_neighbor_ethernet_change_mac, - .function_opaque = 0, - }; - vec_add1 (ethernet_main.address_change_callbacks, ctx); - } - ipn_logger = vlib_log_register_class ("ip", "neighbor"); ip_address_family_t af;