2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00

ovs-vtep: Fix vlan binding.

When bind port to multiple logical switches with
vlan and without vlan tag rules are generated without
priority. Rule without tag is more generic and matches
all traffic by in_port selector.
Since both rules has same priority first rule wins.
This patch adds priority to vlan based rule as 200
and 100 for rule without vlan to make sure rules with
vlan checked first.

Signed-off-by: Vasyl Saienko <vsaienko@mirantis.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
This commit is contained in:
Vasyl Saienko 2025-04-07 22:04:02 +03:00 committed by Aaron Conole
parent 484208bd17
commit 96ee23a218

View File

@ -538,14 +538,16 @@ def add_binding(binding, ls):
patch_no = ovs_vsctl("get Interface %s ofport" % pbinding) patch_no = ovs_vsctl("get Interface %s ofport" % pbinding)
vlan_ = vlan.lstrip('0') vlan_ = vlan.lstrip('0')
if vlan_: if vlan_:
ovs_ofctl("add-flow %s in_port=%s,dl_vlan=%s,action=strip_vlan,%s" ovs_ofctl("add-flow %s priority=200,in_port=%s,dl_vlan=%s,"
"action=strip_vlan,%s"
% (ps_name, port_no, vlan_, patch_no)) % (ps_name, port_no, vlan_, patch_no))
ovs_ofctl("add-flow %s in_port=%s,action=mod_vlan_vid:%s,%s" ovs_ofctl("add-flow %s priority=200,in_port=%s,"
"action=mod_vlan_vid:%s,%s"
% (ps_name, patch_no, vlan_, port_no)) % (ps_name, patch_no, vlan_, port_no))
else: else:
ovs_ofctl("add-flow %s in_port=%s,action=%s" ovs_ofctl("add-flow %s priority=100,in_port=%s,action=%s"
% (ps_name, port_no, patch_no)) % (ps_name, port_no, patch_no))
ovs_ofctl("add-flow %s in_port=%s,action=%s" ovs_ofctl("add-flow %s priority=100,in_port=%s,action=%s"
% (ps_name, patch_no, port_no)) % (ps_name, patch_no, port_no))
# Create a logical_bindings_stats record. # Create a logical_bindings_stats record.
@ -570,12 +572,15 @@ def del_binding(binding, ls):
patch_no = ovs_vsctl("get Interface %s ofport" % pbinding) patch_no = ovs_vsctl("get Interface %s ofport" % pbinding)
vlan_ = vlan.lstrip('0') vlan_ = vlan.lstrip('0')
if vlan_: if vlan_:
ovs_ofctl("del-flows %s in_port=%s,dl_vlan=%s" ovs_ofctl("del-flows %s priority=200,in_port=%s,dl_vlan=%s"
% (ps_name, port_no, vlan_)) % (ps_name, port_no, vlan_))
ovs_ofctl("del-flows %s in_port=%s" % (ps_name, patch_no)) ovs_ofctl("del-flows %s priority=200,in_port=%s"
% (ps_name, patch_no))
else: else:
ovs_ofctl("--strict del-flows %s in_port=%s" % (ps_name, port_no)) ovs_ofctl("--strict del-flows %s priority=100,in_port=%s"
ovs_ofctl("--strict del-flows %s in_port=%s" % (ps_name, patch_no)) % (ps_name, port_no))
ovs_ofctl("--strict del-flows %s priority=100,in_port=%s"
% (ps_name, patch_no))
ls.del_lbinding(lbinding) ls.del_lbinding(lbinding)