]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Netlink on FreeBSD support
authorAlexander V. Chernikov <melifaro@ipfw.ru>
Fri, 9 Dec 2022 14:59:06 +0000 (15:59 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 9 Dec 2022 15:01:30 +0000 (16:01 +0100)
Netlink support was added to FreeBSD recently. It is not as full-featured
as its Linux counterpart yet, however the added subset is enough to make
a routing daemon work. Specifically, it supports multiple tables,
multipath, nexthops and nexthops groups. No MPLS support yet.

The attached change adds 'bsd-netlink’ sysconf target, allowing to build
both netlink & rtsock versions on FreeBSD.

sysdep/cf/bsd-netlink.h [new file with mode: 0644]
sysdep/cf/linux.h
sysdep/linux/netlink.c

diff --git a/sysdep/cf/bsd-netlink.h b/sysdep/cf/bsd-netlink.h
new file mode 100644 (file)
index 0000000..09149dc
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *     Configuration for FreeBSD based systems with netlink support
+ *
+ *     (c) 2022 Alexander Chernikov <melifaro@FreeBSD.org>
+ *
+ *     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
+ */
index 56ecf017667542e04722703b714eb1e57d2a39ba..85598c10248bcf619b45fa0681795a5b9d650780 100644 (file)
@@ -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"
 
index d9e81c104ac42bbfd448e2b652c625c5a9c623c8..dcb2591179129a35361ac2d5b936491ac04ea92f 100644 (file)
@@ -6,7 +6,6 @@
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
 
-#include <alloca.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include "lib/hash.h"
 #include "conf/conf.h"
 
+#ifdef CONFIG_LINUX_NETLINK
 #include <asm/types.h>
 #include <linux/if.h>
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
+#endif
+#ifdef CONFIG_FREEBSD_NETLINK
+#include <netlink/netlink.h>
+#include <netlink/netlink_route.h>
+#endif
 
 #ifdef HAVE_MPLS_KERNEL
 #include <linux/lwtunnel.h>