summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-05-14 20:35:07 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-05-14 20:35:07 +0000
commit7594b685ab9212f6847f6fdeacfcf835db7d503e (patch)
treedaa88b846e9d4ab637de85248206258d774c7497
parent9e4bb85628efbe948df7d70ba12fafbca4b4a8f7 (diff)
KNF. markus ok
-rw-r--r--sys/netinet/ip_mroute.c1246
1 files changed, 633 insertions, 613 deletions
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index ce870d4b16c..efd44070703 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.c,v 1.29 2003/05/06 07:28:39 deraadt Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.30 2003/05/14 20:35:06 itojun Exp $ */
/* $NetBSD: ip_mroute.c,v 1.27 1996/05/07 02:40:50 thorpej Exp $ */
/*
@@ -227,7 +227,7 @@ static int pim_assert;
* Type of service parameter to be added in the future!!!
*/
-#define MFCFIND(o, g, rt) { \
+#define MFCFIND(o, g, rt) do { \
register struct mfc *_rt; \
(rt) = NULL; \
++mrtstat.mrts_mfc_lookups; \
@@ -242,13 +242,13 @@ static int pim_assert;
} \
if ((rt) == NULL) \
++mrtstat.mrts_mfc_misses; \
-}
+} while (0)
/*
* Macros to compute elapsed time efficiently
* Borrowed from Van Jacobson's scheduling code
*/
-#define TV_DELTA(a, b, delta) { \
+#define TV_DELTA(a, b, delta) do { \
register int xxs; \
delta = (a).tv_usec - (b).tv_usec; \
xxs = (a).tv_sec - (b).tv_sec; \
@@ -265,7 +265,7 @@ static int pim_assert;
delta += (1000000 * xxs); \
break; \
} \
-}
+} while (0)
#ifdef UPCALL_TIMING
u_int32_t upcall_data[51];
@@ -812,7 +812,7 @@ add_mfc(m)
/* If an entry already exists, just update the fields */
if (rt) {
if (mrtdebug & DEBUG_MFC)
- log(LOG_DEBUG,"add_mfc update o %x g %x p %x\n",
+ log(LOG_DEBUG, "add_mfc update o %x g %x p %x\n",
ntohl(mfccp->mfcc_origin.s_addr),
ntohl(mfccp->mfcc_mcastgrp.s_addr),
mfccp->mfcc_parent);
@@ -843,7 +843,7 @@ add_mfc(m)
mfccp->mfcc_parent, rt->mfc_stall);
if (mrtdebug & DEBUG_MFC)
- log(LOG_DEBUG,"add_mfc o %x g %x p %x dbg %p\n",
+ log(LOG_DEBUG, "add_mfc o %x g %x p %x dbg %p\n",
ntohl(mfccp->mfcc_origin.s_addr),
ntohl(mfccp->mfcc_mcastgrp.s_addr),
mfccp->mfcc_parent, rt->mfc_stall);
@@ -875,7 +875,7 @@ add_mfc(m)
* No mfc; make a new one
*/
if (mrtdebug & DEBUG_MFC)
- log(LOG_DEBUG,"add_mfc no upcall o %x g %x p %x\n",
+ log(LOG_DEBUG, "add_mfc no upcall o %x g %x p %x\n",
ntohl(mfccp->mfcc_origin.s_addr),
ntohl(mfccp->mfcc_mcastgrp.s_addr),
mfccp->mfcc_parent);
@@ -908,23 +908,23 @@ add_mfc(m)
* collect delay statistics on the upcalls
*/
static void collate(t)
-register struct timeval *t;
+ register struct timeval *t;
{
- register u_int32_t d;
- register struct timeval tp;
- register u_int32_t delta;
+ register u_int32_t d;
+ register struct timeval tp;
+ register u_int32_t delta;
- microtime(&tp);
+ microtime(&tp);
- if (timercmp(t, &tp, <)) {
- TV_DELTA(tp, *t, delta);
+ if (timercmp(t, &tp, <)) {
+ TV_DELTA(tp, *t, delta);
- d = delta >> 10;
- if (d > 50)
- d = 50;
+ d = delta >> 10;
+ if (d > 50)
+ d = 50;
- ++upcall_data[d];
- }
+ ++upcall_data[d];
+ }
}
#endif /* UPCALL_TIMING */
@@ -946,7 +946,8 @@ del_mfc(m)
if (mrtdebug & DEBUG_MFC)
log(LOG_DEBUG, "del_mfc origin %x mcastgrp %x\n",
- ntohl(mfccp->mfcc_origin.s_addr), ntohl(mfccp->mfcc_mcastgrp.s_addr));
+ ntohl(mfccp->mfcc_origin.s_addr),
+ ntohl(mfccp->mfcc_mcastgrp.s_addr));
s = splsoftnet();
@@ -965,18 +966,19 @@ del_mfc(m)
static int
socket_send(s, mm, src)
- struct socket *s;
- struct mbuf *mm;
- struct sockaddr_in *src;
+ struct socket *s;
+ struct mbuf *mm;
+ struct sockaddr_in *src;
{
- if (s) {
- if (sbappendaddr(&s->so_rcv, sintosa(src), mm, (struct mbuf *)0) != 0) {
- sorwakeup(s);
- return (0);
+ if (s) {
+ if (sbappendaddr(&s->so_rcv, sintosa(src), mm,
+ (struct mbuf *)0) != 0) {
+ sorwakeup(s);
+ return (0);
+ }
}
- }
- m_freem(mm);
- return (-1);
+ m_freem(mm);
+ return (-1);
}
/*
@@ -999,225 +1001,228 @@ ip_mforward(m, ifp, imo)
#else
ip_mforward(m, ifp)
#endif /* RSVP_ISI */
- struct mbuf *m;
- struct ifnet *ifp;
+ struct mbuf *m;
+ struct ifnet *ifp;
#ifdef RSVP_ISI
- struct ip_moptions *imo;
+ struct ip_moptions *imo;
#endif /* RSVP_ISI */
{
- register struct ip *ip = mtod(m, struct ip *);
- register struct mfc *rt;
- register u_char *ipoptions;
- static int srctun = 0;
- register struct mbuf *mm;
- int s;
+ register struct ip *ip = mtod(m, struct ip *);
+ register struct mfc *rt;
+ register u_char *ipoptions;
+ static int srctun = 0;
+ register struct mbuf *mm;
+ int s;
#ifdef RSVP_ISI
- register struct vif *vifp;
- vifi_t vifi;
+ register struct vif *vifp;
+ vifi_t vifi;
#endif /* RSVP_ISI */
- if (mrtdebug & DEBUG_FORWARD)
- log(LOG_DEBUG, "ip_mforward: src %x, dst %x, ifp %p\n",
- ntohl(ip->ip_src.s_addr), ntohl(ip->ip_dst.s_addr), ifp);
+ if (mrtdebug & DEBUG_FORWARD)
+ log(LOG_DEBUG, "ip_mforward: src %x, dst %x, ifp %p\n",
+ ntohl(ip->ip_src.s_addr), ntohl(ip->ip_dst.s_addr), ifp);
- if (ip->ip_hl < (IP_HDR_LEN + TUNNEL_LEN) >> 2 ||
- (ipoptions = (u_char *)(ip + 1))[1] != IPOPT_LSRR) {
- /*
- * Packet arrived via a physical interface or
- * an encapuslated tunnel.
- */
- } else {
- /*
- * Packet arrived through a source-route tunnel.
- * Source-route tunnels are no longer supported.
- */
- if ((srctun++ % 1000) == 0)
- log(LOG_ERR, "ip_mforward: received source-routed packet from %x\n",
- ntohl(ip->ip_src.s_addr));
+ if (ip->ip_hl < (IP_HDR_LEN + TUNNEL_LEN) >> 2 ||
+ (ipoptions = (u_char *)(ip + 1))[1] != IPOPT_LSRR) {
+ /*
+ * Packet arrived via a physical interface or
+ * an encapuslated tunnel.
+ */
+ } else {
+ /*
+ * Packet arrived through a source-route tunnel.
+ * Source-route tunnels are no longer supported.
+ */
+ if ((srctun++ % 1000) == 0)
+ log(LOG_ERR,
+ "ip_mforward: received source-routed packet from %x\n",
+ ntohl(ip->ip_src.s_addr));
- return (1);
- }
+ return (1);
+ }
#ifdef RSVP_ISI
- if (imo && ((vifi = imo->imo_multicast_vif) < numvifs)) {
- if (ip->ip_ttl < 255)
- ip->ip_ttl++; /* compensate for -1 in *_send routines */
+ if (imo && ((vifi = imo->imo_multicast_vif) < numvifs)) {
+ if (ip->ip_ttl < 255)
+ ip->ip_ttl++; /* compensate for -1 in *_send routines */
+ if (rsvpdebug && ip->ip_p == IPPROTO_RSVP) {
+ vifp = viftable + vifi;
+ printf("Sending IPPROTO_RSVP from %x to %x on vif %d (%s%s)\n",
+ ntohl(ip->ip_src), ntohl(ip->ip_dst), vifi,
+ (vifp->v_flags & VIFF_TUNNEL) ? "tunnel on " : "",
+ vifp->v_ifp->if_xname);
+ }
+ return (ip_mdq(m, ifp, rt, vifi));
+ }
if (rsvpdebug && ip->ip_p == IPPROTO_RSVP) {
- vifp = viftable + vifi;
- printf("Sending IPPROTO_RSVP from %x to %x on vif %d (%s%s)\n",
- ntohl(ip->ip_src), ntohl(ip->ip_dst), vifi,
- (vifp->v_flags & VIFF_TUNNEL) ? "tunnel on " : "",
- vifp->v_ifp->if_xname);
+ printf("Warning: IPPROTO_RSVP from %x to %x without vif option\n",
+ ntohl(ip->ip_src), ntohl(ip->ip_dst));
}
- return (ip_mdq(m, ifp, rt, vifi));
- }
- if (rsvpdebug && ip->ip_p == IPPROTO_RSVP) {
- printf("Warning: IPPROTO_RSVP from %x to %x without vif option\n",
- ntohl(ip->ip_src), ntohl(ip->ip_dst));
- }
#endif /* RSVP_ISI */
- /*
- * Don't forward a packet with time-to-live of zero or one,
- * or a packet destined to a local-only group.
- */
- if (ip->ip_ttl <= 1 ||
- IN_LOCAL_GROUP(ip->ip_dst.s_addr))
- return (0);
+ /*
+ * Don't forward a packet with time-to-live of zero or one,
+ * or a packet destined to a local-only group.
+ */
+ if (ip->ip_ttl <= 1 || IN_LOCAL_GROUP(ip->ip_dst.s_addr))
+ return (0);
- /*
- * Determine forwarding vifs from the forwarding cache table
- */
- s = splsoftnet();
- MFCFIND(ip->ip_src.s_addr, ip->ip_dst.s_addr, rt);
+ /*
+ * Determine forwarding vifs from the forwarding cache table
+ */
+ s = splsoftnet();
+ MFCFIND(ip->ip_src.s_addr, ip->ip_dst.s_addr, rt);
- /* Entry exists, so forward if necessary */
- if (rt != NULL) {
- splx(s);
+ /* Entry exists, so forward if necessary */
+ if (rt != NULL) {
+ splx(s);
#ifdef RSVP_ISI
- return (ip_mdq(m, ifp, rt, -1));
+ return (ip_mdq(m, ifp, rt, -1));
#else
- return (ip_mdq(m, ifp, rt));
+ return (ip_mdq(m, ifp, rt));
#endif /* RSVP_ISI */
- } else {
- /*
- * If we don't have a route for packet's origin,
- * Make a copy of the packet &
- * send message to routing daemon
- */
+ } else {
+ /*
+ * If we don't have a route for packet's origin,
+ * Make a copy of the packet &
+ * send message to routing daemon
+ */
- register struct mbuf *mb0;
- register struct rtdetq *rte;
- register u_int32_t hash;
+ register struct mbuf *mb0;
+ register struct rtdetq *rte;
+ register u_int32_t hash;
#ifdef UPCALL_TIMING
- struct timeval tp;
+ struct timeval tp;
- microtime(&tp);
+ microtime(&tp);
#endif /* UPCALL_TIMING */
- mrtstat.mrts_no_route++;
- if (mrtdebug & (DEBUG_FORWARD | DEBUG_MFC))
- log(LOG_DEBUG, "ip_mforward: no rte s %x g %x\n",
- ntohl(ip->ip_src.s_addr),
- ntohl(ip->ip_dst.s_addr));
+ mrtstat.mrts_no_route++;
+ if (mrtdebug & (DEBUG_FORWARD | DEBUG_MFC))
+ log(LOG_DEBUG, "ip_mforward: no rte s %x g %x\n",
+ ntohl(ip->ip_src.s_addr),
+ ntohl(ip->ip_dst.s_addr));
- /*
- * Allocate mbufs early so that we don't do extra work if we are
- * just going to fail anyway.
- */
- rte = (struct rtdetq *)malloc(sizeof(*rte), M_MRTABLE, M_NOWAIT);
- if (rte == NULL) {
- splx(s);
- return (ENOBUFS);
- }
- mb0 = m_copy(m, 0, M_COPYALL);
- if (mb0 == NULL) {
- free(rte, M_MRTABLE);
- splx(s);
- return (ENOBUFS);
- }
+ /*
+ * Allocate mbufs early so that we don't do extra work if we are
+ * just going to fail anyway.
+ */
+ rte = (struct rtdetq *)malloc(sizeof(*rte), M_MRTABLE, M_NOWAIT);
+ if (rte == NULL) {
+ splx(s);
+ return (ENOBUFS);
+ }
+ mb0 = m_copy(m, 0, M_COPYALL);
+ if (mb0 == NULL) {
+ free(rte, M_MRTABLE);
+ splx(s);
+ return (ENOBUFS);
+ }
- /* is there an upcall waiting for this packet? */
- hash = MFCHASH(ip->ip_src.s_addr, ip->ip_dst.s_addr);
- for (rt = mfchashtbl[hash].lh_first; rt; rt = rt->mfc_hash.le_next) {
- if (ip->ip_src.s_addr == rt->mfc_origin.s_addr &&
- ip->ip_dst.s_addr == rt->mfc_mcastgrp.s_addr &&
- rt->mfc_stall != NULL)
- break;
- }
+ /* is there an upcall waiting for this packet? */
+ hash = MFCHASH(ip->ip_src.s_addr, ip->ip_dst.s_addr);
+ for (rt = mfchashtbl[hash].lh_first; rt; rt = rt->mfc_hash.le_next) {
+ if (ip->ip_src.s_addr == rt->mfc_origin.s_addr &&
+ ip->ip_dst.s_addr == rt->mfc_mcastgrp.s_addr &&
+ rt->mfc_stall != NULL)
+ break;
+ }
- if (rt == NULL) {
- int hlen = ip->ip_hl << 2;
- int i;
- struct igmpmsg *im;
+ if (rt == NULL) {
+ int hlen = ip->ip_hl << 2;
+ int i;
+ struct igmpmsg *im;
- /* no upcall, so make a new entry */
- rt = (struct mfc *)malloc(sizeof(*rt), M_MRTABLE, M_NOWAIT);
- if (rt == NULL) {
- free(rte, M_MRTABLE);
- m_free(mb0);
- splx(s);
- return (ENOBUFS);
- }
- /* Make a copy of the header to send to the user level process */
- mm = m_copy(m, 0, hlen);
- M_PULLUP(mm, hlen);
- if (mm == NULL) {
- free(rte, M_MRTABLE);
- m_free(mb0);
- free(rt, M_MRTABLE);
- splx(s);
- return (ENOBUFS);
- }
+ /* no upcall, so make a new entry */
+ rt = (struct mfc *)malloc(sizeof(*rt), M_MRTABLE, M_NOWAIT);
+ if (rt == NULL) {
+ free(rte, M_MRTABLE);
+ m_free(mb0);
+ splx(s);
+ return (ENOBUFS);
+ }
+ /*
+ * Make a copy of the header to send to the user level
+ * process
+ */
+ mm = m_copy(m, 0, hlen);
+ M_PULLUP(mm, hlen);
+ if (mm == NULL) {
+ free(rte, M_MRTABLE);
+ m_free(mb0);
+ free(rt, M_MRTABLE);
+ splx(s);
+ return (ENOBUFS);
+ }
- /*
- * Send message to routing daemon to install
- * a route into the kernel table
- */
- sin.sin_addr = ip->ip_src;
+ /*
+ * Send message to routing daemon to install
+ * a route into the kernel table
+ */
+ sin.sin_addr = ip->ip_src;
- im = mtod(mm, struct igmpmsg *);
- im->im_msgtype = IGMPMSG_NOCACHE;
- im->im_mbz = 0;
+ im = mtod(mm, struct igmpmsg *);
+ im->im_msgtype = IGMPMSG_NOCACHE;
+ im->im_mbz = 0;
- mrtstat.mrts_upcalls++;
+ mrtstat.mrts_upcalls++;
- if (socket_send(ip_mrouter, mm, &sin) < 0) {
- log(LOG_WARNING, "ip_mforward: ip_mrouter socket queue full\n");
- ++mrtstat.mrts_upq_sockfull;
- free(rte, M_MRTABLE);
- m_free(mb0);
- free(rt, M_MRTABLE);
- splx(s);
- return (ENOBUFS);
- }
-
- /* insert new entry at head of hash chain */
- rt->mfc_origin = ip->ip_src;
- rt->mfc_mcastgrp = ip->ip_dst;
- rt->mfc_pkt_cnt = 0;
- rt->mfc_byte_cnt = 0;
- rt->mfc_wrong_if = 0;
- rt->mfc_expire = UPCALL_EXPIRE;
- nexpire[hash]++;
- for (i = 0; i < numvifs; i++)
- rt->mfc_ttls[i] = 0;
- rt->mfc_parent = -1;
-
- /* link into table */
- LIST_INSERT_HEAD(&mfchashtbl[hash], rt, mfc_hash);
- /* Add this entry to the end of the queue */
- rt->mfc_stall = rte;
- } else {
- /* determine if q has overflowed */
- struct rtdetq **p;
- register int npkts = 0;
-
- for (p = &rt->mfc_stall; *p != NULL; p = &(*p)->next)
- if (++npkts > MAX_UPQ) {
- mrtstat.mrts_upq_ovflw++;
- free(rte, M_MRTABLE);
- m_free(mb0);
- splx(s);
- return (0);
- }
-
- /* Add this entry to the end of the queue */
- *p = rte;
- }
+ if (socket_send(ip_mrouter, mm, &sin) < 0) {
+ log(LOG_WARNING,
+ "ip_mforward: ip_mrouter socket queue full\n");
+ ++mrtstat.mrts_upq_sockfull;
+ free(rte, M_MRTABLE);
+ m_free(mb0);
+ free(rt, M_MRTABLE);
+ splx(s);
+ return (ENOBUFS);
+ }
- rte->next = NULL;
- rte->m = mb0;
- rte->ifp = ifp;
-#ifdef UPCALL_TIMING
- rte->t = tp;
-#endif /* UPCALL_TIMING */
+ /* insert new entry at head of hash chain */
+ rt->mfc_origin = ip->ip_src;
+ rt->mfc_mcastgrp = ip->ip_dst;
+ rt->mfc_pkt_cnt = 0;
+ rt->mfc_byte_cnt = 0;
+ rt->mfc_wrong_if = 0;
+ rt->mfc_expire = UPCALL_EXPIRE;
+ nexpire[hash]++;
+ for (i = 0; i < numvifs; i++)
+ rt->mfc_ttls[i] = 0;
+ rt->mfc_parent = -1;
+
+ /* link into table */
+ LIST_INSERT_HEAD(&mfchashtbl[hash], rt, mfc_hash);
+ /* Add this entry to the end of the queue */
+ rt->mfc_stall = rte;
+ } else {
+ /* determine if q has overflowed */
+ struct rtdetq **p;
+ register int npkts = 0;
+
+ for (p = &rt->mfc_stall; *p != NULL; p = &(*p)->next)
+ if (++npkts > MAX_UPQ) {
+ mrtstat.mrts_upq_ovflw++;
+ free(rte, M_MRTABLE);
+ m_free(mb0);
+ splx(s);
+ return (0);
+ }
+
+ /* Add this entry to the end of the queue */
+ *p = rte;
+ }
+ rte->next = NULL;
+ rte->m = mb0;
+ rte->ifp = ifp;
+ #ifdef UPCALL_TIMING
+ rte->t = tp;
+ #endif /* UPCALL_TIMING */
- splx(s);
+ splx(s);
- return (0);
- }
+ return (0);
+ }
}
@@ -1240,8 +1245,7 @@ expire_upcalls(v)
for (rt = mfchashtbl[i].lh_first; rt; rt = nrt) {
nrt = rt->mfc_hash.le_next;
- if (rt->mfc_expire == 0 ||
- --rt->mfc_expire > 0)
+ if (rt->mfc_expire == 0 || --rt->mfc_expire > 0)
continue;
nexpire[i]--;
@@ -1269,119 +1273,120 @@ ip_mdq(m, ifp, rt, xmt_vif)
#else
ip_mdq(m, ifp, rt)
#endif /* RSVP_ISI */
- register struct mbuf *m;
- register struct ifnet *ifp;
- register struct mfc *rt;
+ register struct mbuf *m;
+ register struct ifnet *ifp;
+ register struct mfc *rt;
#ifdef RSVP_ISI
- register vifi_t xmt_vif;
+ register vifi_t xmt_vif;
#endif /* RSVP_ISI */
{
- register struct ip *ip = mtod(m, struct ip *);
- register vifi_t vifi;
- register struct vif *vifp;
- register int plen = ip->ip_len;
+ register struct ip *ip = mtod(m, struct ip *);
+ register vifi_t vifi;
+ register struct vif *vifp;
+ register int plen = ip->ip_len;
/*
* Macro to send packet on vif. Since RSVP packets don't get counted on
* 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) do { \
+ if ((vifp)->v_flags & VIFF_TUNNEL) \
+ encap_send((ip), (vifp), (m)); \
+ else \
+ phyint_send((ip), (vifp), (m)); \
+} while (0)
#ifdef RSVP_ISI
- /*
- * If xmt_vif is not -1, send on only the requested vif.
- *
- * (since vifi_t is u_short, -1 becomes MAXUSHORT, which > numvifs.
- */
- if (xmt_vif < numvifs) {
- MC_SEND(ip, viftable + xmt_vif, m);
- return (1);
- }
+ /*
+ * If xmt_vif is not -1, send on only the requested vif.
+ *
+ * (since vifi_t is u_short, -1 becomes MAXUSHORT, which > numvifs.
+ */
+ if (xmt_vif < numvifs) {
+ MC_SEND(ip, viftable + xmt_vif, m);
+ return (1);
+ }
#endif /* RSVP_ISI */
- /*
- * Don't forward if it didn't arrive from the parent vif for its origin.
- */
- vifi = rt->mfc_parent;
- if ((vifi >= numvifs) || (viftable[vifi].v_ifp != ifp)) {
- /* came in the wrong interface */
- if (mrtdebug & DEBUG_FORWARD)
- log(LOG_DEBUG, "wrong if: ifp %p vifi %d vififp %p\n",
- ifp, vifi, vifi >= numvifs ? 0 : viftable[vifi].v_ifp);
- ++mrtstat.mrts_wrong_if;
- ++rt->mfc_wrong_if;
/*
- * If we are doing PIM assert processing, and we are forwarding
- * packets on this interface, and it is a broadcast medium
- * interface (and not a tunnel), send a message to the routing daemon.
+ * Don't forward if it didn't arrive from the parent vif for its origin.
*/
- if (pim_assert && rt->mfc_ttls[vifi] &&
- (ifp->if_flags & IFF_BROADCAST) &&
- !(viftable[vifi].v_flags & VIFF_TUNNEL)) {
- struct mbuf *mm;
- struct igmpmsg *im;
- int hlen = ip->ip_hl << 2;
- struct timeval now;
- register u_int32_t delta;
-
- microtime(&now);
-
- TV_DELTA(rt->mfc_last_assert, now, delta);
-
- if (delta > ASSERT_MSG_TIME) {
- mm = m_copy(m, 0, hlen);
- M_PULLUP(mm, hlen);
- if (mm == NULL) {
- return (ENOBUFS);
- }
+ vifi = rt->mfc_parent;
+ if ((vifi >= numvifs) || (viftable[vifi].v_ifp != ifp)) {
+ /* came in the wrong interface */
+ if (mrtdebug & DEBUG_FORWARD)
+ log(LOG_DEBUG, "wrong if: ifp %p vifi %d vififp %p\n",
+ ifp, vifi,
+ vifi >= numvifs ? 0 : viftable[vifi].v_ifp);
+ ++mrtstat.mrts_wrong_if;
+ ++rt->mfc_wrong_if;
+ /*
+ * If we are doing PIM assert processing, and we are forwarding
+ * packets on this interface, and it is a broadcast medium
+ * interface (and not a tunnel), send a message to the routing daemon.
+ */
+ if (pim_assert && rt->mfc_ttls[vifi] &&
+ (ifp->if_flags & IFF_BROADCAST) &&
+ !(viftable[vifi].v_flags & VIFF_TUNNEL)) {
+ struct mbuf *mm;
+ struct igmpmsg *im;
+ int hlen = ip->ip_hl << 2;
+ struct timeval now;
+ register u_int32_t delta;
+
+ microtime(&now);
+
+ TV_DELTA(rt->mfc_last_assert, now, delta);
- rt->mfc_last_assert = now;
+ if (delta > ASSERT_MSG_TIME) {
+ mm = m_copy(m, 0, hlen);
+ M_PULLUP(mm, hlen);
+ if (mm == NULL) {
+ return (ENOBUFS);
+ }
- im = mtod(mm, struct igmpmsg *);
- im->im_msgtype = IGMPMSG_WRONGVIF;
- im->im_mbz = 0;
- im->im_vif = vifi;
+ rt->mfc_last_assert = now;
- sin.sin_addr = im->im_src;
+ im = mtod(mm, struct igmpmsg *);
+ im->im_msgtype = IGMPMSG_WRONGVIF;
+ im->im_mbz = 0;
+ im->im_vif = vifi;
- socket_send(ip_mrouter, m, &sin);
- }
+ sin.sin_addr = im->im_src;
+
+ socket_send(ip_mrouter, m, &sin);
+ }
+ }
+ return (0);
}
- return (0);
- }
-
- /* If I sourced this packet, it counts as output, else it was input. */
- if (ip->ip_src.s_addr == viftable[vifi].v_lcl_addr.s_addr) {
- viftable[vifi].v_pkt_out++;
- viftable[vifi].v_bytes_out += plen;
- } else {
- viftable[vifi].v_pkt_in++;
- viftable[vifi].v_bytes_in += plen;
- }
- rt->mfc_pkt_cnt++;
- rt->mfc_byte_cnt += plen;
-
- /*
- * For each vif, decide if a copy of the packet should be forwarded.
- * Forward if:
- * - the ttl exceeds the vif's threshold
- * - there are group members downstream on interface
- */
- for (vifp = viftable, vifi = 0; vifi < numvifs; vifp++, vifi++)
- if ((rt->mfc_ttls[vifi] > 0) &&
- (ip->ip_ttl > rt->mfc_ttls[vifi])) {
- vifp->v_pkt_out++;
- vifp->v_bytes_out += plen;
- MC_SEND(ip, vifp, m);
+
+ /* If I sourced this packet, it counts as output, else it was input. */
+ if (ip->ip_src.s_addr == viftable[vifi].v_lcl_addr.s_addr) {
+ viftable[vifi].v_pkt_out++;
+ viftable[vifi].v_bytes_out += plen;
+ } else {
+ viftable[vifi].v_pkt_in++;
+ viftable[vifi].v_bytes_in += plen;
}
+ rt->mfc_pkt_cnt++;
+ rt->mfc_byte_cnt += plen;
- return (0);
+ /*
+ * For each vif, decide if a copy of the packet should be forwarded.
+ * Forward if:
+ * - the ttl exceeds the vif's threshold
+ * - there are group members downstream on interface
+ */
+ for (vifp = viftable, vifi = 0; vifi < numvifs; vifp++, vifi++)
+ if ((rt->mfc_ttls[vifi] > 0) &&
+ (ip->ip_ttl > rt->mfc_ttls[vifi])) {
+ vifp->v_pkt_out++;
+ vifp->v_bytes_out += plen;
+ MC_SEND(ip, vifp, m);
+ }
+
+ return (0);
}
#ifdef RSVP_ISI
@@ -1391,12 +1396,12 @@ ip_mdq(m, ifp, rt)
*/
int
legal_vif_num(vif)
- int vif;
+ int vif;
{
- if (vif >= 0 && vif < numvifs)
- return (1);
- else
- return (0);
+ if (vif >= 0 && vif < numvifs)
+ return (1);
+ else
+ return (0);
}
#endif /* RSVP_ISI */
@@ -1616,22 +1621,22 @@ tbf_control(vifp, m, ip, p_len)
*/
static void
tbf_queue(vifp, m, ip)
- register struct vif *vifp;
- register struct mbuf *m;
- register struct ip *ip;
+ register struct vif *vifp;
+ register struct mbuf *m;
+ register struct ip *ip;
{
- register u_int32_t ql;
- register int index = (vifp - viftable);
- register int s = splsoftnet();
+ register u_int32_t ql;
+ register int index = (vifp - viftable);
+ register int s = splsoftnet();
- ql = vifp->v_tbf.q_len;
+ ql = vifp->v_tbf.q_len;
- qtable[index][ql].pkt_m = m;
- qtable[index][ql].pkt_len = (mtod(m, struct ip *))->ip_len;
- qtable[index][ql].pkt_ip = ip;
+ qtable[index][ql].pkt_m = m;
+ qtable[index][ql].pkt_len = (mtod(m, struct ip *))->ip_len;
+ qtable[index][ql].pkt_ip = ip;
- vifp->v_tbf.q_len++;
- splx(s);
+ vifp->v_tbf.q_len++;
+ splx(s);
}
@@ -1640,33 +1645,33 @@ tbf_queue(vifp, m, ip)
*/
static void
tbf_process_q(vifp)
- register struct vif *vifp;
+ register struct vif *vifp;
{
- register struct pkt_queue pkt_1;
- register int index = (vifp - viftable);
- register int s = splsoftnet();
-
- /* loop through the queue at the interface and send as many packets
- * as possible
- */
- while (vifp->v_tbf.q_len > 0) {
- /* locate the first packet */
- pkt_1 = qtable[index][0];
-
- /* determine if the packet can be sent */
- if (pkt_1.pkt_len <= vifp->v_tbf.n_tok) {
- /* if so,
- * reduce no of tokens, dequeue the queue,
- * send the packet.
- */
- vifp->v_tbf.n_tok -= pkt_1.pkt_len;
-
- tbf_dequeue(vifp, 0);
- tbf_send_packet(vifp, pkt_1.pkt_m);
- } else
- break;
- }
- splx(s);
+ register struct pkt_queue pkt_1;
+ register int index = (vifp - viftable);
+ register int s = splsoftnet();
+
+ /* loop through the queue at the interface and send as many packets
+ * as possible
+ */
+ while (vifp->v_tbf.q_len > 0) {
+ /* locate the first packet */
+ pkt_1 = qtable[index][0];
+
+ /* determine if the packet can be sent */
+ if (pkt_1.pkt_len <= vifp->v_tbf.n_tok) {
+ /* if so,
+ * reduce no of tokens, dequeue the queue,
+ * send the packet.
+ */
+ vifp->v_tbf.n_tok -= pkt_1.pkt_len;
+
+ tbf_dequeue(vifp, 0);
+ tbf_send_packet(vifp, pkt_1.pkt_m);
+ } else
+ break;
+ }
+ splx(s);
}
/*
@@ -1674,23 +1679,24 @@ tbf_process_q(vifp)
*/
static void
tbf_dequeue(vifp, j)
- register struct vif *vifp;
- register int j;
+ register struct vif *vifp;
+ register int j;
{
- register u_int32_t index = vifp - viftable;
- register int i;
+ register u_int32_t index = vifp - viftable;
+ register int i;
- for (i=j+1; i <= vifp->v_tbf.q_len - 1; i++) {
- qtable[index][i-1] = qtable[index][i];
- }
- qtable[index][i-1].pkt_m = NULL;
- qtable[index][i-1].pkt_len = NULL;
- qtable[index][i-1].pkt_ip = NULL;
+ for (i = j + 1; i <= vifp->v_tbf.q_len - 1; i++) {
+ qtable[index][i-1] = qtable[index][i];
+ }
+ qtable[index][i-1].pkt_m = NULL;
+ qtable[index][i-1].pkt_len = NULL;
+ qtable[index][i-1].pkt_ip = NULL;
- vifp->v_tbf.q_len--;
+ vifp->v_tbf.q_len--;
- if (tbfdebug > 1)
- log(LOG_DEBUG, "tbf_dequeue: vif# %d qlen %d\n",vifp-viftable, i-1);
+ if (tbfdebug > 1)
+ log(LOG_DEBUG, "tbf_dequeue: vif# %d qlen %d\n",
+ vifp - viftable, i - 1);
}
static void
@@ -1715,57 +1721,58 @@ tbf_reprocess_q(arg)
*/
static int
tbf_dq_sel(vifp, ip)
- register struct vif *vifp;
- register struct ip *ip;
+ register struct vif *vifp;
+ register struct ip *ip;
{
- register int i;
- register int s = splsoftnet();
- register u_int p;
-
- p = priority(vifp, ip);
-
- for(i=vifp->v_tbf.q_len-1;i >= 0;i--) {
- if (p > priority(vifp, qtable[vifp-viftable][i].pkt_ip)) {
- m_freem(qtable[vifp-viftable][i].pkt_m);
- tbf_dequeue(vifp, i);
- splx(s);
- mrtstat.mrts_drop_sel++;
- return (1);
+ register int i;
+ register int s = splsoftnet();
+ register u_int p;
+
+ p = priority(vifp, ip);
+
+ for (i = vifp->v_tbf.q_len - 1; i >= 0; i--) {
+ if (p > priority(vifp, qtable[vifp-viftable][i].pkt_ip)) {
+ m_freem(qtable[vifp-viftable][i].pkt_m);
+ tbf_dequeue(vifp, i);
+ splx(s);
+ mrtstat.mrts_drop_sel++;
+ return (1);
+ }
}
- }
- splx(s);
- return (0);
+ splx(s);
+ return (0);
}
static void
-tbf_send_packet(vifp,m)
- register struct vif *vifp;
- register struct mbuf *m;
+tbf_send_packet(vifp, m)
+ register struct vif *vifp;
+ register struct mbuf *m;
{
- int error;
- int s = splsoftnet();
-
- if (vifp->v_flags & VIFF_TUNNEL) {
- /* If tunnel options */
- ip_output(m, (struct mbuf *)0, &vifp->v_route,
- IP_FORWARDING, (void *)NULL, (void *)NULL);
- } else {
- /* if physical interface option, extract the options and then send */
- struct ip *ip = mtod(m, struct ip *);
- struct ip_moptions imo;
- imo.imo_multicast_ifp = vifp->v_ifp;
- imo.imo_multicast_ttl = ip->ip_ttl - 1;
- imo.imo_multicast_loop = 1;
+ int error;
+ int s = splsoftnet();
+
+ if (vifp->v_flags & VIFF_TUNNEL) {
+ /* If tunnel options */
+ ip_output(m, (struct mbuf *)0, &vifp->v_route,
+ IP_FORWARDING, (void *)NULL, (void *)NULL);
+ } else {
+ /* if physical interface option, extract the options and then send */
+ struct ip *ip = mtod(m, struct ip *);
+ struct ip_moptions imo;
+ imo.imo_multicast_ifp = vifp->v_ifp;
+ imo.imo_multicast_ttl = ip->ip_ttl - 1;
+ imo.imo_multicast_loop = 1;
#ifdef RSVP_ISI
- imo.imo_multicast_vif = -1;
+ imo.imo_multicast_vif = -1;
#endif
- error = ip_output(m, (struct mbuf *)0, (struct route *)0,
- IP_FORWARDING|IP_MULTICASTOPTS, &imo, (void *)NULL);
- if (mrtdebug & DEBUG_XMIT)
- log(LOG_DEBUG, "phyint_send on vif %d err %d\n", vifp-viftable, error);
- }
- splx(s);
+ error = ip_output(m, (struct mbuf *)0, (struct route *)0,
+ IP_FORWARDING|IP_MULTICASTOPTS, &imo, (void *)NULL);
+ if (mrtdebug & DEBUG_XMIT)
+ log(LOG_DEBUG, "phyint_send on vif %d err %d\n",
+ vifp - viftable, error);
+ }
+ splx(s);
}
/* determine the current time and then
@@ -1774,283 +1781,296 @@ tbf_send_packet(vifp,m)
*/
static void
tbf_update_tokens(vifp)
- register struct vif *vifp;
+ register struct vif *vifp;
{
- struct timeval tp;
- register u_int32_t t;
- register u_int32_t elapsed;
- register int s = splsoftnet();
+ struct timeval tp;
+ register u_int32_t t;
+ register u_int32_t elapsed;
+ register int s = splsoftnet();
- microtime(&tp);
+ microtime(&tp);
- t = tp.tv_sec*1000 + tp.tv_usec/1000;
+ t = tp.tv_sec * 1000 + tp.tv_usec / 1000;
- elapsed = (t - vifp->v_tbf.last_pkt_t) * vifp->v_rate_limit /8;
- vifp->v_tbf.n_tok += elapsed;
- vifp->v_tbf.last_pkt_t = t;
+ elapsed = (t - vifp->v_tbf.last_pkt_t) * vifp->v_rate_limit / 8;
+ vifp->v_tbf.n_tok += elapsed;
+ vifp->v_tbf.last_pkt_t = t;
- if (vifp->v_tbf.n_tok > MAX_BKT_SIZE)
- vifp->v_tbf.n_tok = MAX_BKT_SIZE;
+ if (vifp->v_tbf.n_tok > MAX_BKT_SIZE)
+ vifp->v_tbf.n_tok = MAX_BKT_SIZE;
- splx(s);
+ splx(s);
}
static int
priority(vifp, ip)
- register struct vif *vifp;
- register struct ip *ip;
+ register struct vif *vifp;
+ register struct ip *ip;
{
- register int prio;
-
- /* temporary hack; may add general packet classifier some day */
-
- /*
- * The UDP port space is divided up into four priority ranges:
- * [0, 16384) : unclassified - lowest priority
- * [16384, 32768) : audio - highest priority
- * [32768, 49152) : whiteboard - medium priority
- * [49152, 65536) : video - low priority
- */
- if (ip->ip_p == IPPROTO_UDP) {
- struct udphdr *udp = (struct udphdr *)(((char *)ip) + (ip->ip_hl << 2));
-
- switch (ntohs(udp->uh_dport) & 0xc000) {
- case 0x4000:
- prio = 70;
- break;
- case 0x8000:
- prio = 60;
- break;
- case 0xc000:
- prio = 55;
- break;
- default:
- prio = 50;
- break;
- }
+ register int prio;
- if (tbfdebug > 1) log(LOG_DEBUG, "port %x prio %d\n", ntohs(udp->uh_dport), prio);
- } else
- prio = 50;
+ /* temporary hack; may add general packet classifier some day */
+ /*
+ * The UDP port space is divided up into four priority ranges:
+ * [0, 16384) : unclassified - lowest priority
+ * [16384, 32768) : audio - highest priority
+ * [32768, 49152) : whiteboard - medium priority
+ * [49152, 65536) : video - low priority
+ */
+ if (ip->ip_p == IPPROTO_UDP) {
+ struct udphdr *udp = (struct udphdr *)(((char *)ip) + (ip->ip_hl << 2));
- return (prio);
+ switch (ntohs(udp->uh_dport) & 0xc000) {
+ case 0x4000:
+ prio = 70;
+ break;
+ case 0x8000:
+ prio = 60;
+ break;
+ case 0xc000:
+ prio = 55;
+ break;
+ default:
+ prio = 50;
+ break;
+ }
+
+ if (tbfdebug > 1)
+ log(LOG_DEBUG, "port %x prio %d\n",
+ ntohs(udp->uh_dport), prio);
+ } else
+ prio = 50;
+
+ return (prio);
}
/*
* End of token bucket filter modifications
*/
-
#ifdef RSVP_ISI
-
int
ip_rsvp_vif_init(so, m)
- struct socket *so;
- struct mbuf *m;
+ struct socket *so;
+ struct mbuf *m;
{
- int i;
- register int s;
+ int i;
+ register int s;
- if (rsvpdebug)
- printf("ip_rsvp_vif_init: so_type = %d, pr_protocol = %d\n",
- so->so_type, so->so_proto->pr_protocol);
+ if (rsvpdebug)
+ printf("ip_rsvp_vif_init: so_type = %d, pr_protocol = %d\n",
+ so->so_type, so->so_proto->pr_protocol);
- if (so->so_type != SOCK_RAW || so->so_proto->pr_protocol != IPPROTO_RSVP)
- return (EOPNOTSUPP);
+ if (so->so_type != SOCK_RAW ||
+ so->so_proto->pr_protocol != IPPROTO_RSVP)
+ return (EOPNOTSUPP);
- /* Check mbuf. */
- if (m == NULL || m->m_len != sizeof(int)) {
- return (EINVAL);
- }
- i = *(mtod(m, int *));
+ /* Check mbuf. */
+ if (m == NULL || m->m_len != sizeof(int)) {
+ return (EINVAL);
+ }
+ i = *(mtod(m, int *));
- if (rsvpdebug)
- printf("ip_rsvp_vif_init: vif = %d rsvp_on = %d\n",i,rsvp_on);
+ if (rsvpdebug)
+ printf("ip_rsvp_vif_init: vif = %d rsvp_on = %d\n", i, rsvp_on);
- s = splsoftnet();
+ s = splsoftnet();
- /* Check vif. */
- if (!legal_vif_num(i)) {
- splx(s);
- return (EADDRNOTAVAIL);
- }
+ /* Check vif. */
+ if (!legal_vif_num(i)) {
+ splx(s);
+ return (EADDRNOTAVAIL);
+ }
+
+ /* Check if socket is available. */
+ if (viftable[i].v_rsvpd != NULL) {
+ splx(s);
+ return (EADDRINUSE);
+ }
+
+ viftable[i].v_rsvpd = so;
+ /* This may seem silly, but we need to be sure we don't over-increment
+ * the RSVP counter, in case something slips up.
+ */
+ if (!viftable[i].v_rsvp_on) {
+ viftable[i].v_rsvp_on = 1;
+ rsvp_on++;
+ }
- /* Check if socket is available. */
- if (viftable[i].v_rsvpd != NULL) {
splx(s);
- return (EADDRINUSE);
- }
-
- viftable[i].v_rsvpd = so;
- /* This may seem silly, but we need to be sure we don't over-increment
- * the RSVP counter, in case something slips up.
- */
- if (!viftable[i].v_rsvp_on) {
- viftable[i].v_rsvp_on = 1;
- rsvp_on++;
- }
-
- splx(s);
- return (0);
+ return (0);
}
int
ip_rsvp_vif_done(so, m)
- struct socket *so;
- struct mbuf *m;
+ struct socket *so;
+ struct mbuf *m;
{
- int i;
- register int s;
+ int i;
+ register int s;
+
+ if (rsvpdebug)
+ printf("ip_rsvp_vif_done: so_type = %d, pr_protocol = %d\n",
+ so->so_type, so->so_proto->pr_protocol);
+
+ if (so->so_type != SOCK_RAW ||
+ so->so_proto->pr_protocol != IPPROTO_RSVP)
+ return (EOPNOTSUPP);
+
+ /* Check mbuf. */
+ if (m == NULL || m->m_len != sizeof(int)) {
+ return (EINVAL);
+ }
+ i = *(mtod(m, int *));
- if (rsvpdebug)
- printf("ip_rsvp_vif_done: so_type = %d, pr_protocol = %d\n",
- so->so_type, so->so_proto->pr_protocol);
+ s = splsoftnet();
- if (so->so_type != SOCK_RAW || so->so_proto->pr_protocol != IPPROTO_RSVP)
- return (EOPNOTSUPP);
+ /* Check vif. */
+ if (!legal_vif_num(i)) {
+ splx(s);
+ return (EADDRNOTAVAIL);
+ }
- /* Check mbuf. */
- if (m == NULL || m->m_len != sizeof(int)) {
- return (EINVAL);
- }
- i = *(mtod(m, int *));
+ if (rsvpdebug)
+ printf("ip_rsvp_vif_done: v_rsvpd = %x so = %x\n",
+ viftable[i].v_rsvpd, so);
- s = splsoftnet();
+ viftable[i].v_rsvpd = NULL;
+ /*
+ * This may seem silly, but we need to be sure we don't over-decrement
+ * the RSVP counter, in case something slips up.
+ */
+ if (viftable[i].v_rsvp_on) {
+ viftable[i].v_rsvp_on = 0;
+ rsvp_on--;
+ }
- /* Check vif. */
- if (!legal_vif_num(i)) {
splx(s);
- return (EADDRNOTAVAIL);
- }
-
- if (rsvpdebug)
- printf("ip_rsvp_vif_done: v_rsvpd = %x so = %x\n",
- viftable[i].v_rsvpd, so);
-
- viftable[i].v_rsvpd = NULL;
- /* This may seem silly, but we need to be sure we don't over-decrement
- * the RSVP counter, in case something slips up.
- */
- if (viftable[i].v_rsvp_on) {
- viftable[i].v_rsvp_on = 0;
- rsvp_on--;
- }
-
- splx(s);
- return (0);
+ return (0);
}
void
ip_rsvp_force_done(so)
- struct socket *so;
+ struct socket *so;
{
- int vifi;
- register int s;
+ int vifi;
+ register int s;
- /* Don't bother if it is not the right type of socket. */
- if (so->so_type != SOCK_RAW || so->so_proto->pr_protocol != IPPROTO_RSVP)
- return;
+ /* Don't bother if it is not the right type of socket. */
+ if (so->so_type != SOCK_RAW ||
+ so->so_proto->pr_protocol != IPPROTO_RSVP)
+ return;
- s = splsoftnet();
-
- /* The socket may be attached to more than one vif...this
- * is perfectly legal.
- */
- for (vifi = 0; vifi < numvifs; vifi++) {
- if (viftable[vifi].v_rsvpd == so) {
- viftable[vifi].v_rsvpd = NULL;
- /* This may seem silly, but we need to be sure we don't
- * over-decrement the RSVP counter, in case something slips up.
- */
- if (viftable[vifi].v_rsvp_on) {
- viftable[vifi].v_rsvp_on = 0;
- rsvp_on--;
- }
+ s = splsoftnet();
+
+ /*
+ * The socket may be attached to more than one vif...this
+ * is perfectly legal.
+ */
+ for (vifi = 0; vifi < numvifs; vifi++) {
+ if (viftable[vifi].v_rsvpd == so) {
+ viftable[vifi].v_rsvpd = NULL;
+ /*
+ * This may seem silly, but we need to be sure we don't
+ * over-decrement the RSVP counter, in case something
+ * slips up.
+ */
+ if (viftable[vifi].v_rsvp_on) {
+ viftable[vifi].v_rsvp_on = 0;
+ rsvp_on--;
+ }
+ }
}
- }
- splx(s);
- return;
+ splx(s);
+ return;
}
void
rsvp_input(m, ifp)
- struct mbuf *m;
- struct ifnet *ifp;
+ struct mbuf *m;
+ struct ifnet *ifp;
{
- int vifi;
- register struct ip *ip = mtod(m, struct ip *);
- static struct sockaddr_in rsvp_src = { sizeof(sin), AF_INET };
- register int s;
-
- if (rsvpdebug)
- printf("rsvp_input: rsvp_on %d\n",rsvp_on);
-
- /* Can still get packets with rsvp_on = 0 if there is a local member
- * of the group to which the RSVP packet is addressed. But in this
- * case we want to throw the packet away.
- */
- if (!rsvp_on) {
- m_freem(m);
- return;
- }
+ int vifi;
+ register struct ip *ip = mtod(m, struct ip *);
+ static struct sockaddr_in rsvp_src = { sizeof(sin), AF_INET };
+ register int s;
- /* If the old-style non-vif-associated socket is set, then use
- * it and ignore the new ones.
- */
- if (ip_rsvpd != NULL) {
if (rsvpdebug)
- printf("rsvp_input: Sending packet up old-style socket\n");
- rip_input(m, 0);
- return;
- }
+ printf("rsvp_input: rsvp_on %d\n", rsvp_on);
- s = splsoftnet();
+ /*
+ * Can still get packets with rsvp_on = 0 if there is a local member
+ * of the group to which the RSVP packet is addressed. But in this
+ * case we want to throw the packet away.
+ */
+ if (!rsvp_on) {
+ m_freem(m);
+ return;
+ }
- if (rsvpdebug)
- printf("rsvp_input: check vifs\n");
+ /*
+ * If the old-style non-vif-associated socket is set, then use
+ * it and ignore the new ones.
+ */
+ if (ip_rsvpd != NULL) {
+ if (rsvpdebug)
+ printf("rsvp_input: "
+ "Sending packet up old-style socket\n");
+ rip_input(m, 0);
+ return;
+ }
- /* Find which vif the packet arrived on. */
- for (vifi = 0; vifi < numvifs; vifi++) {
- if (viftable[vifi].v_ifp == ifp)
- break;
- }
+ s = splsoftnet();
- if (vifi == numvifs) {
- /* Can't find vif packet arrived on. Drop packet. */
if (rsvpdebug)
- printf("rsvp_input: Can't find vif for packet...dropping it.\n");
- m_freem(m);
- splx(s);
- return;
- }
+ printf("rsvp_input: check vifs\n");
- if (rsvpdebug)
- printf("rsvp_input: check socket\n");
+ /* Find which vif the packet arrived on. */
+ for (vifi = 0; vifi < numvifs; vifi++) {
+ if (viftable[vifi].v_ifp == ifp)
+ break;
+ }
+
+ if (vifi == numvifs) {
+ /* Can't find vif packet arrived on. Drop packet. */
+ if (rsvpdebug)
+ printf("rsvp_input: "
+ "Can't find vif for packet...dropping it.\n");
+ m_freem(m);
+ splx(s);
+ return;
+ }
- if (viftable[vifi].v_rsvpd == NULL) {
- /* drop packet, since there is no specific socket for this
- * interface */
if (rsvpdebug)
- printf("rsvp_input: No socket defined for vif %d\n",vifi);
- m_freem(m);
- splx(s);
- return;
- }
+ printf("rsvp_input: check socket\n");
+
+ if (viftable[vifi].v_rsvpd == NULL) {
+ /*
+ * drop packet, since there is no specific socket for this
+ * interface
+ */
+ if (rsvpdebug)
+ printf("rsvp_input: No socket defined for vif %d\n",
+ vifi);
+ m_freem(m);
+ splx(s);
+ return;
+ }
- rsvp_src.sin_addr = ip->ip_src;
+ rsvp_src.sin_addr = ip->ip_src;
- if (rsvpdebug && m)
- printf("rsvp_input: m->m_len = %d, sbspace() = %d\n",
- m->m_len,sbspace(&viftable[vifi].v_rsvpd->so_rcv));
+ if (rsvpdebug && m)
+ printf("rsvp_input: m->m_len = %d, sbspace() = %d\n",
+ m->m_len, sbspace(&viftable[vifi].v_rsvpd->so_rcv));
- if (socket_send(viftable[vifi].v_rsvpd, m, &rsvp_src) < 0)
- if (rsvpdebug)
- printf("rsvp_input: Failed to append to socket\n");
- else
- if (rsvpdebug)
- printf("rsvp_input: send packet up\n");
+ if (socket_send(viftable[vifi].v_rsvpd, m, &rsvp_src) < 0)
+ if (rsvpdebug)
+ printf("rsvp_input: Failed to append to socket\n");
+ else
+ if (rsvpdebug)
+ printf("rsvp_input: send packet up\n");
- splx(s);
+ splx(s);
}
#endif /* RSVP_ISI */