From owner-p4-projects@FreeBSD.ORG Fri Jul 23 03:41:51 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 501141065678; Fri, 23 Jul 2010 03:41:51 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE88D1065672 for ; Fri, 23 Jul 2010 03:41:50 +0000 (UTC) (envelope-from anchie@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id CB40C8FC0C for ; Fri, 23 Jul 2010 03:41:50 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o6N3foxb074317 for ; Fri, 23 Jul 2010 03:41:50 GMT (envelope-from anchie@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o6N3fo9j074315 for perforce@freebsd.org; Fri, 23 Jul 2010 03:41:50 GMT (envelope-from anchie@FreeBSD.org) Date: Fri, 23 Jul 2010 03:41:50 GMT Message-Id: <201007230341.o6N3fo9j074315@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to anchie@FreeBSD.org using -f From: Ana Kukec To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 181350 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jul 2010 03:41:51 -0000 http://p4web.freebsd.org/@@181350?ac=10 Change 181350 by anchie@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;