]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Set table id *before* we enable the vrf
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sun, 25 Mar 2018 23:35:27 +0000 (19:35 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sun, 25 Mar 2018 23:35:27 +0000 (19:35 -0400)
The table id of the vrf is being given to us as part
of the vrf creation netlink callback.  Unfortunately it
was being set in the zvrf *after* the vrf_enable callback.

This didn't used to matter until we started having config data
stored on the side that we needed to act on when the vrf
came up enough to start working.

So when we were storing static routes and installing them
they were being pushed into the default table for non-default
vrf's.

Ticket: CM-19141
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/if_netlink.c

index a37d74416be37fb1ee4430b03bafaecc27677694..f1a12f5310fe233bce1a46c9962488fc2ebb5273 100644 (file)
@@ -314,21 +314,28 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,
                        return;
                }
 
-               /* Enable the created VRF. */
-               if (!vrf_enable(vrf)) {
-                       zlog_err("Failed to enable VRF %s id %u", name,
-                                ifi->ifi_index);
-                       return;
-               }
-
                /*
                 * This is the only place that we get the actual kernel table_id
                 * being used.  We need it to set the table_id of the routes
                 * we are passing to the kernel.... And to throw some totally
                 * awesome parties. that too.
+                *
+                * At this point we *must* have a zvrf because the vrf_create
+                * callback creates one.  We *must* set the table id
+                * before the vrf_enable because of( at the very least )
+                * static routes being delayed for installation until
+                * during the vrf_enable callbacks.
                 */
                zvrf = (struct zebra_vrf *)vrf->info;
                zvrf->table_id = nl_table_id;
+
+               /* Enable the created VRF. */
+               if (!vrf_enable(vrf)) {
+                       zlog_err("Failed to enable VRF %s id %u", name,
+                                ifi->ifi_index);
+                       return;
+               }
+
        } else // h->nlmsg_type == RTM_DELLINK
        {
                if (IS_ZEBRA_DEBUG_KERNEL)