]> git.proxmox.com Git - mirror_ifupdown2.git/log
mirror_ifupdown2.git
7 years agoifupdownmain: missing return statement and fixing 'network down' error checking
Julien Fortin [Mon, 10 Oct 2016 13:22:30 +0000 (15:22 +0200)]
ifupdownmain: missing return statement and fixing 'network down' error checking

Ticket:
Reviewed By: Roopa, Nikhil G

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agodocs: examples: adding new example interface file
Julien Fortin [Wed, 5 Oct 2016 14:44:42 +0000 (16:44 +0200)]
docs: examples: adding new example interface file

Ticket: None
Reviewed By: Roopa
Testing Done:

This new interface file uses bridge, vlan, vxlan, bond and vrf interfaces.
It's a good way to try ifupdown2 capabilities.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: vrf: cosmetic print statement fix
Nikhil [Tue, 4 Oct 2016 18:37:52 +0000 (11:37 -0700)]
addons: vrf: cosmetic print statement fix

Ticket: CM-12753
Reviewed By: roopa, julien
Testing Done: used same config mentioned in the bug

Changed %d to %s inorder to print a string.

Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
7 years agoifupdownaddons: bridgeutils: iproute2: skipping unsupported commands
Julien Fortin [Tue, 4 Oct 2016 08:18:26 +0000 (10:18 +0200)]
ifupdownaddons: bridgeutils: iproute2: skipping unsupported commands

Ticket:
Reviewed By: Roopa, Nikhil G
Testing Done:

When using ifupdown2 on regular distribution (debian/ubuntu etc...) users may
not have the latest iproute2/bridge-utils version. Thus the output parsed from
the various subcommands executed by ifupdown2 might defer and cause exception
to be throwned.
We identified several cases:
/sbin/bridge -c -json vlan show
/sbin/brctl showmcqv4src bridge0
/sbin/brctl showstp bridge0

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: vrf: removing ifaceobj.name from exception message
Julien Fortin [Tue, 4 Oct 2016 08:13:23 +0000 (10:13 +0200)]
addons: vrf: removing ifaceobj.name from exception message

Ticket: None
Reviewed By:
Testing Done:

The function _create_vrf_dev is surrounded by a try/catch as follow:
    try:
        vrf_table = self._create_vrf_dev(ifaceobj, vrf_table)
    except Exception, e:
        self.log_error('%s: %s' %(ifaceobj.name, str(e)), ifaceobj)

Thus we shouldn't include the ifaceobj.name in any error message passed to
log_error(). Since this function will raise an exception by default, it will
result in something like this:

