ip-neighbor: ARP and ND stats per-interface.
Type: feature stats of the like from: https://datatracker.ietf.org/doc/html/draft-ietf-rtgwg-arp-yang-model-03#section-4 Signed-off-by: Neale Ranns <neale@graphiant.com> Change-Id: Icb1bf4f6f7e6ccc2f44b0008d4774b61cae96184
This commit is contained in:
committed by
Beno�t Ganne
parent
896b184b78
commit
fd2417b2a4
@@ -771,15 +771,13 @@ gbb_endpoint_fwd_recalc (gbp_endpoint_t * ge)
|
||||
gbp_endpoint_add_itf (gbp_itf_get_sw_if_index (gef->gef_itf),
|
||||
gei);
|
||||
if (FIB_PROTOCOL_IP4 == pfx->fp_proto)
|
||||
ip4_neighbor_advertise (vlib_get_main (),
|
||||
vnet_get_main (),
|
||||
gg->gg_uplink_sw_if_index,
|
||||
&pfx->fp_addr.ip4);
|
||||
ip4_neighbor_advertise (
|
||||
vlib_get_main (), vnet_get_main (), gg->gg_uplink_sw_if_index,
|
||||
vlib_get_thread_index (), &pfx->fp_addr.ip4);
|
||||
else
|
||||
ip6_neighbor_advertise (vlib_get_main (),
|
||||
vnet_get_main (),
|
||||
gg->gg_uplink_sw_if_index,
|
||||
&pfx->fp_addr.ip6);
|
||||
ip6_neighbor_advertise (
|
||||
vlib_get_main (), vnet_get_main (), gg->gg_uplink_sw_if_index,
|
||||
vlib_get_thread_index (), &pfx->fp_addr.ip6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1162,6 +1162,31 @@ class TestGBP(VppTestCase):
|
||||
lf = VppL2FibEntry(self, epg_nat.bd.bd, ep.mac, ep.recirc.recirc, bvi_mac=0)
|
||||
lf.add_vpp_config()
|
||||
|
||||
self.assert_equal(
|
||||
self.statistics["/net/arp/tx/gratuitous"][
|
||||
:, epgs[0].uplink.sw_if_index
|
||||
].sum(),
|
||||
2,
|
||||
)
|
||||
self.assert_equal(
|
||||
self.statistics["/net/arp/tx/gratuitous"][
|
||||
:, epgs[1].uplink.sw_if_index
|
||||
].sum(),
|
||||
1,
|
||||
)
|
||||
self.assert_equal(
|
||||
self.statistics["/net/ip6-nd/tx/gratuitous"][
|
||||
:, epgs[0].uplink.sw_if_index
|
||||
].sum(),
|
||||
2,
|
||||
)
|
||||
self.assert_equal(
|
||||
self.statistics["/net/ip6-nd/tx/gratuitous"][
|
||||
:, epgs[1].uplink.sw_if_index
|
||||
].sum(),
|
||||
1,
|
||||
)
|
||||
|
||||
#
|
||||
# ARP packets for unknown IP are sent to the EPG uplink
|
||||
#
|
||||
|
||||
@@ -500,6 +500,7 @@ arping_neighbor_advertisement (vlib_main_t *vm, arping_args_t *args)
|
||||
vlib_cli_output (vm, "Sending %u GARP to %U", send_count,
|
||||
format_ip4_address, &args->address.ip.ip4);
|
||||
ip4_neighbor_advertise (vm, vnm, args->sw_if_index,
|
||||
vlib_get_thread_index (),
|
||||
&args->address.ip.ip4);
|
||||
}
|
||||
else
|
||||
@@ -509,6 +510,7 @@ arping_neighbor_advertisement (vlib_main_t *vm, arping_args_t *args)
|
||||
send_count, format_ip6_address,
|
||||
&args->address.ip.ip6);
|
||||
ip6_neighbor_advertise (vm, vnm, args->sw_if_index,
|
||||
vlib_get_thread_index (),
|
||||
&args->address.ip.ip6);
|
||||
}
|
||||
args->repeat--;
|
||||
@@ -587,7 +589,8 @@ arping_neighbor_probe_dst (vlib_main_t *vm, arping_args_t *args)
|
||||
if (args->silence == 0)
|
||||
vlib_cli_output (vm, "Sending %u ARP Request to %U", send_count,
|
||||
format_ip4_address, &args->address.ip.ip4);
|
||||
ip4_neighbor_probe_dst (args->sw_if_index, &args->address.ip.ip4);
|
||||
ip4_neighbor_probe_dst (args->sw_if_index, vlib_get_thread_index (),
|
||||
&args->address.ip.ip4);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -595,7 +598,8 @@ arping_neighbor_probe_dst (vlib_main_t *vm, arping_args_t *args)
|
||||
vlib_cli_output (vm, "Sending %u Neighbor Solicitation to %U",
|
||||
send_count, format_ip6_address,
|
||||
&args->address.ip.ip6);
|
||||
ip6_neighbor_probe_dst (args->sw_if_index, &args->address.ip.ip6);
|
||||
ip6_neighbor_probe_dst (args->sw_if_index, vlib_get_thread_index (),
|
||||
&args->address.ip.ip6);
|
||||
}
|
||||
args->repeat--;
|
||||
if ((args->interval > 0.0) && (args->repeat > 0))
|
||||
|
||||
+20
-2
@@ -25,6 +25,7 @@
|
||||
#include <vnet/pg/pg.h>
|
||||
|
||||
#include <vnet/ip-neighbor/ip_neighbor.h>
|
||||
#include <vnet/ip-neighbor/ip4_neighbor.h>
|
||||
#include <vnet/ip-neighbor/ip_neighbor_dp.h>
|
||||
|
||||
#include <vlibmemory/api.h>
|
||||
@@ -565,8 +566,14 @@ arp_reply (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
|
||||
error0 = ETHERNET_ARP_ERROR_l3_dst_address_not_local;
|
||||
else if (arp0->ip4_over_ethernet[0].ip4.as_u32 ==
|
||||
arp0->ip4_over_ethernet[1].ip4.as_u32)
|
||||
error0 = arp_learn (sw_if_index0,
|
||||
&arp0->ip4_over_ethernet[0]);
|
||||
{
|
||||
vlib_increment_simple_counter (
|
||||
&ip_neighbor_counters[AF_IP4]
|
||||
.ipnc[VLIB_RX][IP_NEIGHBOR_CTR_GRAT],
|
||||
vm->thread_index, sw_if_index0, 1);
|
||||
error0 =
|
||||
arp_learn (sw_if_index0, &arp0->ip4_over_ethernet[0]);
|
||||
}
|
||||
goto drop;
|
||||
case ARP_DST_FIB_CONN:
|
||||
/* destination is connected, continue to process */
|
||||
@@ -600,6 +607,14 @@ arp_reply (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
|
||||
goto drop;
|
||||
}
|
||||
|
||||
vlib_increment_simple_counter (
|
||||
&ip_neighbor_counters[AF_IP4]
|
||||
.ipnc[VLIB_RX][arp0->opcode == clib_host_to_net_u16 (
|
||||
ETHERNET_ARP_OPCODE_reply) ?
|
||||
IP_NEIGHBOR_CTR_REPLY :
|
||||
IP_NEIGHBOR_CTR_REQUEST],
|
||||
vm->thread_index, sw_if_index0, 1);
|
||||
|
||||
/* Learn or update sender's mapping only for replies to addresses
|
||||
* that are local to the subnet */
|
||||
if (arp0->opcode ==
|
||||
@@ -653,6 +668,9 @@ arp_reply (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
|
||||
if (!error0)
|
||||
error0 = arp_learn (sw_if_index0, &arp0->ip4_over_ethernet[1]);
|
||||
|
||||
vlib_increment_simple_counter (
|
||||
&ip_neighbor_counters[AF_IP4].ipnc[VLIB_TX][IP_NEIGHBOR_CTR_REPLY],
|
||||
vm->thread_index, sw_if_index0, 1);
|
||||
n_replies_sent += 1;
|
||||
goto enqueue;
|
||||
|
||||
|
||||
@@ -581,8 +581,10 @@ bond_active_interface_switch_cb (vnet_main_t * vnm, u32 sw_if_index,
|
||||
{
|
||||
bond_main_t *bm = &bond_main;
|
||||
|
||||
ip4_neighbor_advertise (bm->vlib_main, bm->vnet_main, sw_if_index, NULL);
|
||||
ip6_neighbor_advertise (bm->vlib_main, bm->vnet_main, sw_if_index, NULL);
|
||||
ip4_neighbor_advertise (bm->vlib_main, bm->vnet_main, sw_if_index,
|
||||
vlib_get_thread_index (), NULL);
|
||||
ip6_neighbor_advertise (bm->vlib_main, bm->vnet_main, sw_if_index,
|
||||
vlib_get_thread_index (), NULL);
|
||||
|
||||
return (WALK_CONTINUE);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ VLIB_REGISTER_LOG_CLASS (ip4_neighbor_log, static) = {
|
||||
vlib_log_debug (ip4_neighbor_log.class, fmt, __VA_ARGS__)
|
||||
|
||||
void
|
||||
ip4_neighbor_probe_dst (u32 sw_if_index, const ip4_address_t * dst)
|
||||
ip4_neighbor_probe_dst (u32 sw_if_index, u32 thread_index,
|
||||
const ip4_address_t *dst)
|
||||
{
|
||||
ip4_address_t src;
|
||||
adj_index_t ai;
|
||||
@@ -71,9 +72,8 @@ ip4_neighbor_probe_dst (u32 sw_if_index, const ip4_address_t * dst)
|
||||
}
|
||||
|
||||
void
|
||||
ip4_neighbor_advertise (vlib_main_t * vm,
|
||||
vnet_main_t * vnm,
|
||||
u32 sw_if_index, const ip4_address_t * addr)
|
||||
ip4_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index,
|
||||
u32 thread_index, const ip4_address_t *addr)
|
||||
{
|
||||
vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
|
||||
ip4_main_t *i4m = &ip4_main;
|
||||
@@ -126,6 +126,10 @@ ip4_neighbor_advertise (vlib_main_t * vm,
|
||||
to_next[0] = bi;
|
||||
f->n_vectors = 1;
|
||||
vlib_put_frame_to_node (vm, hi->output_node_index, f);
|
||||
|
||||
vlib_increment_simple_counter (
|
||||
&ip_neighbor_counters[AF_IP4].ipnc[VLIB_TX][IP_NEIGHBOR_CTR_GRAT],
|
||||
thread_index, sw_if_index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,19 +18,18 @@
|
||||
|
||||
#include <vnet/ip/ip.h>
|
||||
#include <vnet/ethernet/arp_packet.h>
|
||||
#include <vnet/ip-neighbor/ip_neighbor_types.h>
|
||||
|
||||
extern void ip4_neighbor_probe_dst (u32 sw_if_index,
|
||||
const ip4_address_t * dst);
|
||||
extern void ip4_neighbor_advertise (vlib_main_t * vm,
|
||||
vnet_main_t * vnm,
|
||||
u32 sw_if_index,
|
||||
const ip4_address_t * addr);
|
||||
extern void ip4_neighbor_probe_dst (u32 sw_if_index, u32 thread_index,
|
||||
const ip4_address_t *dst);
|
||||
extern void ip4_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm,
|
||||
u32 sw_if_index, u32 thread_index,
|
||||
const ip4_address_t *addr);
|
||||
|
||||
always_inline vlib_buffer_t *
|
||||
ip4_neighbor_probe (vlib_main_t * vm,
|
||||
vnet_main_t * vnm,
|
||||
const ip_adjacency_t * adj0,
|
||||
const ip4_address_t * src, const ip4_address_t * dst)
|
||||
ip4_neighbor_probe (vlib_main_t *vm, vnet_main_t *vnm,
|
||||
const ip_adjacency_t *adj0, const ip4_address_t *src,
|
||||
const ip4_address_t *dst)
|
||||
{
|
||||
vnet_hw_interface_t *hw_if0;
|
||||
ethernet_arp_header_t *h0;
|
||||
@@ -73,6 +72,10 @@ ip4_neighbor_probe (vlib_main_t * vm,
|
||||
vlib_put_frame_to_node (vm, hw_if0->output_node_index, f);
|
||||
}
|
||||
|
||||
vlib_increment_simple_counter (
|
||||
&ip_neighbor_counters[AF_IP4].ipnc[VLIB_TX][IP_NEIGHBOR_CTR_REQUEST],
|
||||
vm->thread_index, adj0->rewrite_header.sw_if_index, 1);
|
||||
|
||||
return b0;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,20 +31,20 @@ VLIB_REGISTER_LOG_CLASS (ip6_neighbor_log, static) = {
|
||||
#define log_debug(fmt, ...) \
|
||||
vlib_log_debug (ip6_neighbor_log.class, fmt, __VA_ARGS__)
|
||||
void
|
||||
ip6_neighbor_probe_dst (u32 sw_if_index, const ip6_address_t * dst)
|
||||
ip6_neighbor_probe_dst (u32 sw_if_index, u32 thread_index,
|
||||
const ip6_address_t *dst)
|
||||
{
|
||||
ip6_address_t src;
|
||||
|
||||
if (fib_sas6_get (sw_if_index, dst, &src) ||
|
||||
ip6_sas_by_sw_if_index (sw_if_index, dst, &src))
|
||||
ip6_neighbor_probe (vlib_get_main (), vnet_get_main (),
|
||||
sw_if_index, &src, dst);
|
||||
ip6_neighbor_probe (vlib_get_main (), vnet_get_main (), sw_if_index,
|
||||
thread_index, &src, dst);
|
||||
}
|
||||
|
||||
void
|
||||
ip6_neighbor_advertise (vlib_main_t * vm,
|
||||
vnet_main_t * vnm,
|
||||
u32 sw_if_index, const ip6_address_t * addr)
|
||||
ip6_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index,
|
||||
u32 thread_index, const ip6_address_t *addr)
|
||||
{
|
||||
vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
|
||||
ip6_main_t *i6m = &ip6_main;
|
||||
@@ -105,6 +105,10 @@ ip6_neighbor_advertise (vlib_main_t * vm,
|
||||
to_next[0] = bi;
|
||||
f->n_vectors = 1;
|
||||
vlib_put_frame_to_node (vm, hi->output_node_index, f);
|
||||
|
||||
vlib_increment_simple_counter (
|
||||
&ip_neighbor_counters[AF_IP6].ipnc[VLIB_TX][IP_NEIGHBOR_CTR_GRAT],
|
||||
thread_index, sw_if_index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,8 +226,8 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
|
||||
continue;
|
||||
}
|
||||
|
||||
b0 = ip6_neighbor_probe (vm, vnm, sw_if_index0,
|
||||
&src, &ip0->dst_address);
|
||||
b0 = ip6_neighbor_probe (vm, vnm, sw_if_index0, thread_index, &src,
|
||||
&ip0->dst_address);
|
||||
|
||||
if (PREDICT_TRUE (NULL != b0))
|
||||
{
|
||||
|
||||
@@ -25,23 +25,22 @@
|
||||
#include <vnet/ip/icmp46_packet.h>
|
||||
#include <vnet/ethernet/ethernet.h>
|
||||
#include <vnet/adj/adj_internal.h>
|
||||
#include <vnet/ip-neighbor/ip_neighbor_types.h>
|
||||
|
||||
/* Template used to generate IP6 neighbor solicitation packets. */
|
||||
extern vlib_packet_template_t ip6_neighbor_packet_template;
|
||||
|
||||
extern void ip6_neighbor_advertise (vlib_main_t * vm,
|
||||
vnet_main_t * vnm,
|
||||
u32 sw_if_index,
|
||||
const ip6_address_t * addr);
|
||||
extern void ip6_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm,
|
||||
u32 sw_if_index, u32 thread_index,
|
||||
const ip6_address_t *addr);
|
||||
|
||||
extern void ip6_neighbor_probe_dst (u32 sw_if_index,
|
||||
const ip6_address_t * dst);
|
||||
extern void ip6_neighbor_probe_dst (u32 sw_if_index, u32 thread_index,
|
||||
const ip6_address_t *dst);
|
||||
|
||||
always_inline vlib_buffer_t *
|
||||
ip6_neighbor_probe (vlib_main_t * vm,
|
||||
vnet_main_t * vnm,
|
||||
u32 sw_if_index,
|
||||
const ip6_address_t * src, const ip6_address_t * dst)
|
||||
ip6_neighbor_probe (vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index,
|
||||
u32 thread_index, const ip6_address_t *src,
|
||||
const ip6_address_t *dst)
|
||||
{
|
||||
icmp6_neighbor_solicitation_header_t *h0;
|
||||
vnet_hw_interface_t *hw_if0;
|
||||
@@ -104,6 +103,10 @@ ip6_neighbor_probe (vlib_main_t * vm,
|
||||
vlib_put_frame_to_node (vm, adj->ia_node_index, f);
|
||||
}
|
||||
|
||||
vlib_increment_simple_counter (
|
||||
&ip_neighbor_counters[AF_IP6].ipnc[VLIB_TX][IP_NEIGHBOR_CTR_REQUEST],
|
||||
thread_index, sw_if_index, 1);
|
||||
|
||||
return b0;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,74 @@
|
||||
#include <vnet/fib/fib_table.h>
|
||||
#include <vnet/adj/adj_mcast.h>
|
||||
|
||||
ip_neighbor_counters_t ip_neighbor_counters[] =
|
||||
{
|
||||
[AF_IP4] = {
|
||||
.ipnc = {
|
||||
[VLIB_RX] = {
|
||||
[IP_NEIGHBOR_CTR_REPLY] = {
|
||||
.name = "arp-rx-replies",
|
||||
.stat_segment_name = "/net/arp/rx/replies",
|
||||
},
|
||||
[IP_NEIGHBOR_CTR_REQUEST] = {
|
||||
.name = "arp-rx-requests",
|
||||
.stat_segment_name = "/net/arp/rx/requests",
|
||||
},
|
||||
[IP_NEIGHBOR_CTR_GRAT] = {
|
||||
.name = "arp-rx-gratuitous",
|
||||
.stat_segment_name = "/net/arp/rx/gratuitous",
|
||||
},
|
||||
},
|
||||
[VLIB_TX] = {
|
||||
[IP_NEIGHBOR_CTR_REPLY] = {
|
||||
.name = "arp-tx-replies",
|
||||
.stat_segment_name = "/net/arp/tx/replies",
|
||||
},
|
||||
[IP_NEIGHBOR_CTR_REQUEST] = {
|
||||
.name = "arp-tx-requests",
|
||||
.stat_segment_name = "/net/arp/tx/requests",
|
||||
},
|
||||
[IP_NEIGHBOR_CTR_GRAT] = {
|
||||
.name = "arp-tx-gratuitous",
|
||||
.stat_segment_name = "/net/arp/tx/gratuitous",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
[AF_IP6] = {
|
||||
.ipnc = {
|
||||
[VLIB_RX] = {
|
||||
[IP_NEIGHBOR_CTR_REPLY] = {
|
||||
.name = "ip6-nd-rx-replies",
|
||||
.stat_segment_name = "/net/ip6-nd/rx/replies",
|
||||
},
|
||||
[IP_NEIGHBOR_CTR_REQUEST] = {
|
||||
.name = "ip6-nd-rx-requests",
|
||||
.stat_segment_name = "/net/ip6-nd/rx/requests",
|
||||
},
|
||||
[IP_NEIGHBOR_CTR_GRAT] = {
|
||||
.name = "ip6-nd-rx-gratuitous",
|
||||
.stat_segment_name = "/net/ip6-nd/rx/gratuitous",
|
||||
},
|
||||
},
|
||||
[VLIB_TX] = {
|
||||
[IP_NEIGHBOR_CTR_REPLY] = {
|
||||
.name = "ip6-nd-tx-replies",
|
||||
.stat_segment_name = "/net/ip6-nd/tx/replies",
|
||||
},
|
||||
[IP_NEIGHBOR_CTR_REQUEST] = {
|
||||
.name = "ip6-nd-tx-requests",
|
||||
.stat_segment_name = "/net/ip6-nd/tx/requests",
|
||||
},
|
||||
[IP_NEIGHBOR_CTR_GRAT] = {
|
||||
.name = "ip6-nd-tx-gratuitous",
|
||||
.stat_segment_name = "/net/ip6-nd/tx/gratuitous",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/** Pool for All IP neighbors */
|
||||
static ip_neighbor_t *ip_neighbor_pool;
|
||||
|
||||
@@ -1017,8 +1085,8 @@ ip_neighbor_register (ip_address_family_t af, const ip_neighbor_vft_t * vft)
|
||||
}
|
||||
|
||||
void
|
||||
ip_neighbor_probe_dst (u32 sw_if_index,
|
||||
ip_address_family_t af, const ip46_address_t * dst)
|
||||
ip_neighbor_probe_dst (u32 sw_if_index, u32 thread_index,
|
||||
ip_address_family_t af, const ip46_address_t *dst)
|
||||
{
|
||||
if (!vnet_sw_interface_is_admin_up (vnet_get_main (), sw_if_index))
|
||||
return;
|
||||
@@ -1026,10 +1094,10 @@ ip_neighbor_probe_dst (u32 sw_if_index,
|
||||
switch (af)
|
||||
{
|
||||
case AF_IP6:
|
||||
ip6_neighbor_probe_dst (sw_if_index, &dst->ip6);
|
||||
ip6_neighbor_probe_dst (sw_if_index, thread_index, &dst->ip6);
|
||||
break;
|
||||
case AF_IP4:
|
||||
ip4_neighbor_probe_dst (sw_if_index, &dst->ip4);
|
||||
ip4_neighbor_probe_dst (sw_if_index, thread_index, &dst->ip4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1038,6 +1106,7 @@ void
|
||||
ip_neighbor_probe (const ip_adjacency_t * adj)
|
||||
{
|
||||
ip_neighbor_probe_dst (adj->rewrite_header.sw_if_index,
|
||||
vlib_get_thread_index (),
|
||||
ip_address_family_from_fib_proto (adj->ia_nh_proto),
|
||||
&adj->sub_type.nbr.next_hop);
|
||||
}
|
||||
@@ -1291,8 +1360,8 @@ VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (ip_neighbor_interface_admin_change);
|
||||
* Remove any arp entries associated with the specified interface
|
||||
*/
|
||||
static clib_error_t *
|
||||
ip_neighbor_delete_sw_interface (vnet_main_t * vnm,
|
||||
u32 sw_if_index, u32 is_add)
|
||||
ip_neighbor_add_del_sw_interface (vnet_main_t *vnm, u32 sw_if_index,
|
||||
u32 is_add)
|
||||
{
|
||||
IP_NEIGHBOR_DBG ("interface-change: %U %s",
|
||||
format_vnet_sw_if_index_name, vnet_get_main (),
|
||||
@@ -1305,10 +1374,16 @@ ip_neighbor_delete_sw_interface (vnet_main_t * vnm,
|
||||
FOR_EACH_IP_ADDRESS_FAMILY (af) ip_neighbor_flush (af, sw_if_index);
|
||||
}
|
||||
|
||||
if (is_add)
|
||||
{
|
||||
ip_neighbor_alloc_ctr (&ip_neighbor_counters[AF_IP4], sw_if_index);
|
||||
ip_neighbor_alloc_ctr (&ip_neighbor_counters[AF_IP6], sw_if_index);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
VNET_SW_INTERFACE_ADD_DEL_FUNCTION (ip_neighbor_delete_sw_interface);
|
||||
VNET_SW_INTERFACE_ADD_DEL_FUNCTION (ip_neighbor_add_del_sw_interface);
|
||||
|
||||
typedef struct ip_neighbor_walk_covered_ctx_t_
|
||||
{
|
||||
@@ -1519,8 +1594,9 @@ ip_neighbour_age_out (index_t ipni, f64 now, f64 * wait)
|
||||
}
|
||||
else
|
||||
{
|
||||
ip_neighbor_probe_dst (ip_neighbor_get_sw_if_index (ipn),
|
||||
af, &ip_addr_46 (&ipn->ipn_key->ipnk_ip));
|
||||
ip_neighbor_probe_dst (ip_neighbor_get_sw_if_index (ipn), af,
|
||||
vlib_get_thread_index (),
|
||||
&ip_addr_46 (&ipn->ipn_key->ipnk_ip));
|
||||
|
||||
ipn->ipn_n_probes++;
|
||||
*wait = 1;
|
||||
@@ -1745,6 +1821,47 @@ done:
|
||||
return error;
|
||||
}
|
||||
|
||||
static void
|
||||
ip_neighbor_stats_show_one (vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index)
|
||||
{
|
||||
vlib_cli_output (vm, " %U", format_vnet_sw_if_index_name, vnm, sw_if_index);
|
||||
vlib_cli_output (vm, " arp:%U", format_ip_neighbor_counters,
|
||||
&ip_neighbor_counters[AF_IP4], sw_if_index);
|
||||
vlib_cli_output (vm, " nd: %U", format_ip_neighbor_counters,
|
||||
&ip_neighbor_counters[AF_IP6], sw_if_index);
|
||||
}
|
||||
|
||||
static walk_rc_t
|
||||
ip_neighbor_stats_show_cb (vnet_main_t *vnm, vnet_sw_interface_t *si,
|
||||
void *ctx)
|
||||
{
|
||||
ip_neighbor_stats_show_one (ctx, vnm, si->sw_if_index);
|
||||
|
||||
return (WALK_CONTINUE);
|
||||
}
|
||||
|
||||
static clib_error_t *
|
||||
ip_neighbor_stats_show (vlib_main_t *vm, unformat_input_t *input,
|
||||
vlib_cli_command_t *cmd)
|
||||
{
|
||||
vnet_main_t *vnm;
|
||||
u32 sw_if_index;
|
||||
|
||||
vnm = vnet_get_main ();
|
||||
sw_if_index = ~0;
|
||||
(void) unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index);
|
||||
|
||||
if (~0 == sw_if_index)
|
||||
{
|
||||
vnet_sw_interface_walk (vnm, ip_neighbor_stats_show_cb, vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
ip_neighbor_stats_show_one (vm, vnm, sw_if_index);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
VLIB_CLI_COMMAND (show_ip_neighbor_cfg_cmd_node, static) = {
|
||||
.path = "show ip neighbor-config",
|
||||
@@ -1757,6 +1874,11 @@ VLIB_CLI_COMMAND (set_ip_neighbor_cfg_cmd_node, static) = {
|
||||
.short_help = "set ip neighbor-config ip4|ip6 [limit <limit>] [age <age>] "
|
||||
"[recycle|norecycle]",
|
||||
};
|
||||
VLIB_CLI_COMMAND (show_ip_neighbor_stats_cmd_node, static) = {
|
||||
.path = "show ip neighbor-stats",
|
||||
.function = ip_neighbor_stats_show,
|
||||
.short_help = "show ip neighbor-stats [interface]",
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
static clib_error_t *
|
||||
|
||||
@@ -54,9 +54,9 @@ extern void ip_neighbor_learn (const ip_neighbor_learn_t * l);
|
||||
extern void ip_neighbor_update (vnet_main_t * vnm, adj_index_t ai);
|
||||
|
||||
extern void ip_neighbor_probe (const ip_adjacency_t * adj);
|
||||
extern void ip_neighbor_probe_dst (u32 sw_if_index,
|
||||
extern void ip_neighbor_probe_dst (u32 sw_if_index, u32 thread_index,
|
||||
ip_address_family_t af,
|
||||
const ip46_address_t * ip);
|
||||
const ip46_address_t *ip);
|
||||
|
||||
extern void ip_neighbor_mark (ip_address_family_t af);
|
||||
extern void ip_neighbor_sweep (ip_address_family_t af);
|
||||
@@ -112,7 +112,6 @@ typedef struct ip_neighbor_vft_t_
|
||||
extern void ip_neighbor_register (ip_address_family_t af,
|
||||
const ip_neighbor_vft_t * vft);
|
||||
|
||||
|
||||
#endif /* __INCLUDE_IP_NEIGHBOR_H__ */
|
||||
|
||||
/*
|
||||
|
||||
@@ -83,6 +83,53 @@ format_ip_neighbor (u8 * s, va_list * va)
|
||||
ipn->ipn_key->ipnk_sw_if_index));
|
||||
}
|
||||
|
||||
static void
|
||||
ip_neighbor_alloc_one_ctr (ip_neighbor_counters_t *ctr, vlib_dir_t dir,
|
||||
ip_neighbor_counter_type_t type, u32 sw_if_index)
|
||||
{
|
||||
vlib_validate_simple_counter (&(ctr->ipnc[dir][type]), sw_if_index);
|
||||
vlib_zero_simple_counter (&(ctr->ipnc[dir][type]), sw_if_index);
|
||||
}
|
||||
|
||||
void
|
||||
ip_neighbor_alloc_ctr (ip_neighbor_counters_t *ctr, u32 sw_if_index)
|
||||
{
|
||||
ip_neighbor_counter_type_t type;
|
||||
vlib_dir_t dir;
|
||||
|
||||
FOREACH_VLIB_DIR (dir)
|
||||
{
|
||||
FOREACH_IP_NEIGHBOR_CTR (type)
|
||||
{
|
||||
ip_neighbor_alloc_one_ctr (ctr, dir, type, sw_if_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u8 *
|
||||
format_ip_neighbor_counters (u8 *s, va_list *args)
|
||||
{
|
||||
ip_neighbor_counters_t *ctr = va_arg (*args, ip_neighbor_counters_t *);
|
||||
u32 sw_if_index = va_arg (*args, u32);
|
||||
vlib_dir_t dir;
|
||||
|
||||
FOREACH_VLIB_DIR (dir)
|
||||
{
|
||||
s = format (s, " %U:[", format_vlib_rx_tx, dir);
|
||||
|
||||
#define _(a, b) \
|
||||
s = format (s, "%s:%lld ", b, \
|
||||
vlib_get_simple_counter (&ctr->ipnc[dir][IP_NEIGHBOR_CTR_##a], \
|
||||
sw_if_index));
|
||||
foreach_ip_neighbor_counter_type
|
||||
#undef _
|
||||
|
||||
s = format (s, "]");
|
||||
}
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
|
||||
@@ -120,7 +120,37 @@ extern void ip_neighbor_clone (const ip_neighbor_t * ipn,
|
||||
|
||||
extern void ip_neighbor_free (ip_neighbor_t * ipn);
|
||||
|
||||
/**
|
||||
* Keep RX and TX counts per-AF
|
||||
*/
|
||||
#define foreach_ip_neighbor_counter_type \
|
||||
_ (REPLY, "reply") \
|
||||
_ (REQUEST, "request") \
|
||||
_ (GRAT, "gratuitous")
|
||||
|
||||
typedef enum ip_neighbor_counter_type_t_
|
||||
{
|
||||
#define _(a, b) IP_NEIGHBOR_CTR_##a,
|
||||
foreach_ip_neighbor_counter_type
|
||||
#undef _
|
||||
} ip_neighbor_counter_type_t;
|
||||
|
||||
#define N_IP_NEIGHBOR_CTRS (IP_NEIGHBOR_CTR_GRAT + 1)
|
||||
|
||||
#define FOREACH_IP_NEIGHBOR_CTR(_type) \
|
||||
for (_type = 0; _type < N_IP_NEIGHBOR_CTRS; _type++)
|
||||
|
||||
typedef struct ip_neighbor_counters_t_
|
||||
{
|
||||
vlib_simple_counter_main_t ipnc[VLIB_N_DIR][N_IP_NEIGHBOR_CTRS];
|
||||
} ip_neighbor_counters_t;
|
||||
|
||||
extern u8 *format_ip_neighbor_counters (u8 *s, va_list *args);
|
||||
|
||||
extern void ip_neighbor_alloc_ctr (ip_neighbor_counters_t *ctr,
|
||||
u32 sw_if_index);
|
||||
|
||||
extern ip_neighbor_counters_t ip_neighbor_counters[N_AF];
|
||||
|
||||
#endif /* __INCLUDE_IP_NEIGHBOR_H__ */
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ icmp6_neighbor_solicitation_or_advertisement (vlib_main_t * vm,
|
||||
icmp6_neighbor_discovery_ethernet_link_layer_address_option_t *o0;
|
||||
u32 bi0, options_len0, sw_if_index0, next0, error0;
|
||||
u32 ip6_sadd_link_local, ip6_sadd_unspecified;
|
||||
ip_neighbor_counter_type_t c_type;
|
||||
int is_rewrite0;
|
||||
u32 ni0;
|
||||
|
||||
@@ -230,16 +231,24 @@ icmp6_neighbor_solicitation_or_advertisement (vlib_main_t * vm,
|
||||
}
|
||||
|
||||
if (is_solicitation)
|
||||
next0 = (error0 != ICMP6_ERROR_NONE
|
||||
? ICMP6_NEIGHBOR_SOLICITATION_NEXT_DROP
|
||||
: ICMP6_NEIGHBOR_SOLICITATION_NEXT_REPLY);
|
||||
{
|
||||
next0 = (error0 != ICMP6_ERROR_NONE ?
|
||||
ICMP6_NEIGHBOR_SOLICITATION_NEXT_DROP :
|
||||
ICMP6_NEIGHBOR_SOLICITATION_NEXT_REPLY);
|
||||
c_type = IP_NEIGHBOR_CTR_REQUEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
next0 = 0;
|
||||
error0 = error0 == ICMP6_ERROR_NONE ?
|
||||
ICMP6_ERROR_NEIGHBOR_ADVERTISEMENTS_RX : error0;
|
||||
c_type = IP_NEIGHBOR_CTR_REPLY;
|
||||
}
|
||||
|
||||
vlib_increment_simple_counter (
|
||||
&ip_neighbor_counters[AF_IP6].ipnc[VLIB_RX][c_type],
|
||||
vm->thread_index, sw_if_index0, 1);
|
||||
|
||||
if (is_solicitation && error0 == ICMP6_ERROR_NONE)
|
||||
{
|
||||
icmp6_send_neighbor_advertisement (vm, p0, ip0, h0, o0,
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <vnet/ethernet/ethernet.h>
|
||||
#include <vnet/ip/icmp46_packet.h>
|
||||
#include <vnet/ip/ip6.h>
|
||||
#include <vnet/ip-neighbor/ip_neighbor_types.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -88,6 +89,10 @@ icmp6_send_neighbor_advertisement (
|
||||
vnet_buffer (b)->sw_if_index[VLIB_TX] = sw_if_index0;
|
||||
vnet_buffer (b)->sw_if_index[VLIB_RX] =
|
||||
vnet_main.local_interface_sw_if_index;
|
||||
|
||||
vlib_increment_simple_counter (
|
||||
&ip_neighbor_counters[AF_IP6].ipnc[VLIB_TX][IP_NEIGHBOR_CTR_REPLY],
|
||||
vm->thread_index, sw_if_index0, 1);
|
||||
}
|
||||
|
||||
#endif /* included_ip6_nd_inline_h */
|
||||
|
||||
@@ -193,6 +193,22 @@ class TestIPv6ND(VppTestCase):
|
||||
self.assertEqual(ip.src, sip)
|
||||
self.assertEqual(ip.dst, dip)
|
||||
|
||||
def get_ip6_nd_rx_requests(self, itf):
|
||||
"""Get IP6 ND RX request stats for and interface"""
|
||||
return self.statistics["/net/ip6-nd/rx/requests"][:, itf.sw_if_index].sum()
|
||||
|
||||
def get_ip6_nd_tx_requests(self, itf):
|
||||
"""Get IP6 ND TX request stats for and interface"""
|
||||
return self.statistics["/net/ip6-nd/tx/requests"][:, itf.sw_if_index].sum()
|
||||
|
||||
def get_ip6_nd_rx_replies(self, itf):
|
||||
"""Get IP6 ND RX replies stats for and interface"""
|
||||
return self.statistics["/net/ip6-nd/rx/replies"][:, itf.sw_if_index].sum()
|
||||
|
||||
def get_ip6_nd_tx_replies(self, itf):
|
||||
"""Get IP6 ND TX replies stats for and interface"""
|
||||
return self.statistics["/net/ip6-nd/tx/replies"][:, itf.sw_if_index].sum()
|
||||
|
||||
|
||||
@tag_run_solo
|
||||
class TestIPv6(TestIPv6ND):
|
||||
@@ -430,6 +446,9 @@ class TestIPv6(TestIPv6ND):
|
||||
- Send NS for a target address the router does not onn.
|
||||
"""
|
||||
|
||||
n_rx_req_pg0 = self.get_ip6_nd_rx_requests(self.pg0)
|
||||
n_tx_rep_pg0 = self.get_ip6_nd_tx_replies(self.pg0)
|
||||
|
||||
#
|
||||
# An NS from a non link source address
|
||||
#
|
||||
@@ -447,6 +466,7 @@ class TestIPv6(TestIPv6ND):
|
||||
self.send_and_assert_no_replies(
|
||||
self.pg0, pkts, "No response to NS source by address not on sub-net"
|
||||
)
|
||||
self.assert_equal(self.get_ip6_nd_rx_requests(self.pg0), n_rx_req_pg0 + 1)
|
||||
|
||||
#
|
||||
# An NS for sent to a solicited mcast group the router is
|
||||
@@ -485,6 +505,7 @@ class TestIPv6(TestIPv6ND):
|
||||
self.send_and_assert_no_replies(
|
||||
self.pg0, pkts, "No response to NS for unknown target"
|
||||
)
|
||||
self.assert_equal(self.get_ip6_nd_rx_requests(self.pg0), n_rx_req_pg0 + 2)
|
||||
|
||||
#
|
||||
# A neighbor entry that has no associated FIB-entry
|
||||
@@ -525,6 +546,8 @@ class TestIPv6(TestIPv6ND):
|
||||
dst_ip=self.pg0._remote_hosts[2].ip6_ll,
|
||||
tgt_ip=self.pg0.local_ip6,
|
||||
)
|
||||
self.assert_equal(self.get_ip6_nd_rx_requests(self.pg0), n_rx_req_pg0 + 3)
|
||||
self.assert_equal(self.get_ip6_nd_tx_replies(self.pg0), n_tx_rep_pg0 + 1)
|
||||
|
||||
#
|
||||
# we should have learned an ND entry for the peer's link-local
|
||||
@@ -574,6 +597,37 @@ class TestIPv6(TestIPv6ND):
|
||||
)
|
||||
self.assertFalse(find_route(self, self.pg0._remote_hosts[3].ip6_ll, 128))
|
||||
|
||||
def test_nd_incomplete(self):
|
||||
"""IP6-ND Incomplete"""
|
||||
self.pg1.generate_remote_hosts(3)
|
||||
|
||||
p0 = (
|
||||
Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
|
||||
/ IPv6(src=self.pg0.remote_ip6, dst=self.pg1.remote_hosts[1].ip6)
|
||||
/ UDP(sport=1234, dport=1234)
|
||||
/ Raw()
|
||||
)
|
||||
|
||||
#
|
||||
# a packet to an unresolved destination generates an ND request
|
||||
#
|
||||
n_tx_req_pg1 = self.get_ip6_nd_tx_requests(self.pg1)
|
||||
self.send_and_expect_ns(self.pg0, self.pg1, p0, self.pg1.remote_hosts[1].ip6)
|
||||
self.assert_equal(self.get_ip6_nd_tx_requests(self.pg1), n_tx_req_pg1 + 1)
|
||||
|
||||
#
|
||||
# a reply to the request
|
||||
#
|
||||
self.assert_equal(self.get_ip6_nd_rx_replies(self.pg1), 0)
|
||||
na = (
|
||||
Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac)
|
||||
/ IPv6(dst=self.pg1.local_ip6, src=self.pg1.remote_hosts[1].ip6)
|
||||
/ ICMPv6ND_NA(tgt=self.pg1.remote_hosts[1].ip6)
|
||||
/ ICMPv6NDOptSrcLLAddr(lladdr=self.pg1.remote_hosts[1].mac)
|
||||
)
|
||||
self.send_and_assert_no_replies(self.pg1, [na])
|
||||
self.assert_equal(self.get_ip6_nd_rx_replies(self.pg1), 1)
|
||||
|
||||
def test_ns_duplicates(self):
|
||||
"""ND Duplicates"""
|
||||
|
||||
|
||||
@@ -160,6 +160,30 @@ class ARPTestCase(VppTestCase):
|
||||
self.assertEqual(ip.src, sip)
|
||||
self.assertEqual(ip.dst, dip)
|
||||
|
||||
def get_arp_rx_requests(self, itf):
|
||||
"""Get ARP RX request stats for and interface"""
|
||||
return self.statistics["/net/arp/rx/requests"][:, itf.sw_if_index].sum()
|
||||
|
||||
def get_arp_tx_requests(self, itf):
|
||||
"""Get ARP TX request stats for and interface"""
|
||||
return self.statistics["/net/arp/tx/requests"][:, itf.sw_if_index].sum()
|
||||
|
||||
def get_arp_rx_replies(self, itf):
|
||||
"""Get ARP RX replies stats for and interface"""
|
||||
return self.statistics["/net/arp/rx/replies"][:, itf.sw_if_index].sum()
|
||||
|
||||
def get_arp_tx_replies(self, itf):
|
||||
"""Get ARP TX replies stats for and interface"""
|
||||
return self.statistics["/net/arp/tx/replies"][:, itf.sw_if_index].sum()
|
||||
|
||||
def get_arp_rx_garp(self, itf):
|
||||
"""Get ARP RX grat stats for and interface"""
|
||||
return self.statistics["/net/arp/rx/gratuitous"][:, itf.sw_if_index].sum()
|
||||
|
||||
def get_arp_tx_garp(self, itf):
|
||||
"""Get ARP RX grat stats for and interface"""
|
||||
return self.statistics["/net/arp/tx/gratuitous"][:, itf.sw_if_index].sum()
|
||||
|
||||
def test_arp(self):
|
||||
"""ARP"""
|
||||
|
||||
@@ -208,6 +232,10 @@ class ARPTestCase(VppTestCase):
|
||||
rx[0], self.pg1.local_mac, self.pg1.local_ip4, self.pg1._remote_hosts[1].ip4
|
||||
)
|
||||
|
||||
self.logger.info(self.vapi.cli("sh ip neighbor-stats"))
|
||||
self.logger.info(self.vapi.cli("sh ip neighbor-stats pg1"))
|
||||
self.assert_equal(self.get_arp_tx_requests(self.pg1), 1)
|
||||
|
||||
#
|
||||
# And a dynamic ARP entry for host 1
|
||||
#
|
||||
@@ -328,6 +356,7 @@ class ARPTestCase(VppTestCase):
|
||||
self.verify_arp_req(
|
||||
rx[0], self.pg1.local_mac, self.pg1.local_ip4, self.pg1._remote_hosts[1].ip4
|
||||
)
|
||||
self.assert_equal(self.get_arp_tx_requests(self.pg1), 2)
|
||||
|
||||
self.assertFalse(dyn_arp.query_vpp_config())
|
||||
self.assertTrue(static_arp.query_vpp_config())
|
||||
@@ -353,6 +382,9 @@ class ARPTestCase(VppTestCase):
|
||||
self.pg1.local_ip4,
|
||||
self.pg1._remote_hosts[3].ip4,
|
||||
)
|
||||
self.logger.info(self.vapi.cli("sh ip neighbor-stats pg1"))
|
||||
self.assert_equal(self.get_arp_rx_requests(self.pg1), 1)
|
||||
self.assert_equal(self.get_arp_tx_replies(self.pg1), 1)
|
||||
|
||||
#
|
||||
# VPP should have learned the mapping for the remote host
|
||||
@@ -1662,6 +1694,7 @@ class ARPTestCase(VppTestCase):
|
||||
mac=self.pg1.remote_hosts[2].mac,
|
||||
)
|
||||
)
|
||||
self.assert_equal(self.get_arp_rx_garp(self.pg1), 1)
|
||||
|
||||
#
|
||||
# Send a GARP (reply) to swap the host 1's address to that of host 3
|
||||
@@ -1686,6 +1719,7 @@ class ARPTestCase(VppTestCase):
|
||||
mac=self.pg1.remote_hosts[3].mac,
|
||||
)
|
||||
)
|
||||
self.assert_equal(self.get_arp_rx_garp(self.pg1), 2)
|
||||
|
||||
#
|
||||
# GARPs (request nor replies) for host we don't know yet
|
||||
|
||||
Reference in New Issue
Block a user