diff mbox series

[ovs-dev] ovs-vtep: Fix vlan binding.

Message ID 20250407190402.63304-1-vsaienko@mirantis.com
State Accepted
Commit 96ee23a218a6d26114a32706f8c69844b665a59d
Delegated to: aaron conole
Headers show
Series [ovs-dev] ovs-vtep: Fix vlan binding. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/cirrus-robot success cirrus build: passed

Commit Message

Vasyl Saienko April 7, 2025, 7:04 p.m. UTC
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 trafic 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>
---
 vtep/ovs-vtep.in | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

Comments

Aaron Conole April 24, 2025, 1:25 p.m. UTC | #1
Vasyl Saienko <vsaienko@mirantis.com> writes:

> 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 trafic 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>
> ---

Thanks for the contribution, Vasyl.  It's not a common setup to intermix
tagged and untagged as you're describing which is likely why this bug
existed since ovs-vtep was introduced.  I've applied and backported down
to 3.2.
diff mbox series

Patch

diff --git a/vtep/ovs-vtep.in b/vtep/ovs-vtep.in
index 0ee23b119..20476f89f 100755
--- a/vtep/ovs-vtep.in
+++ b/vtep/ovs-vtep.in
@@ -538,14 +538,16 @@  def add_binding(binding, ls):
     patch_no = ovs_vsctl("get Interface %s ofport" % pbinding)
     vlan_ = vlan.lstrip('0')
     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))
-        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))
     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))
-        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))
 
     # Create a logical_bindings_stats record.
@@ -570,12 +572,15 @@  def del_binding(binding, ls):
     patch_no = ovs_vsctl("get Interface %s ofport" % pbinding)
     vlan_ = vlan.lstrip('0')
     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_))
-        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:
-        ovs_ofctl("--strict del-flows %s in_port=%s" % (ps_name, port_no))
-        ovs_ofctl("--strict del-flows %s in_port=%s" % (ps_name, patch_no))
+        ovs_ofctl("--strict del-flows %s priority=100,in_port=%s"
+                  % (ps_name, port_no))
+        ovs_ofctl("--strict del-flows %s priority=100,in_port=%s"
+                  % (ps_name, patch_no))
 
     ls.del_lbinding(lbinding)