error:br0.4002: red: red: create failed (cmd 'ip link add name red type vrf table 1001' failed: returned 1 ...[snip]
error:red: red: create failed (cmd 'ip link add name red type vrf table 1002' failed: returned 1 ...[snip]

after this patch:
error: red: create failed (cmd 'ip link add name red type vrf table 1002' failed: returned 1 ... [snip]

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons may provide a list of ifupdown scripts to ignore
Julien Fortin [Tue, 27 Sep 2016 09:05:37 +0000 (11:05 +0200)]
addons may provide a list of ifupdown scripts to ignore

Ticket:
Reviewed By: Roopa, Nikhil G
Testing Done:

ifupdown2's python addons are replacing some/most of the old ifupdown shell
scripts. When addon_scripts_support is set to 1, ifupdown2 will execute every
scripts present in /etc/network/if-$ACTION.d/ if a script exists with a name
identical to an ifupdown2 addon, this script won't be executed.

Sometimes an ifupdown2 addons doesn't have the same name as the ifupdown script
it's supposed to replace. Or maybe one addon is replacing several scripts.
For example: bond.py is replacing /etc/network/if-*.d/ifenslave

Now each addon is able to provide a list of script to ignore.

[16:54:40] root:ifupdown2 # ifquery bond0
iface bond0
      bond-slaves tap0 tap1

[16:54:49] root:ifupdown2 # ifreload -a -d &> /tmp/ifreload.log
[16:54:54] root:ifupdown2 # cat /tmp/ifreload.log | grep ifenslave
debug: tap1: pre-up : running script /etc/network/if-pre-up.d/ifenslave
info: executing /etc/network/if-pre-up.d/ifenslave
debug: tap1: up : running script /etc/network/if-up.d/ifenslave
info: executing /etc/network/if-up.d/ifenslave
debug: lo: pre-up : running script /etc/network/if-pre-up.d/ifenslave
info: executing /etc/network/if-pre-up.d/ifenslave
debug: lo: up : running script /etc/network/if-up.d/ifenslave
info: executing /etc/network/if-up.d/ifenslave
debug: eth0: pre-up : running script /etc/network/if-pre-up.d/ifenslave
info: executing /etc/network/if-pre-up.d/ifenslave
debug: eth0: up : running script /etc/network/if-up.d/ifenslave
info: executing /etc/network/if-up.d/ifenslave
debug: tap0: pre-up : running script /etc/network/if-pre-up.d/ifenslave
info: executing /etc/network/if-pre-up.d/ifenslave
debug: tap0: up : running script /etc/network/if-up.d/ifenslave
info: executing /etc/network/if-up.d/ifenslave
[16:54:55] root:ifupdown2 #
...
apply patch
...
[16:55:16] root:ifupdown2 # ifreload -a -d &> /tmp/ifreload.log
[16:55:18] root:ifupdown2 # cat /tmp/ifreload.log | grep ifenslave
[16:55:19] root:ifupdown2 #

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: mstpctl: warning user when using portadminedge attr on bridge vlan aware
Julien Fortin [Mon, 26 Sep 2016 13:59:43 +0000 (15:59 +0200)]
addons: mstpctl: warning user when using portadminedge attr on bridge vlan aware

Ticket: CM-12478
Reviewed By: Roopa, Nikhil G

Roopa: "For vlan aware bridge, we don't support the port attributes under the
bridge. It was deliberately done when vlan aware bridge config was introduced
because people wanted to get rid of the legacy under the bridge way of decla-
-ring port attributes. It was supported for a bit for evorack...in limited
 form. we should probably just warn the user about this."

auto br100
iface br100
      bridge_ports swp3 swp4 swp5
      mstpctl-portadminedge swp3=yes swp4=yes swp5=yes
      bridge-vlan-aware yes

$ ifreload -a -s
warning: br100: unsupported use of keyword 'mstpctl-portadminedge' when bridge-vlan-aware is on
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdownmain: sending ifaceobj to syntax_check method
Julien Fortin [Mon, 26 Sep 2016 08:37:33 +0000 (10:37 +0200)]
ifupdownmain: sending ifaceobj to syntax_check method

Ticket: None
Reviewed By: Roopa, Nikhil G

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdown: scheduler: ignore errors generated by upperiface bring up
Roopa Prabhu [Wed, 21 Sep 2016 23:03:11 +0000 (16:03 -0700)]
ifupdown: scheduler: ignore errors generated by upperiface bring up

Ticket: CM-12923
Reviewed By: julien, nikhil
Testing Done: tested implicit upperiface bring up

upperiface bringup is best effort, so ignore errors.

$ifquery -c -a
..[snip]...
auto br0
iface br0
        bridge-vlan-aware yes                        [pass]
        bridge-ports vx-14 vx-11 vx-10 vx-13 vx-12   [pass]

$ifdown vx-10
$ifdown vx-11

before patch:
$ifup vx-10
..[snip]...
info: running upperifaces (parent interfaces) if available ..
info: br0: running ops ...
error: br0: bridge port vx-11 does not exist
....

After patch:
$ifup vx-10
..[snip]...
info: running upperifaces (parent interfaces) if available ..
info: br0: running ops ...
....

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: usercmds: add environment variables passed to user scripts
Julien Fortin [Tue, 20 Sep 2016 16:16:57 +0000 (09:16 -0700)]
addons: usercmds: add environment variables passed to user scripts

Ticket: github issue #14
Reviewed By: Roopa, Nikhil G
Testing Done:

$ cat /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
      up /root/test.sh
$
$ cat /root/test.sh
echo 'IFACE=' $IFACE
echo 'LOGICAL=' $LOGICAL
echo 'METHOD=' $METHOD
echo 'ADDRFAM=' $ADDRFAM
$
$ ifreload -a
IFACE= eth0
LOGICAL= eth0
METHOD= dhcp
ADDRFAM= inet
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agodebian: changelog: fixup last released and unreleased versions
Roopa Prabhu [Mon, 19 Sep 2016 23:30:42 +0000 (16:30 -0700)]
debian: changelog: fixup last released and unreleased versions

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoMerge branch 'staging3.1.1' into dev
Roopa Prabhu [Fri, 16 Sep 2016 19:41:06 +0000 (12:41 -0700)]
Merge branch 'staging3.1.1' into dev

7 years agofix for passing parameters to templateEngine() class
Marek Grzybowski [Thu, 15 Sep 2016 19:39:16 +0000 (21:39 +0200)]
fix for passing parameters to templateEngine() class

Signed-off-by: Marek Grzybowski <marek.grzybowski@rtbhouse.com>
7 years agoifupdownmain: dont catch link_up and link_down errors in ifupdownmain
Roopa Prabhu [Fri, 16 Sep 2016 18:29:27 +0000 (11:29 -0700)]
ifupdownmain: dont catch link_up and link_down errors in ifupdownmain

Ticket: CM-12843
Reviewed By: julien, nikhil
Testing Done: Tested the failing test case in the bug

The scheduler already has some checking for errors from
link_up and link_down introduced by
commit 61c4d7244735 ("Suppress 'Network down' warnings when
link_master_slave feature is on").

The above fix was removed by a recent commit
707aeb737882 ("netlink ip link set up/down may silently fail, adding
try/except statements"). The scheduler does catch these errors.
so we will need to figure out why the scheduler is not catching it.
Right now this is failing an automation test. So the best fix
is to make sure the previous behaviour is restored.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: vrf: close sockets when vrf interface goes down
Roopa Prabhu [Thu, 15 Sep 2016 17:10:39 +0000 (10:10 -0700)]
addons: vrf: close sockets when vrf interface goes down

Ticket: CM-11393
Reviewed By: dsa, julien, nikhil
Testing Done: tested up and down of a vrf interface

$ifdown -v blue
..snip ..
info: executing /usr/lib/vrf/vrf-helper delete blue 1030
info: executing ip link del blue
info: executing /bin/ss -aK "dev == 54"
info: vrf: syncing table map to
/etc/iproute2/rt_tables.d/ifupdown2_vrf_map.conf

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: addressvirtual: fix handling of admin state of macvlan interfaces
Roopa Prabhu [Wed, 14 Sep 2016 18:19:57 +0000 (11:19 -0700)]
addons: addressvirtual: fix handling of admin state of macvlan interfaces

Ticket: CM-12823
Reviewed By: julien, nikhil
Testing Done: Tested addressvirtual config with vrfs (as described in
the bug)

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: addressvirtual: adjusting macvlan mtu based on the lower device
Julien Fortin [Thu, 15 Sep 2016 00:15:36 +0000 (17:15 -0700)]
addons: addressvirtual: adjusting macvlan mtu based on the lower device

Ticket: CM-11214
Reviewed By: Roopa
Testing Done:

Previously we were adjusting the macvlan mtu based on the wrong device.
We used to do, using the config example bellow:

get_mtu(ifaceobj.lowerifaces[0])
get_mtu("bridge")

instead of doing get_mtu(bridge.20)

$ cat /etc/network/interfaces
auto tap0
iface tap0
      #mtu 9000
      mtu 1500

auto bridge
iface bridge
      bridge-ports tap0

auto bridge.20
iface bridge.20
      address 10.7.192.194/27
      address-virtual 44:38:39:ff:00:20 10.7.192.193
$ ifreload -a
$ ip link show
bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
bridge.20@bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
bridge-20-v0@bridge.20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
$ #change mtu to 9000
$ ifreload -a
$ ip link show
bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP mode DEFAULT group default
bridge.20@bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP mode DEFAULT group default
bridge-20-v0@bridge.20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP mode DEFAULT group default
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agonormalizing ip address(s) to IPNetwork format for string comparaison
Julien Fortin [Wed, 14 Sep 2016 23:00:25 +0000 (16:00 -0700)]
normalizing ip address(s) to IPNetwork format for string comparaison

Ticket: CM-12798
Reviewed By: Roopa, Nikhil G
Testing Done:

We are seeing some issue when using IP addresses with inner values padded with
zeros. Such as: 2a01:75e0:0000:09b0::1/64
The kernel will process the ip properly but when we query the kernel again (with
iproute2 or netlink) it returns 2a01:75e0:0:09b0::1/64

Since we are doing string comparaison we are seeing failures. We are now
converting all ip address to a standard format using IPNetwork or IPAddress obj

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoMerge remote-tracking branch 'origin/staging3.1.1' into dev
Julien Fortin [Wed, 14 Sep 2016 00:11:38 +0000 (17:11 -0700)]
Merge remote-tracking branch 'origin/staging3.1.1' into dev

7 years agoaddons: address: ignoring iproute2 'rtnetlink file exists' errors
Julien Fortin [Wed, 14 Sep 2016 00:03:24 +0000 (17:03 -0700)]
addons: address: ignoring iproute2 'rtnetlink file exists' errors

Ticket: CM-12798
Reviewed By: Roopa
Testing Done:

A customer discovered a corner case: the kernel is shrinking/reducing the ip
address fields containing 0s. For example if we configure and address such as
2a01:75e0:0000:09b0::1/64

Then if we query the kernel (using iproute2 or netlink) it will come back as:
2a01:75e0:0:09b0::1/64

Because of this issue we were seeing
root@r4u28:~# ifreload -a
error: bridge.200: cmd 'ip -force -batch - [addr add 10.50.103.193/26 dev bridge.200
addr add 2a01:75e0:0000:09b1::1/64 dev bridge.200
]' failed: returned 1 (RTNETLINK answers: File exists
Command failed -:1
)

Before adding an address to an iface we query it to know if the change is
necessary, since we only do a string comparaison between:
2a01:75e0:0000:09b1::1/64 and 2a01:75e0:0:09b1::1/64

it fails, ifupdown2 thinks that a change is needed. So we try to add the new
address via iproute2. iproute2 will fail because this address in a "shrinked"
format already exists.

This patch hot-fixes this problem by ignoring the error if it's an "exists"
error, we don't want to confuse the user.
A later fix will the real issue by normalizing all ip addr to the IPNetwork
format.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdown: netlink: removing log message when retrieving ifindex
Julien Fortin [Tue, 13 Sep 2016 18:27:14 +0000 (11:27 -0700)]
ifupdown: netlink: removing log message when retrieving ifindex

Ticket: None
Reviewed By: Roopa

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agodebian: fixing lintian warnings/errors
Julien Fortin [Fri, 9 Sep 2016 19:30:50 +0000 (12:30 -0700)]
debian: fixing lintian warnings/errors

Ticket:
Reviewed By: Roopa
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years ago3.2 - nclu - net add bridge alias not taking text in quotes
Daniel Walton [Wed, 7 Sep 2016 19:13:58 +0000 (19:13 +0000)]
3.2 - nclu - net add bridge alias not taking text in quotes

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: roopa@cumulusnetworks.com
Ticket: CM-12764

7 years ago3.2 - nclu - adding v6 gateway followed by v4 - v6 is lost
Daniel Walton [Wed, 7 Sep 2016 16:57:55 +0000 (16:57 +0000)]
3.2 - nclu - adding v6 gateway followed by v4 - v6 is lost

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: roopa@cumulusnetworks.com
Ticket: CM-12725

7 years agoMerge branch 'eadev' into dev
Roopa Prabhu [Fri, 2 Sep 2016 23:06:58 +0000 (16:06 -0700)]
Merge branch 'eadev' into dev

Conflicts:
addons/address.py
addons/bridge.py
nlmanager/nlmanager.py

7 years agoaddons: vrf: be more friendly to older iproute2 versions
Roopa Prabhu [Fri, 2 Sep 2016 22:10:24 +0000 (15:10 -0700)]
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

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: bridge: protect all vids to int calls under try/except
Roopa Prabhu [Fri, 2 Sep 2016 19:35:05 +0000 (12:35 -0700)]
addons: bridge: protect all vids to int calls under try/except

Ticket: CM-12716
Reviewed By: julien, nikhil
Testing Done: tested with non-int vids and pvid

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agonlmanager: fixing error messages when receiving NLMSG_ERROR
Julien Fortin [Thu, 25 Aug 2016 21:57:21 +0000 (14:57 -0700)]
nlmanager: fixing error messages when receiving NLMSG_ERROR

Ticket: CM-12596
Reviewed By: Roopa, Daniel W
Testing Done:

before this patch:

$ cat /etc/network/interfaces
auto tapppppppppppp0.42
iface tapppppppppppp0.42
$
$ ifreload -a
warning: /etc/network/interfaces: line8: tapppppppppppp0.42: interface name too long
error: netlink: tapppppppppppp0: cannot create vlan 42: Operation failed with 'None' (RXed  NLMSG_ERROR, pid 3346, seq 6, 108 bytes)
$

after:

$ ifreload -a
warning: /etc/network/interfaces: line8: tapppppppppppp0.42: interface name too long
error: netlink: tapppppppppppp0: cannot create vlan 42: Operation failed with 'Numerical result out of range'
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agonlmanager: support for bridge vlan and show commands
Julien Fortin [Thu, 25 Aug 2016 21:39:36 +0000 (14:39 -0700)]
nlmanager: support for bridge vlan and show commands

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: julien@cumulusnetworks.com
Ticket: CM-12199

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agonetlink ip link set up/down may silently fail, adding try/except statements
Julien Fortin [Wed, 24 Aug 2016 21:20:45 +0000 (14:20 -0700)]
netlink ip link set up/down may silently fail, adding try/except statements

Ticket: CM-12609
Reviewed By: Roopa, Nikhil G
Testing Done: ifupdown2 smoke tests

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: bridge: remove pvid from vids list on ifquery -r for bridge port
Nikhil [Wed, 24 Aug 2016 16:38:17 +0000 (09:38 -0700)]
addons: bridge: remove pvid from vids list on ifquery -r for bridge port

Ticket: CM-12494
Reviewed By: roopa, julien
Testing Done: used config mentioned in bug

'ifquery -r' on a specific bridge port was not removing
pvid from the list of vids.
This patch does that.

Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
7 years agonlmanager: changing log level (info->debug) for TXed messages
Julien Fortin [Tue, 23 Aug 2016 23:38:36 +0000 (16:38 -0700)]
nlmanager: changing log level (info->debug) for TXed messages

Ticket: CM-11857
Reviewed By: Roopa, Daniel W
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agordnbrd "Interrupted system call" traceback in nlmanager
Julien Fortin [Sun, 21 Aug 2016 21:35:04 +0000 (14:35 -0700)]
rdnbrd "Interrupted system call" traceback in nlmanager

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: roopa@cumulusnetworks.com
Ticket: CM-12487

7 years agonlmanager: rdnbrd "Interrupted system call" traceback in nlmanager
Julien Fortin [Sun, 21 Aug 2016 03:43:12 +0000 (20:43 -0700)]
nlmanager: rdnbrd "Interrupted system call" traceback in nlmanager

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: roopa@cumulusnetworks.com
Ticket: CM-12487

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: bridge: fix running_vids value when cache is stale
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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: vrf: don't delete vrf map file at init if mgmt vrf already exists
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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agonetlink: adding ifacename name at the beginning of log info msg
Julien Fortin [Fri, 12 Aug 2016 15:36:27 +0000 (17:36 +0200)]
netlink: adding ifacename name at the beginning of log info msg

Ticket: None
Reviewed By: Roopa
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdownaddons: modulebase: log_error will log.error or raise an exception
Julien Fortin [Fri, 12 Aug 2016 14:30:53 +0000 (16:30 +0200)]
ifupdownaddons: modulebase: log_error will log.error or raise an exception

Ticket: None
Reviewed By: Roopa, Nikhil G
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agonetlink: logging equivalent iproute2 commands
Julien Fortin [Fri, 12 Aug 2016 13:45:52 +0000 (15:45 +0200)]
netlink: logging equivalent iproute2 commands

Ticket: None
Reviewed By: Roopa, Nikhil G
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: bridge: move the default running_pvid assignment to before
Roopa Prabhu [Fri, 12 Aug 2016 05:36:39 +0000 (22:36 -0700)]
addons: bridge: move the default running_pvid assignment to before
pvid_to_del is calculated

Ticket: CM-12355
Reviewed By: julien, nikhil
Testing Done: tested with failing config

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

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: vxlan: fix ifquery running to not proceed when vxlan-id is not
Roopa Prabhu [Thu, 11 Aug 2016 23:35:01 +0000 (16:35 -0700)]
addons: vxlan: fix ifquery running to not proceed when vxlan-id is not
available

Ticket: CM-12378
Reviewed By: julien, nikhil
Testing Done: tested ifquery running with examples in the bug

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agomodulebase: dont set iface status to error if raise_err is False
Roopa Prabhu [Thu, 11 Aug 2016 23:30:00 +0000 (16:30 -0700)]
modulebase: dont set iface status to error if raise_err is False

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: vrf: change warn to error if vrf master is not configured
Roopa Prabhu [Thu, 11 Aug 2016 23:20:16 +0000 (16:20 -0700)]
addons: vrf: change warn to error if vrf master is not configured

Ticket: CM-12360
Reviewed By: julien, nikhil
Testing Done: tested vrf slaves without master

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agonlpacket: add new attribute: AttributeStringInterfaceName with length check
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.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: bridge: fix default pvid handling in cases where cache is stale
Roopa Prabhu [Wed, 10 Aug 2016 22:35:48 +0000 (15:35 -0700)]
addons: bridge: fix default pvid handling in cases where cache is stale

Ticket: CM-12355
Reviewed By: julien, nikhil
Testing Done: tested with failing config

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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agonlmanager: changing messages logged and raised when RXed NLMSG_ERROR
Julien Fortin [Thu, 11 Aug 2016 00:41:29 +0000 (02:41 +0200)]
nlmanager: changing messages logged and raised when RXed NLMSG_ERROR

Ticket: None
Reviewed By: Roopa, Nikhil G, Daniel
Testing Done: ifupdown2 smokes

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.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agonlmanager: wait for ACK after single packet operation
Julien Fortin [Thu, 11 Aug 2016 00:40:24 +0000 (02:40 +0200)]
nlmanager: wait for ACK after single packet operation

Ticket: None
Reviewed By: Roopa, Nikhil G, Daniel
Testing Done: ifupdown2 smoke

We used to have these checks in the old rtnetlink python library.
They were missing in python-nlmanager this was a big regression for
ifupdown2.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdownaddons: iproute2: Cache vxlan remote ip addresses only if
Balakrishnan Raman [Tue, 9 Aug 2016 05:09:32 +0000 (22:09 -0700)]
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.

Signed-off-by: Balakrishnan Raman <ramanb@cumulusnetworks.com>
7 years agoaddons: ethtool: skip speed zero from query running
Roopa Prabhu [Tue, 9 Aug 2016 06:15:20 +0000 (23:15 -0700)]
addons: ethtool: skip speed zero from query running

kernel might return running speed 0 if port does
not have carrier

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: address: never reset mtu on lo implicity
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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: bridge: use bridge json output for vlan
Roopa Prabhu [Mon, 8 Aug 2016 15:18:34 +0000 (08:18 -0700)]
addons: bridge: use bridge json output for vlan

Ticket: CM-11274
Reviewed By: julien, nikhil
Testing Done: tested with various bridge config

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: vrf: bring up vrf master when ALL or CLASS
Roopa Prabhu [Fri, 5 Aug 2016 18:32:21 +0000 (11:32 -0700)]
addons: vrf: bring up vrf master when ALL or CLASS

Ticket: CM-12084
Reviewed By: julien, nikhil
Testing Done: Tested ifreload/ifup/ifdown --allow=<class>

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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoifupdown: move IFACE_CLASS ifupdownmain flag to ifupdownflags.CLASS
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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: vlan: fix checking of vlan device in query-running
Roopa Prabhu [Thu, 4 Aug 2016 16:03:00 +0000 (09:03 -0700)]
addons: vlan: fix checking of vlan device in query-running

Ticket: CM-11804
Reviewed By: julien, nikhil
Testing Done: Tested with failing config in the bug

This patch makes sure macvlan devices are ignored by ifquery -ra

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agonlmanager: changing log level (info->debug) for TXed messages
Julien Fortin [Tue, 23 Aug 2016 23:38:36 +0000 (16:38 -0700)]
nlmanager: changing log level (info->debug) for TXed messages

Ticket: CM-11857
Reviewed By: Roopa, Daniel W
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoMerge branch 'dev' into release/cl-stable
Julien Fortin [Sun, 21 Aug 2016 21:35:56 +0000 (14:35 -0700)]
Merge branch 'dev' into release/cl-stable

7 years agordnbrd "Interrupted system call" traceback in nlmanager
Julien Fortin [Sun, 21 Aug 2016 21:35:04 +0000 (14:35 -0700)]
rdnbrd "Interrupted system call" traceback in nlmanager

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: roopa@cumulusnetworks.com
Ticket: CM-12487

7 years agoMerge branch 'dev' into release/cl-stable
Julien Fortin [Sun, 21 Aug 2016 03:48:53 +0000 (20:48 -0700)]
Merge branch 'dev' into release/cl-stable

7 years agonlmanager: rdnbrd "Interrupted system call" traceback in nlmanager
Julien Fortin [Sun, 21 Aug 2016 03:43:12 +0000 (20:43 -0700)]
nlmanager: rdnbrd "Interrupted system call" traceback in nlmanager

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: roopa@cumulusnetworks.com
Ticket: CM-12487

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: bridge: fix running_vids value when cache is stale
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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoChanging to a correct version fro EA track builds
John Berezovik [Fri, 19 Aug 2016 16:35:21 +0000 (09:35 -0700)]
Changing to a correct version fro EA track builds

7 years agoMerge branch 'dev' into release/cl-stable
Roopa Prabhu [Sat, 13 Aug 2016 06:56:12 +0000 (23:56 -0700)]
Merge branch 'dev' into release/cl-stable

7 years agoaddons: vrf: don't delete vrf map file at init if mgmt vrf already exists
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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoMerge branch 'dev' into release/cl-stable
Julien Fortin [Sat, 13 Aug 2016 03:10:30 +0000 (05:10 +0200)]
Merge branch 'dev' into release/cl-stable

7 years agonetlink: adding ifacename name at the beginning of log info msg
Julien Fortin [Fri, 12 Aug 2016 15:36:27 +0000 (17:36 +0200)]
netlink: adding ifacename name at the beginning of log info msg

Ticket: None
Reviewed By: Roopa
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdownaddons: modulebase: log_error will log.error or raise an exception
Julien Fortin [Fri, 12 Aug 2016 14:30:53 +0000 (16:30 +0200)]
ifupdownaddons: modulebase: log_error will log.error or raise an exception

Ticket: None
Reviewed By: Roopa, Nikhil G
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agonetlink: logging equivalent iproute2 commands
Julien Fortin [Fri, 12 Aug 2016 13:45:52 +0000 (15:45 +0200)]
netlink: logging equivalent iproute2 commands

Ticket: None
Reviewed By: Roopa, Nikhil G
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoMerge branch 'dev' into release/cl-stable
Roopa Prabhu [Fri, 12 Aug 2016 06:10:43 +0000 (23:10 -0700)]
Merge branch 'dev' into release/cl-stable

7 years agoaddons: bridge: move the default running_pvid assignment to before
Roopa Prabhu [Fri, 12 Aug 2016 05:36:39 +0000 (22:36 -0700)]
addons: bridge: move the default running_pvid assignment to before
pvid_to_del is calculated

Ticket: CM-12355
Reviewed By: julien, nikhil
Testing Done: tested with failing config

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

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoMerge branch 'dev' into release/cl-stable
Roopa Prabhu [Thu, 11 Aug 2016 23:59:14 +0000 (16:59 -0700)]
Merge branch 'dev' into release/cl-stable

7 years agoaddons: vxlan: fix ifquery running to not proceed when vxlan-id is not
Roopa Prabhu [Thu, 11 Aug 2016 23:35:01 +0000 (16:35 -0700)]
addons: vxlan: fix ifquery running to not proceed when vxlan-id is not
available

Ticket: CM-12378
Reviewed By: julien, nikhil
Testing Done: tested ifquery running with examples in the bug

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agomodulebase: dont set iface status to error if raise_err is False
Roopa Prabhu [Thu, 11 Aug 2016 23:30:00 +0000 (16:30 -0700)]
modulebase: dont set iface status to error if raise_err is False

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: vrf: change warn to error if vrf master is not configured
Roopa Prabhu [Thu, 11 Aug 2016 23:20:16 +0000 (16:20 -0700)]
addons: vrf: change warn to error if vrf master is not configured

Ticket: CM-12360
Reviewed By: julien, nikhil
Testing Done: tested vrf slaves without master

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agonlpacket: add new attribute: AttributeStringInterfaceName with length check
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.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: bridge: fix default pvid handling in cases where cache is stale
Roopa Prabhu [Wed, 10 Aug 2016 22:35:48 +0000 (15:35 -0700)]
addons: bridge: fix default pvid handling in cases where cache is stale

Ticket: CM-12355
Reviewed By: julien, nikhil
Testing Done: tested with failing config

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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: address: catching and logging exception coming from `ip` batch execution
Julien Fortin [Wed, 10 Aug 2016 13:08:38 +0000 (15:08 +0200)]
addons: address: catching and logging exception coming from `ip` batch execution

Ticket: CM-8610
Reviewed By: Roopa, Nikhil G
Testing Done:

It used to be a silent exception, but not anymore because we catch it and log
accordingly (error) and flag the ifaceobj so that ifupdown2 returns 1.

$ cat /etc/network/interfaces
auto tap0
iface tap0
      mtu 9000
            address 172.17.28.0/31

$ ifreload -a
$ echo "address 2002:17:27:17/120" >> /etc/network/interfaces
$ ifreload -a
$ echo $?
0
$ # applying this patch
$ ifreload -a
error: tap0: cmd 'ip -force -batch - [addr add 172.17.28.0/31 dev tap0
addr add 2002:17:27:17/120 dev tap0
]' failed: returned 1 (RTNETLINK answers: File exists
Command failed -:1
Error: an inet prefix is expected rather than "2002:17:27:17/120".
)
$ echo $?
1
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdown: template: changing error message when import mako fail
Julien Fortin [Wed, 10 Aug 2016 13:15:15 +0000 (15:15 +0200)]
ifupdown: template: changing error message when import mako fail

Ticket: CM-11590
Reviewed By: Roopa, Nikhil G
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agonlmanager: changing messages logged and raised when RXed NLMSG_ERROR
Julien Fortin [Thu, 11 Aug 2016 00:41:29 +0000 (02:41 +0200)]
nlmanager: changing messages logged and raised when RXed NLMSG_ERROR

Ticket: None
Reviewed By: Roopa, Nikhil G, Daniel
Testing Done: ifupdown2 smokes

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.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agonlmanager: wait for ACK after single packet operation
Julien Fortin [Thu, 11 Aug 2016 00:40:24 +0000 (02:40 +0200)]
nlmanager: wait for ACK after single packet operation

Ticket: None
Reviewed By: Roopa, Nikhil G, Daniel
Testing Done: ifupdown2 smoke

We used to have these checks in the old rtnetlink python library.
They were missing in python-nlmanager this was a big regression for
ifupdown2.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdown: utils: user command output on stdout
Julien Fortin [Wed, 10 Aug 2016 15:48:18 +0000 (17:48 +0200)]
ifupdown: utils: user command output on stdout

Ticket: None
Reviewed By: Roopa, Nikhil G
Testing Done:

$ cat /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
      up ls -l
$

I realized that user command's output wasn't on stdout but in a pipe
This commit fixes this case, the user cmd output is now on stdout.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdown: template: changing error message when import mako fail
Julien Fortin [Wed, 10 Aug 2016 13:15:15 +0000 (15:15 +0200)]
ifupdown: template: changing error message when import mako fail

Ticket: CM-11590
Reviewed By: Roopa, Nikhil G
Testing Done:

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: address: catching and logging exception coming from `ip` batch execution
Julien Fortin [Wed, 10 Aug 2016 13:08:38 +0000 (15:08 +0200)]
addons: address: catching and logging exception coming from `ip` batch execution

Ticket: CM-8610
Reviewed By: Roopa, Nikhil G
Testing Done:

It used to be a silent exception, but not anymore because we catch it and log
accordingly (error) and flag the ifaceobj so that ifupdown2 returns 1.

$ cat /etc/network/interfaces
auto tap0
iface tap0
      mtu 9000
            address 172.17.28.0/31

$ ifreload -a
$ echo "address 2002:17:27:17/120" >> /etc/network/interfaces
$ ifreload -a
$ echo $?
0
$ # applying this patch
$ ifreload -a
error: tap0: cmd 'ip -force -batch - [addr add 172.17.28.0/31 dev tap0
addr add 2002:17:27:17/120 dev tap0
]' failed: returned 1 (RTNETLINK answers: File exists
Command failed -:1
Error: an inet prefix is expected rather than "2002:17:27:17/120".
)
$ echo $?
1
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdownaddons: iproute2: Cache vxlan remote ip addresses only if
Balakrishnan Raman [Tue, 9 Aug 2016 05:09:32 +0000 (22:09 -0700)]
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.

