Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Dec 2012 06:54:36 +0900 (JST)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        mjguzik@gmail.com, ae@FreeBSD.org, adrian@FreeBSD.org, rpaulo@FreeBSD.org
Cc:        freebsd-net@FreeBSD.org
Subject:   Re: LOR in rtsock/ifnet
Message-ID:  <20121202.065436.1086216324076847740.hrs@allbsd.org>
In-Reply-To: <20121201.225004.2232262673795057435.hrs@allbsd.org>
References:  <CAJ-Vmo=UMDif-56yagEd8WXsNOfiLE0NoyGLsXFCDRBtz0acSg@mail.gmail.com> <20121201133609.GA5450@dft-labs.eu> <20121201.225004.2232262673795057435.hrs@allbsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
----Security_Multipart0(Sun_Dec__2_06_54_36_2012_215)--
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Sun_Dec__2_06_54_36_2012_395)--"
Content-Transfer-Encoding: 7bit

----Next_Part(Sun_Dec__2_06_54_36_2012_395)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hiroki Sato <hrs@freebsd.org> wrote
  in <20121201.225004.2232262673795057435.hrs@allbsd.org>:

hr> Mateusz Guzik <mjguzik@gmail.com> wrote
hr>   in <20121201133609.GA5450@dft-labs.eu>:
hr>
hr> mj> On Fri, Nov 30, 2012 at 11:16:25PM -0800, Adrian Chadd wrote:
hr> mj> > Mateusz: are you sure it's that commit?
hr> mj> >
hr> mj>
hr> mj> Yes, I double-checked right now.
hr> mj>
hr> mj> > I still get this in -HEAD:
hr> mj> >
hr> mj>
hr> mj> Maybe I expressed myself incorrectly, I meant to say that LOR started
hr> mj> showing up since r243187.
hr> mj>
hr> mj> The code is still in head and no fixes were comitted (that I know of at
hr> mj> least), so I guess that you seeing this LOR on head is expected. :)
hr>
hr>  Thanks for the info.  I am investigating this now.

 Can anyone test the attached patch and let me know if the LOR
 persists or not?

-- Hiroki

----Next_Part(Sun_Dec__2_06_54_36_2012_395)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="scope6_lorfix_20121201-1.diff"

Index: sys/net/rtsock.c
===================================================================
--- sys/net/rtsock.c	(revision 243465)
+++ sys/net/rtsock.c	(working copy)
@@ -175,14 +175,6 @@
 #define	RTSOCK_LOCK_ASSERT()	mtx_assert(&rtsock_mtx, MA_OWNED)

 static SYSCTL_NODE(_net, OID_AUTO, route, CTLFLAG_RD, 0, "");
-#ifdef INET6
-static VNET_DEFINE(int, deembed_scopeid) = 1;
-#define	V_deembed_scopeid	VNET(deembed_scopeid)
-SYSCTL_DECL(_net_inet6_ip6);
-SYSCTL_VNET_INT(_net_inet6_ip6, OID_AUTO, deembed_scopeid, CTLFLAG_RW,
-    &VNET_NAME(deembed_scopeid), 0,
-    "Extract embedded zone ID and set it to sin6_scope_id in sockaddr_in6.");
-#endif

 struct walkarg {
 	int	w_tmemsize;
@@ -804,28 +796,31 @@
 			}
 			info.rti_info[RTAX_DST] = rt_key(rt);
 #ifdef INET6
