mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-09 20:01:10 +00:00
bgpd: allow VPN next hop to be different AFI than NLRI next hop (Issue #71)
Signed-off-by: Lou Berger <lberger@labn.net>
This commit is contained in:
parent
9857dafd62
commit
4c6f219aa2
@ -2643,6 +2643,8 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi,
|
|||||||
stream_putw (s, afi);
|
stream_putw (s, afi);
|
||||||
stream_putc (s, (safi == SAFI_MPLS_VPN) ? SAFI_MPLS_LABELED_VPN : safi);
|
stream_putc (s, (safi == SAFI_MPLS_VPN) ? SAFI_MPLS_LABELED_VPN : safi);
|
||||||
|
|
||||||
|
if (nh_afi == AFI_MAX)
|
||||||
|
nh_afi = BGP_NEXTHOP_AFI_FROM_NHLEN(attr->extra->mp_nexthop_len);
|
||||||
/* Nexthop */
|
/* Nexthop */
|
||||||
switch (nh_afi)
|
switch (nh_afi)
|
||||||
{
|
{
|
||||||
@ -2894,7 +2896,8 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
|
|||||||
size_t mpattrlen_pos = 0;
|
size_t mpattrlen_pos = 0;
|
||||||
|
|
||||||
mpattrlen_pos = bgp_packet_mpattr_start(s, afi, safi,
|
mpattrlen_pos = bgp_packet_mpattr_start(s, afi, safi,
|
||||||
(peer_cap_enhe(peer) ? AFI_IP6 : afi),
|
(peer_cap_enhe(peer) ? AFI_IP6 :
|
||||||
|
AFI_MAX), /* get from NH */
|
||||||
vecarr, attr);
|
vecarr, attr);
|
||||||
bgp_packet_mpattr_prefix(s, afi, safi, p, prd, tag,
|
bgp_packet_mpattr_prefix(s, afi, safi, p, prd, tag,
|
||||||
addpath_encode, addpath_tx_id);
|
addpath_encode, addpath_tx_id);
|
||||||
|
@ -1435,9 +1435,10 @@ subgroup_announce_check (struct bgp_info *ri, struct update_subgroup *subgrp,
|
|||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
#define NEXTHOP_IS_V6 (\
|
#define NEXTHOP_IS_V6 (\
|
||||||
(safi != SAFI_ENCAP && \
|
(safi != SAFI_ENCAP && safi != SAFI_MPLS_VPN &&\
|
||||||
(p->family == AF_INET6 || peer_cap_enhe(peer))) || \
|
(p->family == AF_INET6 || peer_cap_enhe(peer))) || \
|
||||||
(safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
|
((safi == SAFI_ENCAP || safi != SAFI_MPLS_VPN) &&\
|
||||||
|
attr->extra->mp_nexthop_len >= IPV6_MAX_BYTELEN))
|
||||||
|
|
||||||
/* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
|
/* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
|
||||||
* the peer (group) is configured to receive link-local nexthop unchanged
|
* the peer (group) is configured to receive link-local nexthop unchanged
|
||||||
|
@ -179,6 +179,10 @@ struct bgp_static
|
|||||||
u_char tag[3];
|
u_char tag[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen) \
|
||||||
|
((nhlen) < IPV4_MAX_BYTELEN ? 0 : \
|
||||||
|
((nhlen) < IPV6_MAX_BYTELEN ? AFI_IP : AFI_IP6))
|
||||||
|
|
||||||
#define BGP_ATTR_NEXTHOP_AFI_IP6(attr) \
|
#define BGP_ATTR_NEXTHOP_AFI_IP6(attr) \
|
||||||
(! CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)) && \
|
(! CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)) && \
|
||||||
(attr)->extra && ((attr)->extra->mp_nexthop_len == 16 || \
|
(attr)->extra && ((attr)->extra->mp_nexthop_len == 16 || \
|
||||||
|
@ -423,12 +423,11 @@ bpacket_reformat_for_peer (struct bpacket *pkt, struct peer_af *paf)
|
|||||||
nhlen = stream_getc_from (s, vec->offset);
|
nhlen = stream_getc_from (s, vec->offset);
|
||||||
if (paf->afi == AFI_IP || paf->afi == AFI_IP6)
|
if (paf->afi == AFI_IP || paf->afi == AFI_IP6)
|
||||||
{
|
{
|
||||||
if (nhlen < IPV6_MAX_BYTELEN && !peer_cap_enhe(peer))
|
nhafi = BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen);
|
||||||
nhafi = AFI_IP;
|
if (peer_cap_enhe(peer))
|
||||||
else
|
|
||||||
nhafi = AFI_IP6;
|
nhafi = AFI_IP6;
|
||||||
if (paf->safi == SAFI_MPLS_VPN && /* if VPN */
|
if (paf->safi == SAFI_MPLS_VPN && /* if VPN && not global */
|
||||||
nhlen != 48) /* and ! GLOBAL_AND_LL */
|
nhlen != BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL)
|
||||||
nhafi = AFI_MAX; /* no change allowed */
|
nhafi = AFI_MAX; /* no change allowed */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +485,7 @@ bpacket_reformat_for_peer (struct bpacket *pkt, struct peer_af *paf)
|
|||||||
|
|
||||||
if (bgp_debug_update(peer, NULL, NULL, 0))
|
if (bgp_debug_update(peer, NULL, NULL, 0))
|
||||||
zlog_debug ("u%" PRIu64 ":s%" PRIu64 " %s send UPDATE w/ nexthop %s%s",
|
zlog_debug ("u%" PRIu64 ":s%" PRIu64 " %s send UPDATE w/ nexthop %s%s",
|
||||||
PAF_SUBGRP(paf)->update_group->id, PAF_SUBGRP(paf)->id,
|
PAF_SUBGRP(paf)->update_group->id, PAF_SUBGRP(paf)->id,
|
||||||
peer->host, inet_ntoa (*mod_v4nh),
|
peer->host, inet_ntoa (*mod_v4nh),
|
||||||
(nhlen == 12 ? " and RD" : ""));
|
(nhlen == 12 ? " and RD" : ""));
|
||||||
}
|
}
|
||||||
@ -762,7 +761,8 @@ subgroup_update_packet (struct update_subgroup *subgrp)
|
|||||||
|
|
||||||
if (stream_empty (snlri))
|
if (stream_empty (snlri))
|
||||||
mpattrlen_pos = bgp_packet_mpattr_start (snlri, afi, safi,
|
mpattrlen_pos = bgp_packet_mpattr_start (snlri, afi, safi,
|
||||||
(peer_cap_enhe(peer) ? AFI_IP6 : afi),
|
(peer_cap_enhe(peer) ? AFI_IP6 :
|
||||||
|
AFI_MAX), /* get from NH */
|
||||||
&vecarr, adv->baa->attr);
|
&vecarr, adv->baa->attr);
|
||||||
bgp_packet_mpattr_prefix (snlri, afi, safi, &rn->p, prd, tag,
|
bgp_packet_mpattr_prefix (snlri, afi, safi, &rn->p, prd, tag,
|
||||||
addpath_encode, addpath_tx_id);
|
addpath_encode, addpath_tx_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user