summaryrefslogtreecommitdiffstats
path: root/pimd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-07-13 17:41:41 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-07-13 17:41:41 +0200
commit3667e8a081ee4e036c1ffb7cf8f14477c051478f (patch)
tree4c7d7fb1c58f1132987866377ba3714a7d814481 /pimd
parentbgpd: Disallow ebgp-multihop on swpX peers (diff)
downloadfrr-3667e8a081ee4e036c1ffb7cf8f14477c051478f.tar.xz
frr-3667e8a081ee4e036c1ffb7cf8f14477c051478f.zip
pimd: Add generic function to retrieve mroute stats
Add a generic function to retrieve mroute statistics from the kernel. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'pimd')
-rw-r--r--pimd/pim_cmd.c53
-rw-r--r--pimd/pim_mroute.c39
-rw-r--r--pimd/pim_mroute.h1
-rw-r--r--pimd/pim_oil.h12
4 files changed, 60 insertions, 45 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index f27e3ff76..13cc30527 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -22,8 +22,6 @@
#include <zebra.h>
-#include <sys/ioctl.h>
-
#include "command.h"
#include "if.h"
#include "prefix.h"
@@ -2309,37 +2307,21 @@ static void show_mroute_count(struct vty *vty)
for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
char group_str[100];
char source_str[100];
- struct sioc_sg_req sgreq;
if (!c_oil->installed)
continue;
- memset(&sgreq, 0, sizeof(sgreq));
- sgreq.src = c_oil->oil.mfcc_origin;
- sgreq.grp = c_oil->oil.mfcc_mcastgrp;
+ pim_mroute_update_counters (c_oil);
pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
- if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
- int e = errno;
- vty_out(vty,
- "ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=(%s,%s): errno=%d: %s%s",
- (unsigned long)SIOCGETSGCNT,
- source_str,
- group_str,
- e,
- safe_strerror(e),
- VTY_NEWLINE);
- continue;
- }
-
vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
source_str,
group_str,
- sgreq.pktcnt,
- sgreq.bytecnt,
- sgreq.wrong_if,
+ c_oil->cc.pktcnt,
+ c_oil->cc.bytecnt,
+ c_oil->cc.wrong_if,
VTY_NEWLINE);
}
@@ -2347,40 +2329,21 @@ static void show_mroute_count(struct vty *vty)
for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
char group_str[100];
char source_str[100];
- struct sioc_sg_req sgreq;
if (!s_route->c_oil.installed)
continue;
- memset(&sgreq, 0, sizeof(sgreq));
- sgreq.src = s_route->c_oil.oil.mfcc_origin;
- sgreq.grp = s_route->c_oil.oil.mfcc_mcastgrp;
+ pim_mroute_update_counters (&s_route->c_oil);
pim_inet4_dump("<group?>", s_route->c_oil.oil.mfcc_mcastgrp, group_str, sizeof(group_str));
pim_inet4_dump("<source?>", s_route->c_oil.oil.mfcc_origin, source_str, sizeof(source_str));
- if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
- int e = errno;
- vty_out(vty,
- "ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=(%s,%s): errno=%d: %s%s",
- /* note that typeof ioctl defs can vary across platforms, from
- * int, to unsigned int, to long unsigned int
- */
- (unsigned long)SIOCGETSGCNT,
- source_str,
- group_str,
- e,
- safe_strerror(e),
- VTY_NEWLINE);
- continue;
- }
-
vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
source_str,
group_str,
- sgreq.pktcnt,
- sgreq.bytecnt,
- sgreq.wrong_if,
+ s_route->c_oil.cc.pktcnt,
+ s_route->c_oil.cc.bytecnt,
+ s_route->c_oil.cc.wrong_if,
VTY_NEWLINE);
}
}
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 4d9a9d0b7..b5463fac5 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -143,6 +143,8 @@ pim_mroute_msg_nocache (int fd, struct interface *ifp, const struct igmpmsg *msg
return 0;
}
+ pim_upstream_keep_alive_timer_start (up, PIM_KEEPALIVE_PERIOD);
+
up->channel_oil = pim_channel_oil_add(msg->im_dst,
msg->im_src,
pim_ifp->mroute_vif_index);
@@ -629,3 +631,40 @@ int pim_mroute_del (struct channel_oil *c_oil)
return 0;
}
+
+void
+pim_mroute_update_counters (struct channel_oil *c_oil)
+{
+ struct sioc_sg_req sgreq;
+
+ memset (&sgreq, 0, sizeof(sgreq));
+ sgreq.src = c_oil->oil.mfcc_origin;
+ sgreq.grp = c_oil->oil.mfcc_mcastgrp;
+
+ c_oil->cc.oldpktcnt = c_oil->cc.pktcnt;
+ c_oil->cc.oldbytecnt = c_oil->cc.bytecnt;
+ c_oil->cc.oldwrong_if = c_oil->cc.wrong_if;
+
+ if (ioctl (qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq))
+ {
+ char group_str[100];
+ char source_str[100];
+
+ pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
+ pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
+
+ zlog_warn ("ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=(%s,%s): errno=%d: %s",
+ (unsigned long)SIOCGETSGCNT,
+ source_str,
+ group_str,
+ errno,
+ safe_strerror(errno));
+ return;
+ }
+
+ c_oil->cc.pktcnt = sgreq.pktcnt;
+ c_oil->cc.bytecnt = sgreq.bytecnt;
+ c_oil->cc.wrong_if = sgreq.wrong_if;
+
+ return;
+}
diff --git a/pimd/pim_mroute.h b/pimd/pim_mroute.h
index 25532614a..176fb81cb 100644
--- a/pimd/pim_mroute.h
+++ b/pimd/pim_mroute.h
@@ -174,4 +174,5 @@ int pim_mroute_del(struct channel_oil *c_oil);
int pim_mroute_msg(int fd, const char *buf, int buf_size);
+void pim_mroute_update_counters (struct channel_oil *c_oil);
#endif /* PIM_MROUTE_H */
diff --git a/pimd/pim_oil.h b/pimd/pim_oil.h
index 143f2345f..c63c026c0 100644
--- a/pimd/pim_oil.h
+++ b/pimd/pim_oil.h
@@ -50,6 +50,17 @@
#define PIM_OIF_PIM_REGISTER_VIF (MAXVIFS - 1)
#define PIM_MAX_USABLE_VIFS (MAXVIFS - 2)
+
+struct channel_counts
+{
+ unsigned long pktcnt;
+ unsigned long oldpktcnt;
+ unsigned long bytecnt;
+ unsigned long oldbytecnt;
+ unsigned long wrong_if;
+ unsigned long oldwrong_if;
+};
+
/*
qpim_channel_oil_list holds a list of struct channel_oil.
@@ -64,6 +75,7 @@ struct channel_oil {
int oil_ref_count;
time_t oif_creation[MAXVIFS];
uint32_t oif_flags[MAXVIFS];
+ struct channel_counts cc;
};
void pim_channel_oil_free(struct channel_oil *c_oil);