X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fip_neighbor.c;h=2edd737aa0725da4d086c462830b9610b990c82b;hb=0bdd319b3b5d7d4037605f9baba8889d30bd1717;hp=a43fdfd58b34dde4aa98248481a2591424a3c5ab;hpb=7f358b30b04aabe9a35680997cc1eeefb080a869;p=vpp.git diff --git a/src/vnet/ip/ip_neighbor.c b/src/vnet/ip/ip_neighbor.c index a43fdfd58b3..2edd737aa07 100644 --- a/src/vnet/ip/ip_neighbor.c +++ b/src/vnet/ip/ip_neighbor.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include /* * IP neighbor scan parameter defaults are as follows: @@ -47,6 +47,69 @@ typedef struct static ip_neighbor_scan_config_t ip_neighbor_scan_conf; +int +ip_neighbor_add (const ip46_address_t * ip, + u8 is_ip6, + const u8 * mac, u32 sw_if_index, ip_neighbor_flags_t flags) +{ + int rv; + + /* + * there's no validation here of the ND/ARP entry being added. + * The expectation is that the FIB will ensure that nothing bad + * will come of adding bogus entries. + */ + if (is_ip6) + { + rv = vnet_set_ip6_ethernet_neighbor (vlib_get_main (), + sw_if_index, &ip->ip6, mac, 6, + (flags & IP_NEIGHBOR_FLAG_STATIC), + (flags & + IP_NEIGHBOR_FLAG_NO_ADJ_FIB)); + + } + else + { + ethernet_arp_ip4_over_ethernet_address_t a = { + .ip4 = ip->ip4, + }; + + clib_memcpy (&a.ethernet, mac, 6); + + rv = vnet_arp_set_ip4_over_ethernet (vnet_get_main (), + sw_if_index, + &a, + (flags & IP_NEIGHBOR_FLAG_STATIC), + (flags & + IP_NEIGHBOR_FLAG_NO_ADJ_FIB)); + } + + return (rv); +} + +int +ip_neighbor_del (const ip46_address_t * ip, u8 is_ip6, u32 sw_if_index) +{ + int rv; + + if (is_ip6) + { + rv = vnet_unset_ip6_ethernet_neighbor (vlib_get_main (), + sw_if_index, &ip->ip6); + } + else + { + ethernet_arp_ip4_over_ethernet_address_t a = { + .ip4 = ip->ip4, + }; + + rv = + vnet_arp_unset_ip4_over_ethernet (vnet_get_main (), sw_if_index, &a); + } + + return (rv); +} + void ip_neighbor_scan_enable_disable (ip_neighbor_scan_arg_t * arg) { @@ -57,13 +120,13 @@ ip_neighbor_scan_enable_disable (ip_neighbor_scan_arg_t * arg) if (arg->mode) { cfg->scan_interval = arg->scan_interval ? - arg->scan_interval * 1.0 : IP_NEIGHBOR_DEF_SCAN_INTERVAL; + arg->scan_interval * 60.0 : IP_NEIGHBOR_DEF_SCAN_INTERVAL; cfg->max_proc_time = arg->max_proc_time ? arg->max_proc_time * 1e-6 : IP_NEIGHBOR_DEF_MAX_PROC_TIME; cfg->scan_int_delay = arg->scan_int_delay ? arg->scan_int_delay * 1e-3 : IP_NEIGHBOR_DEF_SCAN_INT_DELAY; cfg->stale_threshold = arg->stale_threshold ? - arg->stale_threshold * 1.0 : cfg->scan_interval * 4; + arg->stale_threshold * 60.0 : cfg->scan_interval * 4; cfg->max_update = arg->max_update ? cfg->max_update : IP_NEIGHBOR_DEF_MAX_UPDATE; } @@ -134,8 +197,7 @@ ip_neighbor_scan (vlib_main_t * vm, f64 start_time, u32 start_idx, else { vnet_unset_ip6_ethernet_neighbor - (vm, n6->key.sw_if_index, &n6->key.ip6_address, - n6->link_layer_address, 6); + (vm, n6->key.sw_if_index, &n6->key.ip6_address); } } else if (delta >= cfg->scan_interval) @@ -143,10 +205,10 @@ ip_neighbor_scan (vlib_main_t * vm, f64 start_time, u32 start_idx, update_count[0]++; /* probe neighbor */ if (!is_ip6) - ip4_probe_neighbor (vm, &n4->ip4_address, n4->sw_if_index); + ip4_probe_neighbor (vm, &n4->ip4_address, n4->sw_if_index, 1); else ip6_probe_neighbor (vm, &n6->key.ip6_address, - n6->key.sw_if_index); + n6->key.sw_if_index, 1); } next_neighbor: