2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2002-12-13 21:15:29 +01:00
|
|
|
/*
|
|
|
|
* Kernel routing table read by sysctl function.
|
|
|
|
* Copyright (C) 1997, 98 Kunihiro Ishiguro
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
2024-01-04 22:09:47 +01:00
|
|
|
#include <net/route.h>
|
|
|
|
|
2020-09-09 05:59:18 +02:00
|
|
|
#if !defined(GNU_LINUX)
|
2017-07-26 19:49:15 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "memory.h"
|
|
|
|
#include "log.h"
|
2014-07-03 12:23:09 +02:00
|
|
|
#include "vrf.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
[zebra] fix some small compile errors, mark several functions static
2005-11-23 Paul Jakma <paul.jakma@sun.com>
* (general) fix some small compile errors, and mark several
functions as static.
* kernel_socket.c: (ifan_read) should be static.
fix missing brackets.
(ifm_read,ifam_read,rtm_read_mesg,kernel_read) Make static
(ifam_read_mesg) make static. fix incorrect variable name.
(rtm_read) make static. Fix call to rib_delete_ipv4 which
should be rib_delete_ipv6.
(routing_socket,kernel_init) should be static. Void argument
should be specified as such, not left incomplete.
* rt_netlink.c: rt.h should be included, contains prototypes of
exported functions.
(kernel_delete_ipv6_old) fix sign of index argument.
* rt_socket.c: Exact same as previous. Also, make various
functions static.
* rtread_getmsg.c: Include zserv.h, which prototypes
route_read. Make static.
* rtread_sysctl.c: zserv.h and rt.h should be included.
fix definition of route_read.
2005-11-23 14:02:08 +01:00
|
|
|
#include "zebra/rt.h"
|
2005-11-24 16:15:17 +01:00
|
|
|
#include "zebra/kernel_socket.h"
|
2018-02-04 13:33:33 +01:00
|
|
|
#include "zebra/zebra_pbr.h"
|
2022-09-06 09:10:11 +02:00
|
|
|
#include "zebra/zebra_tc.h"
|
2018-08-24 19:14:09 +02:00
|
|
|
#include "zebra/zebra_errors.h"
|
[zebra] fix some small compile errors, mark several functions static
2005-11-23 Paul Jakma <paul.jakma@sun.com>
* (general) fix some small compile errors, and mark several
functions as static.
* kernel_socket.c: (ifan_read) should be static.
fix missing brackets.
(ifm_read,ifam_read,rtm_read_mesg,kernel_read) Make static
(ifam_read_mesg) make static. fix incorrect variable name.
(rtm_read) make static. Fix call to rib_delete_ipv4 which
should be rib_delete_ipv6.
(routing_socket,kernel_init) should be static. Void argument
should be specified as such, not left incomplete.
* rt_netlink.c: rt.h should be included, contains prototypes of
exported functions.
(kernel_delete_ipv6_old) fix sign of index argument.
* rt_socket.c: Exact same as previous. Also, make various
functions static.
* rtread_getmsg.c: Include zserv.h, which prototypes
route_read. Make static.
* rtread_sysctl.c: zserv.h and rt.h should be included.
fix definition of route_read.
2005-11-23 14:02:08 +01:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Kernel routing table read up by sysctl function. */
|
2016-02-01 19:55:42 +01:00
|
|
|
void route_read(struct zebra_ns *zns)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
caddr_t buf, end, ref;
|
|
|
|
size_t bufsiz;
|
|
|
|
struct rt_msghdr *rtm;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#define MIBSIZ 6
|
|
|
|
int mib[MIBSIZ] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_DUMP, 0};
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-02-01 19:55:42 +01:00
|
|
|
if (zns->ns_id != NS_DEFAULT)
|
2014-07-03 12:23:09 +02:00
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Get buffer size. */
|
|
|
|
if (sysctl(mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0) {
|
2018-09-13 21:21:05 +02:00
|
|
|
flog_warn(EC_ZEBRA_SYSCTL_FAILED, "sysctl fail: %s",
|
2018-08-16 22:10:32 +02:00
|
|
|
safe_strerror(errno));
|
2005-11-24 16:15:17 +01:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Allocate buffer. */
|
|
|
|
ref = buf = XMALLOC(MTYPE_TMP, bufsiz);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Read routing table information by calling sysctl(). */
|
|
|
|
if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0) {
|
2018-09-13 21:21:05 +02:00
|
|
|
flog_warn(EC_ZEBRA_SYSCTL_FAILED, "sysctl() fail by %s",
|
2018-08-16 22:10:32 +02:00
|
|
|
safe_strerror(errno));
|
2015-09-02 14:19:44 +02:00
|
|
|
XFREE(MTYPE_TMP, ref);
|
2005-11-24 16:15:17 +01:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
for (end = buf + bufsiz; buf < end; buf += rtm->rtm_msglen) {
|
|
|
|
rtm = (struct rt_msghdr *)buf;
|
2007-09-06 16:34:41 +02:00
|
|
|
/* We must set RTF_DONE here, so rtm_read() doesn't ignore the
|
|
|
|
* message. */
|
|
|
|
SET_FLAG(rtm->rtm_flags, RTF_DONE);
|
2002-12-13 21:15:29 +01:00
|
|
|
rtm_read(rtm);
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Free buffer. */
|
|
|
|
XFREE(MTYPE_TMP, ref);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2005-11-24 16:15:17 +01:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-05-15 07:44:13 +02:00
|
|
|
|
|
|
|
/* Only implemented for the netlink method. */
|
|
|
|
void macfdb_read(struct zebra_ns *zns)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void macfdb_read_for_bridge(struct zebra_ns *zns, struct interface *ifp,
|
2021-07-27 09:47:52 +02:00
|
|
|
struct interface *br_if, vlanid_t vid)
|
2017-05-15 07:44:13 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-07-27 18:29:00 +02:00
|
|
|
void macfdb_read_mcast_entry_for_vni(struct zebra_ns *zns,
|
|
|
|
struct interface *ifp, vni_t vni)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-12-11 06:33:16 +01:00
|
|
|
void macfdb_read_specific_mac(struct zebra_ns *zns, struct interface *br_if,
|
2021-04-19 20:26:57 +02:00
|
|
|
const struct ethaddr *mac, vlanid_t vid)
|
2018-12-11 06:33:16 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-05-15 07:44:13 +02:00
|
|
|
void neigh_read(struct zebra_ns *zns)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void neigh_read_for_vlan(struct zebra_ns *zns, struct interface *vlan_if)
|
|
|
|
{
|
|
|
|
}
|
2017-07-26 19:49:15 +02:00
|
|
|
|
2021-04-19 20:26:57 +02:00
|
|
|
void neigh_read_specific_ip(const struct ipaddr *ip, struct interface *vlan_if)
|
2018-12-11 06:33:16 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-02-04 13:33:33 +01:00
|
|
|
void kernel_read_pbr_rules(struct zebra_ns *zns)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-09-06 09:10:11 +02:00
|
|
|
void kernel_read_tc_qdisc(struct zebra_ns *zns)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-04-28 21:45:29 +02:00
|
|
|
void vlan_read(struct zebra_ns *zns)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-09-09 05:59:18 +02:00
|
|
|
#endif /* !defined(GNU_LINUX) */
|