MFC r260481:
Add MRT6_DLOG() macro for debugging. Reduce number of MRT6DEBUG ifdefs and fix some broken format strings.
This commit is contained in:
parent
2789cacd95
commit
7c65e72b87
@ -221,6 +221,14 @@ static VNET_DEFINE(u_int, mrt6debug) = 0; /* debug level */
|
|||||||
#define DEBUG_XMIT 0x10
|
#define DEBUG_XMIT 0x10
|
||||||
#define DEBUG_REG 0x20
|
#define DEBUG_REG 0x20
|
||||||
#define DEBUG_PIM 0x40
|
#define DEBUG_PIM 0x40
|
||||||
|
#define DEBUG_ERR 0x80
|
||||||
|
#define DEBUG_ANY 0x7f
|
||||||
|
#define MRT6_DLOG(m, fmt, ...) \
|
||||||
|
if (V_mrt6debug & (m)) \
|
||||||
|
log(((m) & DEBUG_ERR) ? LOG_ERR: LOG_DEBUG, \
|
||||||
|
"%s: " fmt "\n", __func__, ##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define MRT6_DLOG(m, fmt, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void expire_upcalls(void *);
|
static void expire_upcalls(void *);
|
||||||
@ -526,12 +534,8 @@ static int
|
|||||||
ip6_mrouter_init(struct socket *so, int v, int cmd)
|
ip6_mrouter_init(struct socket *so, int v, int cmd)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_ANY, "so_type = %d, pr_protocol = %d",
|
||||||
if (V_mrt6debug)
|
so->so_type, so->so_proto->pr_protocol);
|
||||||
log(LOG_DEBUG,
|
|
||||||
"ip6_mrouter_init: so_type = %d, pr_protocol = %d\n",
|
|
||||||
so->so_type, so->so_proto->pr_protocol);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (so->so_type != SOCK_RAW ||
|
if (so->so_type != SOCK_RAW ||
|
||||||
so->so_proto->pr_protocol != IPPROTO_ICMPV6)
|
so->so_proto->pr_protocol != IPPROTO_ICMPV6)
|
||||||
@ -560,11 +564,7 @@ ip6_mrouter_init(struct socket *so, int v, int cmd)
|
|||||||
expire_upcalls, NULL);
|
expire_upcalls, NULL);
|
||||||
|
|
||||||
MROUTER6_UNLOCK();
|
MROUTER6_UNLOCK();
|
||||||
|
MRT6_DLOG(DEBUG_ANY, "finished");
|
||||||
#ifdef MRT6DEBUG
|
|
||||||
if (V_mrt6debug)
|
|
||||||
log(LOG_DEBUG, "ip6_mrouter_init\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -642,11 +642,7 @@ X_ip6_mrouter_done(void)
|
|||||||
V_ip6_mrouter_ver = 0;
|
V_ip6_mrouter_ver = 0;
|
||||||
|
|
||||||
MROUTER6_UNLOCK();
|
MROUTER6_UNLOCK();
|
||||||
|
MRT6_DLOG(DEBUG_ANY, "finished");
|
||||||
#ifdef MRT6DEBUG
|
|
||||||
if (V_mrt6debug)
|
|
||||||
log(LOG_DEBUG, "ip6_mrouter_done\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -727,14 +723,8 @@ add_m6if(struct mif6ctl *mifcp)
|
|||||||
nummifs = mifcp->mif6c_mifi + 1;
|
nummifs = mifcp->mif6c_mifi + 1;
|
||||||
|
|
||||||
MIF6_UNLOCK();
|
MIF6_UNLOCK();
|
||||||
|
MRT6_DLOG(DEBUG_ANY, "mif #%d, phyint %s", mifcp->mif6c_mifi,
|
||||||
#ifdef MRT6DEBUG
|
if_name(ifp));
|
||||||
if (V_mrt6debug)
|
|
||||||
log(LOG_DEBUG,
|
|
||||||
"add_mif #%d, phyint %s\n",
|
|
||||||
mifcp->mif6c_mifi,
|
|
||||||
ifp->if_xname);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -777,11 +767,7 @@ del_m6if_locked(mifi_t *mifip)
|
|||||||
if (mif6table[mifi - 1].m6_ifp)
|
if (mif6table[mifi - 1].m6_ifp)
|
||||||
break;
|
break;
|
||||||
nummifs = mifi;
|
nummifs = mifi;
|
||||||
|
MRT6_DLOG(DEBUG_ANY, "mif %d, nummifs %d", *mifip, nummifs);
|
||||||
#ifdef MRT6DEBUG
|
|
||||||
if (V_mrt6debug)
|
|
||||||
log(LOG_DEBUG, "del_m6if %d, nummifs %d\n", *mifip, nummifs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -817,15 +803,10 @@ add_m6fc(struct mf6cctl *mfccp)
|
|||||||
|
|
||||||
/* If an entry already exists, just update the fields */
|
/* If an entry already exists, just update the fields */
|
||||||
if (rt) {
|
if (rt) {
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_MFC, "no upcall o %s g %s p %x",
|
||||||
if (V_mrt6debug & DEBUG_MFC) {
|
ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr),
|
||||||
log(LOG_DEBUG,
|
ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr),
|
||||||
"add_m6fc no upcall h %d o %s g %s p %x\n",
|
mfccp->mf6cc_parent);
|
||||||
ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr),
|
|
||||||
ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr),
|
|
||||||
mfccp->mf6cc_parent);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rt->mf6c_parent = mfccp->mf6cc_parent;
|
rt->mf6c_parent = mfccp->mf6cc_parent;
|
||||||
rt->mf6c_ifset = mfccp->mf6cc_ifset;
|
rt->mf6c_ifset = mfccp->mf6cc_ifset;
|
||||||
@ -856,16 +837,12 @@ add_m6fc(struct mf6cctl *mfccp)
|
|||||||
&mfccp->mf6cc_mcastgrp.sin6_addr),
|
&mfccp->mf6cc_mcastgrp.sin6_addr),
|
||||||
mfccp->mf6cc_parent, rt->mf6c_stall);
|
mfccp->mf6cc_parent, rt->mf6c_stall);
|
||||||
|
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_MFC, "o %s g %s p %x dbg %p",
|
||||||
if (V_mrt6debug & DEBUG_MFC)
|
ip6_sprintf(ip6bufo,
|
||||||
log(LOG_DEBUG,
|
&mfccp->mf6cc_origin.sin6_addr),
|
||||||
"add_m6fc o %s g %s p %x dbg %x\n",
|
ip6_sprintf(ip6bufg,
|
||||||
ip6_sprintf(ip6bufo,
|
&mfccp->mf6cc_mcastgrp.sin6_addr),
|
||||||
&mfccp->mf6cc_origin.sin6_addr),
|
mfccp->mf6cc_parent, rt->mf6c_stall);
|
||||||
ip6_sprintf(ip6bufg,
|
|
||||||
&mfccp->mf6cc_mcastgrp.sin6_addr),
|
|
||||||
mfccp->mf6cc_parent, rt->mf6c_stall);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rt->mf6c_origin = mfccp->mf6cc_origin;
|
rt->mf6c_origin = mfccp->mf6cc_origin;
|
||||||
rt->mf6c_mcastgrp = mfccp->mf6cc_mcastgrp;
|
rt->mf6c_mcastgrp = mfccp->mf6cc_mcastgrp;
|
||||||
@ -898,15 +875,10 @@ add_m6fc(struct mf6cctl *mfccp)
|
|||||||
* It is possible that an entry is being inserted without an upcall
|
* It is possible that an entry is being inserted without an upcall
|
||||||
*/
|
*/
|
||||||
if (nstl == 0) {
|
if (nstl == 0) {
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_MFC, "no upcall h %lu o %s g %s p %x", hash,
|
||||||
if (V_mrt6debug & DEBUG_MFC)
|
ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr),
|
||||||
log(LOG_DEBUG,
|
ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr),
|
||||||
"add_mfc no upcall h %d o %s g %s p %x\n",
|
mfccp->mf6cc_parent);
|
||||||
hash,
|
|
||||||
ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr),
|
|
||||||
ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr),
|
|
||||||
mfccp->mf6cc_parent);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (rt = mf6ctable[hash]; rt; rt = rt->mf6c_next) {
|
for (rt = mf6ctable[hash]; rt; rt = rt->mf6c_next) {
|
||||||
|
|
||||||
@ -992,6 +964,9 @@ collate(struct timeval *t)
|
|||||||
static int
|
static int
|
||||||
del_m6fc(struct mf6cctl *mfccp)
|
del_m6fc(struct mf6cctl *mfccp)
|
||||||
{
|
{
|
||||||
|
#ifdef MRT6DEBUG
|
||||||
|
char ip6bufo[INET6_ADDRSTRLEN], ip6bufg[INET6_ADDRSTRLEN];
|
||||||
|
#endif
|
||||||
struct sockaddr_in6 origin;
|
struct sockaddr_in6 origin;
|
||||||
struct sockaddr_in6 mcastgrp;
|
struct sockaddr_in6 mcastgrp;
|
||||||
struct mf6c *rt;
|
struct mf6c *rt;
|
||||||
@ -1002,14 +977,9 @@ del_m6fc(struct mf6cctl *mfccp)
|
|||||||
mcastgrp = mfccp->mf6cc_mcastgrp;
|
mcastgrp = mfccp->mf6cc_mcastgrp;
|
||||||
hash = MF6CHASH(origin.sin6_addr, mcastgrp.sin6_addr);
|
hash = MF6CHASH(origin.sin6_addr, mcastgrp.sin6_addr);
|
||||||
|
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_MFC, "orig %s mcastgrp %s",
|
||||||
if (V_mrt6debug & DEBUG_MFC) {
|
ip6_sprintf(ip6bufo, &origin.sin6_addr),
|
||||||
char ip6bufo[INET6_ADDRSTRLEN], ip6bufg[INET6_ADDRSTRLEN];
|
ip6_sprintf(ip6bufg, &mcastgrp.sin6_addr));
|
||||||
log(LOG_DEBUG,"del_m6fc orig %s mcastgrp %s\n",
|
|
||||||
ip6_sprintf(ip6bufo, &origin.sin6_addr),
|
|
||||||
ip6_sprintf(ip6bufg, &mcastgrp.sin6_addr));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MFC6_LOCK();
|
MFC6_LOCK();
|
||||||
|
|
||||||
@ -1080,13 +1050,9 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
|
|||||||
mifi_t mifi;
|
mifi_t mifi;
|
||||||
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
|
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_FORWARD, "src %s, dst %s, ifindex %d",
|
||||||
if (V_mrt6debug & DEBUG_FORWARD)
|
ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
||||||
log(LOG_DEBUG, "ip6_mforward: src %s, dst %s, ifindex %d\n",
|
ip6_sprintf(ip6bufd, &ip6->ip6_dst), ifp->if_index);
|
||||||
ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
|
||||||
ip6_sprintf(ip6bufd, &ip6->ip6_dst),
|
|
||||||
ifp->if_index);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't forward a packet with Hop limit of zero or one,
|
* Don't forward a packet with Hop limit of zero or one,
|
||||||
@ -1148,12 +1114,9 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
|
|||||||
#endif /* UPCALL_TIMING */
|
#endif /* UPCALL_TIMING */
|
||||||
|
|
||||||
MRT6STAT_INC(mrt6s_no_route);
|
MRT6STAT_INC(mrt6s_no_route);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_FORWARD | DEBUG_MFC, "no rte s %s g %s",
|
||||||
if (V_mrt6debug & (DEBUG_FORWARD | DEBUG_MFC))
|
ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
||||||
log(LOG_DEBUG, "ip6_mforward: no rte s %s g %s\n",
|
ip6_sprintf(ip6bufd, &ip6->ip6_dst));
|
||||||
ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
|
||||||
ip6_sprintf(ip6bufd, &ip6->ip6_dst));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate mbufs early so that we don't do extra work if we
|
* Allocate mbufs early so that we don't do extra work if we
|
||||||
@ -1249,11 +1212,8 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
|
|||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_FORWARD,
|
||||||
if (V_mrt6debug & DEBUG_FORWARD)
|
"getting the iif info in the kernel");
|
||||||
log(LOG_DEBUG,
|
|
||||||
"getting the iif info in the kernel\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (mifp = mif6table, mifi = 0;
|
for (mifp = mif6table, mifi = 0;
|
||||||
mifi < nummifs && mifp->m6_ifp != ifp;
|
mifi < nummifs && mifp->m6_ifp != ifp;
|
||||||
@ -1339,6 +1299,9 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
|
|||||||
static void
|
static void
|
||||||
expire_upcalls(void *unused)
|
expire_upcalls(void *unused)
|
||||||
{
|
{
|
||||||
|
#ifdef MRT6DEBUG
|
||||||
|
char ip6bufo[INET6_ADDRSTRLEN], ip6bufg[INET6_ADDRSTRLEN];
|
||||||
|
#endif
|
||||||
struct rtdetq *rte;
|
struct rtdetq *rte;
|
||||||
struct mf6c *mfc, **nptr;
|
struct mf6c *mfc, **nptr;
|
||||||
u_long i;
|
u_long i;
|
||||||
@ -1358,15 +1321,9 @@ expire_upcalls(void *unused)
|
|||||||
if (rte != NULL &&
|
if (rte != NULL &&
|
||||||
mfc->mf6c_expire != 0 &&
|
mfc->mf6c_expire != 0 &&
|
||||||
--mfc->mf6c_expire == 0) {
|
--mfc->mf6c_expire == 0) {
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_EXPIRE, "expiring (%s %s)",
|
||||||
if (V_mrt6debug & DEBUG_EXPIRE) {
|
ip6_sprintf(ip6bufo, &mfc->mf6c_origin.sin6_addr),
|
||||||
char ip6bufo[INET6_ADDRSTRLEN];
|
ip6_sprintf(ip6bufg, &mfc->mf6c_mcastgrp.sin6_addr));
|
||||||
char ip6bufg[INET6_ADDRSTRLEN];
|
|
||||||
log(LOG_DEBUG, "expire_upcalls: expiring (%s %s)\n",
|
|
||||||
ip6_sprintf(ip6bufo, &mfc->mf6c_origin.sin6_addr),
|
|
||||||
ip6_sprintf(ip6bufg, &mfc->mf6c_mcastgrp.sin6_addr));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
* drop all the packets
|
* drop all the packets
|
||||||
* free the mbuf with the pkt, if, timing info
|
* free the mbuf with the pkt, if, timing info
|
||||||
@ -1426,13 +1383,9 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
|
|||||||
mifi = rt->mf6c_parent;
|
mifi = rt->mf6c_parent;
|
||||||
if ((mifi >= nummifs) || (mif6table[mifi].m6_ifp != ifp)) {
|
if ((mifi >= nummifs) || (mif6table[mifi].m6_ifp != ifp)) {
|
||||||
/* came in the wrong interface */
|
/* came in the wrong interface */
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_FORWARD,
|
||||||
if (V_mrt6debug & DEBUG_FORWARD)
|
"wrong if: ifid %d mifi %d mififid %x", ifp->if_index,
|
||||||
log(LOG_DEBUG,
|
mifi, mif6table[mifi].m6_ifp->if_index);
|
||||||
"wrong if: ifid %d mifi %d mififid %x\n",
|
|
||||||
ifp->if_index, mifi,
|
|
||||||
mif6table[mifi].m6_ifp->if_index);
|
|
||||||
#endif
|
|
||||||
MRT6STAT_INC(mrt6s_wrong_if);
|
MRT6STAT_INC(mrt6s_wrong_if);
|
||||||
rt->mf6c_wrong_if++;
|
rt->mf6c_wrong_if++;
|
||||||
/*
|
/*
|
||||||
@ -1509,10 +1462,8 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
|
|||||||
MRT6STAT_INC(mrt6s_upcalls);
|
MRT6STAT_INC(mrt6s_upcalls);
|
||||||
|
|
||||||
if (socket_send(V_ip6_mrouter, mm, &sin6) < 0) {
|
if (socket_send(V_ip6_mrouter, mm, &sin6) < 0) {
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_ANY,
|
||||||
if (V_mrt6debug)
|
"ip6_mrouter socket queue full");
|
||||||
log(LOG_WARNING, "mdq, ip6_mrouter socket queue full\n");
|
|
||||||
#endif
|
|
||||||
MRT6STAT_INC(mrt6s_upq_sockfull);
|
MRT6STAT_INC(mrt6s_upq_sockfull);
|
||||||
return (ENOBUFS);
|
return (ENOBUFS);
|
||||||
} /* if socket Q full */
|
} /* if socket Q full */
|
||||||
@ -1576,6 +1527,9 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
|
|||||||
static void
|
static void
|
||||||
phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
|
phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
|
||||||
{
|
{
|
||||||
|
#ifdef MRT6DEBUG
|
||||||
|
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
|
||||||
|
#endif
|
||||||
struct mbuf *mb_copy;
|
struct mbuf *mb_copy;
|
||||||
struct ifnet *ifp = mifp->m6_ifp;
|
struct ifnet *ifp = mifp->m6_ifp;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
@ -1613,11 +1567,8 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
|
|||||||
error = ip6_output(mb_copy, NULL, NULL, IPV6_FORWARDING, &im6o,
|
error = ip6_output(mb_copy, NULL, NULL, IPV6_FORWARDING, &im6o,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_XMIT, "mif %u err %d",
|
||||||
if (V_mrt6debug & DEBUG_XMIT)
|
(uint16_t)(mifp - mif6table), error);
|
||||||
log(LOG_DEBUG, "phyint_send on mif %d err %d\n",
|
|
||||||
mifp - mif6table, error);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1656,11 +1607,8 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
|
|||||||
m_clrprotoflags(m); /* Avoid confusing lower layers. */
|
m_clrprotoflags(m); /* Avoid confusing lower layers. */
|
||||||
error = (*ifp->if_output)(ifp, mb_copy,
|
error = (*ifp->if_output)(ifp, mb_copy,
|
||||||
(struct sockaddr *)&dst6, NULL);
|
(struct sockaddr *)&dst6, NULL);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_XMIT, "mif %u err %d",
|
||||||
if (V_mrt6debug & DEBUG_XMIT)
|
(uint16_t)(mifp - mif6table), error);
|
||||||
log(LOG_DEBUG, "phyint_send on mif %d err %d\n",
|
|
||||||
mifp - mif6table, error);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* pMTU discovery is intentionally disabled by default, since
|
* pMTU discovery is intentionally disabled by default, since
|
||||||
@ -1670,19 +1618,11 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
|
|||||||
if (V_ip6_mcast_pmtu)
|
if (V_ip6_mcast_pmtu)
|
||||||
icmp6_error(mb_copy, ICMP6_PACKET_TOO_BIG, 0, linkmtu);
|
icmp6_error(mb_copy, ICMP6_PACKET_TOO_BIG, 0, linkmtu);
|
||||||
else {
|
else {
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_XMIT, " packet too big on %s o %s "
|
||||||
if (V_mrt6debug & DEBUG_XMIT) {
|
"g %s size %d (discarded)", if_name(ifp),
|
||||||
char ip6bufs[INET6_ADDRSTRLEN];
|
ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
||||||
char ip6bufd[INET6_ADDRSTRLEN];
|
ip6_sprintf(ip6bufd, &ip6->ip6_dst),
|
||||||
log(LOG_DEBUG,
|
mb_copy->m_pkthdr.len);
|
||||||
"phyint_send: packet too big on %s o %s "
|
|
||||||
"g %s size %d(discarded)\n",
|
|
||||||
if_name(ifp),
|
|
||||||
ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
|
||||||
ip6_sprintf(ip6bufd, &ip6->ip6_dst),
|
|
||||||
mb_copy->m_pkthdr.len);
|
|
||||||
}
|
|
||||||
#endif /* MRT6DEBUG */
|
|
||||||
m_freem(mb_copy); /* simply discard the packet */
|
m_freem(mb_copy); /* simply discard the packet */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1691,19 +1631,17 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
|
|||||||
static int
|
static int
|
||||||
register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m)
|
register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m)
|
||||||
{
|
{
|
||||||
|
#ifdef MRT6DEBUG
|
||||||
|
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
|
||||||
|
#endif
|
||||||
struct mbuf *mm;
|
struct mbuf *mm;
|
||||||
int i, len = m->m_pkthdr.len;
|
int i, len = m->m_pkthdr.len;
|
||||||
static struct sockaddr_in6 sin6 = { sizeof(sin6), AF_INET6 };
|
static struct sockaddr_in6 sin6 = { sizeof(sin6), AF_INET6 };
|
||||||
struct mrt6msg *im6;
|
struct mrt6msg *im6;
|
||||||
|
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_ANY, "src %s dst %s",
|
||||||
if (V_mrt6debug) {
|
ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
||||||
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
|
ip6_sprintf(ip6bufd, &ip6->ip6_dst));
|
||||||
log(LOG_DEBUG, "** IPv6 register_send **\n src %s dst %s\n",
|
|
||||||
ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
|
||||||
ip6_sprintf(ip6bufd, &ip6->ip6_dst));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
PIM6STAT_INC(pim6s_snd_registers);
|
PIM6STAT_INC(pim6s_snd_registers);
|
||||||
|
|
||||||
/* Make a copy of the packet to send to the user level process. */
|
/* Make a copy of the packet to send to the user level process. */
|
||||||
@ -1741,11 +1679,7 @@ register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m)
|
|||||||
MRT6STAT_INC(mrt6s_upcalls);
|
MRT6STAT_INC(mrt6s_upcalls);
|
||||||
|
|
||||||
if (socket_send(V_ip6_mrouter, mm, &sin6) < 0) {
|
if (socket_send(V_ip6_mrouter, mm, &sin6) < 0) {
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_ANY, "ip6_mrouter socket queue full");
|
||||||
if (V_mrt6debug)
|
|
||||||
log(LOG_WARNING,
|
|
||||||
"register_send: ip6_mrouter socket queue full\n");
|
|
||||||
#endif
|
|
||||||
MRT6STAT_INC(mrt6s_upq_sockfull);
|
MRT6STAT_INC(mrt6s_upq_sockfull);
|
||||||
return (ENOBUFS);
|
return (ENOBUFS);
|
||||||
}
|
}
|
||||||
@ -1797,10 +1731,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
|
|||||||
*/
|
*/
|
||||||
if (pimlen < PIM_MINLEN) {
|
if (pimlen < PIM_MINLEN) {
|
||||||
PIM6STAT_INC(pim6s_rcv_tooshort);
|
PIM6STAT_INC(pim6s_rcv_tooshort);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_PIM, "PIM packet too short");
|
||||||
if (V_mrt6debug & DEBUG_PIM)
|
|
||||||
log(LOG_DEBUG,"pim6_input: PIM packet too short\n");
|
|
||||||
#endif
|
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
return (IPPROTO_DONE);
|
return (IPPROTO_DONE);
|
||||||
}
|
}
|
||||||
@ -1850,11 +1781,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
|
|||||||
|
|
||||||
if (in6_cksum(m, IPPROTO_PIM, off, cksumlen)) {
|
if (in6_cksum(m, IPPROTO_PIM, off, cksumlen)) {
|
||||||
PIM6STAT_INC(pim6s_rcv_badsum);
|
PIM6STAT_INC(pim6s_rcv_badsum);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_PIM, "invalid checksum");
|
||||||
if (V_mrt6debug & DEBUG_PIM)
|
|
||||||
log(LOG_DEBUG,
|
|
||||||
"pim6_input: invalid checksum\n");
|
|
||||||
#endif
|
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
return (IPPROTO_DONE);
|
return (IPPROTO_DONE);
|
||||||
}
|
}
|
||||||
@ -1864,11 +1791,9 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
|
|||||||
/* PIM version check */
|
/* PIM version check */
|
||||||
if (pim->pim_ver != PIM_VERSION) {
|
if (pim->pim_ver != PIM_VERSION) {
|
||||||
PIM6STAT_INC(pim6s_rcv_badversion);
|
PIM6STAT_INC(pim6s_rcv_badversion);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_ANY | DEBUG_ERR,
|
||||||
log(LOG_ERR,
|
"incorrect version %d, expecting %d",
|
||||||
"pim6_input: incorrect version %d, expecting %d\n",
|
|
||||||
pim->pim_ver, PIM_VERSION);
|
pim->pim_ver, PIM_VERSION);
|
||||||
#endif
|
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
return (IPPROTO_DONE);
|
return (IPPROTO_DONE);
|
||||||
}
|
}
|
||||||
@ -1892,12 +1817,8 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
|
|||||||
PIM6STAT_INC(pim6s_rcv_registers);
|
PIM6STAT_INC(pim6s_rcv_registers);
|
||||||
|
|
||||||
if ((reg_mif_num >= nummifs) || (reg_mif_num == (mifi_t) -1)) {
|
if ((reg_mif_num >= nummifs) || (reg_mif_num == (mifi_t) -1)) {
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_PIM, "register mif not set: %d",
|
||||||
if (V_mrt6debug & DEBUG_PIM)
|
reg_mif_num);
|
||||||
log(LOG_DEBUG,
|
|
||||||
"pim6_input: register mif not set: %d\n",
|
|
||||||
reg_mif_num);
|
|
||||||
#endif
|
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
return (IPPROTO_DONE);
|
return (IPPROTO_DONE);
|
||||||
}
|
}
|
||||||
@ -1913,35 +1834,25 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
|
|||||||
if (pimlen < PIM6_REG_MINLEN) {
|
if (pimlen < PIM6_REG_MINLEN) {
|
||||||
PIM6STAT_INC(pim6s_rcv_tooshort);
|
PIM6STAT_INC(pim6s_rcv_tooshort);
|
||||||
PIM6STAT_INC(pim6s_rcv_badregisters);
|
PIM6STAT_INC(pim6s_rcv_badregisters);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_ANY | DEBUG_ERR, "register packet "
|
||||||
log(LOG_ERR,
|
"size too small %d from %s",
|
||||||
"pim6_input: register packet size too "
|
|
||||||
"small %d from %s\n",
|
|
||||||
pimlen, ip6_sprintf(ip6bufs, &ip6->ip6_src));
|
pimlen, ip6_sprintf(ip6bufs, &ip6->ip6_src));
|
||||||
#endif
|
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
return (IPPROTO_DONE);
|
return (IPPROTO_DONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
eip6 = (struct ip6_hdr *) (reghdr + 1);
|
eip6 = (struct ip6_hdr *) (reghdr + 1);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_PIM, "eip6: %s -> %s, eip6 plen %d",
|
||||||
if (V_mrt6debug & DEBUG_PIM)
|
ip6_sprintf(ip6bufs, &eip6->ip6_src),
|
||||||
log(LOG_DEBUG,
|
ip6_sprintf(ip6bufd, &eip6->ip6_dst),
|
||||||
"pim6_input[register], eip6: %s -> %s, "
|
ntohs(eip6->ip6_plen));
|
||||||
"eip6 plen %d\n",
|
|
||||||
ip6_sprintf(ip6bufs, &eip6->ip6_src),
|
|
||||||
ip6_sprintf(ip6bufd, &eip6->ip6_dst),
|
|
||||||
ntohs(eip6->ip6_plen));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* verify the version number of the inner packet */
|
/* verify the version number of the inner packet */
|
||||||
if ((eip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
|
if ((eip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
|
||||||
PIM6STAT_INC(pim6s_rcv_badregisters);
|
PIM6STAT_INC(pim6s_rcv_badregisters);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_ANY, "invalid IP version (%d) "
|
||||||
log(LOG_DEBUG, "pim6_input: invalid IP version (%d) "
|
"of the inner packet",
|
||||||
"of the inner packet\n",
|
|
||||||
(eip6->ip6_vfc & IPV6_VERSION));
|
(eip6->ip6_vfc & IPV6_VERSION));
|
||||||
#endif
|
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
return (IPPROTO_NONE);
|
return (IPPROTO_NONE);
|
||||||
}
|
}
|
||||||
@ -1949,13 +1860,9 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
|
|||||||
/* verify the inner packet is destined to a mcast group */
|
/* verify the inner packet is destined to a mcast group */
|
||||||
if (!IN6_IS_ADDR_MULTICAST(&eip6->ip6_dst)) {
|
if (!IN6_IS_ADDR_MULTICAST(&eip6->ip6_dst)) {
|
||||||
PIM6STAT_INC(pim6s_rcv_badregisters);
|
PIM6STAT_INC(pim6s_rcv_badregisters);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_PIM, "inner packet of register "
|
||||||
if (V_mrt6debug & DEBUG_PIM)
|
"is not multicast %s",
|
||||||
log(LOG_DEBUG,
|
ip6_sprintf(ip6bufd, &eip6->ip6_dst));
|
||||||
"pim6_input: inner packet of register "
|
|
||||||
"is not multicast %s\n",
|
|
||||||
ip6_sprintf(ip6bufd, &eip6->ip6_dst));
|
|
||||||
#endif
|
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
return (IPPROTO_DONE);
|
return (IPPROTO_DONE);
|
||||||
}
|
}
|
||||||
@ -1965,11 +1872,8 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
|
|||||||
*/
|
*/
|
||||||
mcp = m_copy(m, 0, off + PIM6_REG_MINLEN);
|
mcp = m_copy(m, 0, off + PIM6_REG_MINLEN);
|
||||||
if (mcp == NULL) {
|
if (mcp == NULL) {
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_ANY | DEBUG_ERR, "pim register: "
|
||||||
log(LOG_ERR,
|
"could not copy register head");
|
||||||
"pim6_input: pim register: "
|
|
||||||
"could not copy register head\n");
|
|
||||||
#endif
|
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
return (IPPROTO_DONE);
|
return (IPPROTO_DONE);
|
||||||
}
|
}
|
||||||
@ -1978,16 +1882,10 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
|
|||||||
* forward the inner ip6 packet; point m_data at the inner ip6.
|
* forward the inner ip6 packet; point m_data at the inner ip6.
|
||||||
*/
|
*/
|
||||||
m_adj(m, off + PIM_MINLEN);
|
m_adj(m, off + PIM_MINLEN);
|
||||||
#ifdef MRT6DEBUG
|
MRT6_DLOG(DEBUG_PIM, "forwarding decapsulated register: "
|
||||||
if (V_mrt6debug & DEBUG_PIM) {
|
"src %s, dst %s, mif %d",
|
||||||
log(LOG_DEBUG,
|
ip6_sprintf(ip6bufs, &eip6->ip6_src),
|
||||||
"pim6_input: forwarding decapsulated register: "
|
ip6_sprintf(ip6bufd, &eip6->ip6_dst), reg_mif_num);
|
||||||
"src %s, dst %s, mif %d\n",
|
|
||||||
ip6_sprintf(ip6bufs, &eip6->ip6_src),
|
|
||||||
ip6_sprintf(ip6bufd, &eip6->ip6_dst),
|
|
||||||
reg_mif_num);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rc = if_simloop(mif6table[reg_mif_num].m6_ifp, m,
|
rc = if_simloop(mif6table[reg_mif_num].m6_ifp, m,
|
||||||
dst.sin6_family, 0);
|
dst.sin6_family, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user