Dan Kenigsberg has uploaded a new change for review. Change subject: tc: retire ifconfig ......................................................................
tc: retire ifconfig ifconfig was deprecated quite a few years ago, and some modern distribution do not ship it by default. In this patch, we dump its only use, by setting promisc flag directly. We implement set_flags() in hope to see ethtool add it. Change-Id: Ifb4f289efb5754d7c49ac0a08e3a9adc09b12bb7 Signed-off-by: Dan Kenigsberg <[email protected]> --- M configure.ac M vdsm/constants.py.in M vdsm/tc.py M vdsm_reg/deployUtil.py.in 4 files changed, 30 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/9370/1 diff --git a/configure.ac b/configure.ac index 5d8b238..b8f1825 100644 --- a/configure.ac +++ b/configure.ac @@ -144,7 +144,6 @@ AC_PATH_PROG([FUSER_PATH], [fuser], [/sbin/fuser]) AC_PATH_PROG([GRUBBY_PATH], [grubby], [/sbin/grubby]) AC_PATH_PROG([HWCLOCK_PATH], [hwclock], [/usr/sbin/hwclock]) -AC_PATH_PROG([IFCONFIG_PATH], [ifconfig], [/sbin/ifconfig]) AC_PATH_PROG([IFDOWN_PATH], [ifdown], [/sbin/ifdown]) AC_PATH_PROG([IFUP_PATH], [ifup], [/sbin/ifup]) AC_PATH_PROG([IONICE_PATH], [ionice], [/usr/bin/ionice]) diff --git a/vdsm/constants.py.in b/vdsm/constants.py.in index 2e9eb99..07dd431 100644 --- a/vdsm/constants.py.in +++ b/vdsm/constants.py.in @@ -97,7 +97,6 @@ EXT_FSCK = '@FSCK_PATH@' EXT_FUSER = '@FUSER_PATH@' -EXT_IFCONFIG = '@IFCONFIG_PATH@' EXT_IFDOWN = '@IFDOWN_PATH@' EXT_IFUP = '@IFUP_PATH@' EXT_IONICE = '@IONICE_PATH@' diff --git a/vdsm/tc.py b/vdsm/tc.py index a0a612f..7630b9b 100644 --- a/vdsm/tc.py +++ b/vdsm/tc.py @@ -19,11 +19,15 @@ # from collections import namedtuple +from contextlib import closing +import ctypes +import fcntl +import socket import ethtool import storage.misc -from vdsm.constants import EXT_TC, EXT_IFCONFIG +from vdsm.constants import EXT_TC ERR_DEV_NOEXIST = 2 @@ -155,12 +159,32 @@ raise +def set_flags(dev, 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 = dev + ifr.ifr_flags = flags + + fcntl.ioctl(s.fileno(), SIOCSIFFLAGS, ifr) + + def set_promisc(dev, on=True): - promisc = 'promisc' - if not on: - promisc = '-promisc' - command = [EXT_IFCONFIG, dev, promisc] - _process_request(command) + flags = ethtool.get_flags(dev) + + if on: + flags |= ethtool.IFF_PROMISC + else: + flags &= ~ethtool.IFF_PROMISC + + set_flags(dev, flags) Filter = namedtuple('Filter', 'prio handle actions') diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in index dec03c2..0fe1275 100644 --- a/vdsm_reg/deployUtil.py.in +++ b/vdsm_reg/deployUtil.py.in @@ -65,7 +65,6 @@ EX_ECHO = '@ECHO_PATH@' EX_GRUBBY = '@GRUBBY_PATH@' EX_HWCLOCK = '@HWCLOCK_PATH@' -EX_IFCONFIG = '@IFCONFIG_PATH@' EX_NTPQ = '@NTPQ_PATH@' EX_OPENSSL = '@OPENSSL_PATH@' EX_REBOOT = '@REBOOT_PATH@' -- To view, visit http://gerrit.ovirt.org/9370 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifb4f289efb5754d7c49ac0a08e3a9adc09b12bb7 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
