Skip to content

Commit 7177895

Browse files
YiHungWeidavem330
authored andcommitted
openvswitch: Fix conntrack cache with timeout
This patch addresses a conntrack cache issue with timeout policy. Currently, we do not check if the timeout extension is set properly in the cached conntrack entry. Thus, after packet recirculate from conntrack action, the timeout policy is not applied properly. This patch fixes the aforementioned issue. Fixes: 06bd2bd ("openvswitch: Add timeout support to ct action") Reported-by: kbuild test robot <[email protected]> Signed-off-by: Yi-Hung Wei <[email protected]> Acked-by: Pravin B Shelar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 803f3e2 commit 7177895

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

net/openvswitch/conntrack.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct ovs_conntrack_info {
6767
struct md_mark mark;
6868
struct md_labels labels;
6969
char timeout[CTNL_TIMEOUT_NAME_MAX];
70+
struct nf_ct_timeout *nf_ct_timeout;
7071
#if IS_ENABLED(CONFIG_NF_NAT)
7172
struct nf_nat_range2 range; /* Only present for SRC NAT and DST NAT. */
7273
#endif
@@ -697,6 +698,14 @@ static bool skb_nfct_cached(struct net *net,
697698
if (help && rcu_access_pointer(help->helper) != info->helper)
698699
return false;
699700
}
701+
if (info->nf_ct_timeout) {
702+
struct nf_conn_timeout *timeout_ext;
703+
704+
timeout_ext = nf_ct_timeout_find(ct);
705+
if (!timeout_ext || info->nf_ct_timeout !=
706+
rcu_dereference(timeout_ext->timeout))
707+
return false;
708+
}
700709
/* Force conntrack entry direction to the current packet? */
701710
if (info->force && CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) {
702711
/* Delete the conntrack entry if confirmed, else just release
@@ -1657,6 +1666,10 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr,
16571666
ct_info.timeout))
16581667
pr_info_ratelimited("Failed to associated timeout "
16591668
"policy `%s'\n", ct_info.timeout);
1669+
else
1670+
ct_info.nf_ct_timeout = rcu_dereference(
1671+
nf_ct_timeout_find(ct_info.ct)->timeout);
1672+
16601673
}
16611674

16621675
if (helper) {

0 commit comments

Comments
 (0)