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);
}
}
}
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
#
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
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--;
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
{
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))
#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>
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 */
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 ==
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;
{
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);
}
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;
}
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;
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);
}
}
#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;
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;
}
#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;
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);
}
}
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))
{
#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;
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;
}
#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;
}
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;
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;
}
}
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);
}
* 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 (),
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_
{
}
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;
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",
.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 *
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);
extern void ip_neighbor_register (ip_address_family_t af,
const ip_neighbor_vft_t * vft);
-
#endif /* __INCLUDE_IP_NEIGHBOR_H__ */
/*
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
*
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__ */
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;
}
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,
#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
{
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 */
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):
- 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
#
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
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
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
)
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"""
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"""
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
#
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())
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
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
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