addons: vrf: be more friendly to older iproute2 versions
Ticket: CM-12049
Reviewed By: dsa, julien, nikhil
Testing Done: tested with and without /etc/iproute2/rt_tables.d/
OS does not have /etc/iproute2/rt_tables.d, on errors just info:
$ifreload -a -v
info: unable to save iproute2 vrf to table map ([Errno 2] No such file
or directory: '/etc/iproute2/rt_tables.d/ifupdown2_vrf_map.conf')
info: cannot find /etc/iproute2/rt_tables.d. pls check if your iproute2
version supports rt_tables.d
OS has /etc/iproute2/rt_tables.d, on errors warn:
$ifreload -a
warn: unable to save iproute2 vrf to table map ([Errno 2] No such file
Roopa Prabhu [Fri, 19 Aug 2016 18:09:57 +0000 (11:09 -0700)]
addons: bridge: fix running_vids value when cache is stale
Ticket: CM-12552
Reviewed By: julien, nikhil
Testing Done: tested with failing config with bridge-access 1
This is similar to the fix done in the below commit for pvid:
"5061730ea5bf ("addons: bridge: fix default pvid handling in cases where
cache is stale")"
easier steps to reproduce:
- have a vlan aware bridge with more than one ports
- add 'bridge-access 1' to one of the ports
- boot the box with the config
- check that the vlans are fine
- ifdown <interface_with_bridge_access_1>
- ifreload -a
- the interface with bridge_access 1 does
not have the pvid flag on vlan 1
This patch makes sure we assume the right running
vid and pvid value ie [1] and 1 if the
cache returns no values. vid = [1] and pvid = 1
are the kernel default/initial values for a port.
Roopa Prabhu [Sat, 13 Aug 2016 06:49:29 +0000 (23:49 -0700)]
addons: vrf: don't delete vrf map file at init if mgmt vrf already exists
Ticket: CM-12084
Reviewed By: julien, nikhil
Testing Done: tested with --allow=mgmt class
This fixes a problem where vrf map file was getting deleted
at boot during the second invocation of ifup. This is because
the code uses PERFMODE to check it is boot..but does
not realize that this may not be the first invocation of
ifup during the boot.
This patch adds additional checks for mgmt netdev to
make sure we delete the vrf map file only the first time.
My previous fix for the same bug did not fix the problem completly.
In this patch all running pvid calculation
is done before the pvid_to_del is calculated.
This makes sure the old pvid is deleted if it is not
the same as current pvid in all cases
Julien Fortin [Thu, 11 Aug 2016 01:05:04 +0000 (03:05 +0200)]
nlpacket: add new attribute: AttributeStringInterfaceName with length check
Ticket: CM-12302
Reviewed By: Daniel, Roopa, Nikhil G
Testing Done: ifupdown2 smoke test
With this pretty straight forward, we introduce a new Attribute in nlmanager,
so that we have single check and no code redundancy for ifname length. This
also prevent loosing time sending a netlink packet for an known error.
This can happen if the bridge vlans were
cached before the interface become a bridge port.
and when the interface becomes a bridge port
kernel adds a default pvid of 1. so this patch
assumes a default pvid is 1 if we did not find
anything in the cache. This will delete
the default pvid of 1 if the user has configured a
different pvid.
The message logged and the exception raised by nlmanager, when receiving
an NLMSG_ERROR packet from the kernel, wasn't super explicit plus if the
error wasn't a netlink related failure we didn't provide any information
Now we use strerror with the provided error code to generate a nice msg.
ifupdownaddons: iproute2: Cache vxlan remote ip addresses only if
statically configured
Ticket: CM-12277
Reviewed By: CCR-5059
Testing Done: ifreload with a VxlanClagClosConfig.py config
get_vxlan_peers gets remote ip addresses if they are statically configured
through ifupdown2 (vxlan-remoteip <address>). These are cached in
ifupdown2's link object so that they can be used in 'ip link set' (if link
exists already), 'ifquery -r' and 'ifquery -c'. ifupdown2 should ignore and
not cache these addresses if they are provisioned by vxrd. Check if vxrd is
running before caching remote ip addresses. This helps in optimizing time
taken to ifreload with 1k bridge/vxlan interfaces (vlan-aware bridge) in a
vxrd/vxsnd setup.
Roopa Prabhu [Mon, 8 Aug 2016 22:46:13 +0000 (15:46 -0700)]
addons: address: never reset mtu on lo implicity
we should leave the mtu on lo to the default mtu
if user has not requested to change it. lo has
a larger mtu because it does not really depend on a
physical mtu.
vrf slave brings up the master if master is not up yet.
Today this is done only when ALL (auto) option is set
just as an optimization. because you dont want to bring
up the master in cases where user just wants to
bring up the vrf slave. eg ifup -v eth0.
This does not work so well, when user uses
--allow classes to bring up vrf master and slaves
together (eg mgmt vrf).
This patch removes the ALL check when bringing
up master and replaces it with an ALL or
CLASS check. ie make sure vrf master belongs to the
same class as you when CLASS is specified.
Roopa Prabhu [Fri, 5 Aug 2016 18:28:28 +0000 (11:28 -0700)]
ifupdown: move IFACE_CLASS ifupdownmain flag to ifupdownflags.CLASS
This patch moves ifupdownmain flag IFACE_CLASS to
ifupdownflags.CLASS. ifupdownflags.CLASS is set to true
if the user is asking for a class of interfaces.
example: ifreload --allow=mgmt
By moving it to ifupdownflags, we make it visible
to add modules.
Roopa Prabhu [Wed, 3 Aug 2016 22:35:04 +0000 (15:35 -0700)]
addons: bridge: fix bridge vid error on ifaces with multiple stanzas
Ticket: CM-12151
Reviewed By: julien, nikhil
Testing Done: Tested bridge vid errors with multiple iface stanzas for
ports
This patch just uses the HAS_SIBLINGS and OLDEST_SIBLINGS
flags on an iface to make sure we flag the error
on the last interface ie oldest of the siblings. all interfaces
with multiple iface objects have HAS_SIBLINGS set and the last iface
has OLDEST_SIBLINGS set.
The other way to fix this for the user would be to set ifaceobj_squash=1
in /etc/network/ifupdown2/ifupdown2.conf
Roopa Prabhu [Wed, 3 Aug 2016 19:22:14 +0000 (12:22 -0700)]
addons: bridge: reset vlan_filtering when user moves from vlan aware to
unaware
Ticket: CM-12070
Reviewed By: julien, nikhil
Testing Done: Tested with config in the bug
The bug also talks about removing the vlans during this
transition. If the vlans are removed from the interfaces file,
ifupdown2 will delete them on an ifreload. In any case, once moved to
vlan unaware bridge settings, kernel and switchd
don't look at vlans any more.
Julien Fortin [Mon, 1 Aug 2016 07:49:08 +0000 (09:49 +0200)]
ifupdownaddons: mstpctl: treeportprio value is cached. It prevents ifupdown2 from executing mstpctl settreeportprio commands when the running value is the same as the one previously cached
Ticket: CM-11773
Reviewed By: Roopa, Nikhil G
Testing Done: smoke + hand testings :
$ cat /etc/network/interfaces
auto br2
iface br2
bridge-vlan-aware yes
bridge-vids 100
bridge-pvid 1
bridge-ports swp1 swp4 swp5
bridge-stp on
$ ifreload -a -v
[...]
info: netlink: set link swp1 up
info: netlink: set link swp4 up
info: netlink: set link swp5 up
info: br2: applying mstp configuration specific to ports
info: br2: processing mstp config for port swp1
info: executing /sbin/mstpctl showportdetail br2 json
info: executing /sbin/mstpctl settreeportprio br2 swp1 0 128
info: br2: processing mstp config for port swp4
info: executing /sbin/mstpctl settreeportprio br2 swp4 0 128
info: br2: processing mstp config for port swp5
info: executing /sbin/mstpctl settreeportprio br2 swp5 0 128
info: netlink: set link br2 up
[...]
$
/sbin/mstpctl settreeportprio br2 swpX 0 128 is executed for every port.
ifupdown2 tries to set this attr to 128 (the default value). This is a
problem at scale. We shouldn't try to set this value if the running value
is already 128.
With the attached patch:
$ ifreload -a
[...]
info: netlink: set link swp1 up
info: netlink: set link swp4 up
info: netlink: set link swp5 up
info: executing /sbin/mstpctl showportdetail br2 json
info: br2: applying mstp configuration specific to ports
info: br2: processing mstp config for port swp1
info: br2: processing mstp config for port swp4
info: br2: processing mstp config for port swp5
info: netlink: set link br2 up
[...]
$
It's possible to combine a keyword with a range from validrange. example:
validrange: 10-50
validvals: <intrface-range-list>
value: swp1=21 swp2=42 ...
addons: addressvirtual: enslave macvlans on vrf slaves to the vrf master
Ticket: CM-11803
Reviewed By: dsa, scotte, wkok, nikhil, julien
Testing Done: tested config of address-virtual lines on vrf slaves
This patch does the following:
- addressvirtual: enslaves macvlans created on vrf slaves
to the vrf master
- vrf: when looking for stale slaves on vrf master, skip
macvlan devices. This code does basic checking right now
and can be improved to include more cases.
addons: bridge: fix 'ifquery -c' 'bridge vid error' on vlan aware bridge port
Ticket: CM-11811
Reviewed By: roopa, julien
Testing Done: used same configuration from ticket
For a VLAN aware bridge, if 'bridge-pvid' is not configured,
auto bridge
iface bridge
bridge-ports swp7 swp8
bridge-vids 1-200
bridge-vlan-aware yes
'1' is would be running pvid and [2-200] would be running vids.
While doing _query_check() we compare configred versus running
vids excluding running 'pvid'. Configured vids here is [1-200]
and running is [2-200], but instead of excluding running 'pvid'
we used to exclued configured 'pvid' which is None in this case.
Comparison used to fail because of this.
This patch excludes running 'pvid' instead of configured 'pvid'
during _query_check()
This patch also fixes 'ifquery -c' error for bridge-pvid if
configured under a port of vlan aware bridge
This patch also avoids printing 'bridge-pvid' on 'ifquery -c'
if bridge-pvid is not configured under vlan aware bridge port
addons: bridge: fix 'ifquery -c' 'bridge vid error' on vlan aware bridge port
Ticket: CM-11811
Reviewed By: roopa, julien
Testing Done: used same configuration from ticket
For a VLAN aware bridge, if 'bridge-pvid' is not configured,
auto bridge
iface bridge
bridge-ports swp7 swp8
bridge-vids 1-200
bridge-vlan-aware yes
'1' is would be running pvid and [2-200] would be running vids.
While doing _query_check() we compare configred versus running
vids excluding running 'pvid'. Configured vids here is [1-200]
and running is [2-200], but instead of excluding running 'pvid'
we used to exclued configured 'pvid' which is None in this case.
Comparison used to fail because of this.
This patch excludes running 'pvid' instead of configured 'pvid'
during _query_check()
This patch also fixes 'ifquery -c' error for bridge-pvid if
configured under a port of vlan aware bridge
ethtool module should really care only about
physical interfaces. so, this patch makes ethtool
module ignore all logical interfaces, ie interfaces
with link_kind set.
addons: usercmds: adding environment variables passed by the ifupdown2 to user scripts
Ticket: None
Reviewed By: Roopa
Testing Done: with a dummy script I printed the value passed by ifupdown
After the changes I did the same with ifupdown2 and checksd if the values
matched correctly.
ifupdown: fixes to make addon scripts work via special config options
ifupdown2 can invoke scripts under /etc/network/if-*.d/*
in the required order with the required environment variables.
This patch includes fixes to execute these scripts.
The following attributes in /etc/network/ifupdown2/ifupdown.conf
can influence the execution behaviour of python-addon modules
and /etc/network/if-*.d/*
ifupdown: networkinterfaces: not importing template engine if no mako keyword found
Ticket: CM-11807
Reviewed By: Roopa, Daniel
Testing Done:
Loading the default template engine (mako) is adding an extra overhead: 100ms
We also import the template engine even if we are dealing with a json input
The overhead is noticable when using NCLU.
With this change we are now important the template engine when a keyword is
found in the configuration file.
ifupdown: fixes to make addon scripts work via special config options
ifupdown2 can invoke scripts under /etc/network/if-*.d/*
in the required order with the required environment variables.
This patch includes fixes to execute these scripts.
The following attributes in /etc/network/ifupdown2/ifupdown.conf
can influence the execution behaviour of python-addon modules
and /etc/network/if-*.d/*
addons: addressvirtual: allowing address-virtual attr for vrf slave interfaces
Ticket: CM-11745
Reviewed By: Roopa, Nikhil G
Testing Done: configuration provided in the bug
User was attempting to configure a traditional bridge under a VRF with VRR.
When issuing ifreload -a, the configuration failed to apply with an error.
Applying an address-virtual keyword to an interface with upper interfaces
or parent interfaces was not allowed. But now we are allowing the use of
this keyword only for vrf slaves.
iproute2 was parsing the '/sbin/bridge -c vlan show' output with the assumption that
pvid line '711 PVID Egress Untagged' appears before all the vland ids.
Something like this:
port vlan ids
swp1 711 PVID Egress Untagged
600
700-710
712-900
Sam Tannous [Fri, 8 Jul 2016 00:16:22 +0000 (17:16 -0700)]
ifupdown2 defaults for link attributes are not applied
Ticket: CM-11718
Reviewed By: CCR-4931
Testing Done: Tested complete regression suite on hardnode in 3.0.
This patch fixes a problem in the ethtool addon module where a single iface stanza was
configured for a link-speed (1G) other then the default (10G). The link-speed config is then
removed or commented out but the link-speed is not restored to its default value (10G) because of
incorrect logic.
Nikhil [Wed, 29 Jun 2016 23:38:50 +0000 (16:38 -0700)]
addons: bridge: ifquery -c fix for port attributes
Ticket: CM-11195
Reviewed By: roopa, julien
Testing Done: used the configuration mentioned in bug description
Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
running values for bridge-portmcrouter, bridge-portmcfl, and bridge-portprios
were accessed using invalid keys.
Julien Fortin [Sun, 26 Jun 2016 23:24:18 +0000 (00:24 +0100)]
nlmanager: nlpacket: throw an error if the user of nlmanager tries to encode an attribute that we haven't added an encode() method for
+ adding one byte attribute class for protodown operations.
Ticket: CM-11581
Reviewed By: CCR-4721
Testing Done: Smoke + custom interface file with clag bond that requires protodown.
- nlmanager will now throw an exception if a user is trying to use the default
attribute class when in fact he should use a more specific attribute class.
- The protodown implementation needed to use a one byte attribute to set the protodown state
Scott Emery [Thu, 23 Jun 2016 21:58:14 +0000 (14:58 -0700)]
ifupdown2: Disable IPv6 duplicate address detection on VRR interfaces
Ticket: CM-11511
Reviewed By: CCR-4890
Testing Done: Used "address-virtual" keyword to create VRR interface with IPv6
address. Checked sysctl and dad failures.
In a VRR setup, both switches are programmed with the same IPv6 address and that
address is active on both switches. This causes the IPv6 duplicate address
detection to kick in and diable the use of one of the address on one of the
switches. This patch causes duplicate address detection to be disabled on VRR
interfaces by setting the net.ipv6.conf.<ifname>.accept_dad and
net.ipv6.conf.<ifname>.dad_transmits sysctl's to 0. The only IPv6 addresses
which are defined on these interfaces are the virtual addresses and the link
local address (which is unused). No other operational IPv6 addresses should ever
be assigned to these interfaces. Instead, operational IPv6 addresses should be
assigned to the "base", or lower, interface of the VRR interface.
Julien Fortin [Tue, 21 Jun 2016 14:17:09 +0000 (15:17 +0100)]
addons: vlan: ifquery will try to get the vlan-id from the ifacename if vlan-id attr is missing
Ticket: CM-11485
Reviewed By: Roopa
Testing Done: config from the github issue
First reported here https://github.com/CumulusNetworks/ifupdown2/issues/10
ifquery just like ifupdown should try to get the vlan-id from the iface name
if vlan-id attr is not specified.
Nikhil [Wed, 25 May 2016 23:16:22 +0000 (16:16 -0700)]
addons: vrf: Fix to kill current ssh on 'sudo ifreload -a' to enable mgmt VRF
Ticket: CM-11080
Reviewed By: roopa, dsa, dave olson, daniel, julien
Testing Done: yes, with mgmt VRF configured
This patch parses '/usr/bin/pstree -Aps <pid>' output to find
the pid of current ssh session, and send 'sudo ifreload -a'
to background before killing itself.