Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jan 2013 18:25:56 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r245812 - user/ae/inet6/sys/netinet6
Message-ID:  <201301221825.r0MIPuhC065236@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Tue Jan 22 18:25:55 2013
New Revision: 245812
URL: http://svnweb.freebsd.org/changeset/base/245812

Log:
  Automatically fill sin6_scope_id for loopback address.

Modified:
  user/ae/inet6/sys/netinet6/scope6.c

Modified: user/ae/inet6/sys/netinet6/scope6.c
==============================================================================
--- user/ae/inet6/sys/netinet6/scope6.c	Tue Jan 22 18:23:07 2013	(r245811)
+++ user/ae/inet6/sys/netinet6/scope6.c	Tue Jan 22 18:25:55 2013	(r245812)
@@ -466,6 +466,20 @@ sa6_checkzone(struct sockaddr_in6 *sa6)
 
 	scope = in6_addrscope(&sa6->sin6_addr);
 	if (scope == IPV6_ADDR_SCOPE_GLOBAL) {
+		/*
+		 * Since ::1 address always configured on the lo0, we can
+		 * automagically set its zone id, when it is not specified.
+		 * Return error, when specified zone id doesn't match with
+		 * actual value.
+		 */
+		if (IN6_IS_ADDR_LOOPBACK(&sa6->sin6_addr)) {
+			if (sa6.sin6_scope_id == 0) {
+				sa6.sin6_scope_id = in6_getlinkzone(V_loif);
+				return (0);
+			}
+			if (sa6.sin6_scope_id == in6_getlinkzone(V_loif))
+				return (0);
+		}
 		/* We don't want zone id for global scope */
 		return (sa6.sin6_scope_id ? EINVAL: 0);
 	}



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