]>
git.proxmox.com Git - mirror_frr.git/blob - zebra/rtread_sysctl.c
2 * Kernel routing table read by sysctl function.
3 * Copyright (C) 1997, 98 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
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
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.
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
24 #if !defined(GNU_LINUX) && !defined(SUNOS_5)
27 #include "zebra_memory.h"
32 #include "zebra/kernel_socket.h"
33 #include "zebra/zebra_pbr.h"
34 #include "zebra/zebra_errors.h"
36 /* Kernel routing table read up by sysctl function. */
37 void route_read(struct zebra_ns
*zns
)
39 caddr_t buf
, end
, ref
;
41 struct rt_msghdr
*rtm
;
44 int mib
[MIBSIZ
] = {CTL_NET
, PF_ROUTE
, 0, 0, NET_RT_DUMP
, 0};
46 if (zns
->ns_id
!= NS_DEFAULT
)
49 /* Get buffer size. */
50 if (sysctl(mib
, MIBSIZ
, NULL
, &bufsiz
, NULL
, 0) < 0) {
51 flog_warn(EC_ZEBRA_SYSCTL_FAILED
, "sysctl fail: %s",
52 safe_strerror(errno
));
56 /* Allocate buffer. */
57 ref
= buf
= XMALLOC(MTYPE_TMP
, bufsiz
);
59 /* Read routing table information by calling sysctl(). */
60 if (sysctl(mib
, MIBSIZ
, buf
, &bufsiz
, NULL
, 0) < 0) {
61 flog_warn(EC_ZEBRA_SYSCTL_FAILED
, "sysctl() fail by %s",
62 safe_strerror(errno
));
63 XFREE(MTYPE_TMP
, ref
);
67 for (end
= buf
+ bufsiz
; buf
< end
; buf
+= rtm
->rtm_msglen
) {
68 rtm
= (struct rt_msghdr
*)buf
;
69 /* We must set RTF_DONE here, so rtm_read() doesn't ignore the
71 SET_FLAG(rtm
->rtm_flags
, RTF_DONE
);
76 XFREE(MTYPE_TMP
, ref
);
81 /* Only implemented for the netlink method. */
82 void macfdb_read(struct zebra_ns
*zns
)
86 void macfdb_read_for_bridge(struct zebra_ns
*zns
, struct interface
*ifp
,
87 struct interface
*br_if
)
91 void macfdb_read_specific_mac(struct zebra_ns
*zns
, struct interface
*br_if
,
92 struct ethaddr
*mac
, vlanid_t vid
)
96 void neigh_read(struct zebra_ns
*zns
)
100 void neigh_read_for_vlan(struct zebra_ns
*zns
, struct interface
*vlan_if
)
104 void neigh_read_specific_ip(struct ipaddr
*ip
, struct interface
*vlan_if
)
108 void kernel_read_pbr_rules(struct zebra_ns
*zns
)
112 #endif /* !defined(GNU_LINUX) && !defined(SUNOS_5) */