summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/in6_src.c
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2003-11-05 16:09:21 +0000
committerume <ume@FreeBSD.org>2003-11-05 16:09:21 +0000
commitfa05f9d270a83544a2ce14522721614a001fed6f (patch)
tree9777e393ddb9df4115078189365ae54e56edfc2a /sys/netinet6/in6_src.c
parentd7dd8dce01bfbd1d01515f0b7091dc611e396f1f (diff)
downloadFreeBSD-src-fa05f9d270a83544a2ce14522721614a001fed6f.zip
FreeBSD-src-fa05f9d270a83544a2ce14522721614a001fed6f.tar.gz
make sure to treat destrination address as KAME internal form
of embedscope.
Diffstat (limited to 'sys/netinet6/in6_src.c')
-rw-r--r--sys/netinet6/in6_src.c37
1 files changed, 8 insertions, 29 deletions
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 {
OpenPOWER on IntegriCloud