From owner-svn-src-head@FreeBSD.ORG Tue Jan 6 13:27:57 2009 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 206AB106566B; Tue, 6 Jan 2009 13:27:57 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E4298FC1A; Tue, 6 Jan 2009 13:27:57 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n06DRugx032334; Tue, 6 Jan 2009 13:27:56 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n06DRuLo032332; Tue, 6 Jan 2009 13:27:56 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200901061327.n06DRuLo032332@svn.freebsd.org> From: Randall Stewart Date: Tue, 6 Jan 2009 13:27:56 +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: r186821 - in head/sys: netinet netinet6 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: Tue, 06 Jan 2009 13:27:57 -0000 Author: rrs Date: Tue Jan 6 13:27:56 2009 New Revision: 186821 URL: http://svn.freebsd.org/changeset/base/186821 Log: Addresses Roberts comments on comments. Also adds the KASSERT and checks suggested. Reviewed by: The udp tunneling was discussed on net@ under the thread entitled "Heads up -- Thinking about UDP and tunneling" Modified: head/sys/netinet/udp_usrreq.c head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet/udp_usrreq.c ============================================================================== --- head/sys/netinet/udp_usrreq.c Tue Jan 6 13:12:26 2009 (r186820) +++ head/sys/netinet/udp_usrreq.c Tue Jan 6 13:27:56 2009 (r186821) @@ -501,13 +501,8 @@ udp_input(struct mbuf *m, int off) * Engage the tunneling protocol we * will have to leave the info_lock * up, since we are hunting through - * multiple UDP inp's hope we don't - * break. + * multiple UDP's. * - * XXXML: Maybe add a flag to the - * prototype so that the tunneling - * can defer work that can't be done - * under the info lock? */ udp_tun_func_t tunnel_func; @@ -546,9 +541,7 @@ udp_input(struct mbuf *m, int off) INP_INFO_RUNLOCK(&V_udbinfo); } else { /* - * Engage the tunneling protocol we must make sure - * all locks are released when we call the tunneling - * protocol. + * Engage the tunneling protocol. */ udp_tun_func_t tunnel_func; @@ -602,8 +595,7 @@ udp_input(struct mbuf *m, int off) } if (inp->inp_ppcb != NULL) { /* - * Engage the tunneling protocol we must make sure all locks - * are released when we call the tunneling protocol. + * Engage the tunneling protocol. */ udp_tun_func_t tunnel_func; @@ -1205,6 +1197,8 @@ udp_set_kernel_tunneling(struct socket * struct inpcb *inp; inp = (struct inpcb *)so->so_pcb; + KASSERT(so->so_type == SOCK_DGRAM, ("udp_set_kernel_tunneling: !dgram")); + KASSERT(so->so_pcb != NULL, ("udp_set_kernel_tunneling: NULL inp")); if (so->so_type != SOCK_DGRAM) { /* Not UDP socket... sorry! */ return (ENOTSUP); @@ -1214,6 +1208,10 @@ udp_set_kernel_tunneling(struct socket * return (EINVAL); } INP_WLOCK(inp); + if (inp->inp_ppcb != NULL) { + INP_WUNLOCK(inp); + return (EBUSY); + } inp->inp_ppcb = f; INP_WUNLOCK(inp); return (0); Modified: head/sys/netinet6/udp6_usrreq.c ============================================================================== --- head/sys/netinet6/udp6_usrreq.c Tue Jan 6 13:12:26 2009 (r186820) +++ head/sys/netinet6/udp6_usrreq.c Tue Jan 6 13:27:56 2009 (r186821) @@ -293,8 +293,7 @@ udp6_input(struct mbuf **mp, int *offp, * protocol we will have to * leave the info_lock up, * since we are hunting - * through multiple UDP - * inp's hope we don't break. + * through multiple UDP's. * */ udp_tun_func_t tunnel_func; @@ -336,9 +335,7 @@ udp6_input(struct mbuf **mp, int *offp, INP_INFO_RUNLOCK(&V_udbinfo); if (last->inp_ppcb != NULL) { /* - * Engage the tunneling protocol we must make sure - * all locks are released when we call the tunneling - * protocol. + * Engage the tunneling protocol. */ udp_tun_func_t tunnel_func; @@ -386,8 +383,7 @@ udp6_input(struct mbuf **mp, int *offp, INP_INFO_RUNLOCK(&V_udbinfo); if (inp->inp_ppcb != NULL) { /* - * Engage the tunneling protocol we must make sure all locks - * are released when we call the tunneling protocol. + * Engage the tunneling protocol. */ udp_tun_func_t tunnel_func;