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: Auto vrf instance (backports) #17984

Open
wants to merge 3 commits into
base: stable/10.1
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion bgpd/bgp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static int bgp_vrf_disable(struct vrf *vrf)
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("VRF disable %s id %d", vrf->name, vrf->vrf_id);

bgp = bgp_lookup_by_name(vrf->name);
bgp = bgp_lookup_by_name_filter(vrf->name, false);
if (bgp) {

vpn_leak_zebra_vrf_label_withdraw(bgp, AFI_IP);
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -10440,7 +10440,7 @@ DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd,
}
}

vrf_bgp = bgp_lookup_by_name(import_name);
vrf_bgp = bgp_lookup_by_name_filter(import_name, false);
if (!vrf_bgp) {
if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) {
vrf_bgp = bgp_default;
Expand Down
11 changes: 8 additions & 3 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3623,13 +3623,13 @@ struct bgp *bgp_lookup(as_t as, const char *name)
}

/* Lookup BGP structure by view name. */
struct bgp *bgp_lookup_by_name(const char *name)
struct bgp *bgp_lookup_by_name_filter(const char *name, bool filter_auto)
{
struct bgp *bgp;
struct listnode *node, *nnode;

for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) {
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO))
if (filter_auto && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO))
continue;
if ((bgp->name == NULL && name == NULL)
|| (bgp->name && name && strcmp(bgp->name, name) == 0))
Expand All @@ -3638,6 +3638,11 @@ struct bgp *bgp_lookup_by_name(const char *name)
return NULL;
}

struct bgp *bgp_lookup_by_name(const char *name)
{
return bgp_lookup_by_name_filter(name, true);
}

/* Lookup BGP instance based on VRF id. */
/* Note: Only to be used for incoming messages from Zebra. */
struct bgp *bgp_lookup_by_vrf_id(vrf_id_t vrf_id)
Expand Down Expand Up @@ -3730,7 +3735,7 @@ int bgp_lookup_by_as_name_type(struct bgp **bgp_val, as_t *as, const char *name,

/* Multiple instance check. */
if (name)
bgp = bgp_lookup_by_name(name);
bgp = bgp_lookup_by_name_filter(name, true);
else
bgp = bgp_get_default();

Expand Down
1 change: 1 addition & 0 deletions bgpd/bgpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -2224,6 +2224,7 @@ extern void bgp_zclient_reset(void);
extern struct bgp *bgp_get_default(void);
extern struct bgp *bgp_lookup(as_t, const char *);
extern struct bgp *bgp_lookup_by_name(const char *);
extern struct bgp *bgp_lookup_by_name_filter(const char *name, bool filter_auto);
extern struct bgp *bgp_lookup_by_vrf_id(vrf_id_t);
extern struct bgp *bgp_get_evpn(void);
extern void bgp_set_evpn(struct bgp *bgp);
Expand Down
Loading