forked from Mirror/frr
Merge pull request #16439 from louis-6wind/fix-ipv4-mapped-ipv6
bgpd: fixes for ipv4 mapped ipv6 address
This commit is contained in:
commit
cc0fdd3b1d
|
@ -351,7 +351,9 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (afi == AFI_IP6 && p.family == AF_INET)
|
||||||
|
/* IPv4 mapped IPv6 nexthop address */
|
||||||
|
afi = AFI_IP;
|
||||||
srte_color = bgp_attr_get_color(pi->attr);
|
srte_color = bgp_attr_get_color(pi->attr);
|
||||||
|
|
||||||
} else if (peer) {
|
} else if (peer) {
|
||||||
|
@ -1078,14 +1080,25 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
|
||||||
&ipv4);
|
&ipv4);
|
||||||
p->u.prefix4 = ipv4;
|
p->u.prefix4 = ipv4;
|
||||||
p->prefixlen = IPV4_MAX_BITLEN;
|
p->prefixlen = IPV4_MAX_BITLEN;
|
||||||
|
p->family = AF_INET;
|
||||||
} else
|
} else
|
||||||
p->u.prefix6 =
|
p->u.prefix6 =
|
||||||
pi->attr->mp_nexthop_global;
|
pi->attr->mp_nexthop_global;
|
||||||
} else
|
} else
|
||||||
p->u.prefix6 =
|
p->u.prefix6 =
|
||||||
pi->attr->mp_nexthop_local;
|
pi->attr->mp_nexthop_local;
|
||||||
} else
|
} else {
|
||||||
p->u.prefix6 = pi->attr->mp_nexthop_global;
|
if (IS_MAPPED_IPV6(
|
||||||
|
&pi->attr->mp_nexthop_global)) {
|
||||||
|
ipv4_mapped_ipv6_to_ipv4(&pi->attr->mp_nexthop_global,
|
||||||
|
&ipv4);
|
||||||
|
p->u.prefix4 = ipv4;
|
||||||
|
p->prefixlen = IPV4_MAX_BITLEN;
|
||||||
|
p->family = AF_INET;
|
||||||
|
} else
|
||||||
|
p->u.prefix6 =
|
||||||
|
pi->attr->mp_nexthop_global;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -508,6 +508,9 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||||
gnh_modified = 1;
|
gnh_modified = 1;
|
||||||
}
|
}
|
||||||
} else if (IN6_IS_ADDR_UNSPECIFIED(&v6nhglobal)) {
|
} else if (IN6_IS_ADDR_UNSPECIFIED(&v6nhglobal)) {
|
||||||
|
/* the UPDATE is originating from the local router.
|
||||||
|
* Build the global nexthop.
|
||||||
|
*/
|
||||||
mod_v6nhg = &peer->nexthop.v6_global;
|
mod_v6nhg = &peer->nexthop.v6_global;
|
||||||
gnh_modified = 1;
|
gnh_modified = 1;
|
||||||
} else if ((peer->sort == BGP_PEER_EBGP)
|
} else if ((peer->sort == BGP_PEER_EBGP)
|
||||||
|
@ -521,18 +524,32 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||||
*/
|
*/
|
||||||
mod_v6nhg = &peer->nexthop.v6_global;
|
mod_v6nhg = &peer->nexthop.v6_global;
|
||||||
gnh_modified = 1;
|
gnh_modified = 1;
|
||||||
|
} else if (IS_MAPPED_IPV6(&v6nhglobal) &&
|
||||||
|
!IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_global)) {
|
||||||
|
/* prefer a IPv6 native global address over
|
||||||
|
* an IPv4-mapped IPv6 address as nexthop when
|
||||||
|
* forwarding UPDATEs.
|
||||||
|
*/
|
||||||
|
mod_v6nhg = &peer->nexthop.v6_global;
|
||||||
|
gnh_modified = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer->nexthop.v4.s_addr != INADDR_ANY &&
|
if (peer->nexthop.v4.s_addr != INADDR_ANY &&
|
||||||
(IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg) ||
|
(IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg) ||
|
||||||
(IN6_IS_ADDR_LINKLOCAL(mod_v6nhg) &&
|
(IN6_IS_ADDR_LINKLOCAL(mod_v6nhg) &&
|
||||||
peer->connection->su.sa.sa_family == AF_INET6 &&
|
((peer->connection->su.sa.sa_family == AF_INET6 &&
|
||||||
paf->afi == AFI_IP))) {
|
paf->afi == AFI_IP) ||
|
||||||
|
(peer->connection->su.sa.sa_family == AF_INET &&
|
||||||
|
paf->afi == AFI_IP6))))) {
|
||||||
ipv4_to_ipv4_mapped_ipv6(mod_v6nhg, peer->nexthop.v4);
|
ipv4_to_ipv4_mapped_ipv6(mod_v6nhg, peer->nexthop.v4);
|
||||||
gnh_modified = 1;
|
gnh_modified = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_MAPPED_IPV6(&peer->nexthop.v6_global)) {
|
if (IS_MAPPED_IPV6(&peer->nexthop.v6_global)) {
|
||||||
|
/* If the interface to the peer has no global IPv6
|
||||||
|
* address, replace the nexthop in UPDATE with
|
||||||
|
* the IPv4-mapped IPv6 address if any.
|
||||||
|
*/
|
||||||
mod_v6nhg = &peer->nexthop.v6_global;
|
mod_v6nhg = &peer->nexthop.v6_global;
|
||||||
gnh_modified = 1;
|
gnh_modified = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"bestpath": true,
|
"bestpath": true,
|
||||||
"path": "65100",
|
"path": "65100",
|
||||||
"nexthops": [
|
"nexthops": [
|
||||||
|
{
|
||||||
|
"ip": "::ffff:ac10:1",
|
||||||
|
"afi": "ipv6",
|
||||||
|
"scope": "global"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"afi": "ipv6",
|
"afi": "ipv6",
|
||||||
"scope": "link-local",
|
"scope": "link-local",
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"bestpath": true,
|
"bestpath": true,
|
||||||
"path": "65100",
|
"path": "65100",
|
||||||
"nexthops": [
|
"nexthops": [
|
||||||
|
{
|
||||||
|
"ip": "::ffff:ac10:101",
|
||||||
|
"afi": "ipv6",
|
||||||
|
"scope": "global"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"afi": "ipv6",
|
"afi": "ipv6",
|
||||||
"scope": "link-local",
|
"scope": "link-local",
|
||||||
|
|
Loading…
Reference in a new issue