Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: Convert the bgp_advertise_attr->adv to a fifo (backport #14554) #15621

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 7 additions & 25 deletions bgpd/bgp_advertise.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ struct bgp_advertise_attr *bgp_advertise_attr_new(void)

void bgp_advertise_attr_free(struct bgp_advertise_attr *baa)
{
bgp_advertise_attr_fifo_fini(&baa->fifo);

XFREE(MTYPE_BGP_ADVERTISE_ATTR, baa);
}

Expand All @@ -46,6 +48,9 @@ static void *bgp_advertise_attr_hash_alloc(void *p)

baa = bgp_advertise_attr_new();
baa->attr = ref->attr;

bgp_advertise_attr_fifo_init(&baa->fifo);

return baa;
}

Expand Down Expand Up @@ -83,36 +88,13 @@ void bgp_advertise_free(struct bgp_advertise *adv)
void bgp_advertise_add(struct bgp_advertise_attr *baa,
struct bgp_advertise *adv)
{
struct bgp_advertise *spot, *prev = NULL;

spot = baa->adv;

while (spot) {
prev = spot;
spot = spot->next;
}

if (prev) {
prev->next = adv;
adv->prev = prev;
} else
adv->prev = NULL;

adv->next = NULL;

if (!baa->adv)
baa->adv = adv;
bgp_advertise_attr_fifo_add_tail(&baa->fifo, adv);
}

void bgp_advertise_delete(struct bgp_advertise_attr *baa,
struct bgp_advertise *adv)
{
if (adv->next)
adv->next->prev = adv->prev;
if (adv->prev)
adv->prev->next = adv->next;
else
baa->adv = adv->next;
bgp_advertise_attr_fifo_del(&baa->fifo, adv);
}

struct bgp_advertise_attr *bgp_advertise_attr_intern(struct hash *hash,
Expand Down
32 changes: 19 additions & 13 deletions bgpd/bgp_advertise.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,19 @@
PREDECL_DLIST(bgp_adv_fifo);

struct update_subgroup;
struct bgp_advertise;

/* BGP advertise attribute. */
struct bgp_advertise_attr {
/* Head of advertisement pointer. */
struct bgp_advertise *adv;
PREDECL_DLIST(bgp_advertise_attr_fifo);

/* Reference counter. */
unsigned long refcnt;

/* Attribute pointer to be announced. */
struct attr *attr;
};
struct bgp_advertise_attr;

/* BGP advertise attribute. */
struct bgp_advertise {
/* FIFO for advertisement. */
struct bgp_adv_fifo_item fifo;

/* Link list for same attribute advertise. */
struct bgp_advertise *next;
struct bgp_advertise *prev;
/* FIFO for this item in the bgp_advertise_attr fifo */
struct bgp_advertise_attr_fifo_item item;

/* Prefix information. */
struct bgp_dest *dest;
Expand All @@ -45,8 +38,21 @@ struct bgp_advertise {
struct bgp_path_info *pathi;
};

DECLARE_DLIST(bgp_advertise_attr_fifo, struct bgp_advertise, item);
DECLARE_DLIST(bgp_adv_fifo, struct bgp_advertise, fifo);

/* BGP advertise attribute. */
struct bgp_advertise_attr {
/* Head of advertisement pointer. */
struct bgp_advertise_attr_fifo_head fifo;

/* Reference counter. */
unsigned long refcnt;

/* Attribute pointer to be announced. */
struct attr *attr;
};

/* BGP adjacency out. */
struct bgp_adj_out {
/* RB Tree of adjacency entries */
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_updgrp_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
bgp_advertise_delete(baa, adv);

/* Fetch next advertise candidate. */
next = baa->adv;
next = bgp_advertise_attr_fifo_first(&baa->fifo);

/* Unintern BGP advertise attribute. */
bgp_advertise_attr_unintern(subgrp->hash, baa);
Expand Down
Loading