nis problems

Matthew Dillon dillon at apollo.backplane.com
Sun Apr 4 14:29:11 PDT 2004


    I think I found the problem.  Jeff, could you check this?

    The issue is that when UDP binds its socket as a side effect of an
    output or connect, it is not doing the wildcard binding.

    ypserv happens to hit this situation.  Actually, I think the 
    portmapper is doing this.

    This seems to fix it for me.

					-Matt

Index: udp_usrreq.c
===================================================================
RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.20
diff -u -r1.20 udp_usrreq.c
--- udp_usrreq.c	31 Mar 2004 07:21:38 -0000	1.20
+++ udp_usrreq.c	4 Apr 2004 21:25:25 -0000
@@ -141,6 +141,7 @@
 static int udp_detach (struct socket *so);
 static	int udp_output (struct inpcb *, struct mbuf *, struct sockaddr *,
 			    struct mbuf *, struct thread *);
+static int udp_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct thread *td);
 
 void
 udp_init()
@@ -588,9 +589,10 @@
 		if (inp != NULL && inp->inp_socket != NULL)
 			(*notify)(inp, inetctlerrmap[cmd]);
 		splx(s);
-	} else
+	} else {
 		in_pcbnotifyall(&udbinfo.listhead, faddr, inetctlerrmap[cmd],
 		    notify);
+	}
 }
 
 static int
@@ -727,7 +729,7 @@
 	}
 
 	if (inp->inp_lport == 0) {	/* unbound socket */
-		error = in_pcbbind(inp, (struct sockaddr *)NULL, td);
+		error = udp_pcbbind(inp, (struct sockaddr *)NULL, td);
 		if (error)
 			goto release;
 	}
@@ -895,20 +897,22 @@
 }
 
 static int
-udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
+udp_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct thread *td)
 {
-	struct sockaddr_in *sin = (struct sockaddr_in *)nam;
-	struct inpcb *inp;
-	int s, error;
+	struct sockaddr_in *sin;
+	int error;
+	int s;
 
-	inp = sotoinpcb(so);
-	if (inp == 0)
-		return EINVAL;
 	s = splnet();
 	error = in_pcbbind(inp, nam, td);
 	splx(s);
 	if (error == 0) {
-		if (sin->sin_addr.s_addr != INADDR_ANY)
+		/*
+		 * Note that nam is NULL when the udp socket is bound
+		 * as a side effect of an output or connect.
+		 */
+		sin = (struct sockaddr_in *)nam;
+		if (sin && sin->sin_addr.s_addr != INADDR_ANY)
 			inp->inp_flags |= INP_WASBOUND_NOTANY;
 		in_pcbinswildcardhash(inp);
 	}
@@ -916,6 +920,19 @@
 }
 
 static int
+udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
+{
+	struct inpcb *inp;
+	int error;
+
+	inp = sotoinpcb(so);
+	if (inp == NULL)
+		return EINVAL;
+	error = udp_pcbbind(inp, nam, td);
+	return(error);
+}
+
+static int
 udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
 {
 	struct inpcb *inp;
@@ -931,7 +948,7 @@
 	s = splnet();
 	if (td->td_proc && td->td_proc->p_ucred->cr_prison != NULL &&
 	    inp->inp_laddr.s_addr == INADDR_ANY) {
-		error = in_pcbbind(inp, NULL, td);
+		error = udp_pcbbind(inp, NULL, td);
 	}
 	if (error == 0) {
 		sin = (struct sockaddr_in *)nam;





More information about the Bugs mailing list