]>
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 | ||
21 | #if !defined(GNU_LINUX) && (defined(SUNOS_5) || defined(OPEN_BSD)) | |
22 | /* SUNOS_5 or OPEN_BSD */ | |
23 | ||
24 | #include <zebra.h> | |
25 | #include "ns.h" | |
26 | #include "log.h" | |
27 | #include "memory.h" | |
28 | ||
29 | DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context") | |
30 | DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name") | |
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 | ||
113 | /* API to retrieve default NS */ | |
114 | ns_id_t ns_get_default_id(void) | |
115 | { | |
116 | return NS_UNKNOWN; | |
117 | } | |
118 | ||
119 | ||
120 | /* API that can be used to change from NS */ | |
121 | int ns_switchback_to_initial(void) | |
122 | { | |
123 | return 0; | |
124 | } | |
125 | int ns_switch_to_netns(const char *netns_name) | |
126 | { | |
127 | return 0; | |
128 | } | |
129 | ||
130 | /* | |
131 | * NS handling routines. | |
132 | * called by modules that use NS backend | |
133 | */ | |
134 | ||
135 | /* API to search for already present NETNS */ | |
136 | struct ns *ns_lookup(ns_id_t ns_id) | |
137 | { | |
138 | return NULL; | |
139 | } | |
140 | ||
141 | struct ns *ns_lookup_name(const char *name) | |
142 | { | |
143 | return NULL; | |
144 | } | |
145 | ||
146 | /* API to handle NS : creation, enable, disable | |
147 | * for enable, a callback function is passed as parameter | |
148 | * the callback belongs to the module that uses NS as backend | |
149 | * upon enabling the NETNS, the upper layer is informed | |
150 | */ | |
151 | int ns_enable(struct ns *ns, int (*func)(ns_id_t, void *)) | |
152 | { | |
153 | return 0; | |
154 | } | |
155 | ||
03aff2d8 PG |
156 | ns_id_t ns_map_nsid_with_external(ns_id_t ns_id, bool maporunmap) |
157 | { | |
158 | return NS_UNKNOWN; | |
159 | } | |
160 | ||
e26aedbe PG |
161 | struct ns *ns_get_created(struct ns *ns, char *name, ns_id_t ns_id) |
162 | { | |
163 | return NULL; | |
164 | } | |
165 | ||
166 | void ns_disable(struct ns *ns) | |
167 | { | |
168 | } | |
169 | ||
170 | #endif /* !GNU_LINUX */ |