Date: Thu, 24 Oct 2013 00:53:10 +0000 (UTC) From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r257032 - user/ae/inet6/sys/netinet6 Message-ID: <201310240053.r9O0rAqo025951@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ae Date: Thu Oct 24 00:53:09 2013 New Revision: 257032 URL: http://svnweb.freebsd.org/changeset/base/257032 Log: Scope related cleanup in rip6_connect(): * remove sa6_embedscope() and in6_setscope() calls; * use sa6_checkzone() to check sin6_scope_id for correctness; * when laddr or faddr is from link-local scope, initialize in6p_zoneid. Modified: user/ae/inet6/sys/netinet6/raw_ip6.c Modified: user/ae/inet6/sys/netinet6/raw_ip6.c ============================================================================== --- user/ae/inet6/sys/netinet6/raw_ip6.c Thu Oct 24 00:48:31 2013 (r257031) +++ user/ae/inet6/sys/netinet6/raw_ip6.c Thu Oct 24 00:53:09 2013 (r257032) @@ -763,7 +763,7 @@ rip6_connect(struct socket *so, struct s struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam; struct in6_addr in6a; struct ifnet *ifp = NULL; - int error = 0, scope_ambiguous = 0; + int error = 0; inp = sotoinpcb(so); KASSERT(inp != NULL, ("rip6_connect: inp == NULL")); @@ -774,18 +774,8 @@ rip6_connect(struct socket *so, struct s return (EADDRNOTAVAIL); if (addr->sin6_family != AF_INET6) return (EAFNOSUPPORT); - - /* - * Application should provide a proper zone ID or the use of default - * zone IDs should be enabled. Unfortunately, some applications do - * not behave as it should, so we need a workaround. Even if an - * appropriate ID is not determined, we'll see if we can determine - * the outgoing interface. If we can, determine the zone ID based on - * the interface below. - */ - if (addr->sin6_scope_id == 0 && !V_ip6_use_defzone) - scope_ambiguous = 1; - if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0) + error = sa6_checkzone(addr); + if (error != 0) return (error); INP_INFO_WLOCK(&V_ripcbinfo); @@ -798,16 +788,12 @@ rip6_connect(struct socket *so, struct s INP_INFO_WUNLOCK(&V_ripcbinfo); return (error); } - - /* XXX: see above */ - if (ifp && scope_ambiguous && - (error = in6_setscope(&addr->sin6_addr, ifp, NULL)) != 0) { - INP_WUNLOCK(inp); - INP_INFO_WUNLOCK(&V_ripcbinfo); - return (error); - } inp->in6p_faddr = addr->sin6_addr; inp->in6p_laddr = in6a; + if (IN6_IS_ADDR_LINKLOCAL(&inp->in6p_faddr) || + IN6_IS_ADDR_LINKLOCAL(&inp->in6p_laddr)) + inp->in6p_zoneid = in6_getscopezone(ifp, + IPV6_ADDR_SCOPE_LINKLOCAL); soisconnected(so); INP_WUNLOCK(inp); INP_INFO_WUNLOCK(&V_ripcbinfo);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310240053.r9O0rAqo025951>