Skip to content

Commit 227e1e4

Browse files
committed
netfilter: nf_flowtable: skip device lookup from interface index
Use the output device from the route that we cache in the flowtable entry. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent b3dfee3 commit 227e1e4

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

net/netfilter/nf_flow_table_ip.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,10 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
235235
if (tuplehash == NULL)
236236
return NF_ACCEPT;
237237

238-
outdev = dev_get_by_index_rcu(state->net, tuplehash->tuple.oifidx);
239-
if (!outdev)
240-
return NF_ACCEPT;
241-
242238
dir = tuplehash->tuple.dir;
243239
flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]);
244240
rt = (struct rtable *)flow->tuplehash[dir].tuple.dst_cache;
241+
outdev = rt->dst.dev;
245242

246243
if (unlikely(nf_flow_exceeds_mtu(skb, flow->tuplehash[dir].tuple.mtu)) &&
247244
(ip_hdr(skb)->frag_off & htons(IP_DF)) != 0)
@@ -452,13 +449,10 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,
452449
if (tuplehash == NULL)
453450
return NF_ACCEPT;
454451

455-
outdev = dev_get_by_index_rcu(state->net, tuplehash->tuple.oifidx);
456-
if (!outdev)
457-
return NF_ACCEPT;
458-
459452
dir = tuplehash->tuple.dir;
460453
flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]);
461454
rt = (struct rt6_info *)flow->tuplehash[dir].tuple.dst_cache;
455+
outdev = rt->dst.dev;
462456

463457
if (unlikely(nf_flow_exceeds_mtu(skb, flow->tuplehash[dir].tuple.mtu)))
464458
return NF_ACCEPT;

0 commit comments

Comments
 (0)