PERFORCE change 181350 for review
Ana Kukec
anchie at FreeBSD.org
Fri Jul 23 03:41:51 UTC 2010
http://p4web.freebsd.org/@@181350?ac=10
Change 181350 by anchie at anchie_malimis on 2010/07/23 03:40:56
Few changes suggested by Marko Zec.
Affected files ...
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/icmp6.c#44 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6.c#34 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6_nbr.c#20 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/raw_ip6.c#13 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#46 edit
Differences ...
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/icmp6.c#44 (text+ko) ====
@@ -770,19 +770,17 @@
if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
/* give up local */
- /* Send incoming SeND-protected/ND packet to user space. */
+ /* Send incoming SeND packet to user space. */
if (send_sendso_input_hook != NULL) {
IP6_EXTHDR_CHECK(m, off,
icmp6len, IPPROTO_DONE);
- error = send_sendso_input_hook(m,
+ error = send_sendso_input_hook(m,
SND_IN, ip6len);
/* -1 == no app on SEND socket */
- if (!error)
- return (IPPROTO_DONE);
- if (error == -1)
- nd6_rs_input(m, off, icmp6len);
- }
- if (send_sendso_input_hook == NULL)
+ if (error == 0)
+ return (IPPROTO_DONE);
+ nd6_rs_input(m, off, icmp6len);
+ } else
nd6_rs_input(m, off, icmp6len);
m = NULL;
goto freeit;
@@ -790,15 +788,15 @@
if (send_sendso_input_hook != NULL) {
IP6_EXTHDR_CHECK(m, off,
icmp6len, IPPROTO_DONE);
- error = send_sendso_input_hook(n,
+ error = send_sendso_input_hook(n,
SND_IN, ip6len);
- if (!error)
- return (IPPROTO_DONE);
+ if (error == 0) {
+ m_freem(n);
+ return (IPPROTO_DONE);
+ }
/* -1 == no app on SEND socket */
- if (error == -1)
- nd6_rs_input(n, off, icmp6len);
- }
- if (send_sendso_input_hook == NULL)
+ nd6_rs_input(n, off, icmp6len);
+ } else
nd6_rs_input(n, off, icmp6len);
/* m stays. */
break;
@@ -813,27 +811,24 @@
/* Send incoming SeND-protected/ND packet to user space. */
if (send_sendso_input_hook != NULL) {
- error = send_sendso_input_hook(m,
+ error = send_sendso_input_hook(m,
SND_IN, ip6len);
- if (!error)
- return (IPPROTO_DONE);
- if (error == -1)
- nd6_ra_input(m, off, icmp6len);
- }
- if (send_sendso_input_hook == NULL)
+ if (error == 0)
+ return (IPPROTO_DONE);
+ nd6_ra_input(m, off, icmp6len);
+ } else
nd6_ra_input(m, off, icmp6len);
m = NULL;
+ m_freem(n);
goto freeit;
}
if (send_sendso_input_hook != NULL) {
- error = send_sendso_input_hook(n,
+ error = send_sendso_input_hook(n,
SND_IN, ip6len);
- if (!error)
- return (IPPROTO_DONE);
- if (error == -1)
- nd6_ra_input(n, off, icmp6len);
- }
- if (send_sendso_input_hook == NULL)
+ if (error == 0)
+ return (IPPROTO_DONE);
+ nd6_ra_input(n, off, icmp6len);
+ } else
nd6_ra_input(n, off, icmp6len);
/* m stays. */
break;
@@ -845,29 +840,26 @@
if (icmp6len < sizeof(struct nd_neighbor_solicit))
goto badlen;
if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
- if (send_sendso_input_hook != NULL) {
- error = send_sendso_input_hook(m,
+ if (send_sendso_input_hook != NULL) {
+ error = send_sendso_input_hook(m,
SND_IN, ip6len);
- if (!error)
- return (IPPROTO_DONE);
- if (error == -1)
- nd6_ns_input(m, off, icmp6len);
+ if (error == 0)
+ return (IPPROTO_DONE);
+ nd6_ns_input(m, off, icmp6len);
- }
- if (send_sendso_input_hook == NULL)
+ } else
nd6_ns_input(m, off, icmp6len);
+ m_freem(n);
m = NULL;
goto freeit;
}
- if (send_sendso_input_hook != NULL) {
- error = send_sendso_input_hook(n,
+ if (send_sendso_input_hook != NULL) {
+ error = send_sendso_input_hook(n,
SND_IN, ip6len);
- if (!error)
- return (IPPROTO_DONE);
- if (error == -1)
- nd6_ns_input(n, off, icmp6len);
- }
- if (send_sendso_input_hook == NULL)
+ if (error == 0)
+ return (IPPROTO_DONE);
+ nd6_ns_input(n, off, icmp6len);
+ } else
nd6_ns_input(n, off, icmp6len);
/* m stays. */
break;
@@ -882,27 +874,24 @@
/* Send incoming SeND-protected/ND packet to user space. */
if (send_sendso_input_hook != NULL) {
- error = send_sendso_input_hook(m,
+ error = send_sendso_input_hook(m,
SND_IN, ip6len);
- if (!error)
- return (IPPROTO_DONE);
- if (error == -1)
- nd6_na_input(m, off, icmp6len);
- }
- if (send_sendso_input_hook == NULL)
+ if (error == 0)
+ return (IPPROTO_DONE);
+ nd6_na_input(m, off, icmp6len);
+ } else
nd6_na_input(m, off, icmp6len);
+ m_freem(n);
m = NULL;
goto freeit;
}
- if (send_sendso_input_hook != NULL) {
- error = send_sendso_input_hook(n,
+ if (send_sendso_input_hook != NULL) {
+ error = send_sendso_input_hook(n,
SND_IN, ip6len);
- if (!error)
- return (IPPROTO_DONE);
- if (error == -1)
- nd6_na_input(n, off, icmp6len);
- }
- if (send_sendso_input_hook == NULL)
+ if (error == 0)
+ return (IPPROTO_DONE);
+ nd6_na_input(n, off, icmp6len);
+ } else
nd6_na_input(n, off, icmp6len);
/* m stays. */
break;
@@ -914,28 +903,25 @@
if (icmp6len < sizeof(struct nd_redirect))
goto badlen;
if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
- if (send_sendso_input_hook != NULL) {
- error = send_sendso_input_hook(m,
+ if (send_sendso_input_hook != NULL) {
+ error = send_sendso_input_hook(m,
SND_IN, ip6len);
- if (!error)
- return (IPPROTO_DONE);
- if (error == -1)
+ if (error == 0)
+ return (IPPROTO_DONE);
+ icmp6_redirect_input(m, off);
+ } else
icmp6_redirect_input(m, off);
- }
- if (send_sendso_input_hook == NULL)
- icmp6_redirect_input(m, off);
+ m_freem(n);
m = NULL;
goto freeit;
}
- if (send_sendso_input_hook != NULL) {
- error = send_sendso_input_hook(n,
- SND_IN, ip6len);
- if (!error)
- return (IPPROTO_DONE);
- if (error == -1)
+ if (send_sendso_input_hook != NULL) {
+ error = send_sendso_input_hook(n,
+ SND_IN, ip6len);
+ if (error == 0)
+ return (IPPROTO_DONE);
icmp6_redirect_input(n, off);
- }
- if (send_sendso_input_hook == NULL)
+ } else
icmp6_redirect_input(n, off);
/* m stays. */
break;
@@ -2839,7 +2825,7 @@
sizeof(*ip6), ntohs(ip6->ip6_plen));
if (send_sendso_input_hook != NULL) {
- mtag = m_tag_get(PACKET_TAG_ND_OUTGOING, sizeof(unsigned short),
+ mtag = m_tag_get(PACKET_TAG_ND_OUTGOING, sizeof(unsigned short),
M_NOWAIT);
if (mtag == NULL)
goto fail;
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6.c#34 (text+ko) ====
@@ -1772,7 +1772,6 @@
int error = -1;
int flags = 0;
int ip6len;
- int skip = 0;
unsigned short *nd_type;
ip6 = mtod(m, struct ip6_hdr *);
@@ -1952,18 +1951,16 @@
mac_netinet6_nd6_send(ifp, m);
#endif
- skip = 0;
/* send outgoing NS/NA/REDIRECT packet to sendd. */
if (send_sendso_input_hook != NULL) {
mtag = m_tag_find(m, PACKET_TAG_ND_OUTGOING, NULL);
if (mtag != NULL) {
- skip = 1;
nd_type = (unsigned short *)(mtag + 1);
/* Use the SEND socket */
- error = send_sendso_input_hook(m, SND_OUT,
+ error = send_sendso_input_hook(m, SND_OUT,
ip6len);
/* -1 == no app on SEND socket */
- if (error == 0 && error != -1)
+ if (error == 0 || error != -1)
return (error);
}
}
@@ -2023,10 +2020,9 @@
else
LLE_RUNLOCK(ln);
}
- if (skip) {
- if (m)
- m_freem(m);
- }
+ if (m)
+ m_freem(m);
+
return (error);
}
#undef senderr
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6_nbr.c#20 (text+ko) ====
@@ -568,12 +568,12 @@
in6_cksum(m, IPPROTO_ICMPV6, sizeof(*ip6), icmp6len);
if (send_sendso_input_hook != NULL) {
- mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
- sizeof(unsigned short), M_NOWAIT);
+ mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
+ sizeof(unsigned short), M_NOWAIT);
if (mtag == NULL)
goto bad;
*(unsigned short *)(mtag + 1) = nd_ns->nd_ns_type;
- m_tag_prepend(m, mtag);
+ m_tag_prepend(m, mtag);
}
ip6_output(m, NULL, &ro, dad ? IPV6_UNSPECSRC : 0, &im6o, NULL, NULL);
@@ -895,8 +895,8 @@
*/
if (send_sendso_input_hook != NULL) {
- mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
- sizeof(unsigned short), M_NOWAIT);
+ mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
+ sizeof(unsigned short), M_NOWAIT);
if (mtag == NULL)
goto bad;
m_tag_prepend(m, mtag);
@@ -1089,10 +1089,9 @@
nd_na->nd_na_cksum =
in6_cksum(m, IPPROTO_ICMPV6, sizeof(struct ip6_hdr), icmp6len);
- if (send_sendso_input_hook != NULL) {
- mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
- sizeof(unsigned short),
- M_NOWAIT);
+ if (send_sendso_input_hook != NULL) {
+ mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
+ sizeof(unsigned short), M_NOWAIT);
if (mtag == NULL)
goto bad;
*(unsigned short *)(mtag + 1) = nd_na->nd_na_type;
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/raw_ip6.c#13 (text+ko) ====
@@ -535,12 +535,12 @@
* Send RA/RS messages to user land for protection, before sending
* them to rtadvd/rtsol.
*/
- if ((send_sendso_input_hook != NULL) &&
+ if ((send_sendso_input_hook != NULL) &&
so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
switch (type) {
case ND_ROUTER_ADVERT:
case ND_ROUTER_SOLICIT:
- mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
+ mtag = m_tag_get(PACKET_TAG_ND_OUTGOING,
sizeof(unsigned short), M_NOWAIT);
if (mtag == NULL)
goto bad;
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#46 (text+ko) ====
@@ -193,10 +193,8 @@
struct ifnet *ifp;
int error;
- if (V_send_so == NULL) {
- error = ENOTCONN;
- goto err;
- }
+ KASSERT(V_send_so == so, ("%s: socket %p not send socket %p",
+ __func__, so, V_send_so));
sendsrc = (struct sockaddr_send *)nam;
ifp = ifnet_byindex_ref(sendsrc->send_ifidx);
@@ -210,7 +208,7 @@
m = NULL;
err:
- if (error && m != NULL)
+ if (m != NULL)
m_freem(m);
return (error);
}
@@ -284,6 +282,7 @@
static int
send_modevent(module_t mod, int type, void *unused)
{
+ VNET_ITERATOR_DECL(vnet_iter);
int error = 0;
switch (type) {
@@ -297,8 +296,18 @@
send_sendso_input_hook = send_input;
break;
case MOD_UNLOAD:
- if (V_send_so != NULL)
- return (EINVAL);
+ /* Do not allow unloading w/o locking. */
+ return(EBUSY);
+#ifdef 0
+ VNET_FOREACH(vnet_iter) {
+ CURVNET_SET(vnet_iter);
+ if (V_send_so != NULL) {
+ CURVNET_RESTORE();
+ return (EBUSY);
+ }
+ CURVNET_RESTORE();
+ }
+#endif
error = pf_proto_unregister(PF_INET6, IPPROTO_SEND, SOCK_RAW);
send_sendso_input_hook = NULL;
break;
More information about the p4-projects
mailing list