]>
Commit | Line | Data |
---|---|---|
fe18ee2d DS |
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 | * | |
896014f4 DL |
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 | |
fe18ee2d DS |
20 | */ |
21 | #include "zebra.h" | |
22 | ||
13460c44 | 23 | #include "lib/ns.h" |
fe18ee2d DS |
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" | |
7c551956 | 30 | #include "zebra_vrf.h" |
4a1ab8e4 | 31 | #include "zebra_memory.h" |
05f7f5db | 32 | #include "rt.h" |
b7cfce93 | 33 | #include "zebra_vxlan.h" |
4a1ab8e4 | 34 | |
d62a17ae | 35 | DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space") |
fe18ee2d | 36 | |
337960dd | 37 | static struct zebra_ns *dzns; |
fe18ee2d | 38 | |
d62a17ae | 39 | struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id) |
fe18ee2d | 40 | { |
d62a17ae | 41 | return dzns; |
fe18ee2d DS |
42 | } |
43 | ||
d62a17ae | 44 | int zebra_ns_enable(ns_id_t ns_id, void **info) |
fe18ee2d | 45 | { |
d62a17ae | 46 | struct zebra_ns *zns = (struct zebra_ns *)(*info); |
fe18ee2d | 47 | |
d62a17ae | 48 | #if defined(HAVE_RTADV) |
49 | rtadv_init(zns); | |
fe18ee2d DS |
50 | #endif |
51 | ||
d62a17ae | 52 | zns->if_table = route_table_init(); |
b7cfce93 | 53 | zebra_vxlan_ns_init(zns); |
d62a17ae | 54 | kernel_init(zns); |
55 | interface_list(zns); | |
56 | route_read(zns); | |
fe18ee2d | 57 | |
d62a17ae | 58 | return 0; |
fe18ee2d DS |
59 | } |
60 | ||
d62a17ae | 61 | int zebra_ns_disable(ns_id_t ns_id, void **info) |
fe18ee2d | 62 | { |
d62a17ae | 63 | struct zebra_ns *zns = (struct zebra_ns *)(*info); |
fe18ee2d | 64 | |
d62a17ae | 65 | route_table_finish(zns->if_table); |
b7cfce93 | 66 | zebra_vxlan_ns_disable(zns); |
d62a17ae | 67 | #if defined(HAVE_RTADV) |
68 | rtadv_terminate(zns); | |
fe18ee2d DS |
69 | #endif |
70 | ||
d62a17ae | 71 | kernel_terminate(zns); |
fe18ee2d | 72 | |
d62a17ae | 73 | return 0; |
fe18ee2d DS |
74 | } |
75 | ||
d62a17ae | 76 | int zebra_ns_init(void) |
fe18ee2d | 77 | { |
d62a17ae | 78 | dzns = XCALLOC(MTYPE_ZEBRA_NS, sizeof(struct zebra_ns)); |
fe18ee2d | 79 | |
d62a17ae | 80 | ns_init(); |
13460c44 | 81 | |
d62a17ae | 82 | zebra_vrf_init(); |
fe18ee2d | 83 | |
f1abb72c | 84 | zebra_ns_enable(NS_DEFAULT, (void **)&dzns); |
fe18ee2d | 85 | |
d62a17ae | 86 | return 0; |
fe18ee2d | 87 | } |