Edward Haas has uploaded a new change for review. Change subject: net: Define netlink netdev flags constants under netlink.link ......................................................................
net: Define netlink netdev flags constants under netlink.link Add all supported flags and point all usages to the netlink.link module. Change-Id: I338c3ad27426fcd67457026c84565a59bf2a6e77 Signed-off-by: Edward Haas <edwa...@redhat.com> --- M lib/vdsm/network/ipwrapper.py M lib/vdsm/network/link/iface.py M lib/vdsm/network/netlink/link.py M tests/network/ipwrapper_test.py 4 files changed, 27 insertions(+), 12 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/40/63040/1 diff --git a/lib/vdsm/network/ipwrapper.py b/lib/vdsm/network/ipwrapper.py index 5eb72d6..2f9cb9a 100644 --- a/lib/vdsm/network/ipwrapper.py +++ b/lib/vdsm/network/ipwrapper.py @@ -97,8 +97,6 @@ _hiddenBonds = config.get('vars', 'hidden_bonds').split(',') _hiddenNics = config.get('vars', 'hidden_nics').split(',') _hiddenVlans = config.get('vars', 'hidden_vlans').split(',') - IFF_RUNNING = 1 << 6 - IFF_PROMISC = 1 << 8 def __init__(self, address, index, linkType, mtu, name, qdisc, state, vlanid=None, vlanprotocol=None, master=None, device=None, @@ -225,10 +223,10 @@ @property def oper_up(self): - return bool(link.get_link(self.name)['flags'] & self.IFF_RUNNING) + return bool(link.get_link(self.name)['flags'] & link.IFF_RUNNING) def get_promisc(self): - return bool(link.get_link(self.name)['flags'] & self.IFF_PROMISC) + return bool(link.get_link(self.name)['flags'] & link.IFF_PROMISC) def set_promisc(self, value): """Takes a boolean to enable/disable Link promiscuity""" diff --git a/lib/vdsm/network/link/iface.py b/lib/vdsm/network/link/iface.py index a4be512..0a62d60 100644 --- a/lib/vdsm/network/link/iface.py +++ b/lib/vdsm/network/link/iface.py @@ -25,10 +25,6 @@ from vdsm.network.netlink.monitor import Monitor -IFF_UP = 1 << 0 -IFF_RUNNING = 1 << 6 -IFF_PROMISC = 1 << 8 - STATE_UP = 'up' STATE_DOWN = 'down' @@ -64,7 +60,7 @@ def is_promisc(dev): - return bool(link.get_link(dev)['flags'] & IFF_PROMISC) + return bool(link.get_link(dev)['flags'] & link.IFF_PROMISC) def _up_blocking(dev, link_blocking): @@ -81,7 +77,7 @@ def _is_iface_up(link_flags, check_link): - iface_up = link_flags & IFF_UP + iface_up = link_flags & link.IFF_UP if check_link: - iface_up = iface_up and (link_flags & IFF_RUNNING) + iface_up = iface_up and (link_flags & link.IFF_RUNNING) return bool(iface_up) diff --git a/lib/vdsm/network/netlink/link.py b/lib/vdsm/network/netlink/link.py index 10d7807..39f1d13 100644 --- a/lib/vdsm/network/netlink/link.py +++ b/lib/vdsm/network/netlink/link.py @@ -29,6 +29,26 @@ from . import LIBNL_ROUTE, _nl_geterror, _pool, _none_proto from . import _addr_to_str, CHARBUFFSIZE +IFF_UP = 1 << 0 +IFF_BROADCAST = 1 << 1 +IFF_DEBUG = 1 << 2 +IFF_LOOPBACK = 1 << 3 +IFF_POINTOPOINT = 1 << 4 +IFF_NOTRAILERS = 1 << 5 +IFF_RUNNING = 1 << 6 +IFF_NOARP = 1 << 7 +IFF_PROMISC = 1 << 8 +IFF_ALLMULTI = 1 << 9 +IFF_MASTER = 1 << 10 +IFF_SLAVE = 1 << 11 +IFF_MULTICAST = 1 << 12 +IFF_PORTSEL = 1 << 13 +IFF_AUTOMEDIA = 1 << 14 +IFF_DYNAMIC = 1 << 15 +IFF_LOWER_UP = 1 << 16 +IFF_DORMANT = 1 << 17 +IFF_ECHO = 1 << 18 + def get_link(name): """Returns the information dictionary of the name specified link.""" diff --git a/tests/network/ipwrapper_test.py b/tests/network/ipwrapper_test.py index 3d9992a..7e7556b 100644 --- a/tests/network/ipwrapper_test.py +++ b/tests/network/ipwrapper_test.py @@ -28,6 +28,7 @@ from vdsm.network.ipwrapper import Route from vdsm.network.ipwrapper import Rule from vdsm.network.netlink import monitor +from vdsm.network.netlink.link import IFF_PROMISC from .nettestlib import Bridge, requires_brctl from testlib import VdsmTestCase as TestCaseBase @@ -134,7 +135,7 @@ link.promisc = True for event in mon: if (event['event'] == 'new_link' and - event.get('flags', 0) & ipwrapper.Link.IFF_PROMISC): + event.get('flags', 0) & IFF_PROMISC): return self.fail("Could not enable promiscuous mode.") -- To view, visit https://gerrit.ovirt.org/63040 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I338c3ad27426fcd67457026c84565a59bf2a6e77 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Edward Haas <edwa...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org