From patchwork Tue Jul 18 13:33:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 9848359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1C53E602C8 for ; Tue, 18 Jul 2017 13:33:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00DC226BE9 for ; Tue, 18 Jul 2017 13:33:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E95D126E97; Tue, 18 Jul 2017 13:33:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E21826BE9 for ; Tue, 18 Jul 2017 13:33:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751399AbdGRNds (ORCPT ); Tue, 18 Jul 2017 09:33:48 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:39270 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751396AbdGRNds (ORCPT ); Tue, 18 Jul 2017 09:33:48 -0400 Received: from a91-156-4-241.elisa-laajakaista.fi ([91.156.4.241] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1dXSdD-0001Bg-HE; Tue, 18 Jul 2017 16:33:44 +0300 From: Luca Coelho To: egrumbach@gmail.com, arend.vanspriel@broadcom.com Cc: johannes@sipsolutions.net, backports@vger.kernel.org, Luca Coelho Date: Tue, 18 Jul 2017 16:33:38 +0300 Message-Id: <20170718133338.16475-1-luca@coelho.fi> X-Mailer: git-send-email 2.13.2 X-SA-Exim-Connect-IP: 91.156.4.241 X-SA-Exim-Mail-From: luca@coelho.fi Subject: [PATCH] backport: fix netdev destructor backport X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on farmhouse.coelho.fi) Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luca Coelho The commit that changed the netdev destructor was also applied in v4.12-rc6, so we need to update the backport. Another issue was that when the default free_netdev() destructor was supposed to be used, we would get compilation errors, such as this one in hwsim: In file included from ./include/net/dst.h:12:0, from /home/luca/iwlwifi/stack-dev/drivers/net/wireless/mac80211_hwsim.c:22: /home/luca/iwlwifi/stack-dev/drivers/net/wireless/mac80211_hwsim.c: In function hwsim_mon_setup': /home/luca/iwlwifi/stack-dev/backport-include/linux/netdevice.h:325:23: error: '__free_netdev' undeclared (first use in this function) (_dev)->destructor = __ ## _destructor ^ /home/luca/iwlwifi/stack-dev/drivers/net/wireless/mac80211_hwsim.c:2977:2: note: in expansion of macro 'netdev_set_priv_destructor' netdev_set_priv_destructor(dev, free_netdev); ^~~~~~~~~~~~~~~~~~~~~~~~~~ /home/luca/iwlwifi/stack-dev/backport-include/linux/netdevice.h:325:23: note: each undeclared identifier is reported only once for each function it appears in (_dev)->destructor = __ ## _destructor ^ /home/luca/iwlwifi/stack-dev/drivers/net/wireless/mac80211_hwsim.c:2977:2: note: in expansion of macro 'netdev_set_priv_destructor' netdev_set_priv_destructor(dev, free_netdev); ^~~~~~~~~~~~~~~~~~~~~~~~~~ scripts/Makefile.build:300: recipe for target '/home/luca/iwlwifi/stack-dev/drivers/net/wireless/mac80211_hwsim.o' failed To fix this, add a new macro, netdev_set_def_destructor(), that handles this special case. Fixes: 721ae78f9355 ("backport: handle change in netdevice destructor usage") Signed-off-by: Luca Coelho Reviewed-by: Arend van Spriel --- backport/backport-include/linux/netdevice.h | 9 ++++++--- patches/0079-netdev-destructor.cocci | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h index 98e781eeb740..d22eec2d3113 100644 --- a/backport/backport-include/linux/netdevice.h +++ b/backport/backport-include/linux/netdevice.h @@ -320,14 +320,17 @@ static inline void netif_trans_update(struct net_device *dev) } #endif -#if LINUX_VERSION_IS_LESS(4,13,0) +#if LINUX_VERSION_IS_LESS(4,12,0) #define netdev_set_priv_destructor(_dev, _destructor) \ (_dev)->destructor = __ ## _destructor +#define netdev_set_def_destructor(_dev) \ + (_dev)->destructor = free_netdev #else #define netdev_set_priv_destructor(_dev, _destructor) \ (_dev)->needs_free_netdev = true; \ - if ((_destructor) != free_netdev) \ - (_dev)->priv_destructor = (_destructor); + (_dev)->priv_destructor = (_destructor); +#define netdev_set_def_destructor(_dev) \ + (_dev)->needs_free_netdev = true; #endif #endif /* __BACKPORT_NETDEVICE_H */ diff --git a/patches/0079-netdev-destructor.cocci b/patches/0079-netdev-destructor.cocci index fab8af192aac..199aacf29032 100644 --- a/patches/0079-netdev-destructor.cocci +++ b/patches/0079-netdev-destructor.cocci @@ -17,7 +17,7 @@ identifier r1.D, r1.C; fresh identifier E = "__" ## D; @@ -+#if LINUX_VERSION_IS_LESS(4,13,0) ++#if LINUX_VERSION_IS_LESS(4,12,0) +static void E(struct net_device *ndev) +{ + D(ndev); @@ -40,7 +40,7 @@ T RET; RET = \(register_netdevice\|register_ndev\)(NDEV); if (<+... RET ...+>) { <... -+#if LINUX_VERSION_IS_LESS(4,13,0) ++#if LINUX_VERSION_IS_LESS(4,12,0) + D(NDEV); +#endif free_netdev(NDEV); @@ -60,7 +60,7 @@ else RET = register_netdev(NDEV); if (<+... RET ...+>) { <... -+#if LINUX_VERSION_IS_LESS(4,13,0) ++#if LINUX_VERSION_IS_LESS(4,12,0) + D(NDEV); +#endif free_netdev(NDEV); @@ -73,7 +73,7 @@ identifier TRUE =~ "true"; @@ -NDEV->needs_free_netdev = TRUE; -+netdev_set_priv_destructor(NDEV, free_netdev); ++netdev_set_def_destructor(NDEV); @r6@ struct net_device *NDEV;