Module Name: src
Committed By: maxv
Date: Fri Feb 2 09:01:17 UTC 2018
Modified Files:
src/sys/netinet6: ip6_mroute.c
Log Message:
Style, no functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/netinet6/ip6_mroute.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/netinet6/ip6_mroute.c
diff -u src/sys/netinet6/ip6_mroute.c:1.120 src/sys/netinet6/ip6_mroute.c:1.121
--- src/sys/netinet6/ip6_mroute.c:1.120 Fri Feb 2 06:23:45 2018
+++ src/sys/netinet6/ip6_mroute.c Fri Feb 2 09:01:17 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_mroute.c,v 1.120 2018/02/02 06:23:45 maxv Exp $ */
+/* $NetBSD: ip6_mroute.c,v 1.121 2018/02/02 09:01:17 maxv Exp $ */
/* $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $ */
/*
@@ -117,7 +117,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.120 2018/02/02 06:23:45 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.121 2018/02/02 09:01:17 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -162,8 +162,7 @@ static int ip6_mdq(struct mbuf *, struct
static void phyint_send(struct ip6_hdr *, struct mif6 *, struct mbuf *);
static int set_pim6(int *);
-static int socket_send(struct socket *, struct mbuf *,
- struct sockaddr_in6 *);
+static int socket_send(struct socket *, struct mbuf *, struct sockaddr_in6 *);
static int register_send(struct ip6_hdr *, struct mif6 *, struct mbuf *);
/*
@@ -376,7 +375,8 @@ ip6_mrouter_get(struct socket *so, struc
{
int error;
- if (so != ip6_mrouter) return EACCES;
+ if (so != ip6_mrouter)
+ return EACCES;
error = 0;
@@ -479,13 +479,13 @@ ip6_mrouter_init(struct socket *so, int
if (so->so_type != SOCK_RAW ||
so->so_proto->pr_protocol != IPPROTO_ICMPV6)
- return (EOPNOTSUPP);
+ return EOPNOTSUPP;
if (v != 1)
- return (ENOPROTOOPT);
+ return ENOPROTOOPT;
if (ip6_mrouter != NULL)
- return (EADDRINUSE);
+ return EADDRINUSE;
ip6_mrouter = so;
ip6_mrouter_ver = cmd;
@@ -591,7 +591,7 @@ ip6_mrouter_done(void)
if_detach(&multicast_register_if6);
reg_mif_num = (mifi_t)-1;
}
-
+
ip6_mrouter = NULL;
ip6_mrouter_ver = 0;
@@ -639,7 +639,6 @@ ip6_mrouter_detach(struct ifnet *ifp)
}
}
-
/*
* Add a mif to the mif table
*/
@@ -666,16 +665,14 @@ add_m6if(struct mif6ctl *mifcp)
ifp = &multicast_register_if6;
if (reg_mif_num == (mifi_t)-1) {
- strlcpy(ifp->if_xname, "register_mif",
+ strlcpy(ifp->if_xname, "register_mif",
sizeof(ifp->if_xname));
ifp->if_flags |= IFF_LOOPBACK;
ifp->if_index = mifcp->mif6c_mifi;
reg_mif_num = mifcp->mif6c_mifi;
if_attach(ifp);
}
-
- } /* if REGISTER */
- else {
+ } else {
/* Make sure the interface supports multicast */
if ((ifp->if_flags & IFF_MULTICAST) == 0)
return EOPNOTSUPP;
@@ -869,7 +866,7 @@ add_m6fc(struct mf6cctl *mfccp)
m_freem(rte->m);
#ifdef UPCALL_TIMING
collate(&(rte->t));
-#endif /* UPCALL_TIMING */
+#endif
free(rte, M_MRTABLE);
rte = n;
}
@@ -916,8 +913,7 @@ add_m6fc(struct mf6cctl *mfccp)
}
if (rt == NULL) {
/* no upcall, so make a new entry */
- rt = (struct mf6c *)malloc(sizeof(*rt), M_MRTABLE,
- M_NOWAIT);
+ rt = malloc(sizeof(*rt), M_MRTABLE, M_NOWAIT);
if (rt == NULL) {
splx(s);
return ENOBUFS;
@@ -1045,7 +1041,6 @@ socket_send(struct socket *s, struct mbu
* erroneous, in which case a non-zero return value tells the caller to
* discard it.
*/
-
int
ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
{
@@ -1106,23 +1101,21 @@ ip6_mforward(struct ip6_hdr *ip6, struct
/* Entry exists, so forward if necessary */
if (rt) {
splx(s);
- return (ip6_mdq(m, ifp, rt));
+ return ip6_mdq(m, ifp, rt);
} else {
/*
- * If we don't have a route for packet's origin,
- * Make a copy of the packet &
- * send message to routing daemon
+ * If we don't have a route for packet's origin, make a copy
+ * of the packet and send message to routing daemon.
*/
struct mbuf *mb0;
struct rtdetq *rte;
u_long hash;
-/* int i, npkts;*/
+
#ifdef UPCALL_TIMING
struct timeval tp;
-
GET_TIME(tp);
-#endif /* UPCALL_TIMING */
+#endif
mrt6stat.mrt6s_no_route++;
#ifdef MRT6DEBUG
@@ -1136,13 +1129,13 @@ ip6_mforward(struct ip6_hdr *ip6, struct
* 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);
+ rte = malloc(sizeof(*rte), M_MRTABLE, M_NOWAIT);
if (rte == NULL) {
splx(s);
return ENOBUFS;
}
mb0 = m_copy(m, 0, M_COPYALL);
+
/*
* Pullup packet header if needed before storing it,
* as other references may modify it in the meantime.
@@ -1172,14 +1165,14 @@ ip6_mforward(struct ip6_hdr *ip6, struct
struct omrt6msg *oim;
/* no upcall, so make a new entry */
- rt = (struct mf6c *)malloc(sizeof(*rt), M_MRTABLE,
- M_NOWAIT);
+ rt = malloc(sizeof(*rt), M_MRTABLE, M_NOWAIT);
if (rt == NULL) {
free(rte, M_MRTABLE);
m_freem(mb0);
splx(s);
return ENOBUFS;
}
+
/*
* Make a copy of the header to send to the user
* level process
@@ -1273,7 +1266,7 @@ ip6_mforward(struct ip6_hdr *ip6, struct
struct rtdetq **p;
int npkts = 0;
- for (p = &rt->mf6c_stall; *p != NULL; p = &(*p)->next)
+ for (p = &rt->mf6c_stall; *p != NULL; p = &(*p)->next) {
if (++npkts > MAX_UPQ6) {
mrt6stat.mrt6s_upq_ovflw++;
free(rte, M_MRTABLE);
@@ -1281,6 +1274,7 @@ ip6_mforward(struct ip6_hdr *ip6, struct
splx(s);
return 0;
}
+ }
/* Add this entry to the end of the queue */
*p = rte;
@@ -1291,7 +1285,7 @@ ip6_mforward(struct ip6_hdr *ip6, struct
rte->ifp = ifp;
#ifdef UPCALL_TIMING
rte->t = tp;
-#endif /* UPCALL_TIMING */
+#endif
splx(s);
@@ -1368,6 +1362,18 @@ expire_upcalls(void *unused)
}
/*
+ * Macro to send packet on mif. Since RSVP packets don't get counted on
+ * input, they shouldn't get counted on output, so statistics keeping is
+ * separate.
+ */
+#define MC6_SEND(ip6, mifp, m) do { \
+ if ((mifp)->m6_flags & MIFF_REGISTER) \
+ register_send((ip6), (mifp), (m)); \
+ else \
+ phyint_send((ip6), (mifp), (m)); \
+} while (/*CONSTCOND*/ 0)
+
+/*
* Packet forwarding routine once entry in the cache is made
*/
static int
@@ -1381,19 +1387,6 @@ ip6_mdq(struct mbuf *m, struct ifnet *if
u_int32_t iszone, idzone, oszone, odzone;
int error = 0;
-/*
- * Macro to send packet on mif. Since RSVP packets don't get counted on
- * input, they shouldn't get counted on output, so statistics keeping is
- * separate.
- */
-
-#define MC6_SEND(ip6, mifp, m) do { \
- if ((mifp)->m6_flags & MIFF_REGISTER) \
- register_send((ip6), (mifp), (m)); \
- else \
- phyint_send((ip6), (mifp), (m)); \
-} while (/*CONSTCOND*/ 0)
-
/*
* Don't forward if it didn't arrive from the parent mif
* for its origin.
@@ -1411,13 +1404,14 @@ ip6_mdq(struct mbuf *m, struct ifnet *if
#endif
mrt6stat.mrt6s_wrong_if++;
rt->mf6c_wrong_if++;
+
/*
* If we are doing PIM processing, and we are forwarding
* packets on this interface, send a message to the
* routing daemon.
*/
/* have to make sure this is a valid mif */
- if (mifi < nummifs && mif6table[mifi].m6_ifp)
+ if (mifi < nummifs && mif6table[mifi].m6_ifp) {
if (pim6 && (m->m_flags & M_LOOP) == 0) {
/*
* Check the M_LOOP flag to avoid an
@@ -1485,10 +1479,12 @@ ip6_mdq(struct mbuf *m, struct ifnet *if
#endif
++mrt6stat.mrt6s_upq_sockfull;
return ENOBUFS;
- } /* if socket Q full */
- } /* if PIM */
+ }
+ }
+ }
+
return 0;
- } /* if wrong iif */
+ }
/* If I sourced this packet, it counts as output, else it was input. */
if (m->m_pkthdr.rcvif_index == 0) {
@@ -1511,9 +1507,9 @@ ip6_mdq(struct mbuf *m, struct ifnet *if
if ((error = in6_setscope(&src0, ifp, &iszone)) != 0 ||
(error = in6_setscope(&dst0, ifp, &idzone)) != 0) {
IP6_STATINC(IP6_STAT_BADSCOPE);
- return (error);
+ return error;
}
- for (mifp = mif6table, mifi = 0; mifi < nummifs; mifp++, mifi++)
+ for (mifp = mif6table, mifi = 0; mifi < nummifs; mifp++, mifi++) {
if (IF_ISSET(mifi, &rt->mf6c_ifset)) {
if (mif6table[mifi].m6_ifp == NULL)
continue;
@@ -1540,6 +1536,8 @@ ip6_mdq(struct mbuf *m, struct ifnet *if
mifp->m6_bytes_out += plen;
MC6_SEND(ip6, mifp, m);
}
+ }
+
return 0;
}
@@ -1556,6 +1554,7 @@ phyint_send(struct ip6_hdr *ip6, struct
u_long linkmtu;
s = splsoftnet();
+
/*
* Make a new reference to the packet; make sure that
* the IPv6 header is actually copied, not just referenced,
@@ -1569,6 +1568,7 @@ phyint_send(struct ip6_hdr *ip6, struct
splx(s);
return;
}
+
/* set MCAST flag to the outgoing packet */
mb_copy->m_flags |= M_MCAST;
@@ -1587,7 +1587,7 @@ phyint_send(struct ip6_hdr *ip6, struct
im6o.im6o_multicast_hlim = ip6->ip6_hlim;
im6o.im6o_multicast_loop = 1;
error = ip6_output(mb_copy, NULL, &ro, IPV6_FORWARDING,
- &im6o, NULL, NULL);
+ &im6o, NULL, NULL);
#ifdef MRT6DEBUG
if (mrt6debug & DEBUG_XMIT)
@@ -1602,8 +1602,8 @@ phyint_send(struct ip6_hdr *ip6, struct
* If we belong to the destination multicast group
* on the outgoing interface, loop back a copy.
*/
- /*
- * Does not have to check source info, as it's alreay covered by
+ /*
+ * Does not have to check source info, as it's alreay covered by
* ip6_input
*/
sockaddr_in6_init(&dst6, &ip6->ip6_dst, 0, 0, 0);
@@ -1629,12 +1629,13 @@ phyint_send(struct ip6_hdr *ip6, struct
} else {
/*
* pMTU discovery is intentionally disabled by default, since
- * various router may notify pMTU in multicast, which can be
- * a DDoS to a router
+ * various routers may notify pMTU in multicast, which can be
+ * a DDoS to a router.
*/
- if (ip6_mcast_pmtu)
+ if (ip6_mcast_pmtu) {
icmp6_error(mb_copy, ICMP6_PACKET_TOO_BIG, 0, linkmtu);
- else {
+ } else {
+ /* simply discard the packet */
#ifdef MRT6DEBUG
if (mrt6debug & DEBUG_XMIT) {
char ip6bufs[INET6_ADDRSTRLEN];
@@ -1647,8 +1648,8 @@ phyint_send(struct ip6_hdr *ip6, struct
IN6_PRINT(ip6bufd, &ip6->ip6_dst),
mb_copy->m_pkthdr.len);
}
-#endif /* MRT6DEBUG */
- m_freem(mb_copy); /* simply discard the packet */
+#endif
+ m_freem(mb_copy);
}
}
@@ -1690,7 +1691,6 @@ register_send(struct ip6_hdr *ip6, struc
mm = m_pullup(mm, i);
if (mm == NULL)
return ENOBUFS;
-/* TODO: check it! */
mm->m_pkthdr.len = len + sizeof(struct ip6_hdr);
/*
@@ -1699,9 +1699,8 @@ register_send(struct ip6_hdr *ip6, struc
sockaddr_in6_init(&sin6, &ip6->ip6_src, 0, 0, 0);
im6 = mtod(mm, struct mrt6msg *);
- im6->im6_msgtype = MRT6MSG_WHOLEPKT;
- im6->im6_mbz = 0;
-
+ im6->im6_msgtype = MRT6MSG_WHOLEPKT;
+ im6->im6_mbz = 0;
im6->im6_mif = mif - mif6table;
/* iif info is not given for reg. encap.n */
@@ -1716,20 +1715,21 @@ register_send(struct ip6_hdr *ip6, struc
++mrt6stat.mrt6s_upq_sockfull;
return ENOBUFS;
}
+
return 0;
}
/*
- * PIM sparse mode hook
- * Receives the pim control messages, and passes them up to the listening
- * socket, using rip6_input.
+ * PIM sparse mode hook. Receives the pim control messages, and passes them up
+ * to the listening socket, using rip6_input.
+ *
* The only message processed is the REGISTER pim message; the pim header
* is stripped off, and the inner packet is passed to register_mforward.
*/
int
pim6_input(struct mbuf **mp, int *offp, int proto)
{
- struct pim *pim; /* pointer to a pim struct */
+ struct pim *pim;
struct ip6_hdr *ip6 __mrt6debugused;
int pimlen;
struct mbuf *m = *mp;
@@ -1739,7 +1739,7 @@ pim6_input(struct mbuf **mp, int *offp,
PIM6_STATINC(PIM6_STAT_RCV_TOTAL);
ip6 = mtod(m, struct ip6_hdr *);
- pimlen = m->m_pkthdr.len - *offp;
+ pimlen = m->m_pkthdr.len - off;
/*
* Validate lengths
@@ -1751,11 +1751,11 @@ pim6_input(struct mbuf **mp, int *offp,
log(LOG_DEBUG,"pim6_input: PIM packet too short\n");
#endif
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
/*
- * if the packet is at least as big as a REGISTER, go ahead
+ * If the packet is at least as big as a REGISTER, go ahead
* and grab the PIM REGISTER header size, to avoid another
* possible m_pullup() later.
*
@@ -1783,7 +1783,7 @@ pim6_input(struct mbuf **mp, int *offp,
pim->pim_ver, PIM_VERSION);
#endif
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
#define PIM6_CHECKSUM
@@ -1808,7 +1808,7 @@ pim6_input(struct mbuf **mp, int *offp,
"pim6_input: invalid checksum\n");
#endif
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
}
#endif /* PIM_CHECKSUM */
@@ -1838,7 +1838,7 @@ pim6_input(struct mbuf **mp, int *offp,
reg_mif_num);
#endif
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
reghdr = (u_int32_t *)(pim + 1);
@@ -1860,10 +1860,10 @@ pim6_input(struct mbuf **mp, int *offp,
PIM6_STATINC(PIM6_STAT_RCV_TOOSHORT);
PIM6_STATINC(PIM6_STAT_RCV_BADREGISTERS);
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
- eip6 = (struct ip6_hdr *) (reghdr + 1);
+ eip6 = (struct ip6_hdr *)(reghdr + 1);
#ifdef MRT6DEBUG
if (mrt6debug & DEBUG_PIM) {
char ip6bufs[INET6_ADDRSTRLEN];
@@ -1886,7 +1886,7 @@ pim6_input(struct mbuf **mp, int *offp,
(eip6->ip6_vfc & IPV6_VERSION));
#endif
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
/* verify the inner packet is destined to a mcast group */
@@ -1902,7 +1902,7 @@ pim6_input(struct mbuf **mp, int *offp,
}
#endif
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
/*
@@ -1916,7 +1916,7 @@ pim6_input(struct mbuf **mp, int *offp,
"could not copy register head\n");
#endif
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
/*
@@ -1949,9 +1949,9 @@ pim6_input(struct mbuf **mp, int *offp,
* encapsulator ip6 header, pim header, register header and the
* encapsulated ip6 header.
*/
- pim6_input_to_daemon:
+pim6_input_to_daemon:
rip6_input(&m, offp, proto);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
static int