Skip to content

Commit 702151d

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for net: 1) Refetch IP header pointer after pskb_may_pull() in flowtable, from Haishuang Yan. 2) Fix memleak in flowtable offload in nf_flow_table_free(), from Paul Blakey. 3) Set control.addr_type mask in flowtable offload, from Edward Cree. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents b738a18 + 15ff197 commit 702151d

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

net/netfilter/nf_flow_table_core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ void nf_flow_table_free(struct nf_flowtable *flow_table)
554554
nf_flow_table_iterate(flow_table, nf_flow_table_do_cleanup, NULL);
555555
nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step, flow_table);
556556
nf_flow_table_offload_flush(flow_table);
557+
if (nf_flowtable_hw_offload(flow_table))
558+
nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step,
559+
flow_table);
557560
rhashtable_destroy(&flow_table->rhashtable);
558561
}
559562
EXPORT_SYMBOL_GPL(nf_flow_table_free);

net/netfilter/nf_flow_table_ip.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,13 @@ static int nf_flow_nat_ip(const struct flow_offload *flow, struct sk_buff *skb,
146146

147147
if (test_bit(NF_FLOW_SNAT, &flow->flags) &&
148148
(nf_flow_snat_port(flow, skb, thoff, iph->protocol, dir) < 0 ||
149-
nf_flow_snat_ip(flow, skb, iph, thoff, dir) < 0))
149+
nf_flow_snat_ip(flow, skb, ip_hdr(skb), thoff, dir) < 0))
150150
return -1;
151+
152+
iph = ip_hdr(skb);
151153
if (test_bit(NF_FLOW_DNAT, &flow->flags) &&
152154
(nf_flow_dnat_port(flow, skb, thoff, iph->protocol, dir) < 0 ||
153-
nf_flow_dnat_ip(flow, skb, iph, thoff, dir) < 0))
155+
nf_flow_dnat_ip(flow, skb, ip_hdr(skb), thoff, dir) < 0))
154156
return -1;
155157

156158
return 0;
@@ -189,6 +191,7 @@ static int nf_flow_tuple_ip(struct sk_buff *skb, const struct net_device *dev,
189191
if (!pskb_may_pull(skb, thoff + sizeof(*ports)))
190192
return -1;
191193

194+
iph = ip_hdr(skb);
192195
ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
193196

194197
tuple->src_v4.s_addr = iph->saddr;
@@ -426,11 +429,13 @@ static int nf_flow_nat_ipv6(const struct flow_offload *flow,
426429

427430
if (test_bit(NF_FLOW_SNAT, &flow->flags) &&
428431
(nf_flow_snat_port(flow, skb, thoff, ip6h->nexthdr, dir) < 0 ||
429-
nf_flow_snat_ipv6(flow, skb, ip6h, thoff, dir) < 0))
432+
nf_flow_snat_ipv6(flow, skb, ipv6_hdr(skb), thoff, dir) < 0))
430433
return -1;
434+
435+
ip6h = ipv6_hdr(skb);
431436
if (test_bit(NF_FLOW_DNAT, &flow->flags) &&
432437
(nf_flow_dnat_port(flow, skb, thoff, ip6h->nexthdr, dir) < 0 ||
433-
nf_flow_dnat_ipv6(flow, skb, ip6h, thoff, dir) < 0))
438+
nf_flow_dnat_ipv6(flow, skb, ipv6_hdr(skb), thoff, dir) < 0))
434439
return -1;
435440

436441
return 0;
@@ -459,6 +464,7 @@ static int nf_flow_tuple_ipv6(struct sk_buff *skb, const struct net_device *dev,
459464
if (!pskb_may_pull(skb, thoff + sizeof(*ports)))
460465
return -1;
461466

467+
ip6h = ipv6_hdr(skb);
462468
ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
463469

464470
tuple->src_v6 = ip6h->saddr;

net/netfilter/nf_flow_table_offload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static int nf_flow_rule_match(struct nf_flow_match *match,
8787
default:
8888
return -EOPNOTSUPP;
8989
}
90+
mask->control.addr_type = 0xffff;
9091
match->dissector.used_keys |= BIT(key->control.addr_type);
9192
mask->basic.n_proto = 0xffff;
9293

0 commit comments

Comments
 (0)