]> git.proxmox.com Git - mirror_frr.git/blob - zebra/rtread_sysctl.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / rtread_sysctl.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Kernel routing table read by sysctl function.
4 * Copyright (C) 1997, 98 Kunihiro Ishiguro
5 */
6
7 #include <zebra.h>
8
9 #if !defined(GNU_LINUX)
10
11 #include "memory.h"
12 #include "log.h"
13 #include "vrf.h"
14
15 #include "zebra/rt.h"
16 #include "zebra/kernel_socket.h"
17 #include "zebra/zebra_pbr.h"
18 #include "zebra/zebra_tc.h"
19 #include "zebra/zebra_errors.h"
20
21 /* Kernel routing table read up by sysctl function. */
22 void route_read(struct zebra_ns *zns)
23 {
24 caddr_t buf, end, ref;
25 size_t bufsiz;
26 struct rt_msghdr *rtm;
27
28 #define MIBSIZ 6
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) {
36 flog_warn(EC_ZEBRA_SYSCTL_FAILED, "sysctl fail: %s",
37 safe_strerror(errno));
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) {
46 flog_warn(EC_ZEBRA_SYSCTL_FAILED, "sysctl() fail by %s",
47 safe_strerror(errno));
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;
64 }
65
66 /* Only implemented for the netlink method. */
67 void macfdb_read(struct zebra_ns *zns)
68 {
69 }
70
71 void macfdb_read_for_bridge(struct zebra_ns *zns, struct interface *ifp,
72 struct interface *br_if, vlanid_t vid)
73 {
74 }
75
76 void macfdb_read_mcast_entry_for_vni(struct zebra_ns *zns,
77 struct interface *ifp, vni_t vni)
78 {
79 }
80
81 void macfdb_read_specific_mac(struct zebra_ns *zns, struct interface *br_if,
82 const struct ethaddr *mac, vlanid_t vid)
83 {
84 }
85
86 void neigh_read(struct zebra_ns *zns)
87 {
88 }
89
90 void neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if)
91 {
92 }
93
94 void neigh_read_specific_ip(const struct ipaddr *ip, struct interface *vlan_if)
95 {
96 }
97
98 void kernel_read_pbr_rules(struct zebra_ns *zns)
99 {
100 }
101
102 void kernel_read_tc_qdisc(struct zebra_ns *zns)
103 {
104 }
105
106 void vlan_read(struct zebra_ns *zns)
107 {
108 }
109
110 #endif /* !defined(GNU_LINUX) */