mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 18:42:23 +00:00
Merge pull request #1612 from chiragshah6/mdev
ospf6d: Add protocol stats and show command
This commit is contained in:
commit
dab1b55609
@ -1008,6 +1008,103 @@ DEFUN (show_ipv6_ospf6_interface,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static int ospf6_interface_show_traffic(struct vty *vty,
|
||||
uint32_t vrf_id,
|
||||
struct interface *intf_ifp,
|
||||
int display_once)
|
||||
{
|
||||
struct interface *ifp;
|
||||
struct vrf *vrf = NULL;
|
||||
struct ospf6_interface *oi = NULL;
|
||||
|
||||
vrf = vrf_lookup_by_id(vrf_id);
|
||||
|
||||
if (!display_once) {
|
||||
vty_out(vty, "\n");
|
||||
vty_out(vty, "%-12s%-17s%-17s%-17s%-17s%-17s\n",
|
||||
"Interface", " HELLO", " DB-Desc", " LS-Req",
|
||||
" LS-Update", " LS-Ack");
|
||||
vty_out(vty, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "",
|
||||
" Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx");
|
||||
vty_out(vty,
|
||||
"--------------------------------------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
if (intf_ifp == NULL) {
|
||||
FOR_ALL_INTERFACES (vrf, ifp) {
|
||||
if (ifp->info)
|
||||
oi = (struct ospf6_interface *)ifp->info;
|
||||
else
|
||||
continue;
|
||||
|
||||
vty_out(vty,
|
||||
"%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
|
||||
oi->interface->name, oi->hello_in,
|
||||
oi->hello_out,
|
||||
oi->db_desc_in, oi->db_desc_out,
|
||||
oi->ls_req_in, oi->ls_req_out,
|
||||
oi->ls_upd_in, oi->ls_upd_out,
|
||||
oi->ls_ack_in, oi->ls_ack_out);
|
||||
}
|
||||
} else {
|
||||
oi = intf_ifp->info;
|
||||
if (oi == NULL)
|
||||
return CMD_WARNING;
|
||||
|
||||
vty_out(vty,
|
||||
"%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
|
||||
oi->interface->name, oi->hello_in,
|
||||
oi->hello_out,
|
||||
oi->db_desc_in, oi->db_desc_out,
|
||||
oi->ls_req_in, oi->ls_req_out,
|
||||
oi->ls_upd_in, oi->ls_upd_out,
|
||||
oi->ls_ack_in, oi->ls_ack_out);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* show interface */
|
||||
DEFUN (show_ipv6_ospf6_interface_traffic,
|
||||
show_ipv6_ospf6_interface_traffic_cmd,
|
||||
"show ipv6 ospf6 interface traffic [IFNAME]",
|
||||
SHOW_STR
|
||||
IP6_STR
|
||||
OSPF6_STR
|
||||
INTERFACE_STR
|
||||
"Protocol Packet counters\n"
|
||||
IFNAME_STR)
|
||||
{
|
||||
int idx_ifname = 0;
|
||||
int display_once = 0;
|
||||
char *intf_name = NULL;
|
||||
struct interface *ifp = NULL;
|
||||
|
||||
if (argv_find(argv, argc, "IFNAME", &idx_ifname)) {
|
||||
intf_name = argv[idx_ifname]->arg;
|
||||
ifp = if_lookup_by_name(intf_name, VRF_DEFAULT);
|
||||
if (ifp == NULL) {
|
||||
vty_out(vty,
|
||||
"No such Interface: %s\n",
|
||||
intf_name);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
if (ifp->info == NULL) {
|
||||
vty_out(vty,
|
||||
" OSPF not enabled on this interface %s\n",
|
||||
intf_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ospf6_interface_show_traffic(vty, VRF_DEFAULT, ifp,
|
||||
display_once);
|
||||
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
|
||||
show_ipv6_ospf6_interface_ifname_prefix_cmd,
|
||||
"show ipv6 ospf6 interface IFNAME prefix [<X:X::X:X|X:X::X:X/M>] [<match|detail>]",
|
||||
@ -1841,6 +1938,8 @@ void ospf6_interface_init(void)
|
||||
install_element(VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
|
||||
install_element(VIEW_NODE,
|
||||
&show_ipv6_ospf6_interface_ifname_prefix_cmd);
|
||||
install_element(VIEW_NODE,
|
||||
&show_ipv6_ospf6_interface_traffic_cmd);
|
||||
|
||||
install_element(INTERFACE_NODE, &ipv6_ospf6_cost_cmd);
|
||||
install_element(INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd);
|
||||
|
@ -117,6 +117,19 @@ struct ospf6_interface {
|
||||
/* BFD information */
|
||||
void *bfd_info;
|
||||
|
||||
/* Statistics Fields */
|
||||
u_int32_t hello_in;
|
||||
u_int32_t hello_out;
|
||||
u_int32_t db_desc_in;
|
||||
u_int32_t db_desc_out;
|
||||
u_int32_t ls_req_in;
|
||||
u_int32_t ls_req_out;
|
||||
u_int32_t ls_upd_in;
|
||||
u_int32_t ls_upd_out;
|
||||
u_int32_t ls_ack_in;
|
||||
u_int32_t ls_ack_out;
|
||||
u_int32_t discarded;
|
||||
|
||||
QOBJ_FIELDS
|
||||
};
|
||||
DECLARE_QOBJ_TYPE(ospf6_interface)
|
||||
|
@ -321,6 +321,8 @@ static void ospf6_hello_recv(struct in6_addr *src, struct in6_addr *dst,
|
||||
backupseen++;
|
||||
}
|
||||
|
||||
oi->hello_in++;
|
||||
|
||||
/* Execute neighbor events */
|
||||
thread_execute(master, hello_received, on, 0);
|
||||
if (twoway)
|
||||
@ -776,6 +778,8 @@ static void ospf6_dbdesc_recv(struct in6_addr *src, struct in6_addr *dst,
|
||||
dbdesc->reserved2 = 0;
|
||||
}
|
||||
|
||||
oi->db_desc_in++;
|
||||
|
||||
if (ntohl(oh->router_id) < ntohl(ospf6->router_id))
|
||||
ospf6_dbdesc_recv_master(oh, on);
|
||||
else if (ntohl(ospf6->router_id) < ntohl(oh->router_id))
|
||||
@ -811,6 +815,8 @@ static void ospf6_lsreq_recv(struct in6_addr *src, struct in6_addr *dst,
|
||||
return;
|
||||
}
|
||||
|
||||
oi->ls_req_in++;
|
||||
|
||||
/* Process each request */
|
||||
for (p = (char *)((caddr_t)oh + sizeof(struct ospf6_header));
|
||||
p + sizeof(struct ospf6_lsreq_entry) <= OSPF6_MESSAGE_END(oh);
|
||||
@ -1370,6 +1376,8 @@ static void ospf6_lsupdate_recv(struct in6_addr *src, struct in6_addr *dst,
|
||||
lsupdate = (struct ospf6_lsupdate *)((caddr_t)oh
|
||||
+ sizeof(struct ospf6_header));
|
||||
|
||||
oi->ls_upd_in++;
|
||||
|
||||
/* Process LSAs */
|
||||
for (p = (char *)((caddr_t)lsupdate + sizeof(struct ospf6_lsupdate));
|
||||
p < OSPF6_MESSAGE_END(oh)
|
||||
@ -1407,6 +1415,8 @@ static void ospf6_lsack_recv(struct in6_addr *src, struct in6_addr *dst,
|
||||
return;
|
||||
}
|
||||
|
||||
oi->ls_ack_in++;
|
||||
|
||||
for (p = (char *)((caddr_t)oh + sizeof(struct ospf6_header));
|
||||
p + sizeof(struct ospf6_lsa_header) <= OSPF6_MESSAGE_END(oh);
|
||||
p += sizeof(struct ospf6_lsa_header)) {
|
||||
@ -1777,6 +1787,8 @@ int ospf6_hello_send(struct thread *thread)
|
||||
oh->type = OSPF6_MESSAGE_TYPE_HELLO;
|
||||
oh->length = htons(p - sendbuf);
|
||||
|
||||
oi->hello_out++;
|
||||
|
||||
ospf6_send(oi->linklocal_addr, &allspfrouters6, oi, oh);
|
||||
return 0;
|
||||
}
|
||||
@ -1852,6 +1864,8 @@ int ospf6_dbdesc_send(struct thread *thread)
|
||||
else
|
||||
dst = &on->linklocal_addr;
|
||||
|
||||
on->ospf6_if->db_desc_out++;
|
||||
|
||||
ospf6_send(on->ospf6_if->linklocal_addr, dst, on->ospf6_if, oh);
|
||||
|
||||
return 0;
|
||||
@ -1955,6 +1969,8 @@ int ospf6_lsreq_send(struct thread *thread)
|
||||
oh->type = OSPF6_MESSAGE_TYPE_LSREQ;
|
||||
oh->length = htons(p - sendbuf);
|
||||
|
||||
on->ospf6_if->ls_req_out++;
|
||||
|
||||
if (on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT)
|
||||
ospf6_send(on->ospf6_if->linklocal_addr, &allspfrouters6,
|
||||
on->ospf6_if, oh);
|
||||
@ -1979,6 +1995,8 @@ static void ospf6_send_lsupdate(struct ospf6_neighbor *on,
|
||||
{
|
||||
|
||||
if (on) {
|
||||
on->ospf6_if->ls_upd_out++;
|
||||
|
||||
if ((on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT) ||
|
||||
(on->ospf6_if->state == OSPF6_INTERFACE_DR) ||
|
||||
(on->ospf6_if->state == OSPF6_INTERFACE_BDR)) {
|
||||
@ -1989,6 +2007,9 @@ static void ospf6_send_lsupdate(struct ospf6_neighbor *on,
|
||||
&on->linklocal_addr, on->ospf6_if, oh);
|
||||
}
|
||||
} else if (oi) {
|
||||
|
||||
oi->ls_upd_out++;
|
||||
|
||||
if ((oi->state == OSPF6_INTERFACE_POINTTOPOINT) ||
|
||||
(oi->state == OSPF6_INTERFACE_DR) ||
|
||||
(oi->state == OSPF6_INTERFACE_BDR)) {
|
||||
@ -2185,8 +2206,11 @@ int ospf6_lsupdate_send_interface(struct thread *thread)
|
||||
lsupdate->lsa_number = htonl(lsa_cnt);
|
||||
|
||||
ospf6_send_lsupdate(NULL, oi, oh);
|
||||
zlog_debug("%s: LSUpdate length %d",
|
||||
__PRETTY_FUNCTION__, ntohs(oh->length));
|
||||
if (IS_OSPF6_DEBUG_MESSAGE(
|
||||
OSPF6_MESSAGE_TYPE_LSUPDATE, SEND))
|
||||
zlog_debug("%s: LSUpdate length %d",
|
||||
__PRETTY_FUNCTION__,
|
||||
ntohs(oh->length));
|
||||
|
||||
memset(sendbuf, 0, iobuflen);
|
||||
oh = (struct ospf6_header *)sendbuf;
|
||||
@ -2263,6 +2287,8 @@ int ospf6_lsack_send_neighbor(struct thread *thread)
|
||||
oh->type = OSPF6_MESSAGE_TYPE_LSACK;
|
||||
oh->length = htons(p - sendbuf);
|
||||
|
||||
on->ospf6_if->ls_ack_out++;
|
||||
|
||||
ospf6_send(on->ospf6_if->linklocal_addr,
|
||||
&on->linklocal_addr,
|
||||
on->ospf6_if, oh);
|
||||
@ -2288,6 +2314,8 @@ int ospf6_lsack_send_neighbor(struct thread *thread)
|
||||
oh->type = OSPF6_MESSAGE_TYPE_LSACK;
|
||||
oh->length = htons(p - sendbuf);
|
||||
|
||||
on->ospf6_if->ls_ack_out++;
|
||||
|
||||
ospf6_send(on->ospf6_if->linklocal_addr, &on->linklocal_addr,
|
||||
on->ospf6_if, oh);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user