Commit Graph
1655 Commits
Author SHA1 Message Date
Julien Fortin 69cf72ca4a addons: address: execute ipv6 addrgen commands with an ip cmd batch
Signed-off-by: Julien Fortin <[email protected]>
latest_dev
2019-05-21 16:42:28 +08:00
Julien Fortin bfd4ff0939 addons: bridge: replace brctlcmd (LinkUtils) with new lib.nlcache API
Signed-off-by: Julien Fortin <[email protected]>
2019-05-21 15:21:25 +08:00
Julien Fortin 3a9295d39e addons: mstpctl: move bridge_set_stp from LinkUtils to new lib.iproute2
We don't need to import LinkUtils in mstpctl addon anymore.

Signed-off-by: Julien Fortin <[email protected]>
2019-05-16 23:14:20 +08:00
Julien Fortin ddb77b5917 addons: addressvirtual: moving metric code and compare_ips back to addrvirtual addon
Signed-off-by: Julien Fortin <[email protected]>
2019-05-16 23:14:20 +08:00
Julien Fortin 205215af10 lib: iproute2: move LinkUtils.addr_add_multiple to lib.iproute2 (using new cache)
Signed-off-by: Julien Fortin <[email protected]>
2019-05-16 23:14:20 +08:00
Julien Fortin 9139d24795 nlmanager: nlpacket: AttributeIFLA_PROTINFO: fix: attribute type X has an invalid length.
remove extra padding in encode method

Signed-off-by: Julien Fortin <[email protected]>
2019-05-15 01:28:32 +08:00
Julien Fortin 8c4d850c53 addons: vxlan: down vxlan device when group or physdev attribute are changed
vxlan-group/vxlan-mcastgrp and vxlan-physdev changes are not supported on
vxlan devices in UP state. We need to down, change the vxlan attributes
and up the vxlan again.

Ticket: CM-24987
Reviewed-By: Roopa - CCR-8693

Signed-off-by: Julien Fortin <[email protected]>
2019-05-14 13:30:38 +08:00
Julien Fortin 5319a4a77a __main__: add euid check early in the standalone path
Signed-off-by: Julien Fortin <[email protected]>
2019-05-14 13:27:44 +08:00
Julien Fortin 5cd1cac833 nlmanager: nllistener: setsockopt might fail (when process is not root) - add try/except
Signed-off-by: Julien Fortin <[email protected]>
2019-05-14 13:27:01 +08:00
Julien Fortin 965004b74b addons: vxlan: fix TTL log.info when device doesn't exists
Signed-off-by: Julien Fortin <[email protected]>
2019-05-14 12:16:33 +08:00
Julien Fortin f08e6fcb71 addons: vxlan: when updating TTL value log.info the current running value
Signed-off-by: Julien Fortin <[email protected]>
2019-05-14 11:44:43 +08:00
Julien Fortin 7db1cc0123 addons: vxlan: if removed, reset vxlan-local-tunnelip
Signed-off-by: Julien Fortin <[email protected]>
2019-05-14 10:47:42 +08:00
Julien Fortin b5dae0b8a9 addons: vxlan: ifquery-check: add missing handler for ttl and mcastgrp
Ticket: CM-24974
Reviewed By: Roopa
Testing Done:

auto vx-1001
iface vx-1001
        vxlan-id 1001
        vxlan-local-tunnelip 27.0.0.11
        vxlan-mcastgrp 239.1.1.102
	vxlan-ttl 42
        vxlan-physdev swp1

Signed-off-by: Julien Fortin <[email protected]>
2019-05-13 17:24:33 +08:00
Julien Fortin 31fd3849d3 nlmanager: nlpacket: vxlan: set attr value 0 when group or local are None
set IFLA_VXLAN_GROUP or IFLA_VXLAN_LOCAL None will translate to 0

Signed-off-by: Julien Fortin <[email protected]>
2019-05-13 17:24:26 +08:00
Julien Fortin 8304256d47 addons: vxlan: log error on vxlan netlink operation failure and return
Ticket: CM-24973
Reviewed By: Roopa

Signed-off-by: Julien Fortin <[email protected]>
2019-05-13 11:29:18 +08:00
Julien Fortin 3f507db626 addons: addressvirtual: fix netlink calls after merge from dev3
Signed-off-by: Julien Fortin <[email protected]>
2019-05-10 23:56:23 +08:00
Julien Fortin de983d32ee lib: nlcache: register devices as "nomaster" to detect extra IFLA_MASTER notifications
Following commit: 865cf3fcbc (see commit message/explanation
bellow). We thought about a better way to make sure the cache stays synced without dropping
notifications.

