mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
netfilter: nf_reject: Fix build warning when CONFIG_BRIDGE_NETFILTER=n
[ Upstream commit fc56878ca1c288e49b5cbb43860a5938e3463654 ]
If CONFIG_BRIDGE_NETFILTER is not enabled, which is the case for x86_64
defconfig, then building nf_reject_ipv4.c and nf_reject_ipv6.c with W=1
using gcc-14 results in the following warnings, which are treated as
errors:
net/ipv4/netfilter/nf_reject_ipv4.c: In function 'nf_send_reset':
net/ipv4/netfilter/nf_reject_ipv4.c:243:23: error: variable 'niph' set but not used [-Werror=unused-but-set-variable]
243 | struct iphdr *niph;
| ^~~~
cc1: all warnings being treated as errors
net/ipv6/netfilter/nf_reject_ipv6.c: In function 'nf_send_reset6':
net/ipv6/netfilter/nf_reject_ipv6.c:286:25: error: variable 'ip6h' set but not used [-Werror=unused-but-set-variable]
286 | struct ipv6hdr *ip6h;
| ^~~~
cc1: all warnings being treated as errors
Address this by reducing the scope of these local variables to where
they are used, which is code only compiled when CONFIG_BRIDGE_NETFILTER
enabled.
Compile tested and run through netfilter selftests.
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Closes: https://lore.kernel.org/netfilter-devel/20240906145513.567781-1-andriy.shevchenko@linux.intel.com/
Signed-off-by: Simon Horman <horms@kernel.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b52f1fbb06
commit
4dab65aafb
@@ -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,
|
void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
|
||||||
int hook)
|
int hook)
|
||||||
{
|
{
|
||||||
struct sk_buff *nskb;
|
|
||||||
struct iphdr *niph;
|
|
||||||
const struct tcphdr *oth;
|
const struct tcphdr *oth;
|
||||||
|
struct sk_buff *nskb;
|
||||||
struct tcphdr _oth;
|
struct tcphdr _oth;
|
||||||
|
|
||||||
oth = nf_reject_ip_tcphdr_get(oldskb, &_oth, hook);
|
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);
|
nskb->mark = IP4_REPLY_MARK(net, oldskb->mark);
|
||||||
|
|
||||||
skb_reserve(nskb, LL_MAX_HEADER);
|
skb_reserve(nskb, LL_MAX_HEADER);
|
||||||
niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
|
nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
|
||||||
ip4_dst_hoplimit(skb_dst(nskb)));
|
ip4_dst_hoplimit(skb_dst(nskb)));
|
||||||
nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
|
nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
|
||||||
if (ip_route_me_harder(net, sk, nskb, RTN_UNSPEC))
|
if (ip_route_me_harder(net, sk, nskb, RTN_UNSPEC))
|
||||||
goto free_nskb;
|
goto free_nskb;
|
||||||
|
|
||||||
niph = ip_hdr(nskb);
|
|
||||||
|
|
||||||
/* "Never happens" */
|
/* "Never happens" */
|
||||||
if (nskb->len > dst_mtu(skb_dst(nskb)))
|
if (nskb->len > dst_mtu(skb_dst(nskb)))
|
||||||
goto free_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)) {
|
if (nf_bridge_info_exists(oldskb)) {
|
||||||
struct ethhdr *oeth = eth_hdr(oldskb);
|
struct ethhdr *oeth = eth_hdr(oldskb);
|
||||||
|
struct iphdr *niph = ip_hdr(nskb);
|
||||||
struct net_device *br_indev;
|
struct net_device *br_indev;
|
||||||
|
|
||||||
br_indev = nf_bridge_get_physindev(oldskb, net);
|
br_indev = nf_bridge_get_physindev(oldskb, net);
|
||||||
|
|||||||
@@ -273,7 +273,6 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,
|
|||||||
const struct tcphdr *otcph;
|
const struct tcphdr *otcph;
|
||||||
unsigned int otcplen, hh_len;
|
unsigned int otcplen, hh_len;
|
||||||
const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
|
const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
|
||||||
struct ipv6hdr *ip6h;
|
|
||||||
struct dst_entry *dst = NULL;
|
struct dst_entry *dst = NULL;
|
||||||
struct flowi6 fl6;
|
struct flowi6 fl6;
|
||||||
|
|
||||||
@@ -329,8 +328,7 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,
|
|||||||
nskb->mark = fl6.flowi6_mark;
|
nskb->mark = fl6.flowi6_mark;
|
||||||
|
|
||||||
skb_reserve(nskb, hh_len + dst->header_len);
|
skb_reserve(nskb, hh_len + dst->header_len);
|
||||||
ip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP,
|
nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP, ip6_dst_hoplimit(dst));
|
||||||
ip6_dst_hoplimit(dst));
|
|
||||||
nf_reject_ip6_tcphdr_put(nskb, oldskb, otcph, otcplen);
|
nf_reject_ip6_tcphdr_put(nskb, oldskb, otcph, otcplen);
|
||||||
|
|
||||||
nf_ct_attach(nskb, oldskb);
|
nf_ct_attach(nskb, oldskb);
|
||||||
@@ -345,6 +343,7 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,
|
|||||||
*/
|
*/
|
||||||
if (nf_bridge_info_exists(oldskb)) {
|
if (nf_bridge_info_exists(oldskb)) {
|
||||||
struct ethhdr *oeth = eth_hdr(oldskb);
|
struct ethhdr *oeth = eth_hdr(oldskb);
|
||||||
|
struct ipv6hdr *ip6h = ipv6_hdr(nskb);
|
||||||
struct net_device *br_indev;
|
struct net_device *br_indev;
|
||||||
|
|
||||||
br_indev = nf_bridge_get_physindev(oldskb, net);
|
br_indev = nf_bridge_get_physindev(oldskb, net);
|
||||||
|
|||||||
Reference in New Issue
Block a user