Commit b73f8efac5 for frr
commit b73f8efac54300f5b7abb592ff6825c71e38c9b2
Author: Donald Sharp <sharpd@nvidia.com>
Date: Wed Nov 4 10:25:57 2026 -0500
bgpd: Remove extra copy of dest pointer
The `struct bgp_advertise` data structure has a pointer to the dest
that is the same dest pointer that is in `struct bgp_adj_out`. The
bgp_adj_out has the only copy of the `struct bgp_advertise`. We
don't need 2 copies of dest. Let's reduce to one copy.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
diff --git a/bgpd/bgp_advertise.h b/bgpd/bgp_advertise.h
index b8650f68ed..2df37c7fa6 100644
--- a/bgpd/bgp_advertise.h
+++ b/bgpd/bgp_advertise.h
@@ -25,9 +25,6 @@ struct bgp_advertise {
/* FIFO for this item in the bgp_advertise_attr fifo */
struct bgp_advertise_attr_fifo_item item;
- /* Prefix information. */
- struct bgp_dest *dest;
-
/* Reference pointer. */
struct bgp_adj_out *adj;
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index 76b88e9465..d597ef124f 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -653,7 +653,6 @@ bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
adj->adv = bgp_advertise_new();
adv = adj->adv;
- adv->dest = dest;
assert(adv->pathi == NULL);
/* bgp_path_info adj_out reference */
adv->pathi = bgp_path_info_lock(path);
@@ -737,7 +736,6 @@ void bgp_adj_out_unset_subgroup(struct bgp_dest *dest, struct update_subgroup *s
/* We need advertisement structure. */
adj->adv = bgp_advertise_new();
adv = adj->adv;
- adv->dest = dest;
adv->adj = adj;
/*
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index ef51acf6af..1caa690c24 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -712,10 +712,10 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
while (adv) {
const struct prefix *dest_p;
- assert(adv->dest);
- dest = adv->dest;
- dest_p = bgp_dest_get_prefix(dest);
adj = adv->adj;
+ assert(adj->dest);
+ dest = adj->dest;
+ dest_p = bgp_dest_get_prefix(dest);
addpath_tx_id = adj->addpath_tx_id;
path = adv->pathi;
@@ -1045,9 +1045,9 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
while ((adv = bgp_adv_fifo_first(&subgrp->sync->withdraw)) != NULL) {
const struct prefix *dest_p;
- assert(adv->dest);
adj = adv->adj;
- dest = adv->dest;
+ assert(adj->dest);
+ dest = adj->dest;
dest_p = bgp_dest_get_prefix(dest);
addpath_tx_id = adj->addpath_tx_id;