]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Move client_list to the zebra_router data structure
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 11 Jan 2019 18:38:19 +0000 (13:38 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 31 Jan 2019 14:20:46 +0000 (09:20 -0500)
The client_list should be owned by the zebra_router data structure
as that it is part of global state information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/main.c
zebra/redistribute.c
zebra/router-id.c
zebra/zapi_msg.c
zebra/zebra_ptm.c
zebra/zebra_ptm_redistribute.c
zebra/zebra_router.h
zebra/zebra_vrf.c
zebra/zserv.c
zebra/zserv.h

index 16a5ad53c91d3b87e199c0f21db2153c4bcd2fb3..339bb6a9146ec963fb876032f2294565b4ff33ba 100644 (file)
@@ -156,10 +156,10 @@ static void sigint(void)
 
        zebra_dplane_pre_finish();
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, ln, nn, client))
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, ln, nn, client))
                zserv_close_client(client);
 
-       list_delete_all_node(zebrad.client_list);
+       list_delete_all_node(zrouter.client_list);
        zebra_ptm_finish();
 
        if (retain_mode)
@@ -179,7 +179,7 @@ static void sigint(void)
        prefix_list_reset();
        route_map_finish();
 
-       list_delete(&zebrad.client_list);
+       list_delete(&zrouter.client_list);
 
        /* Indicate that all new dplane work has been enqueued. When that
         * work is complete, the dataplane will enqueue an event
index 2c5350fcebe53076f19918590ea41648ee6082ac..a98ed96b99bbce5ad9df60aa3b02075e6c680a63 100644 (file)
@@ -33,7 +33,7 @@
 #include "srcdest_table.h"
 
 #include "zebra/rib.h"
-#include "zebra/zserv.h"
+#include "zebra/zebra_router.h"
 #include "zebra/zebra_ns.h"
 #include "zebra/zebra_vrf.h"
 #include "zebra/zebra_routemap.h"
@@ -173,7 +173,7 @@ void redistribute_update(const struct prefix *p, const struct prefix *src_p,
                return;
        }
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
                send_redistribute = 0;
 
                if (is_default_prefix(p)
@@ -246,7 +246,7 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
                return;
        }
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
                if ((is_default_prefix(p)
                     && vrf_bitmap_check(client->redist_default[afi],
                                         re->vrf_id))
@@ -405,7 +405,8 @@ void zebra_interface_up_update(struct interface *ifp)
                           ifp->name, ifp->vrf_id);
 
        if (ifp->ptm_status || !ifp->ptm_enable) {
-               for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
+               for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode,
+                                      client))
                        if (vrf_bitmap_check(client->ifinfo, ifp->vrf_id)) {
                                zsend_interface_update(ZEBRA_INTERFACE_UP,
                                                       client, ifp);
@@ -424,7 +425,7 @@ void zebra_interface_down_update(struct interface *ifp)
                zlog_debug("MESSAGE: ZEBRA_INTERFACE_DOWN %s(%u)",
                           ifp->name, ifp->vrf_id);
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
                zsend_interface_update(ZEBRA_INTERFACE_DOWN, client, ifp);
        }
 }
@@ -439,7 +440,7 @@ void zebra_interface_add_update(struct interface *ifp)
                zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADD %s(%u)", ifp->name,
                           ifp->vrf_id);
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client))
                if (vrf_bitmap_check(client->ifinfo, ifp->vrf_id)) {
                        client->ifadd_cnt++;
                        zsend_interface_add(client, ifp);
@@ -456,7 +457,7 @@ void zebra_interface_delete_update(struct interface *ifp)
                zlog_debug("MESSAGE: ZEBRA_INTERFACE_DELETE %s(%u)",
                           ifp->name, ifp->vrf_id);
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
                client->ifdel_cnt++;
                zsend_interface_delete(client, ifp);
        }
@@ -488,7 +489,7 @@ void zebra_interface_address_add_update(struct interface *ifp,
 
        router_id_add_address(ifc);
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client))
                if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) {
                        client->connected_rt_add_cnt++;
                        zsend_interface_address(ZEBRA_INTERFACE_ADDRESS_ADD,
@@ -517,7 +518,7 @@ void zebra_interface_address_delete_update(struct interface *ifp,
 
        router_id_del_address(ifc);
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client))
                if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) {
                        client->connected_rt_del_cnt++;
                        zsend_interface_address(ZEBRA_INTERFACE_ADDRESS_DELETE,
@@ -538,7 +539,7 @@ void zebra_interface_vrf_update_del(struct interface *ifp, vrf_id_t new_vrf_id)
                        "MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/DEL %s VRF Id %u -> %u",
                        ifp->name, ifp->vrf_id, new_vrf_id);
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
                /* Need to delete if the client is not interested in the new
                 * VRF. */
                zsend_interface_update(ZEBRA_INTERFACE_DOWN, client, ifp);
