Commit 71778951 authored by Yi-Hung Wei's avatar Yi-Hung Wei Committed by David S. Miller

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: 06bd2bdf ("openvswitch: Add timeout support to ct action")
Reported-by: default avatarkbuild test robot <lkp@intel.com>
Signed-off-by: default avatarYi-Hung Wei <yihung.wei@gmail.com>
Acked-by: default avatarPravin B Shelar <pshelar@ovn.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 803f3e22
...@@ -67,6 +67,7 @@ struct ovs_conntrack_info { ...@@ -67,6 +67,7 @@ struct ovs_conntrack_info {
struct md_mark mark; struct md_mark mark;
struct md_labels labels; struct md_labels labels;
char timeout[CTNL_TIMEOUT_NAME_MAX]; char timeout[CTNL_TIMEOUT_NAME_MAX];
struct nf_ct_timeout *nf_ct_timeout;
#if IS_ENABLED(CONFIG_NF_NAT) #if IS_ENABLED(CONFIG_NF_NAT)
struct nf_nat_range2 range; /* Only present for SRC NAT and DST NAT. */ struct nf_nat_range2 range; /* Only present for SRC NAT and DST NAT. */
#endif #endif
...@@ -697,6 +698,14 @@ static bool skb_nfct_cached(struct net *net, ...@@ -697,6 +698,14 @@ static bool skb_nfct_cached(struct net *net,
if (help && rcu_access_pointer(help->helper) != info->helper) if (help && rcu_access_pointer(help->helper) != info->helper)
return false; return false;
} }
if (info->nf_ct_timeout) {
struct nf_conn_timeout *timeout_ext;
timeout_ext = nf_ct_timeout_find(ct);
if (!timeout_ext || info->nf_ct_timeout !=
rcu_dereference(timeout_ext->timeout))
return false;
}
/* Force conntrack entry direction to the current packet? */ /* Force conntrack entry direction to the current packet? */
if (info->force && CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) { if (info->force && CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) {
/* Delete the conntrack entry if confirmed, else just release /* 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, ...@@ -1657,6 +1666,10 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr,
ct_info.timeout)) ct_info.timeout))
pr_info_ratelimited("Failed to associated timeout " pr_info_ratelimited("Failed to associated timeout "
"policy `%s'\n", ct_info.timeout); "policy `%s'\n", ct_info.timeout);
else
ct_info.nf_ct_timeout = rcu_dereference(
nf_ct_timeout_find(ct_info.ct)->timeout);
} }
if (helper) { if (helper) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment