Module Name:    src
Committed By:   ozaki-r
Date:           Fri Dec 22 11:22:37 UTC 2017

Modified Files:
        src/sys/netinet: ip_output.c

Log Message:
Fix usage of curlwp_bind in ip_output

curlwp_bindx must be called in LIFO order, i.e., we can't call curlwp_bind
and curlwp_bindx like this:
  bound1 = curlwp_bind();
  bound2 = curlwp_bind();
  curlwp_bindx(bound1);
  curlwp_bindx(bound2);

ip_outout did so if NET_MPSAFE. Fix it.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/netinet/ip_output.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/ip_output.c
diff -u src/sys/netinet/ip_output.c:1.287 src/sys/netinet/ip_output.c:1.288
--- src/sys/netinet/ip_output.c:1.287	Fri Dec 15 04:03:46 2017
+++ src/sys/netinet/ip_output.c	Fri Dec 22 11:22:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_output.c,v 1.287 2017/12/15 04:03:46 ozaki-r Exp $	*/
+/*	$NetBSD: ip_output.c,v 1.288 2017/12/22 11:22:37 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.287 2017/12/15 04:03:46 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.288 2017/12/22 11:22:37 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -303,6 +303,10 @@ ip_output(struct mbuf *m0, struct mbuf *
 	    !in_hosteq(dst->sin_addr, ip->ip_dst)))
 		rtcache_free(ro);
 
+	/* XXX must be before rtcache operations */
+	bound = curlwp_bind();
+	bind_need_restore = true;
+
 	if ((rt = rtcache_validate(ro)) == NULL &&
 	    (rt = rtcache_update(ro, 1)) == NULL) {
 		dst = &udst.sin;
@@ -311,8 +315,6 @@ ip_output(struct mbuf *m0, struct mbuf *
 			goto bad;
 	}
 
-	bound = curlwp_bind();
-	bind_need_restore = true;
 	/*
 	 * If routing to interface only, short circuit routing lookup.
 	 */

Reply via email to