netlink: add NETLINK/NETLINK_SUPPORT userland options.
Make userland tools such as netstat, route, arp and ndp use either netlink or rtsock interfaces based on the NETLINK_SUPPORT options. Both NETLINK and NETLINK_SUPPORT options are turned on by default. Reviewed By: eugen Differential Revision: https://reviews.freebsd.org/D39148
This commit is contained in:
parent
04f75b9802
commit
64dfea8651
@ -145,6 +145,7 @@ __DEFAULT_YES_OPTIONS = \
|
|||||||
MLX5TOOL \
|
MLX5TOOL \
|
||||||
NETCAT \
|
NETCAT \
|
||||||
NETGRAPH \
|
NETGRAPH \
|
||||||
|
NETLINK \
|
||||||
NLS_CATALOGS \
|
NLS_CATALOGS \
|
||||||
NS_CACHING \
|
NS_CACHING \
|
||||||
NTP \
|
NTP \
|
||||||
@ -233,6 +234,7 @@ __DEFAULT_DEPENDENT_OPTIONS= \
|
|||||||
KERBEROS \
|
KERBEROS \
|
||||||
KVM \
|
KVM \
|
||||||
NETGRAPH \
|
NETGRAPH \
|
||||||
|
NETLINK \
|
||||||
PAM \
|
PAM \
|
||||||
TESTS \
|
TESTS \
|
||||||
WIRELESS
|
WIRELESS
|
||||||
|
5
tools/build/options/WITHOUT_NETLINK_SUPPORT
Normal file
5
tools/build/options/WITHOUT_NETLINK_SUPPORT
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.\" $FreeBSD$
|
||||||
|
Make libraries and programs use rtsock and
|
||||||
|
.Xr sysctl 3
|
||||||
|
interfaces instead of
|
||||||
|
.Xr snl 3 .
|
@ -6,7 +6,6 @@
|
|||||||
PROG= netstat
|
PROG= netstat
|
||||||
SRCS= if.c inet.c main.c mbuf.c mroute.c netisr.c nl_symbols.c route.c \
|
SRCS= if.c inet.c main.c mbuf.c mroute.c netisr.c nl_symbols.c route.c \
|
||||||
unix.c mroute6.c ipsec.c bpf.c pfkey.c sctp.c common.c nhops.c nhgrp.c \
|
unix.c mroute6.c ipsec.c bpf.c pfkey.c sctp.c common.c nhops.c nhgrp.c \
|
||||||
route_netlink.c \
|
|
||||||
nl_defs.h
|
nl_defs.h
|
||||||
|
|
||||||
nl_symbols.c: nlist_symbols
|
nl_symbols.c: nlist_symbols
|
||||||
@ -64,4 +63,10 @@ LIBADD+= netgraph
|
|||||||
CFLAGS+=-DNETGRAPH
|
CFLAGS+=-DNETGRAPH
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
.if ${MK_NETLINK_SUPPORT} != "no"
|
||||||
|
SRCS+= route_netlink.c
|
||||||
|
.else
|
||||||
|
CFLAGS+=-DWITHOUT_NETLINK
|
||||||
|
.endif
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -96,16 +96,20 @@ struct bits rt_bits[] = {
|
|||||||
{ 0 , 0, NULL }
|
{ 0 , 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef WITHOUT_NETLINK
|
||||||
static struct ifmap_entry *ifmap;
|
static struct ifmap_entry *ifmap;
|
||||||
static size_t ifmap_size;
|
static size_t ifmap_size;
|
||||||
|
#endif
|
||||||
static struct timespec uptime;
|
static struct timespec uptime;
|
||||||
|
|
||||||
static const char *netname4(in_addr_t, in_addr_t);
|
static const char *netname4(in_addr_t, in_addr_t);
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
static const char *netname6(struct sockaddr_in6 *, struct sockaddr_in6 *);
|
static const char *netname6(struct sockaddr_in6 *, struct sockaddr_in6 *);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef WITHOUT_NETLINK
|
||||||
static void p_rtable_sysctl(int, int);
|
static void p_rtable_sysctl(int, int);
|
||||||
static void p_rtentry_sysctl(const char *name, struct rt_msghdr *);
|
static void p_rtentry_sysctl(const char *name, struct rt_msghdr *);
|
||||||
|
#endif
|
||||||
static void domask(char *, size_t, u_long);
|
static void domask(char *, size_t, u_long);
|
||||||
|
|
||||||
const uint32_t rt_default_weight = RT_DEFAULT_WEIGHT;
|
const uint32_t rt_default_weight = RT_DEFAULT_WEIGHT;
|
||||||
@ -143,8 +147,11 @@ routepr(int fibnum, int af)
|
|||||||
if (fibnum)
|
if (fibnum)
|
||||||
xo_emit(" ({L:fib}: {:fib/%d})", fibnum);
|
xo_emit(" ({L:fib}: {:fib/%d})", fibnum);
|
||||||
xo_emit("\n");
|
xo_emit("\n");
|
||||||
if (!p_rtable_netlink(fibnum, af))
|
#ifdef WITHOUT_NETLINK
|
||||||
p_rtable_sysctl(fibnum, af);
|
p_rtable_sysctl(fibnum, af);
|
||||||
|
#else
|
||||||
|
p_rtable_netlink(fibnum, af);
|
||||||
|
#endif
|
||||||
xo_close_container("route-information");
|
xo_close_container("route-information");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +247,7 @@ set_wid(int fam)
|
|||||||
wid.expire = 6;
|
wid.expire = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WITHOUT_NETLINK
|
||||||
static void
|
static void
|
||||||
p_rtable_sysctl(int fibnum, int af)
|
p_rtable_sysctl(int fibnum, int af)
|
||||||
{
|
{
|
||||||
@ -365,6 +373,7 @@ p_rtentry_sysctl(const char *name, struct rt_msghdr *rtm)
|
|||||||
xo_emit("\n");
|
xo_emit("\n");
|
||||||
xo_close_instance(name);
|
xo_close_instance(name);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
p_sockaddr(const char *name, struct sockaddr *sa, struct sockaddr *mask,
|
p_sockaddr(const char *name, struct sockaddr *sa, struct sockaddr *mask,
|
||||||
|
Loading…
Reference in New Issue
Block a user