netlink: fix netlink interface operations when netlink is loaded as a module.

This change completes 089104e0e0.

MFC after:	2 weeks
This commit is contained in:
Alexander V. Chernikov
2023-04-28 13:30:36 +00:00
parent 4f6a5e1d6c
commit 9e79038c50
3 changed files with 27 additions and 2 deletions
+2
View File
@@ -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
+3 -2
View File
@@ -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;
+22
View File
@@ -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,