break;
case AF_INET6:
sa->sa_sin6.sin6_port = 0;
+ sa->sa_sin6.sin6_scope_id = 0;
if (memcmp(sa, &bs->shop.peer, sizeof(sa->sa_sin6)) == 0)
return bs;
break;
ptm_bfd_fetch_local_mac(bpc->bpc_localif, bfd->local_mac);
}
- 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();
break;
case AF_INET6:
bs->shop.peer.sa_sin6.sin6_port = 0;
+ bs->shop.peer.sa_sin6.sin6_scope_id = 0;
break;
}
}
break;
case AF_INET6:
bs->mhop.peer.sa_sin6.sin6_port = 0;
+ bs->mhop.peer.sa_sin6.sin6_scope_id = 0;
bs->mhop.local.sa_sin6.sin6_port = 0;
+ bs->mhop.local.sa_sin6.sin6_scope_id = 0;
break;
}
}
? htons(BFD_DEF_MHOP_DEST_PORT)
: htons(BFD_DEFDESTPORT);
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
+ sin6.sin6_scope_id = bs->ifindex;
+
sd = bs->sock;
sa = (struct sockaddr *)&sin6;
slen = sizeof(sin6);
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
sin6.sin6_len = sizeof(sin6);
#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
+ sin6.sin6_scope_id = bfd->ifindex;
sa = (struct sockaddr_any *)&sin6;
salen = sizeof(sin6);
{
struct cmsghdr *cm;
struct in6_pktinfo *pi6 = NULL;
- int ifindex = 0;
ssize_t mlen;
uint32_t ttlval;
struct sockaddr_in6 msgaddr6;
#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
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;
}
int bp_peer_socketv6(struct bfd_peer_cfg *bpc)
{
- int sd, pcount, ifindex;
+ int sd, pcount;
struct sockaddr_in6 sin6;
static int srcPort = BFD_SRCPORTINIT;
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
sin6.sin6_len = sizeof(sin6);
#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
- sin6 = bpc->bpc_local.sa_sin6;
- ifindex = ptm_bfd_fetch_ifindex(bpc->bpc_localif);
+ memcpy(&sin6.sin6_addr, &bpc->bpc_local.sa_sin6.sin6_addr,
+ sizeof(sin6.sin6_addr));
if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
- sin6.sin6_scope_id = ifindex;
+ sin6.sin6_scope_id = ptm_bfd_fetch_ifindex(bpc->bpc_localif);
if (bpc->bpc_has_localif) {
if (bp_bind_dev(sd, bpc->bpc_localif) != 0) {
if (bpc->bpc_has_localif) {
STREAM_GET(bpc->bpc_localif, msg, ifnamelen);
bpc->bpc_localif[ifnamelen] = 0;
-
- /*
- * IPv6 link-local addresses must use scope id,
- * otherwise the session lookup will always fail
- * and we'll have multiple sessions showing up.
- *
- * This problem only happens with single hop
- * since it is not possible to have link-local
- * address for multi hop sessions.
- */
- if (bpc->bpc_ipv4 == false
- && IN6_IS_ADDR_LINKLOCAL(
- &bpc->bpc_peer.sa_sin6.sin6_addr))
- bpc->bpc_peer.sa_sin6.sin6_scope_id =
- ptm_bfd_fetch_ifindex(bpc->bpc_localif);
}
}