-			switch (rt_key(rt)->sa_family) {
-			case AF_INET6:
-				if (V_deembed_scopeid == 0)
+			if (V_deembed_scopeid) {
+				switch (rt_key(rt)->sa_family) {
+				case AF_INET6:
+					sin6 = (struct sockaddr_in6 *)&ss_dst;
+					bcopy(rt_key(rt), sin6, sizeof(*sin6));
+					if (sa6_recoverscope(sin6) == 0)
+						info.rti_info[RTAX_DST] =
+						    (struct sockaddr *)sin6;
 					break;
-				sin6 = (struct sockaddr_in6 *)&ss_dst;
-				bcopy(rt_key(rt), sin6, sizeof(*sin6));
-				if (sa6_recoverscope(sin6) == 0)
-					info.rti_info[RTAX_DST] =
-					    (struct sockaddr *)sin6;
-				break;
+				}
 			}
 #endif
 			info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
 #ifdef INET6
-			switch (rt->rt_gateway->sa_family) {
-			case AF_INET6:
-				sin6 = (struct sockaddr_in6 *)&ss_gw;
-				bcopy(rt->rt_gateway, sin6, sizeof(*sin6));
-				if (sa6_recoverscope(sin6) == 0)
-					info.rti_info[RTAX_GATEWAY] =
-					    (struct sockaddr *)sin6;
-				break;
+			if (V_deembed_scopeid) {
+				switch (rt->rt_gateway->sa_family) {
+				case AF_INET6:
+					sin6 = (struct sockaddr_in6 *)&ss_gw;
+					bcopy(rt->rt_gateway, sin6,
+					    sizeof(*sin6));
+					if (sa6_recoverscope(sin6) == 0)
+						info.rti_info[RTAX_GATEWAY] =
+						    (struct sockaddr *)sin6;
+					break;
+				}
 			}
 #endif
 			info.rti_info[RTAX_NETMASK] = rt_mask(rt);
@@ -1130,15 +1125,15 @@
 		rtinfo->rti_addrs |= (1 << i);
 		dlen = SA_SIZE(sa);
 #ifdef INET6
-		switch (sa->sa_family) {
-		case AF_INET6:
-			if (V_deembed_scopeid == 0)
+		if (V_deembed_scopeid) {
+			switch (sa->sa_family) {
+			case AF_INET6:
+				sin6 = (struct sockaddr_in6 *)&ss;
+				bcopy(sa, sin6, sizeof(*sin6));
+				if (sa6_recoverscope(sin6) == 0)
+					sa = (struct sockaddr *)sin6;
 				break;
-			sin6 = (struct sockaddr_in6 *)&ss;
-			bcopy(sa, sin6, sizeof(*sin6));
-			if (sa6_recoverscope(sin6) == 0)
-				sa = (struct sockaddr *)sin6;
-			break;
+			}
 		}
 #endif
 		m_copyback(m, len, dlen, (caddr_t)sa);
@@ -1219,15 +1214,15 @@
 		rtinfo->rti_addrs |= (1 << i);
 		dlen = SA_SIZE(sa);
 #ifdef INET6
-		switch (sa->sa_family) {
-		case AF_INET6:
-			if (V_deembed_scopeid == 0)
+		if (V_deembed_scopeid) {
+			switch (sa->sa_family) {
+			case AF_INET6:
+				sin6 = (struct sockaddr_in6 *)&ss;
+				bcopy(sa, sin6, sizeof(*sin6));
+				if (sa6_recoverscope(sin6) == 0)
+					sa = (struct sockaddr *)sin6;
 				break;
-			sin6 = (struct sockaddr_in6 *)&ss;
-			bcopy(sa, sin6, sizeof(*sin6));
-			if (sa6_recoverscope(sin6) == 0)
-				sa = (struct sockaddr *)sin6;
-			break;
+			}
 		}
 #endif
 		if (cp) {
@@ -1594,18 +1589,19 @@
 			info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr;
 	}
 #ifdef INET6
-	for (i = 0; i < RTAX_MAX; i++) {
-		if (info.rti_info[i] == NULL)
-			continue;
-		switch (info.rti_info[i]->sa_family) {
-		case AF_INET6:
-			if (V_deembed_scopeid == 0)
+	if (V_deembed_scopeid) {
+		for (i = 0; i < RTAX_MAX; i++) {
+			if (info.rti_info[i] == NULL)
+				continue;
+			switch (info.rti_info[i]->sa_family) {
+			case AF_INET6:
+				sin6 = (struct sockaddr_in6 *)&ss[i];
+				bcopy(info.rti_info[i], sin6, sizeof(*sin6));
+				if (sa6_recoverscope(sin6) == 0)
+					info.rti_info[i] =
+					    (struct sockaddr *)sin6;
 				break;
-			sin6 = (struct sockaddr_in6 *)&ss[i];
-			bcopy(info.rti_info[i], sin6, sizeof(*sin6));
-			if (sa6_recoverscope(sin6) == 0)
-				info.rti_info[i] = (struct sockaddr *)sin6;
-			break;
+			}
 		}
 	}
 #endif
@@ -1811,7 +1807,7 @@
 	int len, error = 0;

 	bzero((caddr_t)&info, sizeof(info));
-	IFNET_RLOCK();
+	IFNET_RLOCK_NOSLEEP();
 	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
 		if (w->w_arg && w->w_arg != ifp->if_index)
 			continue;
@@ -1856,7 +1852,7 @@
 done:
 	if (ifp != NULL)
 		IF_ADDR_RUNLOCK(ifp);
-	IFNET_RUNLOCK();
+	IFNET_RUNLOCK_NOSLEEP();
 	return (error);
 }

@@ -1870,7 +1866,7 @@
 	struct ifaddr *ifa;

 	bzero((caddr_t)&info, sizeof(info));
-	IFNET_RLOCK();
+	IFNET_RLOCK_NOSLEEP();
 	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
 		if (w->w_arg && w->w_arg != ifp->if_index)
 			continue;
@@ -1905,7 +1901,7 @@
 		IF_ADDR_RUNLOCK(ifp);
 	}
 done:
-	IFNET_RUNLOCK();
+	IFNET_RUNLOCK_NOSLEEP();
 	return (error);
 }

Index: sys/netinet6/in6_cksum.c
===================================================================
--- sys/netinet6/in6_cksum.c	(revision 243465)
+++ sys/netinet6/in6_cksum.c	(working copy)
@@ -66,6 +66,7 @@
 #include <sys/param.h>
 #include <sys/mbuf.h>
 #include <sys/systm.h>
+#include <sys/vnet.h>
 #include <netinet/in.h>
 #include <netinet/ip6.h>
 #include <netinet6/scope6_var.h>
Index: sys/netinet6/scope6.c
===================================================================
--- sys/netinet6/scope6.c	(revision 243465)
+++ sys/netinet6/scope6.c	(working copy)
@@ -38,6 +38,7 @@
 #include <sys/socket.h>
 #include <sys/systm.h>
 #include <sys/queue.h>
+#include <sys/sysctl.h>
 #include <sys/syslog.h>

 #include <net/if.h>
@@ -55,7 +56,11 @@
 #else
 VNET_DEFINE(int, ip6_use_defzone) = 0;
 #endif
-
+VNET_DEFINE(int, deembed_scopeid) = 1;
+SYSCTL_DECL(_net_inet6_ip6);
+SYSCTL_VNET_INT(_net_inet6_ip6, OID_AUTO, deembed_scopeid, CTLFLAG_RW,
+    &VNET_NAME(deembed_scopeid), 0,
+    "Extract embedded zone ID and set it to sin6_scope_id in sockaddr_in6.");
 /*
  * The scope6_lock protects the global sid default stored in
  * sid_default below.
Index: sys/netinet6/scope6_var.h
===================================================================
--- sys/netinet6/scope6_var.h	(revision 243465)
+++ sys/netinet6/scope6_var.h	(working copy)
@@ -42,6 +42,9 @@
 	u_int32_t s6id_list[16];
 };

+VNET_DECLARE(int, deembed_scopeid);
+#define V_deembed_scopeid       VNET(deembed_scopeid)
+
 void	scope6_init(void);
 struct scope6_id *scope6_ifattach(struct ifnet *);
 void	scope6_ifdetach(struct scope6_id *);

----Next_Part(Sun_Dec__2_06_54_36_2012_395)----

----Security_Multipart0(Sun_Dec__2_06_54_36_2012_215)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEABECAAYFAlC6fJwACgkQTyzT2CeTzy0qYQCePFCleprynVx8yxuAPez8Lfd1
+IYAoM5O/ve1Lu7mNIcqRD99kZZd4AMr
=v5c+
-----END PGP SIGNATURE-----

----Security_Multipart0(Sun_Dec__2_06_54_36_2012_215)----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121202.065436.1086216324076847740.hrs>