git: ab393e9548f8 - main - netlink: move NETLINK define to opt_global.h

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Fri, 13 Oct 2023 07:24:58 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=ab393e9548f8cc0ee28499c411963b798ebb38a5

commit ab393e9548f8cc0ee28499c411963b798ebb38a5
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-10-12 19:55:57 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-10-13 07:23:47 +0000

    netlink: move NETLINK define to opt_global.h
    
    Move the NETLINK define into opt_global.h so we can rely on it being
    set correctly, without having to remember to include opt_netlink.h.
    This ensures that the NETLINK define is correctly set. If not we
    may end up with unloadable modules, due to missing symbols (such as
    nlmsg_get_group_writer).
    
    PR:             274306
    Reviewed by:    imp, markj
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D42179
---
 sys/compat/linux/linux_netlink.c                        | 1 -
 sys/conf/options                                        | 2 +-
 sys/modules/carp/Makefile                               | 2 +-
 sys/modules/ktest/ktest/Makefile                        | 1 -
 sys/modules/ktest/ktest_example/Makefile                | 1 -
 sys/modules/ktest/ktest_netlink_message_writer/Makefile | 1 -
 sys/modules/linux/Makefile                              | 3 +--
 sys/modules/linux_common/Makefile                       | 3 +--
 sys/modules/netlink/Makefile                            | 2 +-
 sys/net/if_clone.c                                      | 2 --
 sys/net/if_vlan.c                                       | 1 -
 sys/netinet/ip_carp.c                                   | 2 --
 sys/netlink/ktest_netlink_message_writer.c              | 2 --
 sys/netlink/netlink_domain.c                            | 1 -
 sys/netlink/netlink_generic.c                           | 2 --
 sys/netlink/netlink_glue.c                              | 2 --
 sys/netlink/netlink_io.c                                | 2 --
 sys/netlink/netlink_message_writer.c                    | 2 --
 sys/netlink/netlink_module.c                            | 2 --
 sys/netlink/route/iface.c                               | 2 --
 sys/netlink/route/iface_drivers.c                       | 1 -
 sys/netlink/route/neigh.c                               | 2 --
 sys/netlink/route/nexthop.c                             | 2 --
 sys/netlink/route/rt.c                                  | 2 --
 sys/netpfil/pf/pf_nl.c                                  | 2 --
 sys/tests/ktest.c                                       | 2 --
 26 files changed, 5 insertions(+), 42 deletions(-)

diff --git a/sys/compat/linux/linux_netlink.c b/sys/compat/linux/linux_netlink.c
index a6846035c22e..807cdc7a14bc 100644
--- a/sys/compat/linux/linux_netlink.c
+++ b/sys/compat/linux/linux_netlink.c
@@ -27,7 +27,6 @@
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
-#include "opt_netlink.h"
 
 #include <sys/types.h>
 #include <sys/ck.h>
diff --git a/sys/conf/options b/sys/conf/options
index b6cce3b17ebb..4e74c4ab3a70 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -472,7 +472,7 @@ MBUF_PROFILING
 MBUF_STRESS_TEST
 MROUTING		opt_mrouting.h
 NFSLOCKD
-NETLINK			opt_netlink.h
+NETLINK			opt_global.h
 PF_DEFAULT_TO_DROP	opt_pf.h
 ROUTE_MPATH		opt_route.h
 ROUTETABLES		opt_route.h
diff --git a/sys/modules/carp/Makefile b/sys/modules/carp/Makefile
index 5506d1aaec23..d7a85043539f 100644
--- a/sys/modules/carp/Makefile
+++ b/sys/modules/carp/Makefile
@@ -5,6 +5,6 @@
 KMOD=	carp
 SRCS=	ip_carp.c sha1.c
 SRCS+=	device_if.h bus_if.h vnode_if.h
-SRCS+=	opt_carp.h opt_bpf.h opt_inet.h opt_inet6.h opt_ofed.h opt_netlink.h
+SRCS+=	opt_carp.h opt_bpf.h opt_inet.h opt_inet6.h opt_ofed.h
 
 .include <bsd.kmod.mk>
diff --git a/sys/modules/ktest/ktest/Makefile b/sys/modules/ktest/ktest/Makefile
index f72aa5d820db..264eb7b9f443 100644
--- a/sys/modules/ktest/ktest/Makefile
+++ b/sys/modules/ktest/ktest/Makefile
@@ -8,6 +8,5 @@ SYSDIR?=${SRCTOP}/sys
 
 KMOD=	ktest
 SRCS=	ktest.c
-SRCS+=	opt_netlink.h
 
 .include <bsd.kmod.mk>
