Date: Sun, 7 Mar 2010 10:47:48 +0000 (UTC) From: Robert Watson <rwatson@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r204826 - head/sys/netinet Message-ID: <201003071047.o27AlmYu024574@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rwatson Date: Sun Mar 7 10:47:47 2010 New Revision: 204826 URL: http://svn.freebsd.org/changeset/base/204826 Log: 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. MFC after: 1 week Reviewed by: bz Sponsored by: Juniper Networks Modified: head/sys/netinet/udp_usrreq.c Modified: head/sys/netinet/udp_usrreq.c ============================================================================== --- head/sys/netinet/udp_usrreq.c Sun Mar 7 10:43:45 2010 (r204825) +++ head/sys/netinet/udp_usrreq.c Sun Mar 7 10:47:47 2010 (r204826) @@ -1430,7 +1430,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; @@ -1453,17 +1453,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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003071047.o27AlmYu024574>