* [PATCH net v1 1/1] netfilter: nf_reject: Fix build error when CONFIG_BRIDGE_NETFILTER=n
@ 2024-09-06 14:55 Andy Shevchenko
2024-09-07 13:48 ` Simon Horman
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-09-06 14:55 UTC (permalink / raw)
To: Pablo Neira Ayuso, Pavel Tikhomirov, netfilter-devel, coreteam,
netdev, linux-kernel, llvm
Cc: Jozsef Kadlecsik, David S. Miller, David Ahern, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Shevchenko
In some cases (CONFIG_BRIDGE_NETFILTER=n) the pointer to IP header
is set but not used, it prevents kernel builds with clang, `make W=1`
and CONFIG_WERROR=y:
ipv6: split nf_send_reset6() in smaller functions
netfilter: nf_reject_ipv4: split nf_send_reset() in smaller functions
net/ipv4/netfilter/nf_reject_ipv4.c:243:16: error: variable 'niph' set but not used [-Werror,-Wunused-but-set-variable]
243 | struct iphdr *niph;
| ^
net/ipv6/netfilter/nf_reject_ipv6.c:286:18: error: variable 'ip6h' set but not used [-Werror,-Wunused-but-set-variable]
286 | struct ipv6hdr *ip6h;
| ^
Fix these by marking respective variables with __maybe_unused as it
seems more complicated to address that in a better way due to ifdeffery.
Fixes: 8bfcdf6671b1 ("netfilter: nf_reject_ipv6: split nf_send_reset6() in smaller functions")
Fixes: 052b9498eea5 ("netfilter: nf_reject_ipv4: split nf_send_reset() in smaller functions")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
net/ipv4/netfilter/nf_reject_ipv4.c | 2 +-
net/ipv6/netfilter/nf_reject_ipv6.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
index 04504b2b51df..0af42494ac66 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -240,7 +240,7 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
int hook)
{
struct sk_buff *nskb;
- struct iphdr *niph;
+ struct iphdr *niph __maybe_unused;
const struct tcphdr *oth;
struct tcphdr _oth;
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index dedee264b8f6..f5ed4e779b72 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -283,7 +283,7 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,
const struct tcphdr *otcph;
unsigned int otcplen, hh_len;
const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
- struct ipv6hdr *ip6h;
+ struct ipv6hdr *ip6h __maybe_unused;
struct dst_entry *dst = NULL;
struct flowi6 fl6;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net v1 1/1] netfilter: nf_reject: Fix build error when CONFIG_BRIDGE_NETFILTER=n
2024-09-06 14:55 [PATCH net v1 1/1] netfilter: nf_reject: Fix build error when CONFIG_BRIDGE_NETFILTER=n Andy Shevchenko
@ 2024-09-07 13:48 ` Simon Horman
2024-09-09 9:44 ` Andy Shevchenko
2024-09-15 21:22 ` Pablo Neira Ayuso
0 siblings, 2 replies; 6+ messages in thread
From: Simon Horman @ 2024-09-07 13:48 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Pablo Neira Ayuso, Pavel Tikhomirov, netfilter-devel, coreteam,
netdev, linux-kernel, llvm, Jozsef Kadlecsik, David S. Miller,
David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt
On Fri, Sep 06, 2024 at 05:55:13PM +0300, Andy Shevchenko wrote:
> In some cases (CONFIG_BRIDGE_NETFILTER=n) the pointer to IP header
> is set but not used, it prevents kernel builds with clang, `make W=1`
> and CONFIG_WERROR=y:
>
> ipv6: split nf_send_reset6() in smaller functions
> netfilter: nf_reject_ipv4: split nf_send_reset() in smaller functions
>
> net/ipv4/netfilter/nf_reject_ipv4.c:243:16: error: variable 'niph' set but not used [-Werror,-Wunused-but-set-variable]
> 243 | struct iphdr *niph;
> | ^
> net/ipv6/netfilter/nf_reject_ipv6.c:286:18: error: variable 'ip6h' set but not used [-Werror,-Wunused-but-set-variable]
> 286 | struct ipv6hdr *ip6h;
> | ^
>
> Fix these by marking respective variables with __maybe_unused as it
> seems more complicated to address that in a better way due to ifdeffery.
>
> Fixes: 8bfcdf6671b1 ("netfilter: nf_reject_ipv6: split nf_send_reset6() in smaller functions")
> Fixes: 052b9498eea5 ("netfilter: nf_reject_ipv4: split nf_send_reset() in smaller functions")
Hi Andy,
As mentioned in relation to another similar patch,
I'm not sure that resolution of W=1 warnings are fixes.
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> net/ipv4/netfilter/nf_reject_ipv4.c | 2 +-
> net/ipv6/netfilter/nf_reject_ipv6.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
> index 04504b2b51df..0af42494ac66 100644
> --- a/net/ipv4/netfilter/nf_reject_ipv4.c
> +++ b/net/ipv4/netfilter/nf_reject_ipv4.c
> @@ -240,7 +240,7 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
> int hook)
> {
> struct sk_buff *nskb;
> - struct iphdr *niph;
> + struct iphdr *niph __maybe_unused;
> const struct tcphdr *oth;
> struct tcphdr _oth;
>
Possibly it is broken for some reason - like reading nskb too late -
but I wonder if rather than annotating niph it's scope can be reduced
to the code that is only compiled if CONFIG_BRIDGE_NETFILTER is enabled.
This also addreses what appears to be an assingment of niph without
the value being used - the first assingment.
E.g., for the ipv4 case (compile tested only!):
diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
index 04504b2b51df..87fd945a0d27 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -239,9 +239,8 @@ static int nf_reject_fill_skb_dst(struct sk_buff *skb_in)
void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
int hook)
{
- struct sk_buff *nskb;
- struct iphdr *niph;
const struct tcphdr *oth;
+ struct sk_buff *nskb;
struct tcphdr _oth;
oth = nf_reject_ip_tcphdr_get(oldskb, &_oth, hook);
@@ -266,14 +265,12 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
nskb->mark = IP4_REPLY_MARK(net, oldskb->mark);
skb_reserve(nskb, LL_MAX_HEADER);
- niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
- ip4_dst_hoplimit(skb_dst(nskb)));
+ nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
+ ip4_dst_hoplimit(skb_dst(nskb)));
nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
if (ip_route_me_harder(net, sk, nskb, RTN_UNSPEC))
goto free_nskb;
- niph = ip_hdr(nskb);
-
/* "Never happens" */
if (nskb->len > dst_mtu(skb_dst(nskb)))
goto free_nskb;
@@ -290,6 +287,7 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
*/
if (nf_bridge_info_exists(oldskb)) {
struct ethhdr *oeth = eth_hdr(oldskb);
+ struct iphdr *niph = ip_hdr(nskb);
struct net_device *br_indev;
br_indev = nf_bridge_get_physindev(oldskb, net);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net v1 1/1] netfilter: nf_reject: Fix build error when CONFIG_BRIDGE_NETFILTER=n
2024-09-07 13:48 ` Simon Horman
@ 2024-09-09 9:44 ` Andy Shevchenko
2024-09-15 21:22 ` Pablo Neira Ayuso
1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-09-09 9:44 UTC (permalink / raw)
To: Simon Horman
Cc: Pablo Neira Ayuso, Pavel Tikhomirov, netfilter-devel, coreteam,
netdev, linux-kernel, llvm, Jozsef Kadlecsik, David S. Miller,
David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt
On Sat, Sep 07, 2024 at 02:48:37PM +0100, Simon Horman wrote:
> On Fri, Sep 06, 2024 at 05:55:13PM +0300, Andy Shevchenko wrote:
> As mentioned in relation to another similar patch,
> I'm not sure that resolution of W=1 warnings are fixes.
Up to you, I consider they as fixes as I'm pretty much annoyed each release to
have disable CONFIG_WERROR. But I got your point.
...
> Possibly it is broken for some reason - like reading nskb too late -
> but I wonder if rather than annotating niph it's scope can be reduced
> to the code that is only compiled if CONFIG_BRIDGE_NETFILTER is enabled.
>
> This also addreses what appears to be an assingment of niph without
> the value being used - the first assingment.
>
> E.g., for the ipv4 case (compile tested only!):
Please, submit a formal patch, I'm not so familiar with the guts of networking
core to be able to produce anything better than I already did.
Consider this as
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thank you!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v1 1/1] netfilter: nf_reject: Fix build error when CONFIG_BRIDGE_NETFILTER=n
2024-09-07 13:48 ` Simon Horman
2024-09-09 9:44 ` Andy Shevchenko
@ 2024-09-15 21:22 ` Pablo Neira Ayuso
2024-09-16 7:32 ` Simon Horman
1 sibling, 1 reply; 6+ messages in thread
From: Pablo Neira Ayuso @ 2024-09-15 21:22 UTC (permalink / raw)
To: Simon Horman
Cc: Andy Shevchenko, Pavel Tikhomirov, netfilter-devel, coreteam,
netdev, linux-kernel, llvm, Jozsef Kadlecsik, David S. Miller,
David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt
Hi Simon,
This proposed update to address this compile time warning LGTM.
Would you submit it?
Thanks.
On Sat, Sep 07, 2024 at 02:48:37PM +0100, Simon Horman wrote:
[...]
> diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
> index 04504b2b51df..87fd945a0d27 100644
> --- a/net/ipv4/netfilter/nf_reject_ipv4.c
> +++ b/net/ipv4/netfilter/nf_reject_ipv4.c
> @@ -239,9 +239,8 @@ static int nf_reject_fill_skb_dst(struct sk_buff *skb_in)
> void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
> int hook)
> {
> - struct sk_buff *nskb;
> - struct iphdr *niph;
> const struct tcphdr *oth;
> + struct sk_buff *nskb;
> struct tcphdr _oth;
>
> oth = nf_reject_ip_tcphdr_get(oldskb, &_oth, hook);
> @@ -266,14 +265,12 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
> nskb->mark = IP4_REPLY_MARK(net, oldskb->mark);
>
> skb_reserve(nskb, LL_MAX_HEADER);
> - niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
> - ip4_dst_hoplimit(skb_dst(nskb)));
> + nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
> + ip4_dst_hoplimit(skb_dst(nskb)));
> nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
> if (ip_route_me_harder(net, sk, nskb, RTN_UNSPEC))
> goto free_nskb;
>
> - niph = ip_hdr(nskb);
> -
> /* "Never happens" */
> if (nskb->len > dst_mtu(skb_dst(nskb)))
> goto free_nskb;
> @@ -290,6 +287,7 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
> */
> if (nf_bridge_info_exists(oldskb)) {
> struct ethhdr *oeth = eth_hdr(oldskb);
> + struct iphdr *niph = ip_hdr(nskb);
> struct net_device *br_indev;
>
> br_indev = nf_bridge_get_physindev(oldskb, net);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v1 1/1] netfilter: nf_reject: Fix build error when CONFIG_BRIDGE_NETFILTER=n
2024-09-15 21:22 ` Pablo Neira Ayuso
@ 2024-09-16 7:32 ` Simon Horman
2024-09-16 9:52 ` Simon Horman
0 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2024-09-16 7:32 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: Andy Shevchenko, Pavel Tikhomirov, netfilter-devel, coreteam,
netdev, linux-kernel, llvm, Jozsef Kadlecsik, David S. Miller,
David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt
On Sun, Sep 15, 2024 at 11:22:02PM +0200, Pablo Neira Ayuso wrote:
> Hi Simon,
>
> This proposed update to address this compile time warning LGTM.
>
> Would you submit it?
Hi Pablo,
Yes, it is on my todo list for today.
Sorry for not getting to it sooner.
I plan to post a patch for this to nf-next.
But let me know if you prefer a patch for nf, net,
or some other course of action.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v1 1/1] netfilter: nf_reject: Fix build error when CONFIG_BRIDGE_NETFILTER=n
2024-09-16 7:32 ` Simon Horman
@ 2024-09-16 9:52 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2024-09-16 9:52 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: Andy Shevchenko, Pavel Tikhomirov, netfilter-devel, coreteam,
netdev, linux-kernel, llvm, Jozsef Kadlecsik, David S. Miller,
David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt
On Mon, Sep 16, 2024 at 08:32:01AM +0100, Simon Horman wrote:
> On Sun, Sep 15, 2024 at 11:22:02PM +0200, Pablo Neira Ayuso wrote:
> > Hi Simon,
> >
> > This proposed update to address this compile time warning LGTM.
> >
> > Would you submit it?
>
> Hi Pablo,
>
> Yes, it is on my todo list for today.
> Sorry for not getting to it sooner.
>
> I plan to post a patch for this to nf-next.
> But let me know if you prefer a patch for nf, net,
> or some other course of action.
Patch posted here:
- [PATCH nf-next] netfilter: nf_reject: Fix build warning when CONFIG_BRIDGE_NETFILTER=n
https://lore.kernel.org/netfilter-devel/20240916-nf-reject-v1-1-24b6dd651c83@kernel.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-09-16 9:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 14:55 [PATCH net v1 1/1] netfilter: nf_reject: Fix build error when CONFIG_BRIDGE_NETFILTER=n Andy Shevchenko
2024-09-07 13:48 ` Simon Horman
2024-09-09 9:44 ` Andy Shevchenko
2024-09-15 21:22 ` Pablo Neira Ayuso
2024-09-16 7:32 ` Simon Horman
2024-09-16 9:52 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).