diff options
author | rwatson <rwatson@FreeBSD.org> | 2010-03-07 10:47:47 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2010-03-07 10:47:47 +0000 |
commit | 480b74ed2045d8960d5323595d35f0dfbb5548cf (patch) | |
tree | 9aa1faf671046afd3dcf15ab053a69b277128621 /sys/netinet/udp_usrreq.c | |
parent | 3c620db1c441443ca60d5e94e84d330f214c5ec7 (diff) | |
download | FreeBSD-src-480b74ed2045d8960d5323595d35f0dfbb5548cf.zip FreeBSD-src-480b74ed2045d8960d5323595d35f0dfbb5548cf.tar.gz |
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
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r-- | sys/netinet/udp_usrreq.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index b5846c3..8a9f2e8 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1430,7 +1430,7 @@ udp_attach(struct socket *so, int proto, struct thread *td) 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 *so, udp_tun_func_t f) 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) { |