]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_ns.c
lib: Create ns.c
[mirror_frr.git] / zebra / zebra_ns.c
CommitLineData
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 *
17 * You should have received a copy of the GNU General Public License
18 * along with Quagga; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22#include "zebra.h"
23
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"
fe18ee2d
DS
31
32struct zebra_ns *dzns;
33
34struct zebra_ns *
35zebra_ns_lookup (ns_id_t ns_id)
36{
37 return dzns;
38}
39
40int
41zebra_ns_enable (ns_id_t ns_id, void **info)
42{
43 struct zebra_ns *zns = (struct zebra_ns *) (*info);
44#ifdef HAVE_NETLINK
45 char nl_name[64];
46#endif
47
48#if defined (HAVE_RTADV)
49 rtadv_init (zns);
50#endif
51
52#ifdef HAVE_NETLINK
53 /* Initialize netlink sockets */
54 snprintf (nl_name, 64, "netlink-listen (NS %u)", ns_id);
55 zns->netlink.sock = -1;
56 zns->netlink.name = XSTRDUP (MTYPE_NETLINK_NAME, nl_name);
57
58 snprintf (nl_name, 64, "netlink-cmd (NS %u)", ns_id);
59 zns->netlink_cmd.sock = -1;
60 zns->netlink_cmd.name = XSTRDUP (MTYPE_NETLINK_NAME, nl_name);
61#endif
62 zns->if_table = route_table_init ();
63 kernel_init (zns);
64 interface_list (zns);
65 route_read (zns);
66
67 return 0;
68}
69
70int
71zebra_ns_disable (ns_id_t ns_id, void **info)
72{
73 struct zebra_ns *zns = (struct zebra_ns *) (*info);
74
75#if defined (HAVE_RTADV)
76 rtadv_terminate (zns);
77#endif
78
79 kernel_terminate (zns);
80
81 return 0;
82}
83
84int
85zebra_ns_init (void)
86{
87 dzns = XCALLOC (MTYPE_ZEBRA_NS, sizeof (struct zebra_ns));
88
89 zebra_vrf_init ();
90
91 zebra_ns_enable (0, (void **)&dzns);
92
93 return 0;
94}