]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: interface handling where zebra not yet ready
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 7 Feb 2019 13:55:06 +0000 (14:55 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 11 Feb 2019 12:47:04 +0000 (13:47 +0100)
other daemons need to sync with zebra to get to know which vrf backend
is available. in that time, there may be interface configuration
available. in that specific case, the vrf backend returned is not known.
A specific return value is sent back. This will be useful to know which
specific algorithm to apply.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
lib/if.c
lib/vrf.c
lib/vrf.h

index 0fd65da03a06be957888d03b2ff2bd72df6ef9cb..6ae75939e72757d7239c4739b6fef360ae5789ac 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -1281,6 +1281,7 @@ static int lib_interface_create(enum nb_event event,
                                  vrf->name);
                        return NB_ERR_VALIDATION;
                }
+
                if (vrf_get_backend() == VRF_BACKEND_VRF_LITE) {
                        ifp = if_lookup_by_name_all_vrf(ifname);
                        if (ifp && ifp->vrf_id != vrf->vrf_id) {
index f9f14822cba6009d2a656048f3978e5db463ecd7..c0dd7f5cf7309eba47451f3476b9ef660cde4d21 100644 (file)
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -56,6 +56,7 @@ struct vrf_id_head vrfs_by_id = RB_INITIALIZER(&vrfs_by_id);
 struct vrf_name_head vrfs_by_name = RB_INITIALIZER(&vrfs_by_name);
 
 static int vrf_backend;
+static int vrf_backend_configured;
 static struct zebra_privs_t *vrf_daemon_privs;
 static char vrf_default_name[VRF_NAMSIZ] = VRF_DEFAULT_NAME_INTERNAL;
 
@@ -613,12 +614,15 @@ int vrf_is_backend_netns(void)
 
 int vrf_get_backend(void)
 {
+       if (!vrf_backend_configured)
+               return VRF_BACKEND_UNKNOWN;
        return vrf_backend;
 }
 
 void vrf_configure_backend(int vrf_backend_netns)
 {
        vrf_backend = vrf_backend_netns;
+       vrf_backend_configured = 1;
 }
 
 int vrf_handler_create(struct vty *vty, const char *vrfname,
index e80796f480963324f2a03e4f73d43e6d43306695..1a850f218fb459d907ea8feae4e5a4e5ede9b72f 100644 (file)
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -97,8 +97,9 @@ RB_PROTOTYPE(vrf_name_head, vrf, name_entry, vrf_name_compare)
 DECLARE_QOBJ_TYPE(vrf)
 
 /* Allow VRF with netns as backend */
-#define VRF_BACKEND_VRF_LITE 0
-#define VRF_BACKEND_NETNS    1
+#define VRF_BACKEND_VRF_LITE   0
+#define VRF_BACKEND_NETNS      1
+#define VRF_BACKEND_UNKNOWN    2
 
 extern struct vrf_id_head vrfs_by_id;
 extern struct vrf_name_head vrfs_by_name;