]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_ns.c
*: Handle VRF configuration when VRF gets inactivated and activated
[mirror_frr.git] / zebra / zebra_ns.c
1 /* zebra NS Routines
2 * Copyright (C) 2016 Cumulus Networks, Inc.
3 * Donald Sharp
4 *
5 * This file is part of Quagga.
6 *
7 * Quagga is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * Quagga is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 #include "zebra.h"
22
23 #include "lib/ns.h"
24 #include "lib/vrf.h"
25 #include "lib/prefix.h"
26 #include "lib/memory.h"
27
28 #include "rtadv.h"
29 #include "zebra_ns.h"
30 #include "zebra_vrf.h"
31 #include "zebra_memory.h"
32 #include "rt.h"
33 #include "zebra_vxlan.h"
34
35 DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space")
36
37 static struct zebra_ns *dzns;
38
39 struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id)
40 {
41 return dzns;
42 }
43
44 /* Do global enable actions - open sockets, read kernel config etc. */
45 int zebra_ns_enable(ns_id_t ns_id, void **info)
46 {
47 struct zebra_ns *zns = (struct zebra_ns *)(*info);
48
49 #if defined(HAVE_RTADV)
50 rtadv_init(zns);
51 #endif
52
53 kernel_init(zns);
54 interface_list(zns);
55 route_read(zns);
56
57 return 0;
58 }
59
60 int zebra_ns_disable(ns_id_t ns_id, void **info)
61 {
62 struct zebra_ns *zns = (struct zebra_ns *)(*info);
63
64 route_table_finish(zns->if_table);
65 zebra_vxlan_ns_disable(zns);
66 #if defined(HAVE_RTADV)
67 rtadv_terminate(zns);
68 #endif
69
70 kernel_terminate(zns);
71
72 return 0;
73 }
74
75 int zebra_ns_init(void)
76 {
77 dzns = XCALLOC(MTYPE_ZEBRA_NS, sizeof(struct zebra_ns));
78
79 ns_init();
80
81 /* Do any needed per-NS data structure allocation. */
82 dzns->if_table = route_table_init();
83 zebra_vxlan_ns_init(dzns);
84
85 /* Register zebra VRF callbacks, create and activate default VRF. */
86 zebra_vrf_init();
87
88 /* Default NS is activated */
89 zebra_ns_enable(NS_DEFAULT, (void **)&dzns);
90
91 return 0;
92 }