Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with Nvidia source #272

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 1 addition & 12 deletions etc/network/ifupdown2/addons.conf
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
pre-up,openvswitch
pre-up,openvswitch_port
pre-up,xfrm
pre-up,link
pre-up,ppp
pre-up,bond
pre-up,batman_adv
pre-up,vlan
pre-up,vxlan
pre-up,clagd
pre-up,usercmds
pre-up,bridge
pre-up,bridgevlan
pre-up,mstpctl
pre-up,tunnel
pre-up,vrf
pre-up,tunnel
pre-up,ethtool
pre-up,address
up,dhcp
Expand All @@ -27,7 +22,6 @@ pre-down,ethtool
pre-down,usercmds
pre-down,vxrd
pre-down,dhcp
down,ppp
down,addressvirtual
down,address
down,usercmds
Expand All @@ -39,11 +33,6 @@ post-down,bridge
post-down,vxlan
post-down,vlan
post-down,bond
post-down,batman_adv
post-down,usercmds
post-down,link
post-down,tunnel
post-down,xfrm
post-down,openvswitch_port
post-down,openvswitch

12 changes: 6 additions & 6 deletions etc/network/ifupdown2/ifupdown2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ disable_cli_interfacesfile=0
# are used. But when a mix of scripts and modules are used (which is the
# default case), you may get false warnings for attributes supported
# by scripts
addon_syntax_check=0
addon_syntax_check=1

# Support executing of ifupdown style scripts.
# Note that by default python addon modules override scripts with the same
# name
addon_scripts_support=1
addon_scripts_support=0

# enable python addons
addon_python_modules_support=1

# By default ifupdown2 only supports a single vlan filtering bridge
# on the system. Set this flag to 1 to support multiple vlan
# filtering bridges
multiple_vlan_aware_bridge_support=0
# Originally ifupdown2 only supported a single vlan filtering bridge on the
# system. We now support multiple vlan aware bridges in the system. To move
# back to a single vlan aware bridge, please set this variable to 0.
multiple_vlan_aware_bridge_support=1

# ifquery check status strings.
# By default `ifquery --check` prints the check and
Expand Down
2 changes: 1 addition & 1 deletion ifupdown2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__version__ = '3.0.0'
__version__ = '3.1.0'

# Copyright (C) 2014,2015,2016,2017,2018,2019,2020 Cumulus Networks, Inc. All rights reserved
#
Expand Down
30 changes: 12 additions & 18 deletions ifupdown2/addons/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import time
import subprocess

from setuptools.dist import strtobool
from distutils.util import strtobool

try:
from ifupdown2.lib.addon import AddonWithIpBlackList
from ifupdown2.lib.addon import AddonWithIpBlackList, AddonException
from ifupdown2.nlmanager.nlmanager import Link

from ifupdown2.ifupdown.iface import ifaceType, ifaceLinkKind, ifaceLinkPrivFlags, ifaceStatus, iface
Expand All @@ -27,8 +27,8 @@
import ifupdown2.ifupdown.policymanager as policymanager
import ifupdown2.ifupdown.ifupdownflags as ifupdownflags
import ifupdown2.ifupdown.ifupdownconfig as ifupdownconfig
except (ImportError, ModuleNotFoundError):
from lib.addon import AddonWithIpBlackList
except ImportError:
from lib.addon import AddonWithIpBlackList, AddonException
from nlmanager.nlmanager import Link

from ifupdown.iface import ifaceType, ifaceLinkKind, ifaceLinkPrivFlags, ifaceStatus, iface
Expand Down Expand Up @@ -248,7 +248,7 @@ def __init__(self, *args, **kargs):
module_name=self.__class__.__name__,
attr='l3_intf_default_gateway_set_onlink'
),
default=True
default=False
)

