]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Move rtm_table_default to zrouter
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 11 Jan 2019 19:59:36 +0000 (14:59 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 31 Jan 2019 14:20:46 +0000 (09:20 -0500)
The zrouter should own this particular piece of data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/main.c
zebra/redistribute.c
zebra/zebra_rib.c
zebra/zebra_router.c
zebra/zebra_router.h
zebra/zebra_vrf.c
zebra/zebra_vty.c
zebra/zserv.c
zebra/zserv.h

index 339bb6a9146ec963fb876032f2294565b4ff33ba..faace9306138ed56fdad09df65bd822ad52b7d3d 100644 (file)
@@ -64,7 +64,6 @@
 
 /* Zebra instance */
 struct zebra_t zebrad = {
-       .rtm_table_default = 0,
        .packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS,
 };
 
index a98ed96b99bbce5ad9df60aa3b02075e6c680a63..9c3002e775e81b5e5c9f9f1949b12a3d98524647 100644 (file)
@@ -614,7 +614,7 @@ int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,
        newre->flags = re->flags;
        newre->metric = re->metric;
        newre->mtu = re->mtu;
-       newre->table = zebrad.rtm_table_default;
+       newre->table = zrouter.rtm_table_default;
        newre->nexthop_num = 0;
        newre->uptime = time(NULL);
        newre->instance = re->table;
@@ -635,7 +635,7 @@ int zebra_del_import_table_entry(struct route_node *rn, struct route_entry *re)
 
        rib_delete(afi, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE, re->table,
                   re->flags, &p, NULL, re->ng.nexthop,
-                  zebrad.rtm_table_default, re->metric, re->distance, false);
+                  zrouter.rtm_table_default, re->metric, re->distance, false);
 
        return 0;
 }
@@ -650,7 +650,7 @@ int zebra_import_table(afi_t afi, uint32_t table_id, uint32_t distance,
 
        if (!is_zebra_valid_kernel_table(table_id)
            || ((table_id == RT_TABLE_MAIN)
-               || (table_id == zebrad.rtm_table_default)))
+               || (table_id == zrouter.rtm_table_default)))
                return (-1);
 
        if (afi >= AFI_MAX)
index fd228d754bc1b838f84c0350f88e8a0b5243fdcb..fb9f1331c44994709d6d3c7a3526eae695e5df4b 100644 (file)
@@ -163,7 +163,7 @@ int is_zebra_valid_kernel_table(uint32_t table_id)
 int is_zebra_main_routing_table(uint32_t table_id)
 {
        if ((table_id == RT_TABLE_MAIN)
-           || (table_id == zebrad.rtm_table_default))
+           || (table_id == zrouter.rtm_table_default))
                return 1;
        return 0;
 }