diff --git a/sys/modules/ktest/ktest_example/Makefile b/sys/modules/ktest/ktest_example/Makefile
index 5b0c9b41f9c8..a5fe6d6d7843 100644
--- a/sys/modules/ktest/ktest_example/Makefile
+++ b/sys/modules/ktest/ktest_example/Makefile
@@ -8,6 +8,5 @@ SYSDIR?=${SRCTOP}/sys
 
 KMOD=	ktest_example
 SRCS=	ktest_example.c
-SRCS+=	opt_netlink.h
 
 .include <bsd.kmod.mk>
diff --git a/sys/modules/ktest/ktest_netlink_message_writer/Makefile b/sys/modules/ktest/ktest_netlink_message_writer/Makefile
index cdcd1d2c190f..2f84b2fecd72 100644
--- a/sys/modules/ktest/ktest_netlink_message_writer/Makefile
+++ b/sys/modules/ktest/ktest_netlink_message_writer/Makefile
@@ -8,7 +8,6 @@ SYSDIR?=${SRCTOP}/sys
 
 KMOD=	ktest_netlink_message_writer
 SRCS=	ktest_netlink_message_writer.c
-SRCS+=	opt_netlink.h
 
 .include <bsd.kmod.mk>
 
diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile
index 51b434d91b00..d1035445ccfb 100644
--- a/sys/modules/linux/Makefile
+++ b/sys/modules/linux/Makefile
@@ -70,8 +70,7 @@ SRCS+=	imgact_linux.c \
 	linux_vdso_selector_x86.c \
 	linux_x86.c \
 	linux_copyout.c \
-	linux_netlink.c \
-	opt_netlink.h
+	linux_netlink.c
 .endif
 
 .if ${MACHINE_CPUARCH} == "i386"
diff --git a/sys/modules/linux_common/Makefile b/sys/modules/linux_common/Makefile
index 07df4555d1ee..374bc32215a2 100644
--- a/sys/modules/linux_common/Makefile
+++ b/sys/modules/linux_common/Makefile
@@ -7,8 +7,7 @@
 KMOD=	linux_common
 SRCS=	linux_common.c linux_mib.c linux_mmap.c linux_util.c linux_emul.c \
 	linux_dummy.c linux_errno.c linux_netlink.c \
-	linux.c device_if.h vnode_if.h bus_if.h opt_inet6.h opt_inet.h \
-	opt_netlink.h
+	linux.c device_if.h vnode_if.h bus_if.h opt_inet6.h opt_inet.h
 
 .if ${MACHINE_CPUARCH} == "amd64"
 SRCS+=	linux_x86.c linux_vdso_selector_x86.c
diff --git a/sys/modules/netlink/Makefile b/sys/modules/netlink/Makefile
index 667c0b2475fe..6835be6e7bd7 100644
--- a/sys/modules/netlink/Makefile
+++ b/sys/modules/netlink/Makefile
@@ -5,7 +5,7 @@ SRCS =	netlink_module.c netlink_domain.c netlink_io.c \
 	netlink_message_writer.c  netlink_generic.c \
 	netlink_route.c route/iface.c route/iface_drivers.c route/neigh.c \
 	route/nexthop.c route/rt.c
-SRCS+=	opt_inet.h opt_inet6.h opt_route.h opt_netlink.h
+SRCS+=	opt_inet.h opt_inet6.h opt_route.h
 
 CFLAGS+=	-DNETLINK_MODULE
 
