mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-25 10:08:09 +00:00
Merge pull request #15410 from louis-6wind/optim-nhflags
bgpd: move mp_nexthop_prefer_global boolean attribute to nh_flags
This commit is contained in:
commit
a32d76e8c6
@ -159,6 +159,7 @@ struct attr {
|
|||||||
|
|
||||||
#define BGP_ATTR_NH_VALID 0x01
|
#define BGP_ATTR_NH_VALID 0x01
|
||||||
#define BGP_ATTR_NH_IF_OPERSTATE 0x02
|
#define BGP_ATTR_NH_IF_OPERSTATE 0x02
|
||||||
|
#define BGP_ATTR_NH_MP_PREFER_GLOBAL 0x04 /* MP Nexthop preference */
|
||||||
|
|
||||||
/* Path origin attribute */
|
/* Path origin attribute */
|
||||||
uint8_t origin;
|
uint8_t origin;
|
||||||
@ -255,9 +256,6 @@ struct attr {
|
|||||||
/* MP Nexthop length */
|
/* MP Nexthop length */
|
||||||
uint8_t mp_nexthop_len;
|
uint8_t mp_nexthop_len;
|
||||||
|
|
||||||
/* MP Nexthop preference */
|
|
||||||
uint8_t mp_nexthop_prefer_global;
|
|
||||||
|
|
||||||
/* Static MAC for EVPN */
|
/* Static MAC for EVPN */
|
||||||
uint8_t sticky;
|
uint8_t sticky;
|
||||||
|
|
||||||
|
@ -129,15 +129,19 @@ int bgp_path_info_nexthop_cmp(struct bgp_path_info *bpi1,
|
|||||||
&bpi2->attr->mp_nexthop_global);
|
&bpi2->attr->mp_nexthop_global);
|
||||||
break;
|
break;
|
||||||
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
|
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
|
||||||
addr1 = (bpi1->attr->mp_nexthop_prefer_global)
|
addr1 = (CHECK_FLAG(bpi1->attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL))
|
||||||
? bpi1->attr->mp_nexthop_global
|
? bpi1->attr->mp_nexthop_global
|
||||||
: bpi1->attr->mp_nexthop_local;
|
: bpi1->attr->mp_nexthop_local;
|
||||||
addr2 = (bpi2->attr->mp_nexthop_prefer_global)
|
addr2 = (CHECK_FLAG(bpi2->attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL))
|
||||||
? bpi2->attr->mp_nexthop_global
|
? bpi2->attr->mp_nexthop_global
|
||||||
: bpi2->attr->mp_nexthop_local;
|
: bpi2->attr->mp_nexthop_local;
|
||||||
|
|
||||||
if (!bpi1->attr->mp_nexthop_prefer_global
|
if (!CHECK_FLAG(bpi1->attr->nh_flags,
|
||||||
&& !bpi2->attr->mp_nexthop_prefer_global)
|
BGP_ATTR_NH_MP_PREFER_GLOBAL) &&
|
||||||
|
!CHECK_FLAG(bpi2->attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL))
|
||||||
compare = !bgp_interface_same(
|
compare = !bgp_interface_same(
|
||||||
bpi1->peer->ifp,
|
bpi1->peer->ifp,
|
||||||
bpi2->peer->ifp);
|
bpi2->peer->ifp);
|
||||||
|
@ -1065,7 +1065,8 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
|
|||||||
*/
|
*/
|
||||||
else if (pi->attr->mp_nexthop_len
|
else if (pi->attr->mp_nexthop_len
|
||||||
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
|
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
|
||||||
if (pi->attr->mp_nexthop_prefer_global)
|
if (CHECK_FLAG(pi->attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL))
|
||||||
p->u.prefix6 =
|
p->u.prefix6 =
|
||||||
pi->attr->mp_nexthop_global;
|
pi->attr->mp_nexthop_global;
|
||||||
else
|
else
|
||||||
|
@ -9323,9 +9323,10 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
|
|||||||
"link-local");
|
"link-local");
|
||||||
|
|
||||||
if ((IPV6_ADDR_CMP(&attr->mp_nexthop_global,
|
if ((IPV6_ADDR_CMP(&attr->mp_nexthop_global,
|
||||||
&attr->mp_nexthop_local)
|
&attr->mp_nexthop_local) !=
|
||||||
!= 0)
|
0) &&
|
||||||
&& !attr->mp_nexthop_prefer_global)
|
!CHECK_FLAG(attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL))
|
||||||
json_object_boolean_true_add(
|
json_object_boolean_true_add(
|
||||||
json_nexthop_ll, "used");
|
json_nexthop_ll, "used");
|
||||||
else
|
else
|
||||||
@ -9337,10 +9338,11 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
|
|||||||
} else {
|
} else {
|
||||||
/* Display LL if LL/Global both in table unless
|
/* Display LL if LL/Global both in table unless
|
||||||
* prefer-global is set */
|
* prefer-global is set */
|
||||||
if (((attr->mp_nexthop_len
|
if (((attr->mp_nexthop_len ==
|
||||||
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
|
BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) &&
|
||||||
&& !attr->mp_nexthop_prefer_global)
|
!CHECK_FLAG(attr->nh_flags,
|
||||||
|| (path->peer->conf_if)) {
|
BGP_ATTR_NH_MP_PREFER_GLOBAL)) ||
|
||||||
|
(path->peer->conf_if)) {
|
||||||
if (path->peer->conf_if) {
|
if (path->peer->conf_if) {
|
||||||
len = vty_out(vty, "%s",
|
len = vty_out(vty, "%s",
|
||||||
path->peer->conf_if);
|
path->peer->conf_if);
|
||||||
@ -10588,7 +10590,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
|||||||
json_object_boolean_true_add(json_nexthop_ll,
|
json_object_boolean_true_add(json_nexthop_ll,
|
||||||
"accessible");
|
"accessible");
|
||||||
|
|
||||||
if (!attr->mp_nexthop_prefer_global)
|
if (!CHECK_FLAG(attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL))
|
||||||
json_object_boolean_true_add(json_nexthop_ll,
|
json_object_boolean_true_add(json_nexthop_ll,
|
||||||
"used");
|
"used");
|
||||||
else
|
else
|
||||||
@ -10598,7 +10601,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
|||||||
vty_out(vty, " (%s) %s\n",
|
vty_out(vty, " (%s) %s\n",
|
||||||
inet_ntop(AF_INET6, &attr->mp_nexthop_local,
|
inet_ntop(AF_INET6, &attr->mp_nexthop_local,
|
||||||
buf, INET6_ADDRSTRLEN),
|
buf, INET6_ADDRSTRLEN),
|
||||||
attr->mp_nexthop_prefer_global
|
CHECK_FLAG(attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL)
|
||||||
? "(prefer-global)"
|
? "(prefer-global)"
|
||||||
: "(used)");
|
: "(used)");
|
||||||
}
|
}
|
||||||
|
@ -3935,11 +3935,11 @@ route_set_ipv6_nexthop_prefer_global(void *rule, const struct prefix *prefix,
|
|||||||
if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
|
if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
|
||||||
|| CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) {
|
|| CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) {
|
||||||
/* Set next hop preference to global */
|
/* Set next hop preference to global */
|
||||||
path->attr->mp_nexthop_prefer_global = true;
|
SET_FLAG(path->attr->nh_flags, BGP_ATTR_NH_MP_PREFER_GLOBAL);
|
||||||
SET_FLAG(path->attr->rmap_change_flags,
|
SET_FLAG(path->attr->rmap_change_flags,
|
||||||
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
|
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
|
||||||
} else {
|
} else {
|
||||||
path->attr->mp_nexthop_prefer_global = false;
|
UNSET_FLAG(path->attr->nh_flags, BGP_ATTR_NH_MP_PREFER_GLOBAL);
|
||||||
SET_FLAG(path->attr->rmap_change_flags,
|
SET_FLAG(path->attr->rmap_change_flags,
|
||||||
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
|
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
|
||||||
}
|
}
|
||||||
|
@ -853,7 +853,8 @@ static uint8_t *bgp4v2PathAttrTable(struct variable *v, oid name[],
|
|||||||
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
|
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
|
||||||
return SNMP_INTEGER(2);
|
return SNMP_INTEGER(2);
|
||||||
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
|
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
|
||||||
if (path->attr->mp_nexthop_prefer_global)
|
if (CHECK_FLAG(path->attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL))
|
||||||
return SNMP_INTEGER(2);
|
return SNMP_INTEGER(2);
|
||||||
else
|
else
|
||||||
return SNMP_INTEGER(4);
|
return SNMP_INTEGER(4);
|
||||||
@ -867,7 +868,8 @@ static uint8_t *bgp4v2PathAttrTable(struct variable *v, oid name[],
|
|||||||
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
|
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
|
||||||
return SNMP_IP6ADDRESS(path->attr->mp_nexthop_global);
|
return SNMP_IP6ADDRESS(path->attr->mp_nexthop_global);
|
||||||
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
|
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
|
||||||
if (path->attr->mp_nexthop_prefer_global)
|
if (CHECK_FLAG(path->attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL))
|
||||||
return SNMP_IP6ADDRESS(
|
return SNMP_IP6ADDRESS(
|
||||||
path->attr->mp_nexthop_global);
|
path->attr->mp_nexthop_global);
|
||||||
else
|
else
|
||||||
|
@ -943,7 +943,8 @@ bgp_path_info_to_ipv6_nexthop(struct bgp_path_info *path, ifindex_t *ifindex)
|
|||||||
|| path->attr->mp_nexthop_len
|
|| path->attr->mp_nexthop_len
|
||||||
== BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) {
|
== BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) {
|
||||||
/* Check if route-map is set to prefer global over link-local */
|
/* Check if route-map is set to prefer global over link-local */
|
||||||
if (path->attr->mp_nexthop_prefer_global) {
|
if (CHECK_FLAG(path->attr->nh_flags,
|
||||||
|
BGP_ATTR_NH_MP_PREFER_GLOBAL)) {
|
||||||
nexthop = &path->attr->mp_nexthop_global;
|
nexthop = &path->attr->mp_nexthop_global;
|
||||||
if (IN6_IS_ADDR_LINKLOCAL(nexthop))
|
if (IN6_IS_ADDR_LINKLOCAL(nexthop))
|
||||||
*ifindex = path->attr->nh_ifindex;
|
*ifindex = path->attr->nh_ifindex;
|
||||||
|
Loading…
Reference in New Issue
Block a user