Signed-off-by: Balakrishnan Raman <ramanb@cumulusnetworks.com>
7 years agoaddons: ethtool: skip speed zero from query running
Roopa Prabhu [Tue, 9 Aug 2016 06:15:20 +0000 (23:15 -0700)]
addons: ethtool: skip speed zero from query running

kernel might return running speed 0 if port does
not have carrier

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: address: never reset mtu on lo implicity
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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: bridge: use bridge json output for vlan
Roopa Prabhu [Mon, 8 Aug 2016 15:18:34 +0000 (08:18 -0700)]
addons: bridge: use bridge json output for vlan

Ticket: CM-11274
Reviewed By: julien, nikhil
Testing Done: tested with various bridge config

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: vrf: bring up vrf master when ALL or CLASS
Roopa Prabhu [Fri, 5 Aug 2016 18:32:21 +0000 (11:32 -0700)]
addons: vrf: bring up vrf master when ALL or CLASS

Ticket: CM-12084
Reviewed By: julien, nikhil
Testing Done: Tested ifreload/ifup/ifdown --allow=<class>

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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoifupdown: move IFACE_CLASS ifupdownmain flag to ifupdownflags.CLASS
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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: vlan: fix checking of vlan device in query-running
Roopa Prabhu [Thu, 4 Aug 2016 16:03:00 +0000 (09:03 -0700)]
addons: vlan: fix checking of vlan device in query-running

