473647dcbb234c114970db9baf1f9bbafcb7603c
[openwrt/openwrt.git] /
1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Tue, 23 Mar 2021 00:56:24 +0100
3 Subject: [PATCH] netfilter: flowtable: move FLOW_OFFLOAD_DIR_MAX away
4 from enumeration
5
6 This allows to remove the default case which should not ever happen and
7 that was added to avoid gcc warnings on unhandled FLOW_OFFLOAD_DIR_MAX
8 enumeration case.
9
10 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 ---
12
13 --- a/include/net/netfilter/nf_flow_table.h
14 +++ b/include/net/netfilter/nf_flow_table.h
15 @@ -86,8 +86,8 @@ static inline bool nf_flowtable_hw_offlo
16 enum flow_offload_tuple_dir {
17 FLOW_OFFLOAD_DIR_ORIGINAL = IP_CT_DIR_ORIGINAL,
18 FLOW_OFFLOAD_DIR_REPLY = IP_CT_DIR_REPLY,
19 - FLOW_OFFLOAD_DIR_MAX = IP_CT_DIR_MAX
20 };
21 +#define FLOW_OFFLOAD_DIR_MAX IP_CT_DIR_MAX
22
23 struct flow_offload_tuple {
24 union {
25 --- a/net/netfilter/nf_flow_table_core.c
26 +++ b/net/netfilter/nf_flow_table_core.c
27 @@ -454,8 +454,6 @@ int nf_flow_snat_port(const struct flow_
28 new_port = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.src_port;
29 hdr->dest = new_port;
30 break;
31 - default:
32 - return -1;
33 }
34
35 return nf_flow_nat_port(skb, thoff, protocol, port, new_port);
36 @@ -482,8 +480,6 @@ int nf_flow_dnat_port(const struct flow_
37 new_port = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.dst_port;
38 hdr->source = new_port;
39 break;
40 - default:
41 - return -1;
42 }
43
44 return nf_flow_nat_port(skb, thoff, protocol, port, new_port);
45 --- a/net/netfilter/nf_flow_table_ip.c
46 +++ b/net/netfilter/nf_flow_table_ip.c
47 @@ -96,8 +96,6 @@ static int nf_flow_snat_ip(const struct
48 new_addr = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.src_v4.s_addr;
49 iph->daddr = new_addr;
50 break;
51 - default:
52 - return -1;
53 }
54 csum_replace4(&iph->check, addr, new_addr);
55
56 @@ -121,8 +119,6 @@ static int nf_flow_dnat_ip(const struct
57 new_addr = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.dst_v4.s_addr;
58 iph->saddr = new_addr;
59 break;
60 - default:
61 - return -1;
62 }
63 csum_replace4(&iph->check, addr, new_addr);
64
65 @@ -371,8 +367,6 @@ static int nf_flow_snat_ipv6(const struc
66 new_addr = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.src_v6;
67 ip6h->daddr = new_addr;
68 break;
69 - default:
70 - return -1;
71 }
72
73 return nf_flow_nat_ipv6_l4proto(skb, ip6h, thoff, &addr, &new_addr);
74 @@ -396,8 +390,6 @@ static int nf_flow_dnat_ipv6(const struc
75 new_addr = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.dst_v6;
76 ip6h->saddr = new_addr;
77 break;
78 - default:
79 - return -1;
80 }
81
82 return nf_flow_nat_ipv6_l4proto(skb, ip6h, thoff, &addr, &new_addr);