@@ -561,7 +562,7 @@ void zebra_interface_vrf_update_add(struct interface *ifp, vrf_id_t old_vrf_id)
                        "MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/ADD %s VRF Id %u -> %u",
                        ifp->name, old_vrf_id, ifp->vrf_id);
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
                /* Need to add if the client is interested in the new VRF. */
                client->ifadd_cnt++;
                zsend_interface_add(client, ifp);
@@ -812,7 +813,7 @@ void zebra_interface_parameters_update(struct interface *ifp)
                zlog_debug("MESSAGE: ZEBRA_INTERFACE_LINK_PARAMS %s(%u)",
                           ifp->name, ifp->vrf_id);
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client))
                if (vrf_bitmap_check(client->ifinfo, ifp->vrf_id))
                        zsend_interface_link_params(client, ifp);
 }
index c500f79a6c2c0a275ebbf48ef6798dfad96e8fbd..2775383eb3b2f2ddfae2990fe2ada21c77680a4a 100644 (file)
@@ -38,7 +38,7 @@
 #include "rib.h"
 #include "vrf.h"
 
-#include "zebra/zserv.h"
+#include "zebra/zebra_router.h"
 #include "zebra/zapi_msg.h"
 #include "zebra/zebra_vrf.h"
 #include "zebra/router-id.h"
@@ -114,7 +114,7 @@ static void router_id_set(struct prefix *p, vrf_id_t vrf_id)
 
        router_id_get(&p2, vrf_id);
 
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client))
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client))
                zsend_router_id_update(client, &p2, vrf_id);
 }
 
@@ -145,7 +145,7 @@ void router_id_add_address(struct connected *ifc)
        if (prefix_same(&before, &after))
                return;
 
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client))
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client))
                zsend_router_id_update(client, &after, zvrf_id(zvrf));
 }
 
@@ -177,7 +177,7 @@ void router_id_del_address(struct connected *ifc)
        if (prefix_same(&before, &after))
                return;
 
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client))
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client))
                zsend_router_id_update(client, &after, zvrf_id(zvrf));
 }
 
index 951a411f252ea440f15e771f7dc7312b8e14b675..e560c2b5a253cd7f616eb584fe50f4da401e3d1d 100644 (file)
@@ -42,6 +42,7 @@
 #include "lib/libfrr.h"
 #include "lib/sockopt.h"
 
+#include "zebra/zebra_router.h"
 #include "zebra/rib.h"
 #include "zebra/zebra_memory.h"
 #include "zebra/zebra_ns.h"
@@ -365,7 +366,7 @@ static void zebra_interface_nbr_address_add_update(struct interface *ifp,
                        p->prefixlen, ifc->ifp->name);
        }
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client))
                zsend_interface_nbr_address(ZEBRA_INTERFACE_NBR_ADDRESS_ADD,
                                            client, ifp, ifc);
 }
@@ -389,7 +390,7 @@ static void zebra_interface_nbr_address_delete_update(struct interface *ifp,
                        p->prefixlen, ifc->ifp->name);
        }
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client))
                zsend_interface_nbr_address(ZEBRA_INTERFACE_NBR_ADDRESS_DELETE,
                                            client, ifp, ifc);
 }
@@ -768,7 +769,7 @@ void zsend_rule_notify_owner(struct zebra_pbr_rule *rule,
                zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__,
                           rule->rule.unique);
 
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client)) {
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
                if (rule->sock == client->sock)
                        break;
        }
@@ -804,7 +805,7 @@ void zsend_ipset_notify_owner(struct zebra_pbr_ipset *ipset,
                zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__,
                           ipset->unique);
 
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client)) {
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
                if (ipset->sock == client->sock)
                        break;
        }
@@ -834,7 +835,7 @@ void zsend_ipset_entry_notify_owner(struct zebra_pbr_ipset_entry *ipset,
                zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__,
                           ipset->unique);
 
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client)) {
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
                if (ipset->sock == client->sock)
                        break;
        }
@@ -864,7 +865,7 @@ void zsend_iptable_notify_owner(struct zebra_pbr_iptable *iptable,
                zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__,
                           iptable->unique);
 
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client)) {
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
                if (iptable->sock == client->sock)
                        break;
        }
index 333485073e921b2d63d78306e8026b956b7793a6..1e942d6433f9f8642a9704994ad498f6ed6e30bd 100644 (file)
@@ -41,7 +41,7 @@
 #include "zebra/zebra_errors.h"
 #include "zebra/zebra_ptm.h"
 #include "zebra/zebra_ptm_redistribute.h"
