From patchwork Fri Oct 9 18:45:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 528384 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EE31A1402D8 for ; Sat, 10 Oct 2015 05:46:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756337AbbJISpw (ORCPT ); Fri, 9 Oct 2015 14:45:52 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:59038 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756245AbbJISpv (ORCPT ); Fri, 9 Oct 2015 14:45:51 -0400 Received: from wuerfel.localnet ([149.172.15.242]) by mrelayeu.kundenserver.de (mreue004) with ESMTPSA (Nemesis) id 0M8MHm-1aXn6u10Bm-00vuSX; Fri, 09 Oct 2015 20:45:46 +0200 From: Arnd Bergmann To: "Eric W. Biederman" Cc: Pablo Neira Ayuso , Patrick McHardy , Jozsef Kadlecsik , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-kernel@vger.kernel.org, "David S. Miller" , netdev@vger.kernel.org Subject: [PATCH v2] netfilter: turn NF_HOOK into an inline function Date: Fri, 09 Oct 2015 20:45:42 +0200 Message-ID: <5713169.GvahoqQ9XY@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <87zizryjzs.fsf@x220.int.ebiederm.org> References: <7665226.mEs2QJDTOT@wuerfel> <87zizryjzs.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 X-Provags-ID: V03:K0:nImQkbGFDIacaHCZ2eO5W2kHGdcn+Njpe1Rl053qAXledTD5qAF ja0f5sv+QyOJvG+XZZiGkyS1Pi5kvc0PuWMllI/gabFmipbTuOVUUY5yn57Yx4Cz/8PUvLM Uh0vOsiaWsjIFO3G8kV098YGGADPexmrZg+yWAbKTjJd3uu5EhYFE+x6Tkj9jhKv9QD68Gm DGfHRu7kVD4lXdaiQkPdw== X-UI-Out-Filterresults: notjunk:1; V01:K0:uU1UgytwZ0Y=:RSPwM30xJ06N65RHMIF3Q1 hDyABJsTvLcojvg4mKuo+xPygKR/2kgRHm5nnOr+m20WfaC5Y3l73XcEAYIPcBHKG86gnfWpp dWlfRvwslAHt1nwdQTPgP+htqhJiP++gv8JJb19H/kc9h123rgf+b63Sys4SiyfAyhf0f6zGM IxI3OHN5sqH7U8WWkSAlyAVpMypX4y1Au5Z2eQpxMyTqGV8OAiDKcC3Jv2u6JukLYB+4FE2SB JEKHsuzkisUeHXK4dkW8e/j7y2HOm2UGSn/vaMbVHTD8zYy6t3wPZBcB0mPsfKk4WuhAxrGNV 2ma/s4EAe9tW3OU48zOZcQT3es1Q5EHtoYm0D0TDJ4P2hnl9mujuiDc3dOCLI73sbNV1TYcfo Z7tiscvBUIK8O/T8e4x75+sSQfysImaeO2mIruZsOb0g+ueVkV0E9bY5fCN2nPrxWLbrTjRIM L5uKUYNl5/n5wJwHaWarosxRCmZ+14PMXjzIbGRB1gWsR0CIJuPaej0YBdRRzKnbUlckkL5BI 2pM6RatGXiR+lqb1p0R/MB17GSDm4DZwZbVANkQWjf7///qRr0EsEJUgLnP2n4wPG5fbGUZ2Y sqKPSqaBpFJ719vlZO9BR4nIMz7DIhSI2LvPH/Jepbc8YoJH5b8Yd+ymD1UOkClX8gaYAeiz0 GvieLzvudzXE09iiT+vxLaLtezfKSQkUFTzcFk5h49FKVejU6QvIagBjj4v8Itg60QsLvkLzH h0snq8alf7VX/SVW Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org A recent change to the dst_output handling caused a new warning when the call to NF_HOOK() is the only used of a local variable passed as 'dev', and CONFIG_NETFILTER is disabled: net/ipv6/ip6_output.c: In function 'ip6_output': net/ipv6/ip6_output.c:135:21: warning: unused variable 'dev' [-Wunused-variable] The reason for this is that the NF_HOOK macro in this case does not reference the variable at all, and the call to dev_net(dev) got removed from the ip6_output function. To avoid that warning now and in the future, this changes the macro into an equivalent inline function, which tells the compiler that the variable is passed correctly but still unused. The dn_forward function apparently had the same problem in the past and added a local workaround that no longer works with the inline function. In order to avoid a regression, we have to also remove the #ifdef from decnet in the same patch. Signed-off-by: Arnd Bergmann Fixes: ede2059dbaf9 ("dst: Pass net into dst->output") --- v2: folded the #ifdef removal and reworded based on Eric's feedback. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index edb3dc32f1da..1ff5c3f82820 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h @@ -347,8 +347,23 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family) } #else /* !CONFIG_NETFILTER */ -#define NF_HOOK(pf, hook, net, sk, skb, indev, outdev, okfn) (okfn)(net, sk, skb) -#define NF_HOOK_COND(pf, hook, net, sk, skb, indev, outdev, okfn, cond) (okfn)(net, sk, skb) +static inline int +NF_HOOK_COND(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk, + struct sk_buff *skb, struct net_device *in, struct net_device *out, + int (*okfn)(struct net *, struct sock *, struct sk_buff *), + bool cond) +{ + return okfn(net, sk, skb); +} + +static inline int +NF_HOOK(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk, struct sk_buff *skb, + struct net_device *in, struct net_device *out, + int (*okfn)(struct net *, struct sock *, struct sk_buff *)) +{ + return okfn(net, sk, skb); +} + static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net, struct sock *sk, struct sk_buff *skb, struct net_device *indev, struct net_device *outdev, diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 27fce283117b..607a14f20d88 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c @@ -789,9 +789,7 @@ static int dn_forward(struct sk_buff *skb) struct dn_dev *dn_db = rcu_dereference(dst->dev->dn_ptr); struct dn_route *rt; int header_len; -#ifdef CONFIG_NETFILTER struct net_device *dev = skb->dev; -#endif if (skb->pkt_type != PACKET_HOST) goto drop;