]>
Commit | Line | Data |
---|---|---|
e26aedbe PG |
1 | /* |
2 | * NetNS backend for non Linux systems | |
3 | * Copyright (C) 2018 6WIND S.A. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License as published by the Free | |
7 | * Software Foundation; either version 2 of the License, or (at your option) | |
8 | * any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | * more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; see the file COPYING; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | */ | |
19 | ||
20 | ||
cae8bc96 DS |
21 | #if !defined(GNU_LINUX) && defined(OPEN_BSD) |
22 | /* OPEN_BSD */ | |
e26aedbe PG |
23 | |
24 | #include <zebra.h> | |
25 | #include "ns.h" | |
26 | #include "log.h" | |
27 | #include "memory.h" | |
28 | ||
bf8d3d6a DL |
29 | DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context"); |
30 | DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name"); | |
e26aedbe PG |
31 | |
32 | ||
33 | static inline int ns_compare(const struct ns *ns, const struct ns *ns2); | |
34 | ||
35 | RB_GENERATE(ns_head, ns, entry, ns_compare) | |
36 | ||
1b3e9a21 | 37 | static struct ns_head ns_tree = RB_INITIALIZER(&ns_tree); |
e26aedbe PG |
38 | |
39 | static inline int ns_compare(const struct ns *a, const struct ns *b) | |
40 | { | |
41 | return (a->ns_id - b->ns_id); | |
42 | } | |
43 | ||
44 | void ns_terminate(void) | |
45 | { | |
46 | } | |
47 | ||
48 | /* API to initialize NETNS managerment | |
49 | * parameter is the default ns_id | |
50 | */ | |
51 | void ns_init_management(ns_id_t ns_id) | |
52 | { | |
53 | } | |
54 | ||
55 | ||
56 | /* | |
57 | * NS utilities | |
58 | */ | |
59 | ||
60 | /* Create a socket serving for the given NS | |
61 | */ | |
62 | int ns_socket(int domain, int type, int protocol, ns_id_t ns_id) | |
63 | { | |
64 | return -1; | |
65 | } | |
66 | ||
67 | /* return the path of the NETNS */ | |
68 | char *ns_netns_pathname(struct vty *vty, const char *name) | |
69 | { | |
70 | return NULL; | |
71 | } | |
72 | ||
73 | /* Parse and execute a function on all the NETNS */ | |
74 | void ns_walk_func(int (*func)(struct ns *)) | |
75 | { | |
76 | } | |
77 | ||
78 | /* API to get the NETNS name, from the ns pointer */ | |
79 | const char *ns_get_name(struct ns *ns) | |
80 | { | |
81 | return NULL; | |
82 | } | |
83 | ||
84 | /* only called from vrf ( when removing netns from vrf) | |
c7975431 | 85 | * or at VRF termination |
e26aedbe PG |
86 | */ |
87 | void ns_delete(struct ns *ns) | |
88 | { | |
89 | } | |
90 | ||
91 | /* return > 0 if netns is available | |
92 | * called by VRF to check netns backend is available for VRF | |
93 | */ | |
94 | int ns_have_netns(void) | |
95 | { | |
96 | return 0; | |
97 | } | |
98 | ||
99 | /* API to get context information of a NS */ | |
100 | void *ns_info_lookup(ns_id_t ns_id) | |
101 | { | |
102 | return NULL; | |
103 | } | |
104 | ||
105 | /* | |
106 | * NS init routine | |
107 | * should be called from backendx | |
108 | */ | |
109 | void ns_init(void) | |
110 | { | |
111 | } | |
112 | ||
e26aedbe PG |
113 | /* API that can be used to change from NS */ |
114 | int ns_switchback_to_initial(void) | |
115 | { | |
116 | return 0; | |
117 | } | |
118 | int ns_switch_to_netns(const char *netns_name) | |
119 | { | |
120 | return 0; | |
121 | } | |
122 | ||
123 | /* | |
124 | * NS handling routines. | |
125 | * called by modules that use NS backend | |
126 | */ | |
127 | ||
128 | /* API to search for already present NETNS */ | |
129 | struct ns *ns_lookup(ns_id_t ns_id) | |
130 | { | |
131 | return NULL; | |
132 | } | |
133 | ||
134 | struct ns *ns_lookup_name(const char *name) | |
135 | { | |
136 | return NULL; | |
137 | } | |
138 | ||
139 | /* API to handle NS : creation, enable, disable | |
140 | * for enable, a callback function is passed as parameter | |
141 | * the callback belongs to the module that uses NS as backend | |
142 | * upon enabling the NETNS, the upper layer is informed | |
143 | */ | |
144 | int ns_enable(struct ns *ns, int (*func)(ns_id_t, void *)) | |
145 | { | |
146 | return 0; | |
147 | } | |
148 | ||
03aff2d8 PG |
149 | ns_id_t ns_map_nsid_with_external(ns_id_t ns_id, bool maporunmap) |
150 | { | |
151 | return NS_UNKNOWN; | |
152 | } | |
153 | ||
e26aedbe PG |
154 | struct ns *ns_get_created(struct ns *ns, char *name, ns_id_t ns_id) |
155 | { | |
156 | return NULL; | |
157 | } | |
158 | ||
159 | void ns_disable(struct ns *ns) | |
160 | { | |
161 | } | |
162 | ||
163 | #endif /* !GNU_LINUX */ |