Skip to content

Commit b1b3255

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: conntrack: place confirm-bit setting in a helper
... so it can be re-used from clash resolution in followup patch. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 3d1e0b4 commit b1b3255

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

net/netfilter/nf_conntrack_core.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,19 @@ static void nf_ct_acct_merge(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
894894
}
895895
}
896896

897+
static void __nf_conntrack_insert_prepare(struct nf_conn *ct)
898+
{
899+
struct nf_conn_tstamp *tstamp;
900+
901+
atomic_inc(&ct->ct_general.use);
902+
ct->status |= IPS_CONFIRMED;
903+
904+
/* set conntrack timestamp, if enabled. */
905+
tstamp = nf_conn_tstamp_find(ct);
906+
if (tstamp)
907+
tstamp->start = ktime_get_real_ns();
908+
}
909+
897910
/**
898911
* nf_ct_resolve_clash - attempt to handle clash without packet drop
899912
*
@@ -965,7 +978,6 @@ __nf_conntrack_confirm(struct sk_buff *skb)
965978
struct nf_conntrack_tuple_hash *h;
966979
struct nf_conn *ct;
967980
struct nf_conn_help *help;
968-
struct nf_conn_tstamp *tstamp;
969981
struct hlist_nulls_node *n;
970982
enum ip_conntrack_info ctinfo;
971983
struct net *net;
@@ -1042,13 +1054,8 @@ __nf_conntrack_confirm(struct sk_buff *skb)
10421054
setting time, otherwise we'd get timer wrap in
10431055
weird delay cases. */
10441056
ct->timeout += nfct_time_stamp;
1045-
atomic_inc(&ct->ct_general.use);
1046-
ct->status |= IPS_CONFIRMED;
10471057

1048-
/* set conntrack timestamp, if enabled. */
1049-
tstamp = nf_conn_tstamp_find(ct);
1050-
if (tstamp)
1051-
tstamp->start = ktime_get_real_ns();
1058+
__nf_conntrack_insert_prepare(ct);
10521059

10531060
/* Since the lookup is lockless, hash insertion must be done after
10541061
* starting the timer and setting the CONFIRMED bit. The RCU barriers

0 commit comments

Comments
 (0)