bgpd: fix AIGP calculation in route advertisement (backport #17168) #17188
frrbot / frrbot
completed
Oct 22, 2024 in 32s
Style and/or linter errors found
Style and/or linter errors found
Details
Thanks for your contribution to FRR!
Click for style suggestions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 87da3d2de..9d201836c 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -4246,10 +4246,12 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
bool addpath_capable, uint32_t addpath_tx_id,
struct bgp_path_info *bpi)
=======
-bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer, struct stream *s,
- struct attr *attr, struct bpacket_attr_vec_arr *vecarr,
- struct prefix *p, afi_t afi, safi_t safi, struct peer *from,
- struct prefix_rd *prd, mpls_label_t *label, uint8_t num_labels,
+bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
+ struct stream *s, struct attr *attr,
+ struct bpacket_attr_vec_arr *vecarr,
+ struct prefix *p, afi_t afi, safi_t safi,
+ struct peer *from, struct prefix_rd *prd,
+ mpls_label_t *label, uint8_t num_labels,
bool addpath_capable, uint32_t addpath_tx_id)
>>>>>>> fc82d7750f (bgpd: fix AIGP calculation in route advertisement)
{
@@ -4782,7 +4784,8 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer, struct strea
(CHECK_FLAG(peer->flags, PEER_FLAG_AIGP) ||
peer->sort != BGP_PEER_EBGP)) {
=======
- if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP)) && AIGP_TRANSMIT_ALLOWED(peer)) {
+ if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP)) &&
+ AIGP_TRANSMIT_ALLOWED(peer)) {
>>>>>>> fc82d7750f (bgpd: fix AIGP calculation in route advertisement)
/* At the moment only AIGP Metric TLV exists for AIGP
* attribute. If more comes in, do not forget to update
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index 5066d8a4c..9483c0b71 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -394,11 +394,13 @@ extern bgp_size_t bgp_packet_attribute(
mpls_label_t *label, uint32_t num_labels, bool addpath_capable,
uint32_t addpath_tx_id, struct bgp_path_info *bpi);
=======
-extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer, struct stream *s,
- struct attr *attr, struct bpacket_attr_vec_arr *vecarr,
- struct prefix *p, afi_t afi, safi_t safi, struct peer *from,
- struct prefix_rd *prd, mpls_label_t *label,
- uint8_t num_labels, bool addpath_capable,
+extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
+ struct stream *s, struct attr *attr,
+ struct bpacket_attr_vec_arr *vecarr,
+ struct prefix *p, afi_t afi, safi_t safi,
+ struct peer *from, struct prefix_rd *prd,
+ mpls_label_t *label, uint8_t num_labels,
+ bool addpath_capable,
uint32_t addpath_tx_id);
>>>>>>> fc82d7750f (bgpd: fix AIGP calculation in route advertisement)
extern void bgp_dump_routes_attr(struct stream *s, struct bgp_path_info *bpi,
@@ -591,8 +593,9 @@ static inline void bgp_attr_set_transit(struct attr *attr,
attr->transit = transit;
}
-#define AIGP_TRANSMIT_ALLOWED(peer) \
- (CHECK_FLAG((peer)->flags, PEER_FLAG_AIGP) || ((peer)->sub_sort == BGP_PEER_EBGP_OAD) || \
+#define AIGP_TRANSMIT_ALLOWED(peer) \
+ (CHECK_FLAG((peer)->flags, PEER_FLAG_AIGP) || \
+ ((peer)->sub_sort == BGP_PEER_EBGP_OAD) || \
((peer)->sort != BGP_PEER_EBGP))
static inline uint64_t bgp_attr_get_aigp_metric(const struct attr *attr)
diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c
index 93517156d..59348be96 100644
--- a/bgpd/bgp_bmp.c
+++ b/bgpd/bgp_bmp.c
@@ -840,8 +840,9 @@ static struct stream *bmp_update(const struct prefix *p, struct prefix_rd *prd,
stream_putw(s, 0);
/* 5: Encode all the attributes, except MP_REACH_NLRI attr. */
- total_attr_len = bgp_packet_attribute(NULL, peer, s, attr, &vecarr, NULL, afi, safi, peer,
- NULL, NULL, 0, 0, 0);
+ total_attr_len =
+ bgp_packet_attribute(NULL, peer, s, attr, &vecarr, NULL, afi,
+ safi, peer, NULL, NULL, 0, 0, 0);
/* space check? */
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index b07706aab..05c2fa054 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -2631,9 +2631,10 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
* EBGP. Note in route reflection the nexthop is usually unmodified
* and the AIGP should not be adjusted in that case.
*/
- if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP)) && AIGP_TRANSMIT_ALLOWED(peer)) {
- if (nh_reset ||
- CHECK_FLAG(attr->rmap_change_flags, BATTR_RMAP_NEXTHOP_PEER_ADDRESS)) {
+ if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP)) &&
+ AIGP_TRANSMIT_ALLOWED(peer)) {
+ if (nh_reset || CHECK_FLAG(attr->rmap_change_flags,
+ BATTR_RMAP_NEXTHOP_PEER_ADDRESS)) {
uint64_t aigp = bgp_aigp_metric_total(pi);
bgp_attr_set_aigp_metric(attr, aigp);
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 76d949b04..f5d0a920b 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -738,9 +738,9 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
/* 5: Encode all the attributes, except MP_REACH_NLRI
* attr. */
- total_attr_len = bgp_packet_attribute(NULL, peer, s, adv->baa->attr,
- &vecarr, NULL, afi, safi, from, NULL,
- NULL, 0, 0, 0);
+ total_attr_len = bgp_packet_attribute(
+ NULL, peer, s, adv->baa->attr, &vecarr, NULL,
+ afi, safi, from, NULL, NULL, 0, 0, 0);
space_remaining =
STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))
@@ -1125,9 +1125,10 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
num_labels, addpath_capable,
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE, NULL);
=======
- total_attr_len = bgp_packet_attribute(NULL, peer, s, attr, &vecarr, &p, afi, safi, from,
- NULL, &label, num_labels, addpath_capable,
- BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
+ total_attr_len = bgp_packet_attribute(
+ NULL, peer, s, attr, &vecarr, &p, afi, safi, from, NULL, &label,
+ num_labels, addpath_capable,
+ BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
>>>>>>> fc82d7750f (bgpd: fix AIGP calculation in route advertisement)
/* Set Total Path Attribute Length. */
To apply the style suggestions:
curl https://gist.githubusercontent.com/polychaeta/4f880e707a843003f07869545f6ba359/raw/8aee41deb823535fcb668524d1967f9fcdf0b5b9/style.diff | git apply -
If you are a new contributor to FRR, please see our contributing guidelines.
After making changes, you do not need to create a new PR. You should perform an amend or interactive rebase followed by a force push.
Loading