Date: Thu, 17 May 2012 15:07:51 -0700 From: prabhakar lakhera <prabhakar.lakhera@gmail.com> To: freebsd-net@freebsd.org Subject: How to set the IPv6 linklocal scope id for an interface? Message-ID: <CALg%2BrhVakDqBQdnvwYOsHFNKOo-6dsM2-nk5fGztt7E004hAMA@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hi, Is there any way for the administrator to set an interface's scope if for link local scope? I see that in6_domifattach calls scope6_ifattach which sets the interface local scope and link local scope for the interface equal to the ifp index. scope6_ifattach(struct ifnet *ifp) { ..... ..... /* * XXX: IPV6_ADDR_SCOPE_xxx macros are not standard. * Should we rather hardcode here? */ sid->s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = ifp->if_index; sid->s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = ifp->if_index; ..... ..... } I am trying to avoid the following: Here's the problem. I have two interfaces A and B on same link. Both learn RA for the link. One of these is used to add a default route entry in the routing table. Lets say default router entry for A is picked, we have the following default route entry: destination: ::/0 gw: fe80:<A's link local scope id embedded>::<identifier> route_ifp: A I used IPv6 address hosted on interface B to send a packet to destination X and I got back a neighbor redirect from gw destined for B for X. However the redirect is dropped. Below is the code from icmp6_redirect_input that fails a check: 2346 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2346> 2347 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2347> gw6 = &(((struct sockaddr_in6 <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=sockaddr_in6> *)rt <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=rt>->rt_gateway)->sin6_addr); 2348 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2348> if (bcmp <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=bcmp>(&src6, gw6, sizeof(struct in6_addr <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=in6_addr>)) != 0) { 2349 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2349> nd6log <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=nd6log>((LOG_ERR <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=LOG_ERR>, 2350 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2350> *"ICMP6 redirect rejected; "* 2351 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2351> *"not equal to gw-for-src=%s (must be same): "* 2352 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2352> *"%s\n"*, 2353 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2353> ip6_sprintf <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=ip6_sprintf>(ip6buf, gw6), 2354 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2354> icmp6_redirect_diag <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=icmp6_redirect_diag>(&src6, &reddst6, &redtgt6))); 2355 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2355> RTFREE_LOCKED <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=RTFREE_LOCKED>(rt <http://fxr.watson.org/fxr/ident?v=FREEBSD8;im=bigexcerpts;i=rt>); 2356 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2356> goto bad; 2357 <http://fxr.watson.org/fxr/source/netinet6/icmp6.c?v=FREEBSD8#L2357> } src6 is the router's LLA but since it's received on B, it's embedded with B's link scope embedded id. So we end up comparing: fe80:<A's link local scope id embedded>::<identifier> with fe80:<B's link local scope id embedded>::<identifier> Since ids are different the comparison fails and the redirect is dropped.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALg%2BrhVakDqBQdnvwYOsHFNKOo-6dsM2-nk5fGztt7E004hAMA>