summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_mroute.c
diff options
context:
space:
mode:
authorhsu <hsu@FreeBSD.org>2003-08-05 17:01:33 +0000
committerhsu <hsu@FreeBSD.org>2003-08-05 17:01:33 +0000
commite3e094a1f909528238a5b880910cff77d28146b9 (patch)
tree91a6010b6265daa4c8013d1bc082a2ef26b769d6 /sys/netinet/ip_mroute.c
parent186be00c7486a491b16114fda3e051d4a4fb0e75 (diff)
downloadFreeBSD-src-e3e094a1f909528238a5b880910cff77d28146b9.zip
FreeBSD-src-e3e094a1f909528238a5b880910cff77d28146b9.tar.gz
* makes mfc[MFCTBLSIZ] and vif[MAXVIFS] tables accessible via
sysctl: - sysctlbyname("net.inet.ip.mfctable", ...) - sysctlbyname("net.inet.ip.viftable", ...) This change is needed so netstat can use sysctlbyname() to read the data from those tables. Otherwise, in some cases "netstat -g" may fail to report the multicast forwarding information (e.g., if we run a multicast router on PicoBSD). * Bug fix: when sending IGMPMSG_WRONGVIF upcall to the multicast routing daemon, set properly "im->im_vif" to the receiving incoming interface of the packet that triggered that upcall rather than to the expected incoming interface of that packet. * Bug fix: add missing increment of counter "mrtstat.mrts_upcalls" * Few formatting nits (e.g., replace extra spaces with TABs) Submitted by: Pavlin Radoslavov <pavlin@icir.org>
Diffstat (limited to 'sys/netinet/ip_mroute.c')
-rw-r--r--sys/netinet/ip_mroute.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 5abf2ee..f0f2471 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -68,8 +68,16 @@ SYSCTL_STRUCT(_net_inet_ip, OID_AUTO, mrtstat, CTLFLAG_RW,
"Multicast Routing Statistics (struct mrtstat, netinet/ip_mroute.h)");
static struct mfc *mfctable[MFCTBLSIZ];
-static u_char nexpire[MFCTBLSIZ];
+SYSCTL_OPAQUE(_net_inet_ip, OID_AUTO, mfctable, CTLFLAG_RD,
+ &mfctable, sizeof(mfctable), "S,*mfc[MFCTBLSIZ]",
+ "Multicast Forwarding Table (struct *mfc[MFCTBLSIZ], netinet/ip_mroute.h)");
+
static struct vif viftable[MAXVIFS];
+SYSCTL_OPAQUE(_net_inet_ip, OID_AUTO, viftable, CTLFLAG_RD,
+ &viftable, sizeof(viftable), "S,vif[MAXVIFS]",
+ "Multicast Virtual Interfaces (struct vif[MAXVIFS], netinet/ip_mroute.h)");
+
+static u_char nexpire[MFCTBLSIZ];
static struct callout_handle expire_upcalls_ch;
@@ -1084,9 +1092,9 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp,
* Locate the vifi for the incoming interface for this packet.
* If none found, drop packet.
*/
- for (vifi=0; vifi<numvifs && viftable[vifi].v_ifp != ifp; vifi++)
+ for (vifi=0; vifi < numvifs && viftable[vifi].v_ifp != ifp; vifi++)
;
- if (vifi >= numvifs) /* vif not found, drop packet */
+ if (vifi >= numvifs) /* vif not found, drop packet */
goto non_fatal;
/* no upcall, so make a new entry */
@@ -1241,11 +1249,11 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif)
* input, they shouldn't get counted on output, so statistics keeping is
* separate.
*/
-#define MC_SEND(ip,vifp,m) { \
- if ((vifp)->v_flags & VIFF_TUNNEL) \
- encap_send((ip), (vifp), (m)); \
- else \
- phyint_send((ip), (vifp), (m)); \
+#define MC_SEND(ip,vifp,m) { \
+ if ((vifp)->v_flags & VIFF_TUNNEL) \
+ encap_send((ip), (vifp), (m)); \
+ else \
+ phyint_send((ip), (vifp), (m)); \
}
/*
@@ -1280,6 +1288,12 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif)
struct timeval now;
u_long delta;
+ /* Get vifi for the incoming packet */
+ for (vifi=0; vifi < numvifs && viftable[vifi].v_ifp != ifp; vifi++)
+ ;
+ if (vifi >= numvifs)
+ return 0; /* if not found: ignore the packet */
+
GET_TIME(now);
TV_DELTA(rt->mfc_last_assert, now, delta);
@@ -1302,8 +1316,9 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif)
im->im_mbz = 0;
im->im_vif = vifi;
- k_igmpsrc.sin_addr = im->im_src;
+ mrtstat.mrts_upcalls++;
+ k_igmpsrc.sin_addr = im->im_src;
if (socket_send(ip_mrouter, mm, &k_igmpsrc) < 0) {
log(LOG_WARNING,
"ip_mforward: ip_mrouter socket queue full\n");
OpenPOWER on IntegriCloud