Skip to content

Commit 08733a0

Browse files
committed
netfilter: handle NF_REPEAT from nf_conntrack_in()
NF_REPEAT is only needed from nf_conntrack_in() under a very specific case required by the TCP protocol tracker, we can handle this case without returning to the core hook path. Handling of NF_REPEAT from the nf_reinject() is left untouched. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 26dfab7 commit 08733a0

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

net/netfilter/core.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,6 @@ int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state,
322322
if (ret == 0)
323323
ret = -EPERM;
324324
return ret;
325-
case NF_REPEAT:
326-
continue;
327325
case NF_QUEUE:
328326
ret = nf_queue(skb, state, &entry, verdict);
329327
if (ret == 1 && entry)

net/netfilter/nf_conntrack_core.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
13051305
if (skb->nfct)
13061306
goto out;
13071307
}
1308-
1308+
repeat:
13091309
ct = resolve_normal_ct(net, tmpl, skb, dataoff, pf, protonum,
13101310
l3proto, l4proto, &set_reply, &ctinfo);
13111311
if (!ct) {
@@ -1345,11 +1345,12 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
13451345
nf_conntrack_event_cache(IPCT_REPLY, ct);
13461346
out:
13471347
if (tmpl) {
1348-
/* Special case: we have to repeat this hook, assign the
1349-
* template again to this packet. We assume that this packet
1350-
* has no conntrack assigned. This is used by nf_ct_tcp. */
1348+
/* Special case: TCP tracker reports an attempt to reopen a
1349+
* closed/aborted connection. We have to go back and create a
1350+
* fresh conntrack.
1351+
*/
13511352
if (ret == NF_REPEAT)
1352-
skb->nfct = (struct nf_conntrack *)tmpl;
1353+
goto repeat;
13531354
else
13541355
nf_ct_put(tmpl);
13551356
}

net/openvswitch/conntrack.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,12 +725,8 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
725725
skb->nfctinfo = IP_CT_NEW;
726726
}
727727

728-
/* Repeat if requested, see nf_iterate(). */
729-
do {
730-
err = nf_conntrack_in(net, info->family,
731-
NF_INET_PRE_ROUTING, skb);
732-
} while (err == NF_REPEAT);
733-
728+
err = nf_conntrack_in(net, info->family,
729+
NF_INET_PRE_ROUTING, skb);
734730
if (err != NF_ACCEPT)
735731
return -ENOENT;
736732

0 commit comments

Comments
 (0)