git: 9e79038c5024 - main - netlink: fix netlink interface operations when netlink is loaded as a module.

From: Alexander V. Chernikov <melifaro_at_FreeBSD.org>
Date: Fri, 28 Apr 2023 13:56:18 UTC
The branch main has been updated by melifaro:

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

commit 9e79038c502433f077b4d3b5bb1c0838329f1ebc
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2023-04-28 13:30:36 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2023-04-28 13:35:58 +0000

    netlink: fix netlink interface operations when netlink is loaded as a module.
    
    This change completes 089104e0e01f.
    
    MFC after:      2 weeks
---
 sys/netlink/netlink_module.c      |  2 ++
 sys/netlink/route/iface_drivers.c |  5 +++--
 sys/netlink/route/route_var.h     | 22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/sys/netlink/netlink_module.c b/sys/netlink/netlink_module.c
index 051eb0cb120b..31faf1d003d9 100644
--- a/sys/netlink/netlink_module.c
+++ b/sys/netlink/netlink_module.c
@@ -187,6 +187,8 @@ const static struct nl_function_wrapper nl_module = {
 	.nlmsg_get_group_writer = _nlmsg_get_group_writer,
 	.nlmsg_get_chain_writer = _nlmsg_get_chain_writer,
 	.nlmsg_end_dump = _nlmsg_end_dump,
+	.nl_modify_ifp_generic = _nl_modify_ifp_generic,
+	.nl_store_ifp_cookie = _nl_store_ifp_cookie,
 };
 #endif
 
diff --git a/sys/netlink/route/iface_drivers.c b/sys/netlink/route/iface_drivers.c
index 17fbc1000d23..6f6adc323be6 100644
--- a/sys/netlink/route/iface_drivers.c
+++ b/sys/netlink/route/iface_drivers.c
@@ -25,6 +25,7 @@
  * SUCH DAMAGE.
  */
 
+#include "opt_netlink.h"
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 #include "opt_inet.h"
@@ -64,7 +65,7 @@ _DECLARE_DEBUG(LOG_DEBUG);
  * such as state, mtu or description.
  */
 int
-nl_modify_ifp_generic(struct ifnet *ifp, struct nl_parsed_link *lattrs,
+_nl_modify_ifp_generic(struct ifnet *ifp, struct nl_parsed_link *lattrs,
     const struct nlattr_bmask *bm, struct nl_pstate *npt)
 {
 	int error;
@@ -118,7 +119,7 @@ nl_modify_ifp_generic(struct ifnet *ifp, struct nl_parsed_link *lattrs,
  *  IFLA_IFNAME(string)
  */
 void
-nl_store_ifp_cookie(struct nl_pstate *npt, struct ifnet *ifp)
+_nl_store_ifp_cookie(struct nl_pstate *npt, struct ifnet *ifp)
 {
 	int ifname_len = strlen(if_name(ifp));
 	uint32_t ifindex = (uint32_t)ifp->if_index;
diff --git a/sys/netlink/route/route_var.h b/sys/netlink/route/route_var.h
index cbcc71e9ac21..7b83a533fdc2 100644
--- a/sys/netlink/route/route_var.h
+++ b/sys/netlink/route/route_var.h
@@ -77,9 +77,31 @@ struct nl_parsed_link {
 	uint32_t	ifi_change;
 };
 
+#if defined(NETLINK) || defined(NETLINK_MODULE)
+/* Provide optimized calls to the functions inside the same linking unit */
+
+int _nl_modify_ifp_generic(struct ifnet *ifp, struct nl_parsed_link *lattrs,
+    const struct nlattr_bmask *bm, struct nl_pstate *npt);
+void _nl_store_ifp_cookie(struct nl_pstate *npt, struct ifnet *ifp);
+
+static inline int
+nl_modify_ifp_generic(struct ifnet *ifp, struct nl_parsed_link *lattrs,
+    const struct nlattr_bmask *bm, struct nl_pstate *npt)
+{
+	return (_nl_modify_ifp_generic(ifp, lattrs, bm, npt));
+}
+
+static inline void
+nl_store_ifp_cookie(struct nl_pstate *npt, struct ifnet *ifp)
+{
+	_nl_store_ifp_cookie(npt, ifp);
+}
+#else
+/* Provide access to the functions via netlink_glue.c */
 int nl_modify_ifp_generic(struct ifnet *ifp, struct nl_parsed_link *lattrs,
     const struct nlattr_bmask *bm, struct nl_pstate *npt);
 void nl_store_ifp_cookie(struct nl_pstate *npt, struct ifnet *ifp);
+#endif /* defined(NETLINK) || defined(NETLINK_MODULE) */
 
 
 typedef int rtnl_iface_create_f(struct nl_parsed_link *lattrs,