From owner-svn-src-stable@FreeBSD.ORG Thu Jun 3 09:02:53 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9385C1065675; Thu, 3 Jun 2010 09:02:53 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 68D828FC0C; Thu, 3 Jun 2010 09:02:53 +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 o5392rLS026124; Thu, 3 Jun 2010 09:02:53 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5392rHA026122; Thu, 3 Jun 2010 09:02:53 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201006030902.o5392rHA026122@svn.freebsd.org> From: Robert Watson Date: Thu, 3 Jun 2010 09:02:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208767 - stable/8/sys/netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jun 2010 09:02:53 -0000 Author: rwatson Date: Thu Jun 3 09:02:53 2010 New Revision: 208767 URL: http://svn.freebsd.org/changeset/base/208767 Log: Merge r204826 from head to stable/8: Make udp_set_kernel_tunneling() less forgiving when its invariants are violated: so_pcb can never be NULL for a valid UDP socket, and it is always SOCK_DGRAM. Use sotoinpcb() as the rest of the UDP code does. Reviewed by: bz Sponsored by: Juniper Networks Approved by: re (kib) Modified: stable/8/sys/netinet/udp_usrreq.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/sys/netinet/udp_usrreq.c ============================================================================== --- stable/8/sys/netinet/udp_usrreq.c Thu Jun 3 08:55:45 2010 (r208766) +++ stable/8/sys/netinet/udp_usrreq.c Thu Jun 3 09:02:53 2010 (r208767) @@ -1439,7 +1439,7 @@ udp_attach(struct socket *so, int proto, return (error); } - inp = (struct inpcb *)so->so_pcb; + inp = sotoinpcb(so); inp->inp_vflag |= INP_IPV4; inp->inp_ip_ttl = V_ip_defttl; @@ -1462,17 +1462,10 @@ udp_set_kernel_tunneling(struct socket * struct inpcb *inp; struct udpcb *up; - 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); - } - inp = (struct inpcb *)so->so_pcb; - if (inp == NULL) { - /* NULL INP? */ - return (EINVAL); - } + KASSERT(so->so_type == SOCK_DGRAM, + ("udp_set_kernel_tunneling: !dgram")); + inp = sotoinpcb(so); + KASSERT(inp != NULL, ("udp_set_kernel_tunneling: inp == NULL")); INP_WLOCK(inp); up = intoudpcb(inp); if (up->u_tun_func != NULL) {