The fix is explained in the code with the following comment:
After sending a no master request (IFLA_MASTER=0) the kernels send
2 or 3 notifications (with IFLA_MASTER) before sending the final
notification where IFLA_MASTER is removed. For performance purposes
we don't wait for those notifications, we simply update the cache
to reflect the change (if we got an ACK on the nomaster request).
Those extra notification re-add the former slave to it's master
(in our internal data-structures at least). ifupdown2 relies on
the cache to get accurate information, this puts the cache in an
unreliable state. We can detected this bad state and avoid it. Afer
a nomaster request we "register" the device as "nomaster", meaning
that we will manually remove the IFLA_MASTER attribute from any
subsequent packet, until the final packet arrives - then unregister
the device from the nomasterq.

Ticket: CM-24705
Reviewed By: Roopa

commit 865cf3fcbc
Author: Julien Fortin <[email protected]>
Date:   Thu May 9 14:51:59 2019 +0800

    addons: bond: query cache for bond slaves before running ops

    When un-slaving a device (ip link set dev X nomaster) the kernel
    sends various notifications before sending the final notification
    where the IFLA_MASTER flag is removed.

    For optimization purposes once the nomaster operation is confirmed
    by the kernel (ACK packet) we manually update our cache to reflect
    the change without having to wait for the kernel notification. For
    some reason the kernel sends additional notifications (with IFLA_
    MASTER flag still set) before sending the final notification packet
    which doesn't have this flag.

    Our internal cache is processing those notifications and populates
    its internal data-structure, such as the master-slaves dictionary.
    The cache will eventually reflect the correct kernel state after
    receiving and processing all the notifications.

    The issue here was that we were querying the cache for the bond
    slaves almost immediately after the nomaster requests. Most of the
    time everything worked fine, but it is possible to receive one or
    more "in between notifications" (with IFLA_MASTER flag) thus re-
    adding those slaves to our master-slaves dictionary and returning
    an invalid slave list to the user.

    In my opinion the ideal fix here would be to simply ignore those
    "in between notifications" until we receive the final notifications
    without the IFLA_MASTER flag. Today we are using a similar mechanism
    for link_del RTM_DELLINK and "in between" RTM_NEWLINK notifications

    Dropping netlink packet notifications might introduce side-effects
    and potential errors in the future. Those failure would be very hard
    to track and debug, so today's fix is a workaround.

Signed-off-by: Julien Fortin <[email protected]>
2019-05-10 17:26:42 +08:00
Julien Fortin ababb68fc7 Merge branch 'dev3' into dev
* dev3:
  addons: address: set default mtu on user defined device (via link-type)
  addons: addressvirtual: fix older vrrp macvlan doesn't get removed
2019-05-10 15:56:42 +08:00
Julien Fortin d9f5896c85 addons: address: set default mtu on user defined device (via link-type)
Ticket: CM-23748
Reviewed By: CCR-8644

Signed-off-by: Julien Fortin <[email protected]>
2019-05-10 15:51:21 +08:00
Julien Fortin 1da08a9c07 addons: addressvirtual: fix older vrrp macvlan doesn't get removed
Ticket: CM-24754
Reviewed By: Roopa
Testing Done: l2/vrrp_test.py:TestVrrpPhyBasicFunc.test18_vrrpv3_phyif_reuse_vrrp_group_ids_triggers

Signed-off-by: Julien Fortin <[email protected]>
2019-05-10 15:49:32 +08:00
Julien Fortin ce125b5e50 Merge branch 'dev3' into dev
* dev3:
  addons: protodown vrrp macvlans only when created
2019-05-10 15:49:04 +08:00
Julien Fortin 8b77e34008 addons: addressvirtual: replace ipcmd call with netlink calls
Signed-off-by: Julien Fortin <[email protected]>
2019-05-10 15:45:24 +08:00
Julien Fortin f582228aff ifupdownaddons: LinkUtils: move ip_route_get_dev API to lib.iproute2
Signed-off-by: Julien Fortin <[email protected]>
2019-05-09 17:31:14 +08:00
Julien Fortin 15208a2248 ifupdown: netlink: remove unused file
All the netlink code has been moved to lib.nlcache