self.check_l3_svi_ip_forwarding = utils.get_boolean_from_string(policymanager.policymanager_api.get_module_globals(
Expand Down Expand Up @@ -360,12 +360,12 @@ def syntax_check_enable_l3_iface_forwardings(self, ifaceobj, ifaceobj_getfunc, s

if vlan_addr and vlan_ipforward_off:
if syntax_check:
raise Exception(
raise AddonException(
'configuring ip-forward off and ip address(es) (%s) is not compatible'
% (', '.join(vlan_addr))
)
else:
raise Exception(
raise AddonException(
'%s: configuring ip-forward off and ip address(es) (%s) is not compatible'
% (ifname, ', '.join(vlan_addr))
)
Expand Down Expand Up @@ -406,7 +406,7 @@ def syntax_check_addr_allowed_on(self, ifaceobj, syntax_check=False):
def _syntax_check_multiple_gateway(self, family, found, addr, version):
if ipnetwork.IPNetwork(addr).version == version:
if found:
raise Exception('%s: multiple gateways for %s family'
raise AddonException('%s: multiple gateways for %s family'
% (addr, family))
return True
return False
Expand Down Expand Up @@ -444,11 +444,10 @@ def _process_bridge(self, ifaceobj, up, hwaddress, old_mac_addr=None):
arp_accept = utils.boolean_support_binary(arp_accept)
is_vlan_dev_on_vlan_aware_bridge = False
is_bridge = self.cache.get_link_kind(ifaceobj.name) == 'bridge'
if not is_bridge:
if ifaceobj.link_kind & ifaceLinkKind.VLAN:
bridgename = ifaceobj.lowerifaces[0]
vlan = self._get_vlan_id(ifaceobj)
is_vlan_dev_on_vlan_aware_bridge = self.cache.bridge_is_vlan_aware(bridgename)
if not is_bridge and ifaceobj.link_kind & ifaceLinkKind.VLAN:
bridgename = ifaceobj.lowerifaces[0]
vlan = self._get_vlan_id(ifaceobj)
is_vlan_dev_on_vlan_aware_bridge = self.cache.bridge_is_vlan_aware(bridgename)
if ((is_bridge and not self.cache.bridge_is_vlan_aware(ifaceobj.name))
or is_vlan_dev_on_vlan_aware_bridge):
if self._address_valid(addrs):
Expand Down Expand Up @@ -815,7 +814,6 @@ def _process_mtu_config_mtu_valid(self, ifaceobj, ifaceobj_getfunc, mtu_str, mtu
# ifupdown2 is called on a particular interface and
# it is a physical interface
self._propagate_mtu_to_upper_devs(ifaceobj, mtu_str, mtu_int, ifaceobj_getfunc)
return

def _process_mtu_config_mtu_none(self, ifaceobj):

Expand Down Expand Up @@ -1261,7 +1259,6 @@ def _down(self, ifaceobj, ifaceobj_getfunc=None):
self._process_bridge(ifaceobj, False, hwaddress, None)
except Exception as e:
self.logger.debug('%s : %s' %(ifaceobj.name, str(e)))
pass

def _get_bridge_fdbs(self, bridgename, vlan):
fdbs = self._bridge_fdb_query_cache.get(bridgename)
Expand Down Expand Up @@ -1326,7 +1323,6 @@ def _query_sysctl(self, ifaceobj, ifaceobjcurr):
ifaceobjcurr.update_config_with_status('mpls-enable',
running_mpls_enable,
mpls_enable != running_mpls_enable)
return

def query_check_ipv6_addrgen(self, ifaceobj, ifaceobjcurr):
ipv6_addrgen = ifaceobj.get_attr_value_first('ipv6-addrgen')
Expand All @@ -1347,14 +1343,12 @@ def _query_check(self, ifaceobj, ifaceobjcurr, ifaceobj_getfunc=None):
"""
TODO: Check broadcast address, scope, etc
"""
runningaddrsdict = None
if not self.cache.link_exists(ifaceobj.name):
self.logger.debug('iface %s not found' %ifaceobj.name)
return

self.query_check_ipv6_addrgen(ifaceobj, ifaceobjcurr)

addr_method = ifaceobj.addr_method
self.query_n_update_ifaceobjcurr_attr(ifaceobj, ifaceobjcurr,
'mtu', self.cache.get_link_mtu_str)
hwaddress = self._get_hwaddress(ifaceobj)
Expand Down
6 changes: 1 addition & 5 deletions ifupdown2/addons/addressvirtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import ifupdown2.ifupdown.policymanager as policymanager
import ifupdown2.ifupdown.ifupdownflags as ifupdownflags
import ifupdown2.ifupdown.ifupdownconfig as ifupdownconfig
except (ImportError, ModuleNotFoundError):
except ImportError:
from lib.addon import AddonWithIpBlackList
from ifupdown.iface import ifaceType, ifaceLinkKind, ifaceLinkPrivFlags, ifaceStatus
from ifupdown.utils import utils
Expand Down Expand Up @@ -147,14 +147,12 @@ def _remove_addresses_from_bridge(self, ifaceobj, hwaddress):
self.iproute2.bridge_fdb_del(bridgename, addr, vlan)
except Exception as e:
self.logger.debug("%s: %s" %(ifaceobj.name, str(e)))
pass
elif self.cache.link_is_bridge(ifaceobj.name):
for addr in hwaddress:
try:
self.iproute2.bridge_fdb_del(ifaceobj.name, addr)
except Exception as e:
self.logger.debug("%s: %s" %(ifaceobj.name, str(e)))
pass

def _get_bridge_fdbs(self, bridgename, vlan):
fdbs = self._bridge_fdb_query_cache.get(bridgename)
Expand Down Expand Up @@ -227,7 +225,6 @@ def _fix_connected_route(self, ifaceobj, vifacename, addr):
except Exception as e:
self.logger.debug('%s: fixing route entry failed (%s)'
% (ifaceobj.name, str(e)))
pass

def _get_macs_from_old_config(self, ifaceobj=None):
""" This method returns a list of the mac addresses
Expand Down Expand Up @@ -400,7 +397,6 @@ def sync_macvlan_forwarding_state(self, ifname, macvlan_ifname):
self.logger.info("%s: syncing macvlan forwarding with lower device forwarding state failed: %s" % (ifname, str(e)))

def create_macvlan_and_apply_config(self, ifaceobj, intf_config_list, vrrp=False):

"""
intf_config_list = [
{
Expand Down
7 changes: 3 additions & 4 deletions ifupdown2/addons/bond.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import ifupdown2.ifupdown.ifupdownflags as ifupdownflags

from ifupdown2.ifupdownaddons.modulebase import moduleBase
except (ImportError, ModuleNotFoundError):
except ImportError:
from nlmanager.ipnetwork import IPv4Address
from lib.addon import Addon
from nlmanager.nlmanager import Link
Expand Down Expand Up @@ -381,7 +381,7 @@ def valid_slave_speed(self, ifaceobj, bond_slaves, slave):

try:
self.compare_bond_and_slave_speed(ifaceobj, slave, int(self.read_file_oneline(f"/sys/class/net/{slave}/speed")))
except:
except Exception:
try:
match = self.speed_pattern.search(utils.exec_commandl(["/usr/sbin/ethtool", f"{slave}"]))
if match:
Expand All @@ -400,7 +400,7 @@ def get_bond_speed(self, runningslaves):
continue
try:
slave_speed = int(self.read_file_oneline(f"/sys/class/net/{slave}/speed"))
except:
except Exception:
slave_speed = -1

if bond_speed < 0:
Expand Down Expand Up @@ -470,7 +470,6 @@ def _add_slaves(self, ifaceobj, runningslaves, ifaceobj_getfunc=None):
self.netlink.link_up_force(slave)
except Exception as e:
self.logger.debug('%s: %s' % (ifaceobj.name, str(e)))
pass

if runningslaves:
removed_slave = []
Expand Down