Skip to content

Commit 1063ae0

Browse files
lxinPaolo Abeni
authored andcommitted
Revert "openvswitch: switch to per-action label counting in conntrack"
Currently, ovs_ct_set_labels() is only called for confirmed conntrack entries (ct) within ovs_ct_commit(). However, if the conntrack entry does not have the labels_ext extension, attempting to allocate it in ovs_ct_get_conn_labels() for a confirmed entry triggers a warning in nf_ct_ext_add(): WARN_ON(nf_ct_is_confirmed(ct)); This happens when the conntrack entry is created externally before OVS increments net->ct.labels_used. The issue has become more likely since commit fcb1aa5 ("openvswitch: switch to per-action label counting in conntrack"), which changed to use per-action label counting and increment net->ct.labels_used when a flow with ct action is added. Since there’s no straightforward way to fully resolve this issue at the moment, this reverts the commit to avoid breaking existing use cases. Fixes: fcb1aa5 ("openvswitch: switch to per-action label counting in conntrack") Reported-by: Jianbo Liu <[email protected]> Signed-off-by: Xin Long <[email protected]> Acked-by: Aaron Conole <[email protected]> Link: https://patch.msgid.link/1bdeb2f3a812bca016a225d3de714427b2cd4772.1741457143.git.lucien.xin@gmail.com Signed-off-by: Paolo Abeni <[email protected]>
1 parent a1e64ad commit 1063ae0

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

net/openvswitch/conntrack.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,8 +1368,11 @@ bool ovs_ct_verify(struct net *net, enum ovs_key_attr attr)
13681368
attr == OVS_KEY_ATTR_CT_MARK)
13691369
return true;
13701370
if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) &&
1371-
attr == OVS_KEY_ATTR_CT_LABELS)
1372-
return true;
1371+
attr == OVS_KEY_ATTR_CT_LABELS) {
1372+
struct ovs_net *ovs_net = net_generic(net, ovs_net_id);
1373+
1374+
return ovs_net->xt_label;
1375+
}
13731376

13741377
return false;
13751378
}
@@ -1378,7 +1381,6 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr,
13781381
const struct sw_flow_key *key,
13791382
struct sw_flow_actions **sfa, bool log)
13801383
{
1381-
unsigned int n_bits = sizeof(struct ovs_key_ct_labels) * BITS_PER_BYTE;
13821384
struct ovs_conntrack_info ct_info;
13831385
const char *helper = NULL;
13841386
u16 family;
@@ -1407,12 +1409,6 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr,
14071409
return -ENOMEM;
14081410
}
14091411

1410-
if (nf_connlabels_get(net, n_bits - 1)) {
1411-
nf_ct_tmpl_free(ct_info.ct);
1412-
OVS_NLERR(log, "Failed to set connlabel length");
1413-
return -EOPNOTSUPP;
1414-
}
1415-
14161412
if (ct_info.timeout[0]) {
14171413
if (nf_ct_set_timeout(net, ct_info.ct, family, key->ip.proto,
14181414
ct_info.timeout))
@@ -1581,7 +1577,6 @@ static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info)
15811577
if (ct_info->ct) {
15821578
if (ct_info->timeout[0])
15831579
nf_ct_destroy_timeout(ct_info->ct);
1584-
nf_connlabels_put(nf_ct_net(ct_info->ct));
15851580
nf_ct_tmpl_free(ct_info->ct);
15861581
}
15871582
}
@@ -2006,9 +2001,17 @@ struct genl_family dp_ct_limit_genl_family __ro_after_init = {
20062001

20072002
int ovs_ct_init(struct net *net)
20082003
{
2009-
#if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT)
2004+
unsigned int n_bits = sizeof(struct ovs_key_ct_labels) * BITS_PER_BYTE;
20102005
struct ovs_net *ovs_net = net_generic(net, ovs_net_id);
20112006

2007+
if (nf_connlabels_get(net, n_bits - 1)) {
2008+
ovs_net->xt_label = false;
2009+
OVS_NLERR(true, "Failed to set connlabel length");
2010+
} else {
2011+
ovs_net->xt_label = true;
2012+
}
2013+
2014+
#if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT)
20122015
return ovs_ct_limit_init(net, ovs_net);
20132016
#else
20142017
return 0;
@@ -2017,9 +2020,12 @@ int ovs_ct_init(struct net *net)
20172020

20182021
void ovs_ct_exit(struct net *net)
20192022
{
2020-
#if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT)
20212023
struct ovs_net *ovs_net = net_generic(net, ovs_net_id);
20222024

2025+
#if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT)
20232026
ovs_ct_limit_exit(net, ovs_net);
20242027
#endif
2028+
2029+
if (ovs_net->xt_label)
2030+
nf_connlabels_put(net);
20252031
}

net/openvswitch/datapath.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ struct ovs_net {
160160
#if IS_ENABLED(CONFIG_NETFILTER_CONNCOUNT)
161161
struct ovs_ct_limit_info *ct_limit_info;
162162
#endif
163+
164+
/* Module reference for configuring conntrack. */
165+
bool xt_label;
163166
};
164167

165168
/**

0 commit comments

Comments
 (0)