]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: fix import vrf creates multiple bgp instances
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 9 Jan 2025 09:26:02 +0000 (10:26 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 21 Jan 2025 12:48:36 +0000 (13:48 +0100)
The more the vrf green is referenced in the import bgp command, the more
there are instances created. The below configuration shows that the vrf
green is referenced twice, and two BGP instances of vrf green are
created.

The below configuration:
> router bgp 99
> [..]
>  import vrf green
> exit
> router bgp 99 vrf blue
> [..]
>  import vrf green
> exit
> router bgp 99 vrf green
> [..]
> exit
>
> r4# show bgp vrfs
> Type  Id     routerId          #PeersCfg  #PeersEstb  Name
>              L3-VNI            RouterMAC              Interface
> DFLT  0      10.0.3.4          0          0           default
>              0                 00:00:00:00:00:00      unknown
>  VRF  5      10.0.40.4         0          0           blue
>              0                 00:00:00:00:00:00      unknown
>  VRF  6      0.0.0.0           0          0           green
>              0                 00:00:00:00:00:00      unknown
>  VRF  6      10.0.94.4         0          0           green
>              0                 00:00:00:00:00:00      unknown

Fix this at import command, by looking at an already present bgp
instance.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index 8fefbeb493783ed6128287c7c0c7ff8d3fd9c945..3e71a8948d7bdf501326d7672a2083ab471b74d5 100644 (file)
@@ -10561,7 +10561,7 @@ DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd,
                SET_FLAG(bgp_default->flags, BGP_FLAG_INSTANCE_HIDDEN);
        }
 
-       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;
index c45690a79261585b4bfd2745952120633a537482..d5463f3d0ced2d32aa10f2e425ff863dbcf79abc 100644 (file)
@@ -3634,7 +3634,7 @@ struct bgp *bgp_lookup(as_t as, const char *name)
 }
 
 /* Lookup BGP structure by view name. */
-static struct bgp *bgp_lookup_by_name_filter(const char *name, bool filter_auto)
+struct bgp *bgp_lookup_by_name_filter(const char *name, bool filter_auto)
 {
        struct bgp *bgp;
        struct listnode *node, *nnode;
index 9a1ac6cc786f6e0f34614605df6c4de5cbb68256..96a78e666249ae5f1a7a1744b92e6b4813c82182 100644 (file)
@@ -2285,6 +2285,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);