From fa05f9d270a83544a2ce14522721614a001fed6f Mon Sep 17 00:00:00 2001 From: ume Date: Wed, 5 Nov 2003 16:09:21 +0000 Subject: make sure to treat destrination address as KAME internal form of embedscope. --- sys/netinet6/in6_src.c | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) (limited to 'sys/netinet6') diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index 87dfb0d..cec11c9 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -170,6 +170,13 @@ in6_selectsrc(dstsock, opts, mopts, ro, laddr, errorp) struct in6_addrpolicy *dst_policy = NULL, *best_policy = NULL; u_int32_t odstzone; int prefer_tempaddr; + struct sockaddr_in6 dstsock0; + + dstsock0 = *dstsock; + if ((*errorp = in6_embedscope(&dstsock0.sin6_addr, &dstsock0, + NULL, NULL)) != 0) + return (NULL); + dstsock = &dstsock0; dst = &dstsock->sin6_addr; *errorp = 0; @@ -228,35 +235,6 @@ in6_selectsrc(dstsock, opts, mopts, ro, laddr, errorp) return (laddr); /* - * If the destination address is a link-local unicast address or - * a multicast address, and if the outgoing interface is specified - * by the sin6_scope_id filed, use an address associated with the - * interface. - * XXX: We're now trying to define more specific semantics of - * sin6_scope_id field, so this part will be rewritten in - * the near future. - */ - if ((IN6_IS_ADDR_LINKLOCAL(dst) || IN6_IS_ADDR_MULTICAST(dst)) && - dstsock->sin6_scope_id) { - /* - * I'm not sure if boundary check for scope_id is done - * somewhere... - */ - if (dstsock->sin6_scope_id < 0 || - if_index < dstsock->sin6_scope_id) { - *errorp = ENXIO; /* XXX: better error? */ - return (0); - } - ia = in6_ifawithscope(ifnet_byindex(dstsock->sin6_scope_id), - dst); - if (ia == 0) { - *errorp = EADDRNOTAVAIL; - return (0); - } - return (&ia->ia_addr.sin6_addr); - } - - /* * If the address is not specified, choose the best one based on * the outgoing interface and the destination address. */ @@ -630,6 +608,7 @@ in6_selectroute(dstsock, opts, mopts, ro, retifp, retrt, clone) bzero(&ro->ro_dst, sizeof(struct sockaddr_in6)); sa6 = (struct sockaddr_in6 *)&ro->ro_dst; *sa6 = *dstsock; + sa6->sin6_scope_id = 0; if (clone) { rtalloc((struct route *)ro); } else { -- cgit v1.1