Skip to content

Commit 84b5ee9

Browse files
committed
netfilter: nf_conntrack: add nf_ct_timeout_lookup
This patch adds the new nf_ct_timeout_lookup function to encapsulate the timeout policy attachment that is called in the nf_conntrack_in path. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 236df00 commit 84b5ee9

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

‎include/net/netfilter/nf_conntrack_timeout.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ struct nf_conn_timeout *nf_ct_timeout_ext_add(struct nf_conn *ct,
5555
#endif
5656
};
5757

58+
static inline unsigned int *
59+
nf_ct_timeout_lookup(struct net *net, struct nf_conn *ct,
60+
struct nf_conntrack_l4proto *l4proto)
61+
{
62+
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
63+
struct nf_conn_timeout *timeout_ext;
64+
unsigned int *timeouts;
65+
66+
timeout_ext = nf_ct_timeout_find(ct);
67+
if (timeout_ext)
68+
timeouts = NF_CT_TIMEOUT_EXT_DATA(timeout_ext);
69+
else
70+
timeouts = l4proto->get_timeouts(net);
71+
72+
return timeouts;
73+
#else
74+
return l4proto->get_timeouts(net);
75+
#endif
76+
}
77+
5878
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
5979
extern int nf_conntrack_timeout_init(struct net *net);
6080
extern void nf_conntrack_timeout_fini(struct net *net);

‎net/netfilter/nf_conntrack_core.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,6 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
930930
enum ip_conntrack_info ctinfo;
931931
struct nf_conntrack_l3proto *l3proto;
932932
struct nf_conntrack_l4proto *l4proto;
933-
struct nf_conn_timeout *timeout_ext;
934933
unsigned int *timeouts;
935934
unsigned int dataoff;
936935
u_int8_t protonum;
@@ -997,11 +996,7 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
997996
NF_CT_ASSERT(skb->nfct);
998997

999998
/* Decide what timeout policy we want to apply to this flow. */
1000-
timeout_ext = nf_ct_timeout_find(ct);
1001-
if (timeout_ext)
1002-
timeouts = NF_CT_TIMEOUT_EXT_DATA(timeout_ext);
1003-
else
1004-
timeouts = l4proto->get_timeouts(net);
999+
timeouts = nf_ct_timeout_lookup(net, ct, l4proto);
10051000

10061001
ret = l4proto->packet(ct, skb, dataoff, ctinfo, pf, hooknum, timeouts);
10071002
if (ret <= 0) {

0 commit comments

Comments
 (0)