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