-#include "zebra/zserv.h"
+#include "zebra/zebra_router.h"
 #include "zebra_vrf.h"
 
 /*
@@ -1276,7 +1276,7 @@ static void zebra_ptm_send_bfdd(struct stream *msg)
        }
 
        /* Send message to all running BFDd daemons. */
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client)) {
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
                if (client->proto != ZEBRA_ROUTE_BFD)
                        continue;
 
@@ -1308,7 +1308,7 @@ static void zebra_ptm_send_clients(struct stream *msg)
        }
 
        /* Send message to all running client daemons. */
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client)) {
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
                if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
                        continue;
 
index 3acbe3bf2c85182fc1dc4aafe76530d693d07f73..0c24c732a44b54446f2c78da35ca1cddbcd1e75b 100644 (file)
@@ -22,7 +22,7 @@
 #include "prefix.h"
 #include "vty.h"
 #include "stream.h"
-#include "zebra/zserv.h"
+#include "zebra/zebra_router.h"
 #include "zebra/zapi_msg.h"
 #include "zebra/zebra_ptm.h"
 #include "zebra/zebra_ptm_redistribute.h"
@@ -76,7 +76,7 @@ void zebra_interface_bfd_update(struct interface *ifp, struct prefix *dp,
        struct listnode *node, *nnode;
        struct zserv *client;
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
                if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
                        continue;
 
@@ -106,7 +106,7 @@ void zebra_bfd_peer_replay_req(void)
        struct listnode *node, *nnode;
        struct zserv *client;
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
                if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
                        continue;
 
index 244b8c37a08636444e9bc303648cf4ba6df47401..155841cc9ea4b23cf23f9fa3b22add1484363640 100644 (file)
@@ -48,6 +48,9 @@ struct zebra_router {
        /* Thread master */
        struct thread_master *master;
 
+       /* Lists of clients who have connected to us */
+       struct list *client_list;
+
        struct zebra_router_table_head tables;
 
        /* L3-VNI hash table (for EVPN). Only in default instance */
index f1458cb138b1eabc92161befbe79fe02b57e453a..9812bd448740ee42f1118988e887fbf53d5cd35b 100644 (file)
@@ -58,7 +58,7 @@ static void zebra_vrf_add_update(struct zebra_vrf *zvrf)
        if (IS_ZEBRA_DEBUG_EVENT)
                zlog_debug("MESSAGE: ZEBRA_VRF_ADD %s", zvrf_name(zvrf));
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client))
                zsend_vrf_add(client, zvrf);
 }
 
@@ -70,7 +70,7 @@ static void zebra_vrf_delete_update(struct zebra_vrf *zvrf)
        if (IS_ZEBRA_DEBUG_EVENT)
                zlog_debug("MESSAGE: ZEBRA_VRF_DELETE %s", zvrf_name(zvrf));
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client))
                zsend_vrf_delete(client, zvrf);
 }
 
index 6e450f07b1607df3c2745741b1b72fbe3547ff69..05dea8d2ad1f9b25efb56f115cad69d2d1eae1f7 100644 (file)
@@ -647,7 +647,7 @@ void zserv_close_client(struct zserv *client)
        client->pthread = NULL;
 
        /* remove from client list */
-       listnode_delete(zebrad.client_list, client);
+       listnode_delete(zrouter.client_list, client);
 
        /* delete client */
        zserv_client_free(client);
@@ -714,7 +714,7 @@ static struct zserv *zserv_client_create(int sock)
        client->is_synchronous = 0;
 
        /* Add this client to linked list. */
-       listnode_add(zebrad.client_list, client);
+       listnode_add(zrouter.client_list, client);
 
        struct frr_pthread_attr zclient_pthr_attrs = {
                .start = frr_pthread_attr_default.start,
@@ -1003,7 +1003,7 @@ struct zserv *zserv_find_client(uint8_t proto, unsigned short instance)
        struct listnode *node, *nnode;
        struct zserv *client;
 
-       for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
+       for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
                if (client->proto == proto && client->instance == instance)
                        return client;
        }
@@ -1022,7 +1022,7 @@ DEFUN (show_zebra_client,
        struct listnode *node;
        struct zserv *client;
 
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client))
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client))
                zebra_show_client_detail(vty, client);
 
        return CMD_SUCCESS;
@@ -1045,7 +1045,7 @@ DEFUN (show_zebra_client_summary,
        vty_out(vty,
                "--------------------------------------------------------------------------------\n");
 
-       for (ALL_LIST_ELEMENTS_RO(zebrad.client_list, node, client))
+       for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client))
                zebra_show_client_brief(vty, client);
 
        vty_out(vty, "Routes column shows (added+updated)/deleted\n");
@@ -1068,7 +1068,7 @@ void zserv_read_file(char *input)
 void zserv_init(void)
 {
        /* Client list init. */
-       zebrad.client_list = list_new();
+       zrouter.client_list = list_new();
 
        /* Misc init. */
        zebrad.sock = -1;
index a712e7fb9ca15a432ee8b66a16e006ea0f123f16..77ac40e1ab1e8f872dd4d0c8f30d38b9498c3d09 100644 (file)
@@ -175,8 +175,6 @@ DECLARE_KOOH(zserv_client_close, (struct zserv *client), (client));
 
 /* Zebra instance */
 struct zebra_t {
-       struct list *client_list;
-
        /* Socket */
        int sock;