From owner-svn-src-head@FreeBSD.ORG Thu Apr 14 10:40:58 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 427651065670; Thu, 14 Apr 2011 10:40:58 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 13B508FC21; Thu, 14 Apr 2011 10:40:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EAevC7031510; Thu, 14 Apr 2011 10:40:57 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EAevn9031508; Thu, 14 Apr 2011 10:40:57 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201104141040.p3EAevn9031508@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 14 Apr 2011 10:40:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220620 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Apr 2011 10:40:58 -0000 Author: trasz Date: Thu Apr 14 10:40:57 2011 New Revision: 220620 URL: http://svn.freebsd.org/changeset/base/220620 Log: Refactor udp_input(), moving calls to u_tun_func() into udp_append(). Obtained from: Wheel Systems Sp. z o.o. Reviewed by: bz@ Modified: head/sys/netinet/udp_usrreq.c Modified: head/sys/netinet/udp_usrreq.c ============================================================================== --- head/sys/netinet/udp_usrreq.c Thu Apr 14 09:47:09 2011 (r220619) +++ head/sys/netinet/udp_usrreq.c Thu Apr 14 10:40:57 2011 (r220620) @@ -246,16 +246,24 @@ udp_append(struct inpcb *inp, struct ip #ifdef INET6 struct sockaddr_in6 udp_in6; #endif -#ifdef IPSEC -#ifdef IPSEC_NAT_T -#ifdef INET struct udpcb *up; -#endif -#endif -#endif INP_RLOCK_ASSERT(inp); + /* + * Engage the tunneling protocol. + */ + up = intoudpcb(inp); + if (up->u_tun_func != NULL) { + (*up->u_tun_func)(n, off, inp); + return; + } + + if (n == NULL) + return; + + off += sizeof(struct udphdr); + #ifdef IPSEC /* Check AH/ESP integrity. */ if (ipsec4_in_reject(n, inp)) { @@ -322,7 +330,6 @@ udp_input(struct mbuf *m, int off) struct udphdr *uh; struct ifnet *ifp; struct inpcb *inp; - struct udpcb *up; int len; struct ip save_ip; struct sockaddr_in udp_in; @@ -508,24 +515,7 @@ udp_input(struct mbuf *m, int off) struct mbuf *n; n = m_copy(m, 0, M_COPYALL); - up = intoudpcb(last); - if (up->u_tun_func == NULL) { - if (n != NULL) - udp_append(last, - ip, n, - iphlen + - sizeof(struct udphdr), - &udp_in); - } else { - /* - * Engage the tunneling protocol we - * will have to leave the info_lock - * up, since we are hunting through - * multiple UDP's. - */ - - (*up->u_tun_func)(n, iphlen, last); - } + udp_append(last, ip, n, iphlen, &udp_in); INP_RUNLOCK(last); } last = inp; @@ -551,16 +541,7 @@ udp_input(struct mbuf *m, int off) UDPSTAT_INC(udps_noportbcast); goto badheadlocked; } - up = intoudpcb(last); - if (up->u_tun_func == NULL) { - udp_append(last, ip, m, iphlen + sizeof(struct udphdr), - &udp_in); - } else { - /* - * Engage the tunneling protocol. - */ - (*up->u_tun_func)(m, iphlen, last); - } + udp_append(last, ip, m, iphlen, &udp_in); INP_RUNLOCK(last); INP_INFO_RUNLOCK(&V_udbinfo); return; @@ -606,16 +587,7 @@ udp_input(struct mbuf *m, int off) INP_RUNLOCK(inp); goto badunlocked; } - up = intoudpcb(inp); - if (up->u_tun_func == NULL) { - udp_append(inp, ip, m, iphlen + sizeof(struct udphdr), &udp_in); - } else { - /* - * Engage the tunneling protocol. - */ - - (*up->u_tun_func)(m, iphlen, inp); - } + udp_append(inp, ip, m, iphlen, &udp_in); INP_RUNLOCK(inp); return;