if (bpc->bpc_has_vxlan)
BFD_SET_FLAG(bfd->flags, BFD_SESS_FLAG_VXLAN);
- if (bpc->bpc_ipv4 == false)
+ if (bpc->bpc_ipv4 == false) {
BFD_SET_FLAG(bfd->flags, BFD_SESS_FLAG_IPV6);
+ /* Set the IPv6 scope id for link-local addresses. */
+ if (IN6_IS_ADDR_LINKLOCAL(&bpc->bpc_local.sa_sin6.sin6_addr))
+ bpc->bpc_local.sa_sin6.sin6_scope_id = bfd->ifindex;
+ if (IN6_IS_ADDR_LINKLOCAL(&bpc->bpc_peer.sa_sin6.sin6_addr))
+ bpc->bpc_peer.sa_sin6.sin6_scope_id = bfd->ifindex;
+ }
+
/* Initialize the session */
bfd->ses_state = PTM_BFD_DOWN;
bfd->discrs.my_discr = ptm_bfd_gen_ID();
{
struct cmsghdr *cm;
struct in6_pktinfo *pi6 = NULL;
+ int ifindex = 0;
ssize_t mlen;
memset(port, 0, portlen);
local->sa_sin6.sin6_addr = pi6->ipi6_addr;
fetch_portname_from_ifindex(pi6->ipi6_ifindex,
port, portlen);
+ ifindex = pi6->ipi6_ifindex;
}
}
}
+ /* Set scope ID for link local addresses. */
+ if (IN6_IS_ADDR_LINKLOCAL(&peer->sa_sin6.sin6_addr))
+ peer->sa_sin6.sin6_scope_id = ifindex;
+ if (IN6_IS_ADDR_LINKLOCAL(&local->sa_sin6.sin6_addr))
+ local->sa_sin6.sin6_scope_id = ifindex;
+
return mlen;
}
sin6.sin6_len = sizeof(sin6);
#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
sin6 = bpc->bpc_local.sa_sin6;
- if (sin6.sin6_family != AF_INET6) {
-#if 0 /* XXX what is this? */
- ifindex = ptm_bfd_fetch_ifindex(bpc->bpc_localif);
- if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
- sin6.sin6_scope_id = ifindex;
-#endif
- } else if (bpc->bpc_has_localif) {
- ifindex = ptm_bfd_fetch_ifindex(bpc->bpc_localif);
+ ifindex = ptm_bfd_fetch_ifindex(bpc->bpc_localif);
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
sin6.sin6_scope_id = ifindex;
- }
if (bpc->bpc_has_localif) {
if (bp_bind_dev(sd, bpc->bpc_localif) != 0) {