From: Donald Sharp Date: Fri, 11 Jan 2019 19:59:36 +0000 (-0500) Subject: zebra: Move rtm_table_default to zrouter X-Git-Tag: 7.1_pulled~282^2~9 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b3d43ff4714742c6e9d3d66501b01a392588e940;p=mirror%2Ffrr.git zebra: Move rtm_table_default to zrouter The zrouter should own this particular piece of data. Signed-off-by: Donald Sharp --- diff --git a/zebra/main.c b/zebra/main.c index 339bb6a914..faace93061 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -64,7 +64,6 @@ /* Zebra instance */ struct zebra_t zebrad = { - .rtm_table_default = 0, .packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS, }; diff --git a/zebra/redistribute.c b/zebra/redistribute.c index a98ed96b99..9c3002e775 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -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) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index fd228d754b..fb9f1331c4 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -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; } diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index 3e94d6bca8..1cf73b7b2f 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -206,6 +206,8 @@ void zebra_router_init(void) { zrouter.sequence_num = 0; + zrouter.rtm_table_default = 0; + zebra_vxlan_init(); zebra_mlag_init(); diff --git a/zebra/zebra_router.h b/zebra/zebra_router.h index 155841cc9e..17db34b346 100644 --- a/zebra/zebra_router.h +++ b/zebra/zebra_router.h @@ -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; diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 9812bd4487..8928ba6136 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -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 diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 14288d7bc4..704b729fba 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -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; } diff --git a/zebra/zserv.c b/zebra/zserv.c index e233b79125..e20c0daaa6 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -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); diff --git a/zebra/zserv.h b/zebra/zserv.h index aa8a084ef8..856a6debbd 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -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