From 8e63db05f5fc41c53382c5203d81ab6dad010232 Mon Sep 17 00:00:00 2001 From: Alexander Chernikov Date: Tue, 13 Sep 2022 12:08:58 +0000 Subject: [PATCH 1/1] FreeBSD: add netlink support Netlink can be enabled by picking new sysconfig target: ./configure --with-sysconfig=bsd-netlink --- sysdep/bsd-netlink/Makefile | 6 ++++++ sysdep/cf/bsd-netlink.h | 34 ++++++++++++++++++++++++++++++++++ sysdep/cf/linux.h | 2 ++ sysdep/linux/netlink.c | 7 ++++++- 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 sysdep/bsd-netlink/Makefile create mode 100644 sysdep/cf/bsd-netlink.h diff --git a/sysdep/bsd-netlink/Makefile b/sysdep/bsd-netlink/Makefile new file mode 100644 index 00000000..b34cb9cc --- /dev/null +++ b/sysdep/bsd-netlink/Makefile @@ -0,0 +1,6 @@ +src := ../linux/netlink.c +obj := $(src-o-files) +$(all-daemon) +$(conf-y-targets): $(s)../linux/netlink.Y + +tests_objs := $(tests_objs) $(src-o-files) diff --git a/sysdep/cf/bsd-netlink.h b/sysdep/cf/bsd-netlink.h new file mode 100644 index 00000000..09149dc4 --- /dev/null +++ b/sysdep/cf/bsd-netlink.h @@ -0,0 +1,34 @@ +/* + * Configuration for FreeBSD based systems with netlink support + * + * (c) 2022 Alexander Chernikov + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#define CONFIG_AUTO_ROUTES +#define CONFIG_SELF_CONSCIOUS +#define CONFIG_MULTIPLE_TABLES +#define CONFIG_SINGLE_ROUTE + +#define CONFIG_SKIP_MC_BIND +#define CONFIG_NO_IFACE_BIND +#define CONFIG_USE_HDRINCL + +#define CONFIG_INCLUDE_SYSIO_H "sysdep/bsd/sysio.h" +#define CONFIG_INCLUDE_KRTSYS_H "sysdep/linux/krt-sys.h" + +#define CONFIG_FREEBSD_NETLINK + +#ifndef AF_MPLS +#define AF_MPLS 39 +#endif + +#ifndef SO_RCVBUFFORCE +#define SO_RCVBUFFORCE SO_RCVBUF +#endif + +/* +Link: sysdep/unix +Link: sysdep/bsd-netlink + */ diff --git a/sysdep/cf/linux.h b/sysdep/cf/linux.h index 56ecf017..334dd749 100644 --- a/sysdep/cf/linux.h +++ b/sysdep/cf/linux.h @@ -17,6 +17,8 @@ #define CONFIG_INCLUDE_SYSIO_H "sysdep/linux/sysio.h" #define CONFIG_INCLUDE_KRTSYS_H "sysdep/linux/krt-sys.h" +#define CONFIG_LINUX_NETLINK + #define CONFIG_RESTRICTED_PRIVILEGES #define CONFIG_INCLUDE_SYSPRIV_H "sysdep/linux/syspriv.h" diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index d9e81c10..dcb25911 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -6,7 +6,6 @@ * Can be freely distributed and used under the terms of the GNU GPL. */ -#include #include #include #include @@ -28,10 +27,16 @@ #include "lib/hash.h" #include "conf/conf.h" +#ifdef CONFIG_LINUX_NETLINK #include #include #include #include +#endif +#ifdef CONFIG_FREEBSD_NETLINK +#include +#include +#endif #ifdef HAVE_MPLS_KERNEL #include -- 2.37.1