From owner-dev-commits-src-all@freebsd.org Fri Mar 26 13:11:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2CDF75BEE7B; Fri, 26 Mar 2021 13:11:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F6MnL0lvBz4fwc; Fri, 26 Mar 2021 13:11:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0CB4A1A953; Fri, 26 Mar 2021 13:11:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12QDBnZx037650; Fri, 26 Mar 2021 13:11:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12QDBnwA037649; Fri, 26 Mar 2021 13:11:49 GMT (envelope-from git) Date: Fri, 26 Mar 2021 13:11:49 GMT Message-Id: <202103261311.12QDBnwA037649@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: fdcfe8a298e2 - main - LinuxKPI: netdevice notifier callback argument MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fdcfe8a298e23bef9588cafad2672e0c5f48a327 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2021 13:11:50 -0000 The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=fdcfe8a298e23bef9588cafad2672e0c5f48a327 commit fdcfe8a298e23bef9588cafad2672e0c5f48a327 Author: Bjoern A. Zeeb AuthorDate: 2021-03-21 21:18:34 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-03-26 13:00:23 +0000 LinuxKPI: netdevice notifier callback argument Introduce struct netdev_notifier_info as a container to pass net_device to the callback functions. Adjust netdev_notifier_info_to_dev() to return the net_device field. Add explicit casts from ifp to ni->dev even though currently struct net_device is defined to struct ifnet. This is needed in preparation for untangling this and improving the net_device compat code. Obtained-from: bz_iwlwifi Sponsored-by: The FreeBSD Foundation MFC-after: 2 weeks Reviewed-by: hselasky Differential Revision: https://reviews.freebsd.org/D29365 --- .../linuxkpi/common/include/linux/netdevice.h | 27 +++++++++++++--------- sys/compat/linuxkpi/common/src/linux_compat.c | 22 +++++++++++++----- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/netdevice.h b/sys/compat/linuxkpi/common/include/linux/netdevice.h index 336215b9f7c5..9ec76d9b90ef 100644 --- a/sys/compat/linuxkpi/common/include/linux/netdevice.h +++ b/sys/compat/linuxkpi/common/include/linux/netdevice.h @@ -88,17 +88,6 @@ netdev_priv(const struct net_device *dev) return (dev->if_softc); } -static inline struct net_device * -netdev_notifier_info_to_dev(void *ifp) -{ - return (ifp); -} - -int register_netdevice_notifier(struct notifier_block *); -int register_inetaddr_notifier(struct notifier_block *); -int unregister_netdevice_notifier(struct notifier_block *); -int unregister_inetaddr_notifier(struct notifier_block *); - #define rtnl_lock() #define rtnl_unlock() @@ -140,4 +129,20 @@ dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly) return -if_addmulti(dev, (struct sockaddr *)&sdl, NULL); } +/* According to linux::ipoib_main.c. */ +struct netdev_notifier_info { + struct net_device *dev; +}; + +static inline struct net_device * +netdev_notifier_info_to_dev(struct netdev_notifier_info *ni) +{ + return (ni->dev); +} + +int register_netdevice_notifier(struct notifier_block *); +int register_inetaddr_notifier(struct notifier_block *); +int unregister_netdevice_notifier(struct notifier_block *); +int unregister_inetaddr_notifier(struct notifier_block *); + #endif /* _LINUX_NETDEVICE_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 60745fbf92da..42f47b6e510a 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2256,48 +2256,58 @@ static void linux_handle_ifnet_link_event(void *arg, struct ifnet *ifp, int linkstate) { struct notifier_block *nb; + struct netdev_notifier_info ni; nb = arg; + ni.dev = (struct net_device *)ifp; if (linkstate == LINK_STATE_UP) - nb->notifier_call(nb, NETDEV_UP, ifp); + nb->notifier_call(nb, NETDEV_UP, &ni); else - nb->notifier_call(nb, NETDEV_DOWN, ifp); + nb->notifier_call(nb, NETDEV_DOWN, &ni); } static void linux_handle_ifnet_arrival_event(void *arg, struct ifnet *ifp) { struct notifier_block *nb; + struct netdev_notifier_info ni; nb = arg; - nb->notifier_call(nb, NETDEV_REGISTER, ifp); + ni.dev = (struct net_device *)ifp; + nb->notifier_call(nb, NETDEV_REGISTER, &ni); } static void linux_handle_ifnet_departure_event(void *arg, struct ifnet *ifp) { struct notifier_block *nb; + struct netdev_notifier_info ni; nb = arg; - nb->notifier_call(nb, NETDEV_UNREGISTER, ifp); + ni.dev = (struct net_device *)ifp; + nb->notifier_call(nb, NETDEV_UNREGISTER, &ni); } static void linux_handle_iflladdr_event(void *arg, struct ifnet *ifp) { struct notifier_block *nb; + struct netdev_notifier_info ni; nb = arg; - nb->notifier_call(nb, NETDEV_CHANGEADDR, ifp); + ni.dev = (struct net_device *)ifp; + nb->notifier_call(nb, NETDEV_CHANGEADDR, &ni); } static void linux_handle_ifaddr_event(void *arg, struct ifnet *ifp) { struct notifier_block *nb; + struct netdev_notifier_info ni; nb = arg; - nb->notifier_call(nb, NETDEV_CHANGEIFADDR, ifp); + ni.dev = (struct net_device *)ifp; + nb->notifier_call(nb, NETDEV_CHANGEIFADDR, &ni); } int