summaryrefslogtreecommitdiffstats
path: root/sys/netinet/udp_usrreq.c
diff options
context:
space:
mode:
authorrrs <rrs@FreeBSD.org>2009-01-06 13:27:56 +0000
committerrrs <rrs@FreeBSD.org>2009-01-06 13:27:56 +0000
commitfcaf24fb5440688bbd3997b83b242330459a542a (patch)
tree87ba73fb23ee225a631ab40bbc195ca8efaef231 /sys/netinet/udp_usrreq.c
parentb73b4a5b71b286f756045f937874d341a8645201 (diff)
downloadFreeBSD-src-fcaf24fb5440688bbd3997b83b242330459a542a.zip
FreeBSD-src-fcaf24fb5440688bbd3997b83b242330459a542a.tar.gz
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"
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r--sys/netinet/udp_usrreq.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index cdca664..7eaa0e3 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -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 *so, udp_tun_func_t f)
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 *so, udp_tun_func_t f)
return (EINVAL);
}
INP_WLOCK(inp);
+ if (inp->inp_ppcb != NULL) {
+ INP_WUNLOCK(inp);
+ return (EBUSY);
+ }
inp->inp_ppcb = f;
INP_WUNLOCK(inp);
return (0);
OpenPOWER on IntegriCloud