]>
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 | ||
cae8bc96 | 24 | #if !defined(GNU_LINUX) |
ddfeb486 | 25 | |
718e3744 | 26 | #include "memory.h" |
27 | #include "log.h" | |
8f7d9fc0 | 28 | #include "vrf.h" |
718e3744 | 29 | |
6621ca86 | 30 | #include "zebra/rt.h" |
ec1a4283 | 31 | #include "zebra/kernel_socket.h" |
942bf97b | 32 | #include "zebra/zebra_pbr.h" |
364fed6b | 33 | #include "zebra/zebra_errors.h" |
6621ca86 | 34 | |
718e3744 | 35 | /* Kernel routing table read up by sysctl function. */ |
d62a17ae | 36 | void route_read(struct zebra_ns *zns) |
718e3744 | 37 | { |
d62a17ae | 38 | caddr_t buf, end, ref; |
39 | size_t bufsiz; | |
40 | struct rt_msghdr *rtm; | |
41 | ||
718e3744 | 42 | #define MIBSIZ 6 |
d62a17ae | 43 | int mib[MIBSIZ] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_DUMP, 0}; |
44 | ||
45 | if (zns->ns_id != NS_DEFAULT) | |
46 | return; | |
47 | ||
48 | /* Get buffer size. */ | |
49 | if (sysctl(mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0) { | |
e914ccbe | 50 | flog_warn(EC_ZEBRA_SYSCTL_FAILED, "sysctl fail: %s", |
9df414fe | 51 | safe_strerror(errno)); |
d62a17ae | 52 | return; |
53 | } | |
54 | ||
55 | /* Allocate buffer. */ | |
56 | ref = buf = XMALLOC(MTYPE_TMP, bufsiz); | |
57 | ||
58 | /* Read routing table information by calling sysctl(). */ | |
59 | if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0) { | |
e914ccbe | 60 | flog_warn(EC_ZEBRA_SYSCTL_FAILED, "sysctl() fail by %s", |
9df414fe | 61 | safe_strerror(errno)); |
d62a17ae | 62 | XFREE(MTYPE_TMP, ref); |
63 | return; | |
64 | } | |
65 | ||
66 | for (end = buf + bufsiz; buf < end; buf += rtm->rtm_msglen) { | |
67 | rtm = (struct rt_msghdr *)buf; | |
68 | /* We must set RTF_DONE here, so rtm_read() doesn't ignore the | |
69 | * message. */ | |
70 | SET_FLAG(rtm->rtm_flags, RTF_DONE); | |
71 | rtm_read(rtm); | |
72 | } | |
73 | ||
74 | /* Free buffer. */ | |
75 | XFREE(MTYPE_TMP, ref); | |
76 | ||
77 | return; | |
718e3744 | 78 | } |
2232a77c | 79 | |
80 | /* Only implemented for the netlink method. */ | |
d62a17ae | 81 | void macfdb_read(struct zebra_ns *zns) |
2232a77c | 82 | { |
83 | } | |
84 | ||
d62a17ae | 85 | void macfdb_read_for_bridge(struct zebra_ns *zns, struct interface *ifp, |
86 | struct interface *br_if) | |
2232a77c | 87 | { |
88 | } | |
89 | ||
67fb9374 | 90 | void macfdb_read_specific_mac(struct zebra_ns *zns, struct interface *br_if, |
1a3bd37f | 91 | const struct ethaddr *mac, vlanid_t vid) |
67fb9374 CS |
92 | { |
93 | } | |
94 | ||
d62a17ae | 95 | void neigh_read(struct zebra_ns *zns) |
2232a77c | 96 | { |
97 | } | |
98 | ||
d62a17ae | 99 | void neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if) |
2232a77c | 100 | { |
101 | } | |
ddfeb486 | 102 | |
1a3bd37f | 103 | void neigh_read_specific_ip(const struct ipaddr *ip, struct interface *vlan_if) |
67fb9374 CS |
104 | { |
105 | } | |
106 | ||
942bf97b | 107 | void kernel_read_pbr_rules(struct zebra_ns *zns) |
108 | { | |
109 | } | |
110 | ||
cae8bc96 | 111 | #endif /* !defined(GNU_LINUX) */ |