Remove extra nesting from X_ip6_mforward() function.

Also remove disabled definitions from ip6_mroute.h.

PR:		185148
Sponsored by:	Yandex LLC
This commit is contained in:
Andrey V. Elsukov 2014-01-09 15:38:28 +00:00
parent ffc5432ffc
commit 78415d1082
2 changed files with 161 additions and 180 deletions

View File

@ -1044,11 +1044,19 @@ socket_send(struct socket *s, struct mbuf *mm, struct sockaddr_in6 *src)
int
X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
{
struct rtdetq *rte;
struct mbuf *mb0;
struct mf6c *rt;
struct mif6 *mifp;
struct mbuf *mm;
u_long hash;
mifi_t mifi;
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
#ifdef UPCALL_TIMING
struct timeval tp;
GET_TIME(tp);
#endif /* UPCALL_TIMING */
MRT6_DLOG(DEBUG_FORWARD, "src %s, dst %s, ifindex %d",
ip6_sprintf(ip6bufs, &ip6->ip6_src),
@ -1096,23 +1104,12 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
if (rt) {
MFC6_UNLOCK();
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
* Make a copy of the packet & 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 */
MRT6STAT_INC(mrt6s_no_route);
MRT6_DLOG(DEBUG_FORWARD | DEBUG_MFC, "no rte s %s g %s",
ip6_sprintf(ip6bufs, &ip6->ip6_src),
@ -1122,8 +1119,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
* 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_MRTABLE6,
M_NOWAIT);
rte = (struct rtdetq *)malloc(sizeof(*rte), M_MRTABLE6, M_NOWAIT);
if (rte == NULL) {
MFC6_UNLOCK();
return (ENOBUFS);
@ -1133,8 +1129,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
* Pullup packet header if needed before storing it,
* as other references may modify it in the meantime.
*/
if (mb0 &&
(M_HASCL(mb0) || mb0->m_len < sizeof(struct ip6_hdr)))
if (mb0 && (M_HASCL(mb0) || mb0->m_len < sizeof(struct ip6_hdr)))
mb0 = m_pullup(mb0, sizeof(struct ip6_hdr));
if (mb0 == NULL) {
free(rte, M_MRTABLE6);
@ -1148,8 +1143,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
if (IN6_ARE_ADDR_EQUAL(&ip6->ip6_src,
&rt->mf6c_origin.sin6_addr) &&
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst,
&rt->mf6c_mcastgrp.sin6_addr) &&
(rt->mf6c_stall != NULL))
&rt->mf6c_mcastgrp.sin6_addr) && (rt->mf6c_stall != NULL))
break;
}
@ -1158,10 +1152,8 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
#ifdef MRT6_OINIT
struct omrt6msg *oim;
#endif
/* no upcall, so make a new entry */
rt = (struct mf6c *)malloc(sizeof(*rt), M_MRTABLE6,
M_NOWAIT);
rt = (struct mf6c *)malloc(sizeof(*rt), M_MRTABLE6, M_NOWAIT);
if (rt == NULL) {
free(rte, M_MRTABLE6);
m_freem(mb0);
@ -1173,7 +1165,6 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
* level process
*/
mm = m_copy(mb0, 0, sizeof(struct ip6_hdr));
if (mm == NULL) {
free(rte, M_MRTABLE6);
m_freem(mb0);
@ -1186,7 +1177,6 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
* Send message to routing daemon
*/
sin6.sin6_addr = ip6->ip6_src;
im = NULL;
#ifdef MRT6_OINIT
oim = NULL;
@ -1212,12 +1202,9 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
return (EINVAL);
}
MRT6_DLOG(DEBUG_FORWARD,
"getting the iif info in the kernel");
MRT6_DLOG(DEBUG_FORWARD, "getting the iif info in the kernel");
for (mifp = mif6table, mifi = 0;
mifi < nummifs && mifp->m6_ifp != ifp;
mifp++, mifi++)
mifi < nummifs && mifp->m6_ifp != ifp; mifp++, mifi++)
;
switch (V_ip6_mrouter_ver) {
@ -1290,7 +1277,6 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
return (0);
}
}
/*
* Clean up cache entries if upcalls are not serviced

View File

@ -145,11 +145,6 @@ struct mrt6stat {
struct omrt6msg {
u_long unused1;
u_char im6_msgtype; /* what type of message */
#if 0
#define MRT6MSG_NOCACHE 1
#define MRT6MSG_WRONGMIF 2
#define MRT6MSG_WHOLEPKT 3 /* used for user level encap*/
#endif
u_char im6_mbz; /* must be zero */
u_char im6_mif; /* mif rec'd on */
u_char unused2;
@ -199,7 +194,7 @@ struct sioc_mif_req6 {
u_quad_t obytes; /* Output byte count on mif */
};
#if defined(_KERNEL) || defined(KERNEL)
#ifdef _KERNEL
/*
* The kernel's multicast-interface structure.
*/