Signed-off-by: Julien Fortin <[email protected]>
2019-05-09 17:21:47 +08:00
Julien Fortin 53813546bf ifupdownaddons: LinkUtils: remove netlink import and unused code
Signed-off-by: Julien Fortin <[email protected]>
2019-05-09 17:16:13 +08:00
Julien Fortin e4bdb4517e lib: iproute2: move fix_ipv6_route_metric API from LinkUtils to lib.iproute2
Signed-off-by: Julien Fortin <[email protected]>
2019-05-09 17:13:42 +08:00
Julien Fortin 865cf3fcbc addons: bond: query cache for bond slaves before running ops
When un-slaving a device (ip link set dev X nomaster) the kernel
sends various notifications before sending the final notification
where the IFLA_MASTER flag is removed.

For optimization purposes once the nomaster operation is confirmed
by the kernel (ACK packet) we manually update our cache to reflect
the change without having to wait for the kernel notification. For
some reason the kernel sends additional notifications (with IFLA_
MASTER flag still set) before sending the final notification packet
which doesn't have this flag.

Our internal cache is processing those notifications and populates
its internal data-structure, such as the master-slaves dictionary.
The cache will eventually reflect the correct kernel state after
receiving and processing all the notifications.

The issue here was that we were querying the cache for the bond
slaves almost immediately after the nomaster requests. Most of the
time everything worked fine, but it is possible to receive one or
more "in between notifications" (with IFLA_MASTER flag) thus re-
adding those slaves to our master-slaves dictionary and returning
an invalid slave list to the user.

In my opinion the ideal fix here would be to simply ignore those
"in between notifications" until we receive the final notifications
without the IFLA_MASTER flag. Today we are using a similar mechanism
for link_del RTM_DELLINK and "in between" RTM_NEWLINK notifications

Dropping netlink packet notifications might introduce side-effects
and potential errors in the future. Those failure would be very hard
to track and debug, so today's fix is a workaround.

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

To reproduce the issue, run the following script (bond_loop.sh) on
a switch/VX. On local VX running in VirtualBox the failure would
show after about ~200 loop iterations. The script stores ifreload
logs to make debugging easier. Please read-through this script
before running it.

$ cat bond_loop.sh

function pause(){
   read -p "$*"
}

for index in `seq 1 10000`
do
    echo "Run #$index"
    echo """auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto swp1
iface swp1

auto bond0
iface bond0
      bond-slaves swp1
      bond-mode balance-xor""" > /etc/network/interfaces
    ifreload -av &> /tmp/ifreload-$index-A.log
    if ! ifquery -ac &> /tmp/ifquery-$index-A.log; then
        echo "[A:$index] === FAIL: ifquery returns: $?"
        cat /tmp/ifquery-$index-A.log
        pause 'Press [Enter] key to continue...'
    fi

    ############################################

    sed -i '$d' /etc/network/interfaces ;

    ifreload -av &> /tmp/ifreload-$index-B.log
    if ! ifquery -ac &> /tmp/ifquery-$index-B.log; then
        echo "[B:$index] === FAIL: ifquery returns: $?"
        cat /tmp/ifquery-$index-B.log
        pause 'Press [Enter] key to continue...'
    fi
done

Signed-off-by: Julien Fortin <[email protected]>
2019-05-09 15:16:06 +08:00
Julien Fortin a0cdb632ee DRY-RUN: fix all DRY-RUN handler to use new dry-run logging API
Signed-off-by: Julien Fortin <[email protected]>
2019-05-08 01:06:07 +08:00
Julien Fortin 0379aaf3a1 lib: dry_run: fix DRY-RUN handler using weakrefs
We disabled DRY-RUN mode because it was introducing huge memory leaks. The
cause of this issue was that we kept strong references on objects/modules
and methods in our internal data-structure.

To solve this problem we need to move all the existing dry-run handling code
to use weakrefs. Then another problem emerged ; you can't use the weakref
module on bound methods. To solve this last issue we had to get some inspira
tion from ActiveState recipe 81253, implementing customs class to hold
weakrefs on bound methods but using a ingenious trick to call the dry-run
method when needed.