index 3e94d6bca892dfc6ec7a401a37c3c488eae8e422..1cf73b7b2ff63eeeb6889f1baf315fb61077f6eb 100644 (file)
@@ -206,6 +206,8 @@ void zebra_router_init(void)
 {
        zrouter.sequence_num = 0;
 
+       zrouter.rtm_table_default = 0;
+
        zebra_vxlan_init();
        zebra_mlag_init();
 
index 155841cc9ea4b23cf23f9fa3b22add1484363640..17db34b3465da58c0625e08b764e77ef9e7af32f 100644 (file)
@@ -70,6 +70,9 @@ struct zebra_router {
 
        /* A sequence number used for tracking routes */
        _Atomic uint32_t sequence_num;
+
+       /* The default table used for this router */
+       uint32_t rtm_table_default;
 };
 
 extern struct zebra_router zrouter;
index 9812bd448740ee42f1118988e887fbf53d5cd35b..8928ba61360002d5b35bf14d8dfd3e713b98f3c9 100644 (file)
@@ -326,14 +326,14 @@ struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
 
        if (vrf_id == VRF_DEFAULT) {
                if (table_id == RT_TABLE_MAIN
-                   || table_id == zebrad.rtm_table_default)
+                   || table_id == zrouter.rtm_table_default)
                        table = zebra_vrf_table(afi, safi, vrf_id);
                else
                        table = zebra_vrf_other_route_table(afi, table_id,
                                                            vrf_id);
        } else if (vrf_is_backend_netns()) {
                if (table_id == RT_TABLE_MAIN
-                   || table_id == zebrad.rtm_table_default)
+                   || table_id == zrouter.rtm_table_default)
                        table = zebra_vrf_table(afi, safi, vrf_id);
                else
                        table = zebra_vrf_other_route_table(afi, table_id,
@@ -439,9 +439,9 @@ struct route_table *zebra_vrf_other_route_table(afi_t afi, uint32_t table_id,
                return NULL;
 
        if ((table_id != RT_TABLE_MAIN)
-           && (table_id != zebrad.rtm_table_default)) {
+           && (table_id != zrouter.rtm_table_default)) {
                if (zvrf->table_id == RT_TABLE_MAIN ||
-                   zvrf->table_id == zebrad.rtm_table_default) {
+                   zvrf->table_id == zrouter.rtm_table_default) {
                        /* this VRF use default table
                         * so in all cases, it does not use specific table
                         * so it is possible to configure tables in this VRF
index 14288d7bc4b3714880863e17c9f8db7800bd206c..704b729fbadf5ee776e6c9b3fbb553b9cf4a3e62 100644 (file)
@@ -2581,7 +2581,7 @@ DEFUN (show_table,
        SHOW_STR
        "default routing table to use for all clients\n")
 {
-       vty_out(vty, "table %d\n", zebrad.rtm_table_default);
+       vty_out(vty, "table %d\n", zrouter.rtm_table_default);
        return CMD_SUCCESS;
 }
 
@@ -2591,7 +2591,7 @@ DEFUN (config_table,
        "Configure target kernel routing table\n"
        "TABLE integer\n")
 {
-       zebrad.rtm_table_default = strtol(argv[1]->arg, (char **)0, 10);
+       zrouter.rtm_table_default = strtol(argv[1]->arg, (char **)0, 10);
        return CMD_SUCCESS;
 }
 
@@ -2602,7 +2602,7 @@ DEFUN (no_config_table,
        "Configure target kernel routing table\n"
        "TABLE integer\n")
 {
-       zebrad.rtm_table_default = 0;
+       zrouter.rtm_table_default = 0;
        return CMD_SUCCESS;
 }
 #endif
@@ -2850,8 +2850,8 @@ DEFUN (zebra_show_routing_tables_summary,
 /* Table configuration write function. */
 static int config_write_table(struct vty *vty)
 {
-       if (zebrad.rtm_table_default)
-               vty_out(vty, "table %d\n", zebrad.rtm_table_default);
+       if (zrouter.rtm_table_default)
+               vty_out(vty, "table %d\n", zrouter.rtm_table_default);
        return 0;
 }
 
index e233b791255cc0a733998b8bf39ce699e7b0c94d..e20c0daaa69f56eeb3c7ebd7a9988c6cf2680cbd 100644 (file)
@@ -699,7 +699,7 @@ static struct zserv *zserv_client_create(int sock)
        client->wb = buffer_new(0);
 
        /* Set table number. */
-       client->rtm_table = zebrad.rtm_table_default;
+       client->rtm_table = zrouter.rtm_table_default;
 
        atomic_store_explicit(&client->connect_time, (uint32_t) monotime(NULL),
                              memory_order_relaxed);
index aa8a084ef87262bb569960bc9eba3825f118e423..856a6debbdeb03f47f82d363283fc2a81887609d 100644 (file)
@@ -175,9 +175,6 @@ DECLARE_KOOH(zserv_client_close, (struct zserv *client), (client));
 
 /* Zebra instance */
 struct zebra_t {
-       /* default table */
-       uint32_t rtm_table_default;
-
 /* rib work queue */
 #define ZEBRA_RIB_PROCESS_HOLD_TIME 10
 #define ZEBRA_RIB_PROCESS_RETRY_TIME 1