Ticket: CM-11804
Reviewed By: julien, nikhil
Testing Done: Tested with failing config in the bug

This patch makes sure macvlan devices are ignored by ifquery -ra

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agomstpctl: cache improvement to reduce subprocess calls, vxlan opti
Julien Fortin [Sat, 6 Aug 2016 00:51:46 +0000 (02:51 +0200)]
mstpctl: cache improvement to reduce subprocess calls, vxlan opti

Ticket: CM-11274
Reviewed By: Roopa, Nikhil
Testing Done: ifupdown2 smoke, vxlan_aa smoke

The mstpctl addon and mstpctlutils file now contains a unified way to access
cached data (from mstpctl showportdetails json).

Some numbers:
- Without the patch ifreload -a on a scale vxlan config (1k vxlan) we used
to execute 5098 subcommands.
- With the patch "only" ~3000 (it should be 2k but clag ip link set protodown
needs to be move to netlink).

for ifquery -r -a: 11052 calls before patch, 1031 after.

This should improve time execution as well as CPU usage.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: address: removing netmask validval
Julien Fortin [Thu, 4 Aug 2016 16:20:50 +0000 (18:20 +0200)]
addons: address: removing netmask validval

Ticket: CM-12201
Reviewed By: Roopa
Testing Done:

The syntax: netmask <number> is ifupdown legacy support
We want to deprecate it so we don't want to officially support it.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoaddons: bridge: fix bridge vid error on ifaces with multiple stanzas
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

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoaddons: bridge: reset vlan_filtering when user moves from vlan aware to
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.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoifupdownaddons: fix path to get_reserved_vlan_range.sh hook
Roopa Prabhu [Tue, 2 Aug 2016 01:30:25 +0000 (18:30 -0700)]
ifupdownaddons: fix path to get_reserved_vlan_range.sh hook

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoifupdown: scheduler: add dependency debug dump function
Roopa Prabhu [Fri, 29 Jul 2016 05:55:50 +0000 (22:55 -0700)]
ifupdown: scheduler: add dependency debug dump function

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
7 years agoifupdown: valivals keyword: remove <auto> and renaming <ipaddr> to <ip>
Julien Fortin [Mon, 1 Aug 2016 15:20:44 +0000 (17:20 +0200)]
ifupdown: valivals keyword: remove <auto> and renaming <ipaddr> to <ip>

