Hunt Xu has uploaded a new change for review.

Change subject: tc: set/unset promisc when it's really needed
......................................................................

tc: set/unset promisc when it's really needed

When setPortMirroring is called multiple times for the same network (in
case that more than one vms on the same host would monitor the same
logical network), we don't need to set the device's promisc flag to on
more than once.

Change-Id: I7d38e2f13a059ea916892ab8247509e2e0b612e2
Signed-off-by: huntxu <[email protected]>
---
M vdsm/tc.py
1 file changed, 6 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/07/12307/1

diff --git a/vdsm/tc.py b/vdsm/tc.py
index e3c2770..3f34071 100644
--- a/vdsm/tc.py
+++ b/vdsm/tc.py
@@ -179,12 +179,13 @@
 def set_promisc(dev, on=True):
     flags = ethtool.get_flags(dev)
 
-    if on:
-        flags |= ethtool.IFF_PROMISC
-    else:
-        flags &= ~ethtool.IFF_PROMISC
+    if bool(flags & ethtool.IFF_PROMISC) ^ on:
+        if on:
+            flags |= ethtool.IFF_PROMISC
+        else:
+            flags &= ~ethtool.IFF_PROMISC
 
-    set_flags(dev, flags)
+        set_flags(dev, flags)
 
 
 Filter = namedtuple('Filter', 'prio handle actions')


--
To view, visit http://gerrit.ovirt.org/12307
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d38e2f13a059ea916892ab8247509e2e0b612e2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Hunt Xu <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to