Ido Barkan has uploaded a new change for review.

Change subject: net: better set/get_promisc
......................................................................

net: better set/get_promisc

The new implementation uses iproute2 to set this property and netlink
to get it. The former implementation used ctypes clumsy code and only
looked at the object state, which was set before the ioctl code.

Change-Id: Ib025251c48481c044718b98c623e736070f90d55
Signed-off-by: Ido Barkan <[email protected]>
---
M lib/vdsm/ipwrapper.py
1 file changed, 3 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/45693/1

diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py
index b42cfcb..3ded776 100644
--- a/lib/vdsm/ipwrapper.py
+++ b/lib/vdsm/ipwrapper.py
@@ -21,7 +21,6 @@
 from contextlib import closing
 from glob import iglob
 import array
-import ctypes
 import errno
 import fcntl
 import os
@@ -229,33 +228,14 @@
         return bool(self.flags & self.IFF_RUNNING)
 
     def get_promisc(self):
-        return bool(self.flags & self.IFF_PROMISC)
+        return bool(link.get_link(self.name)['flags'] & self.IFF_PROMISC)
 
     def set_promisc(self, value):
         """Takes a boolean to enable/disable Link promiscuity"""
-        if value:
-            self.flags |= self.IFF_PROMISC
-        else:
-            self.flags &= ~self.IFF_PROMISC
-        self.set_flags(self.flags)
+        promisc = 'on' if value else 'off'
+        linkSet(self.name, ['promisc', promisc])
 
     promisc = property(get_promisc, set_promisc, None, 'Link promiscuity flag')
-
-    def set_flags(self, flags):
-        "Set device flags. We need this local definition until ethtool has it"
-
-        SIOCSIFFLAGS = 0x8914
-
-        class ifreq(ctypes.Structure):
-            _fields_ = [("ifr_ifrn", ctypes.c_char * 16),
-                        ("ifr_flags", ctypes.c_short)]
-
-        with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as s:
-            ifr = ifreq()
-            ifr.ifr_ifrn = self.name
-            ifr.ifr_flags = flags
-
-            fcntl.ioctl(s.fileno(), SIOCSIFFLAGS, ifr)
 
 
 def drv_name(devName):


-- 
To view, visit https://gerrit.ovirt.org/45693
To unsubscribe, visit https://gerrit.ovirt.org/settings

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

Reply via email to