]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * Kernel routing table read by sysctl function. | |
3 | * Copyright (C) 1997, 98 Kunihiro Ishiguro | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra 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 | * GNU Zebra 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 | |
718e3744 | 20 | */ |
21 | ||
22 | #include <zebra.h> | |
23 | ||
ddfeb486 DL |
24 | #if !defined(GNU_LINUX) && !defined(SUNOS_5) |
25 | ||
718e3744 | 26 | #include "memory.h" |
4a1ab8e4 | 27 | #include "zebra_memory.h" |
718e3744 | 28 | #include "log.h" |
8f7d9fc0 | 29 | #include "vrf.h" |
718e3744 | 30 | |
6621ca86 | 31 | #include "zebra/rt.h" |
ec1a4283 | 32 | #include "zebra/kernel_socket.h" |
6621ca86 | 33 | |
718e3744 | 34 | /* Kernel routing table read up by sysctl function. */ |
d62a17ae | 35 | void route_read(struct zebra_ns *zns) |
718e3744 | 36 | { |
d62a17ae | 37 | caddr_t buf, end, ref; |
38 | size_t bufsiz; | |
39 | struct rt_msghdr *rtm; | |
40 | ||
718e3744 | 41 | #define MIBSIZ 6 |
d62a17ae | 42 | int mib[MIBSIZ] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_DUMP, 0}; |
43 | ||
44 | if (zns->ns_id != NS_DEFAULT) | |
45 | return; | |
46 | ||
47 | /* Get buffer size. */ | |
48 | if (sysctl(mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0) { | |
49 | zlog_warn("sysctl fail: %s", safe_strerror(errno)); | |
50 | return; | |
51 | } | |
52 | ||
53 | /* Allocate buffer. */ | |
54 | ref = buf = XMALLOC(MTYPE_TMP, bufsiz); | |
55 | ||
56 | /* Read routing table information by calling sysctl(). */ | |
57 | if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0) { | |
58 | zlog_warn("sysctl() fail by %s", safe_strerror(errno)); | |
59 | XFREE(MTYPE_TMP, ref); | |
60 | return; | |
61 | } | |
62 | ||
63 | for (end = buf + bufsiz; buf < end; buf += rtm->rtm_msglen) { | |
64 | rtm = (struct rt_msghdr *)buf; | |
65 | /* We must set RTF_DONE here, so rtm_read() doesn't ignore the | |
66 | * message. */ | |
67 | SET_FLAG(rtm->rtm_flags, RTF_DONE); | |
68 | rtm_read(rtm); | |
69 | } | |
70 | ||
71 | /* Free buffer. */ | |
72 | XFREE(MTYPE_TMP, ref); | |
73 | ||
74 | return; | |
718e3744 | 75 | } |
2232a77c | 76 | |
77 | /* Only implemented for the netlink method. */ | |
d62a17ae | 78 | void macfdb_read(struct zebra_ns *zns) |
2232a77c | 79 | { |
80 | } | |
81 | ||
d62a17ae | 82 | void macfdb_read_for_bridge(struct zebra_ns *zns, struct interface *ifp, |
83 | struct interface *br_if) | |
2232a77c | 84 | { |
85 | } | |
86 | ||
d62a17ae | 87 | void neigh_read(struct zebra_ns *zns) |
2232a77c | 88 | { |
89 | } | |
90 | ||
d62a17ae | 91 | void neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if) |
2232a77c | 92 | { |
93 | } | |
ddfeb486 DL |
94 | |
95 | #endif /* !defined(GNU_LINUX) && !defined(SUNOS_5) */ |