diff --git a/sys/net/if_clone.c b/sys/net/if_clone.c
index 1a2cea94ad35..5345d613f9d6 100644
--- a/sys/net/if_clone.c
+++ b/sys/net/if_clone.c
@@ -32,8 +32,6 @@
  *	@(#)if.c	8.5 (Berkeley) 1/9/95
  */
 
-#include "opt_netlink.h"
-
 #include <sys/param.h>
 #include <sys/eventhandler.h>
 #include <sys/malloc.h>
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index e7a290564722..b69d8107e30d 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -46,7 +46,6 @@
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_kern_tls.h"
-#include "opt_netlink.h"
 #include "opt_vlan.h"
 #include "opt_ratelimit.h"
 
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index e8ed6afd3853..66ec28e49af3 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -28,8 +28,6 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 #include "opt_bpf.h"
 #include "opt_inet.h"
diff --git a/sys/netlink/ktest_netlink_message_writer.c b/sys/netlink/ktest_netlink_message_writer.c
index c13a25e05a70..e46065dd4bd2 100644
--- a/sys/netlink/ktest_netlink_message_writer.c
+++ b/sys/netlink/ktest_netlink_message_writer.c
@@ -25,8 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <tests/ktest.h>
 #include <sys/cdefs.h>
 #include <sys/systm.h>
diff --git a/sys/netlink/netlink_domain.c b/sys/netlink/netlink_domain.c
index 262361773fbb..7b2bbd39447d 100644
--- a/sys/netlink/netlink_domain.c
+++ b/sys/netlink/netlink_domain.c
@@ -30,7 +30,6 @@
  * This file contains socket and protocol bindings for netlink.
  */
 
-#include "opt_netlink.h"
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/malloc.h>
diff --git a/sys/netlink/netlink_generic.c b/sys/netlink/netlink_generic.c
index b28b206a7ace..b7600b2b6b71 100644
--- a/sys/netlink/netlink_generic.c
+++ b/sys/netlink/netlink_generic.c
@@ -25,8 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <sys/ck.h>
diff --git a/sys/netlink/netlink_glue.c b/sys/netlink/netlink_glue.c
index 29eac82aaffd..e7649c6b13dc 100644
--- a/sys/netlink/netlink_glue.c
+++ b/sys/netlink/netlink_glue.c
@@ -25,8 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/malloc.h>
diff --git a/sys/netlink/netlink_io.c b/sys/netlink/netlink_io.c
index 0745f7fdcb77..0ca71fb6219b 100644
--- a/sys/netlink/netlink_io.c
+++ b/sys/netlink/netlink_io.c
@@ -26,8 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 #include <sys/param.h>
 #include <sys/ck.h>
diff --git a/sys/netlink/netlink_message_writer.c b/sys/netlink/netlink_message_writer.c
index 9fc0eddc78ec..8443cc59d9e0 100644
--- a/sys/netlink/netlink_message_writer.c
+++ b/sys/netlink/netlink_message_writer.c
@@ -25,8 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 #include <sys/param.h>
 #include <sys/malloc.h>
diff --git a/sys/netlink/netlink_module.c b/sys/netlink/netlink_module.c
index ba56ac6d6a17..b4073721fdc4 100644
--- a/sys/netlink/netlink_module.c
+++ b/sys/netlink/netlink_module.c
@@ -26,8 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 #include <sys/param.h>
 #include <sys/kernel.h>
diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c
index b6e120933f83..0587b478431e 100644
--- a/sys/netlink/route/iface.c
+++ b/sys/netlink/route/iface.c
@@ -25,8 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 #include "opt_inet.h"
 #include "opt_inet6.h"
diff --git a/sys/netlink/route/iface_drivers.c b/sys/netlink/route/iface_drivers.c
index 1a7aaffa7dd7..4bf913d9c978 100644
--- a/sys/netlink/route/iface_drivers.c
+++ b/sys/netlink/route/iface_drivers.c
@@ -25,7 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
 #include <sys/cdefs.h>
 #include "opt_inet.h"
 #include "opt_inet6.h"
diff --git a/sys/netlink/route/neigh.c b/sys/netlink/route/neigh.c
index 4168b5936ddc..9914e7febf57 100644
--- a/sys/netlink/route/neigh.c
+++ b/sys/netlink/route/neigh.c
@@ -25,8 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 #include "opt_inet.h"
 #include "opt_inet6.h"
diff --git a/sys/netlink/route/nexthop.c b/sys/netlink/route/nexthop.c
index 722dc5fdee4e..0d6bb5c9ec84 100644
--- a/sys/netlink/route/nexthop.c
+++ b/sys/netlink/route/nexthop.c
@@ -25,8 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 #include "opt_inet.h"
 #include "opt_inet6.h"
diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c
index 2a6a0bc54e85..cfaa2167b0d2 100644
--- a/sys/netlink/route/rt.c
+++ b/sys/netlink/route/rt.c
@@ -26,8 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 #include "opt_inet.h"
 #include "opt_inet6.h"
diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c
index bb50b3b2b321..459a5dc6507e 100644
--- a/sys/netpfil/pf/pf_nl.c
+++ b/sys/netpfil/pf/pf_nl.c
@@ -27,8 +27,6 @@
  *
  */
 
-#include "opt_netlink.h"
-
 #include <sys/cdefs.h>
 
 #include <sys/param.h>
diff --git a/sys/tests/ktest.c b/sys/tests/ktest.c
index 495fedf95dde..cd83a6aaaa3f 100644
--- a/sys/tests/ktest.c
+++ b/sys/tests/ktest.c
@@ -25,8 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include "opt_netlink.h"
-
 #include <sys/param.h>
 #include <sys/refcount.h>
 #include <sys/types.h>