Signed-off-by: Julien Fortin <[email protected]>
2019-05-08 00:25:55 +08:00
Julien Fortin af96646bc1 addons: addressvirtual: move ipcmd code to use new cache
Signed-off-by: Julien Fortin <[email protected]>
2019-05-06 16:59:19 +08:00
Julien Fortin 39f1416945 lib: nlcache: move get_running_addrs API from LinkUtils to lib.nlcache
Signed-off-by: Julien Fortin <[email protected]>
2019-05-06 16:57:37 +08:00
Julien Fortin 151e9e9998 lib: dry_run: re-enabling dry-run mode
Signed-off-by: Julien Fortin <[email protected]>
2019-05-03 18:38:02 +08:00
Julien Fortin 2837dd556b addons: vxlan: log info each vxlan attribute value before add/set
Signed-off-by: Julien Fortin <[email protected]>
2019-05-03 18:14:22 +08:00
Julien Fortin 74bf0299ec Merge branch 'dev' into dev-next
* dev:
  addons: protodown vrrp macvlans only when created
  addons: address: rolling back address configuration to use string instead of IPNetwork objects
2019-05-03 16:36:08 +08:00
Quentin Young fb33a92968 addons: protodown vrrp macvlans only when created
Not when we are reloading and applying config ot existing macvlans -
somebody may be using them, we don't want to protodown them in that
case.

Signed-off-by: Quentin Young <[email protected]>
2019-05-02 18:04:12 +00:00
Quentin Young aeed163267 addons: protodown vrrp macvlans only when created
Not when we are reloading and applying config ot existing macvlans -
somebody may be using them, we don't want to protodown them in that
case.

Signed-off-by: Quentin Young <[email protected]>
2019-05-02 18:01:47 +00:00
Julien Fortin 70cb41ad55 addons: address: rolling back address configuration to use string instead of IPNetwork objects
$ ifquery vlan100
auto vlan100
iface vlan100
      address 2001:aa::2/64
      address 2001:aa::150/64
      vlan-id 100
      vlan-raw-device bridge

$

when commenting the second ipv6 address and doing ifreload -a, the commented out ipv6 wasn't
removed by ifupdown2. The address module compares IPNetwork objects tries to detect changes.
Unfortunately this change wasn't caught because the two object are matching.

IPNetwork("2001:aa::2/64") == IPNetwork("2001:aa::150/64"): True

To avoid this we need to go back to string comparaison. In the future we should do int checks
like we do today for mac addresses.

Signed-off-by: Julien Fortin <[email protected]>
2019-05-02 14:23:36 +08:00
Julien Fortin a1898890e9 Merge branch 'dev' into dev-next
* dev:
  addons: vxlan: set ipmr-lo mtu to 16000
  addons: vxlan: set ipmr-lo mtu to 16k
2019-05-02 12:11:53 +08:00
Roopa Prabhu 4e2607c4f8 addons: vxlan: set ipmr-lo mtu to 16000
Ticket: CM-24835
Reviewed By: anuradhak, julien
Testing Done: Sanity tested

Previous value of 16k (16 * 1024) is still causing problems.

Signed-off-by: Roopa Prabhu <[email protected]>
2019-05-01 11:28:17 -07:00
Roopa Prabhu 8a42e28f44 addons: vxlan: set ipmr-lo mtu to 16k
Ticket: CM-24835
Reviewed By: anuradhak, julien
Testing Done: Sanity tested

Signed-off-by: Roopa Prabhu <[email protected]>
2019-05-01 07:21:10 -07:00
Julien Fortin 3e9ce672b4 lib: nlcache: new netlink API "link_add" (waits for link creation)
Signed-off-by: Julien Fortin <[email protected]>
2019-05-01 03:22:53 +08:00
Julien Fortin 68722c5303 addons: vxlan: fix vxlan-remoteip: changes not dectected on existing vxlan
Signed-off-by: Julien Fortin <[email protected]>
2019-05-01 02:10:58 +08:00
Julien Fortin c5871d2c65 addons: address: rolling back address configuration to use string instead of IPNetwork objects
$ ifquery vlan100
auto vlan100
iface vlan100
      address 2001:aa::2/64
      address 2001:aa::150/64
      vlan-id 100
      vlan-raw-device bridge

$

when commenting the second ipv6 address and doing ifreload -a, the commented out ipv6 wasn't
removed by ifupdown2. The address module compares IPNetwork objects tries to detect changes.
Unfortunately this change wasn't caught because the two object are matching.

IPNetwork("2001:aa::2/64") == IPNetwork("2001:aa::150/64"): True

