]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: On client shutdown cleanup any vrf labels associated with it
authorDonald Sharp <sharpd@nvidia.com>
Wed, 21 Jul 2021 17:55:52 +0000 (13:55 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 21 Jul 2021 18:04:36 +0000 (14:04 -0400)
When a vrf label is created by a client and the client disconnects
we should clean up any vrf labels associated with that client.

eva# show mpls table
 Inbound Label  Type   Nexthop  Outbound Label
 -----------------------------------------------
 1000           SHARP  RED      -

eva# exit
sharpd@eva ~/f/zebra (label_destruction)> ps -ef | grep frr
root     4017793       1  0 13:57 ?        00:00:00 /usr/lib/frr/watchfrr -d -F datacenter --log file:/var/log/frr/watchfrr.log --log-level debug zebra bgpd ospfd isisd pimd eigrpd sharpd staticd
frr      4017824       1  0 13:57 ?        00:00:00 /usr/lib/frr/zebra -d -F datacenter --log file:/tmp/zebra.log -r --graceful_restart 60 -A 127.0.0.1 -s 90000000
frr      4017829       1  0 13:57 ?        00:00:00 /usr/lib/frr/bgpd -d -F datacenter -M rpki -A 127.0.0.1
frr      4017836       1  0 13:57 ?        00:00:00 /usr/lib/frr/ospfd -d -F datacenter -A 127.0.0.1
frr      4017839       1  0 13:57 ?        00:00:00 /usr/lib/frr/isisd -d -F datacenter -A 127.0.0.1
frr      4017842       1  0 13:57 ?        00:00:00 /usr/lib/frr/pimd -d -F datacenter -A 127.0.0.1
frr      4017865       1  0 13:57 ?        00:00:00 /usr/lib/frr/eigrpd -d -F datacenter -A 127.0.0.1
frr      4017869       1  0 13:57 ?        00:00:00 /usr/lib/frr/sharpd -d -F datacenter -A 127.0.0.1
frr      4017888       1  0 13:57 ?        00:00:00 /usr/lib/frr/staticd -d -F datacenter -A 127.0.0.1
sharpd   4018624 3938423  0 14:02 pts/10   00:00:00 grep --color=auto frr
sharpd@eva ~/f/zebra (label_destruction)> sudo kill -9 4017869

sharpd@eva ~/f/zebra (label_destruction)> sudo vtysh -c "show mpls table"
sharpd@eva ~/f/zebra (label_destruction)>

Fixes: #1787
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/zapi_msg.c
zebra/zebra_mpls.c
zebra/zebra_mpls.h
zebra/zebra_vrf.h
zebra/zserv.c

index a53e38806227bd3673d26ce031ebbe94fd18c9ec..5b2b1cc26fba7c287ba920828e28b0faffd380e8 100644 (file)
@@ -3107,6 +3107,8 @@ static void zread_vrf_label(ZAPI_HANDLER_ARGS)
        }
 
        zvrf->label[afi] = nlabel;
+       zvrf->label_proto[afi] = client->proto;
+
 stream_failure:
        return;
 }
index a2d1513ce4874530b71676f10bec90bcd5c001d6..66d2d6b4babbe9f90f03f0c49533918ee87ac5f0 100644 (file)
@@ -3931,6 +3931,40 @@ void zebra_mpls_cleanup_tables(struct zebra_vrf *zvrf)
        }
 }
 
+/*
+ * When a vrf label is assigned and the client goes away
+ * we should cleanup the vrf labels associated with
+ * that zclient.
+ */
+void zebra_mpls_client_cleanup_vrf_label(uint8_t proto)
+{
+       struct vrf *vrf;
+       struct zebra_vrf *def_zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
+
+       if (def_zvrf == NULL)
+               return;
+
+       RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
+               struct zebra_vrf *zvrf = vrf->info;
+               afi_t afi;
+
+               if (!zvrf)
+                       continue;
+
+               for (afi = AFI_IP; afi < AFI_MAX; afi++) {
+                       if (zvrf->label_proto[afi] == proto
+                           && zvrf->label[afi] != MPLS_LABEL_NONE)
+                               lsp_uninstall(def_zvrf, zvrf->label[afi]);
+
+                       /*
+                        * Cleanup data structures by fiat
+                        */
+                       zvrf->label_proto[afi] = 0;
+                       zvrf->label[afi] = MPLS_LABEL_NONE;
+               }
+       }
+}
+
 /*
  * Called upon process exiting, need to delete LSP forwarding
  * entries from the kernel.
index 7059d393edf5af7cbbe907912cc78f4e5156198c..5195b2f14fed8ed76432ea5e8d05263fd8db431d 100644 (file)
@@ -416,6 +416,12 @@ void zebra_mpls_init(void);
  */
 void zebra_mpls_vty_init(void);
 
+/*
+ * When cleaning up a client connection ensure that there are no
+ * vrf labels that need cleaning up too
+ */
+void zebra_mpls_client_cleanup_vrf_label(uint8_t proto);
+
 /* Inline functions. */
 
 /*
index 57dd0c20ad7d37e5365f467ba8f68177f886f947..f32f09850b6a129e8379489d0a2b0abf7d9d5320 100644 (file)
@@ -105,6 +105,7 @@ struct zebra_vrf {
 
        /* MPLS Label to handle L3VPN <-> vrf popping */
        mpls_label_t label[AFI_MAX];
+       uint8_t label_proto[AFI_MAX];
 
        /* MPLS static LSP config table */
        struct hash *slsp_table;
index 1d94fcae6bbd6e06312facb1c54eff355748a9c3..e4a48093f7cbb53cdfb89f1de7a88f83d5953793 100644 (file)
@@ -595,6 +595,8 @@ static void zserv_client_free(struct zserv *client)
                close(client->sock);
 
                if (DYNAMIC_CLIENT_GR_DISABLED(client)) {
+                       zebra_mpls_client_cleanup_vrf_label(client->proto);
+
                        nroutes = rib_score_proto(client->proto,
                                                  client->instance);
                        zlog_notice(