Ticket: None
Reviewed By: Daniel Walton
Testing Done:

This commit was need to keep nclu and ifupdown2 consistent.
The naming were differing and we decided to keep nclu version.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoMerge branch 'dev' into release/cl-stable
Julien Fortin [Mon, 1 Aug 2016 12:33:30 +0000 (14:33 +0200)]
Merge branch 'dev' into release/cl-stable

7 years agoStaging cl3u4 version for merge to stable and release
Julien Fortin [Mon, 1 Aug 2016 07:59:45 +0000 (09:59 +0200)]
Staging cl3u4 version for merge to stable and release

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoifupdownaddons: mstpctl: treeportprio value is cached. It prevents ifupdown2 from...
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
[...]
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
7 years agoattribute syntax check using validvals/validrange and keywords
Julien Fortin [Mon, 1 Aug 2016 07:19:31 +0000 (09:19 +0200)]
attribute syntax check using validvals/validrange and keywords

Ticket: CM-8101
Reviewed By: CCR-4949
Testing Done: smoke tests + ran ifup -a -s on every interface configuration file from GSS cl-supports collection

This commit is introducing ~20 keywords. The value of the different attributes
will be check against raw values and <keywords>:

'<mac>'
'<text>'
'<ipv4>'
'<ipv6>'
'<auto>': "auto"
'<ipaddr>': ipv4/6 with preflix len
'<number>'
'<interface>'
'<ipv4-vrf-text>': equivalent to: <ipv4> "vrf" <text>
'<number-ipv4-list>': example: "100=172.16.100.1 101=172.16.101.1"
'<interface-list>': example: "swp1 swp2 swp3"
'<ipv4/prefixlen>'
'<ipv6/prefixlen>'
'<ipaddr/prefixlen>'
'<number-range-list>': example: "2000 2200-3000"
'<interface-range-list>': example: "swp1=100 swp2=100" ('validrange' : ['0', '65535'])
'<mac-ipaddr/prefixlen-list>'
'<number-interface-list>': example: "4 swp1 swp2"
'<interface-yes-no-list>': example: "swp1=yes swp2=no"
'<interface-yes-no-0-1-list>'
'<interface-yes-no-auto-list>'

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 ...

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>