To avoid this we need to go back to string comparaison. In the future we should do int checks
like we do today for mac addresses.

Signed-off-by: Julien Fortin <[email protected]>
2019-05-01 00:18:11 +08:00
Julien Fortin 21d2a4316f lib: nlcache: fix force_remove_addr API
The internal addresses data structure "self._addr_cache" was updated to a new format:

{
    ifname: {
        4: [ipv4, ...],
	6: [ipv6, ...],
    }
}

Unfortunately force_remove_addr wasn't updated to support this new format hence it
was constantly and silently failing.

Signed-off-by: Julien Fortin <[email protected]>
2019-05-01 00:12:57 +08:00
Julien Fortin 3f8b3b958f ifupdown: networkinterfaces: fix address specific multiple-entry attributes
The following config is valid but `ifquery -a` outputs an invalid config.
This patch prevents ifquery -a to dump an empty attribute. We are just fixing
the dump code here because the address module allow the following attributes
to have empty values: broadcast, scope, preferred-lifetime and pointopoint

$ cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto swp1
iface swp1
      address 71.12.21.48
      address 2001:620:5ca1:160::57
      preferred-lifetime 30
$
$
$ ifquery -a
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto swp1
iface swp1
      address 71.12.21.48
      address 2001:620:5ca1:160::57
      preferred-lifetime
      preferred-lifetime 30
$
$

Signed-off-by: Julien Fortin <[email protected]>
2019-04-30 15:32:01 +08:00
Julien Fortin e547f14791 lib: nlcache: translate preferred_lifetime = "forever" to integer value
Signed-off-by: Julien Fortin <[email protected]>
2019-04-29 15:18:01 +08:00
Julien Fortin 4858cdb23b addons: bridge/bond: replace old netlink api with lib.nlcache API
Signed-off-by: Julien Fortin <[email protected]>
2019-04-29 14:57:47 +08:00
Julien Fortin 23b9b1d991 Merge remote-tracking branch 'upstream/vxlan_refactoring' into daemon
* upstream/vxlan_refactoring:
  addons: vxlan: refactoring up ops to avoid resending all attributes on changes
2019-04-24 14:31:46 +08:00
Julien Fortin ae4c8d6867 addons: vxlan: refactoring up ops to avoid resending all attributes on changes
The vxlan module is due for a big refactoring. The current code is
very messy and hard to get around. Now each attribute has its own
subfunction to get the user config and/or policy value then translate
it to a netlink value saved in a dictionary that we inject in our
VXLAN add/set request.

Ticket: CM-24735
Reviewed-by: CCR-8593

Signed-off-by: Julien Fortin <[email protected]>
2019-04-24 12:15:32 +08:00
Julien Fortin 2386c0d19c Merge remote-tracking branch 'upstream/dev' into daemon
* upstream/dev: (21 commits)
  addons: address: fix same subnet address ignored issue
  debian: ifupdown2.postinst temporarily disabling ifupdown2d
  debian: changelog: update 2.0.0-cl4u0 entry
  addons: bridge: fix 'NoneType' object has no attribute '__getitem__' error
  debian: ifupdown2.service: start ifupdown2d after syslog.service
  debian: changelog: update 2.0.0-cl4u0 entry
  debian: changelog: new "1.2.6-cl3u25" entry
  nlcache: add new internatl cache data-strucutre: _slaves_master dictionary
  Recommit "ifupdown2: Update FEC check for new values in ethtool 4.19"
  Revert "ifupdown2: Update FEC check for new values in ethtool 4.19"
  ifupdown2: Update FEC check for new values in ethtool 4.19
  ifupdown2d: run: add signal handler for SIGTERM, INT, QUIT
  nlmanager: nlpacket: AttributeIPAddress: decode IPAddress without prefixlen attribute
  addons: bridge: change bridge-vxlan-arp-nd-suppress policy default to off
  addons: bridge: brport vxlan learning controlled by new policy: bridge_vxlan_port_learning
  addons: bridge: set bridge-arp-nd-suppress on by default on vxlan interfaces
  addons: bridge: set bridge-arp-nd-suppress on by default on vxlan interfaces
  addons: dhcp|address: on dhcp release flush internal address cache
  addons: address: if hwaddress changed delete old fdb entry
  addons: vxlan: convert anycastip to IPAddress object
  ...
2019-04-24 11:51:41 +08:00