1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

77 Commits

Author SHA1 Message Date
24be632e93 nlcache: add nodad parameter to addr_add 2022-04-05 14:46:13 +02:00
3fd6c20143 Revert "Dad handling" 2022-03-25 14:29:51 +01:00
d7e9168692 nlcache: add nodad parameter to addr_add 2022-03-25 12:23:43 +01:00
24d5192df2 addons: vlan: retry vlan creation if bridge_binding capability is missing
On older ubuntu version bridge_binding is not supported, we can't rely
on `ip link help` to detect this. We have manually check if the first
netlink request is rejected then retry with iproute2.

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2022-02-11 12:33:49 +01:00
cfc34b5b21 Fix adding a static IPv6 default route failed on RA networks
There may be adding a static IPv6 default route failed on networks where
router advertisements are also present.

The flow of up an interface is this:
1. ip link set dev $interface up
2. set sysctl config
3. config ip addr
4. config default ip route

After setting the link up, the kernel might learning an address and a
default route from RA before the default route config. The default route
will fail to be added. If the RA route is expired, and not be refreshed
for some reasons,the system looses IPv6 network connectivity.

Proposed fix is to use "route replace" instead of "route add". When the
RA learned route is still present it gets replaced, when it is not present
the route gets added.

Signed-off-by: Kunkun Li <likunkun@bytedance.com>
2021-10-25 17:08:31 +08:00
1bb6e6f0fb nlcache: fix TypeError: argument of type 'IPNetwork' is not iterable
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-30 11:58:54 +02:00
acfdbff891 nlcache: clean duplicated code (link_add)
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-05 17:00:44 +02:00
b334df6e88 nlcache: update link_set_bridge_info_data_dry_run
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-05 16:59:28 +02:00
9a6a305084 cleanups - upstream sync
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-02 18:20:42 +02:00
ba5437b9ec nlcache: addr_add: convert pointtopoint and broadcast attribute to ipaddress obj
the following config was broken:

auto swp1
iface swp1
      address 10.128.141.37/26
      broadcast 10.128.141.63

error: netlink: swp1: cannot add address 10.128.141.37/26 dev swp1: 'str' object has no attribute 'packed'

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-02 18:15:00 +02:00
f8ed376891 lib: nlcache: new netlink API "link_add" (waits for link creation)
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-02 18:11:09 +02:00
859b8643b6 nlcache: link_set_address: override cache after mac address change is aacked
after a successful mac change we should override our cache so that we don't
keep stale values in cache (in case the cache is queried before the kernel
notification arrives)

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-02 15:24:00 +02:00
9b23b7c684 iproute2: svd: convert vnifilter attr to boolean to cover all case
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 19:59:25 +02:00
e7ecab23d9 addons: vxlan: refactoring code to allow updating an existing SVD
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 19:51:12 +02:00
db4371de3c addons: vxlan: error out when an unsupported mix of SVD and TVDs are configured
Currently mixing SVDs and TVDs on the same system is not supported,
regardless of whether they are in the same vlan-aware bridge or
across different ones. NVUE will configure all VNIs as SVDs by
default so this would hopefully only arise if a user edits
/etc/network/interfaces and manages their configuration with ifupdown2.

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 19:08:04 +02:00
eff6613023 lib: iproute2: fix missing bridge_vni_del function
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 19:05:36 +02:00
abb7644b9c lib: iproute2: batch vni filter commands
Signed-off-by: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 19:04:55 +02:00
af8d5db22b addons: vxlan: use new vni filter api to set mcast groups per vni
Signed-off-by: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 19:00:17 +02:00
8acbc3c523 ifupdown2: lib: dont bring down link during vni filter changes
Signed-off-by: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 18:40:52 +02:00
06926b1979 addons: bridge: bridge-vlan-vni-map: remove stale entry from running config
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 17:53:27 +02:00
995c38e29a addons: bridge: bridge_vlan_aware_list is now a set()
in the case of ifreload bridge.py:get_dependent is entered twice,
once for the old ifaceobjs and once for the new ones. Thus adding
bridges twice to the list. Having a set will prevent this issue.

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 17:45:59 +02:00
c38ff73d90 lib: iproute2: add vxlan bridge default fdb entries with state permanent
This is to make it consistent with default entries added
by control plane (eg FRR E-VPN)

Signed-off-by: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 17:37:43 +02:00
f3229eecaa lib: iproute2: use self flag when adding svd fdb entries
Signed-off-by: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-01 17:37:26 +02:00
0cb747dd9e iproute2: link_set_address: dont check the cache on link up
To change the mac address of the device we need to set it down,
then make the change, then bring it back up. Thus we don't need
to check the cache before bringing the device back up.

Also adding a TODO: link_up/down should check if we are running
in a batch context, if so the cache shouldn't be checked to avoid
situation like this.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 23:59:03 +02:00
66eb9ce3c5 addons: vxlan: add support for new attribute: vxlan-remoteip-map
syntax:
vxlan-remoteip-map 1000-1005=10.0.0.1,10.0.0.42-10.0.0.45,10.0.0.90-10.0.0.95
vxlan-remoteip-map vni-range=ip-range,comma-separated

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 23:42:48 +02:00
7f0310a7a5 bridge: support values of auto, auto+, auto- for vni in bridge-vlan-vni-map
<vlan>=<vni>
<vlan>=auto  /* sets vni = vlan */
<vlan>=auto+2 /* sets vni = vlan+2 */
<vlan>=auto-2 /* sets vni = vlan-2 */

example:
$ifquery vxlan1
auto vxlan1
iface vxlan1
        vxlan-local-tunnelip 27.0.0.30
        bridge-vlan-vni-map 1000-1009=auto+2 2000-2020=auto-2
        mstpctl-portbpdufilter yes
        mstpctl-bpduguard yes

$ifup -v vxlan1
...
info: executing /sbin/bridge -force -batch - [vlan add vid 1000-1009 dev
vxlan1
vlan add dev vxlan1 vid 1000-1009 tunnel_info id 1002-1011
vlan add vid 2000-2020 dev vxlan1
vlan add dev vxlan1 vid 2000-2020 tunnel_info id 1998-2018]
...

changes include:
- supporting the new syntax
- moved vlan vni map handling into a utility function
to be used by bridge tunnel_info and vxlan vnifilter

Reviewed by: slaffer, david marshal, qzil, julien
Signed-off-by: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 23:36:46 +02:00
9144496d01 vxlan: fix ttl for single vxlan device
Signed-off-by: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 23:33:29 +02:00
84c47c4ff0 addons: vxlan: add support for vni filter on single vxlan device
- create single vxlan device with vnifilter flag
- install vni filter with vnis from bridge-vxlan-vni-map
- vni filter can only be applied when the vxlan interface
is in down state
- toggling of vni filter is unsupported (maybe in the future)
- vni filter on a single vxlan or collect metadata/external
device is a new kernel feature yet to be upstreamed
- move vlan/vni id math helpers to utils.py

Reviewed-by: Julien Fortin <jfortin@nvidia.com>
Signed-off-by: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 23:27:45 +02:00
56f3434979 addons: vxlan: improve mcastgrp-map handling of fdb entries
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 23:24:32 +02:00
8515db2733 addons: bridge: bridge-vlan-vni-map: use vlan and vni ranges within iproute2 cmds
Instead of exploding vlans and vnis ranges we can simply pass those ranges to iproute2
which will reduce the load on ifupdown2 side and scale better

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 18:16:07 +02:00
4b16a99797 clag: bridge l3vni: move bridge vxlan l3vni code to parent class + refactoring
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 17:36:11 +02:00
75a9503027 addons: addressvirtual: check macvlan interface name lenght and war if len > 15
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 15:38:39 +02:00
3eb08b79e0 add support for new address policy: 'ip_blacklist'
context:
The IP address 169.254.0.1 is used by BGP unnumbered as an onlink
next-hop for IPv4 prefixes. When this is configured on the box, it
causes major issues which are very difficult to diagnose a debug.
It would be great if ifupdown2 could block this from being installed
on any interface as an address or address-virtual.

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-05-18 17:19:25 +02:00
5f4ab65948 lib: Addon: add new Bridge class with member "bridge_vlan_aware_list"
we need to keep track of how many vlan-aware bridge we have in the user
configuration without having to loop over all ifaceobjs again. So we
store their name as they go through get_dependent_ifacenames

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-05-18 17:19:25 +02:00
e521508b41 addons: vxlan: support ToS and udpcsum 2021-04-29 20:16:46 -06:00
28bf72d8cb addons: vlan: new attribute: vlan-bridge-binding
From Mike Manning:
In the case of vlan filtering on bridges, the bridge may also have the
corresponding vlan devices as upper devices. Currently the link state
of vlan devices is transferred from the lower device. So this is up if
the bridge is in admin up state and there is at least one bridge port
that is up, regardless of the vlan that the port is a member of.

The link state of the vlan device may need to track only the state of
the subset of ports that are also members of the corresponding vlan,
rather than that of all ports.

Add a flag to specify a vlan bridge binding mode, by which the link
state is no longer automatically transferred from the lower device,
but is instead determined by the bridge ports that are members of the
vlan.
----

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2021-01-25 21:30:40 +01:00
872e4a6ec2 nlcache: master_slaves data-structure should use lists instead of sets
nlcache used a set to keep a master's slave list. This wasn't the right
choice as sets can't guarantee ordering. We need to keep an ordered list
of ports.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2021-01-25 19:25:25 +01:00
5f0ba5190f nlcache: link_del: move log.info after get_ifindex check
if the link doesn't exists get_ifindex will raise an exception
new code in the bridge module simply call link_del on a dummy port
that may not exists. It was a bit confusing to see the log.info
stating that a port was getting removed...

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-08-06 14:35:02 +02:00
ca43693778 addons: vxlan: new attribute: vxlan-mcastgrp-map
"vxlan-mcastgrp-map": {
    "help": "vxlan multicast group for single-vxlan device",
    "validvals": ["<number-ipv4-list>"],
    "example": ["vxlan-mcastgrp-map 1000=239.1.1.100 1001=239.1.1.200"],
}

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-08-06 14:32:07 +02:00
792b9a0700 addons: vxlan: add vxlan-mcastgrp support for single-vxlan device
this patch adds support for the vxlan-mcastgrp attribute on single
vxlan device. Prior to this commit the vxlan-mcastgrp was only
applied to regular vxlans.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-08-06 14:20:41 +02:00
3218f49d81 use "except Exception:" instead of "except:"
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-06-24 01:12:24 +02:00
0e159829a6 lib: iproute2: re-add missing bridge_vlan_add_vid_list method
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-06-18 18:18:00 +02:00
5f6de69fd3 lockfile: return a specific exit code when another instance is already running
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-06-18 18:17:12 +02:00
7b56575ebd nlcache: force_add_slave: don't update internal data-structure if not needed
force_add_slave was designed to be called right after the link_set_master
call to override our internal cache and not wait for the kernel and register
the slave/master relationship in our internal data-structures. It turns
out the kernel can be faster than us here. So an additional check is needed
to make sure we don't do duplicate operations that would result in the
slave being removed from an internal data-structure.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-06-18 18:16:34 +02:00
47090bf6df lib: iproute2: don't flush macvlan addresses but only removed addrs
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-06-18 18:13:46 +02:00
f00d0dcd8c addons: dhcp: enable syslog at boot & fix syslog log-level
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-06-18 17:48:18 +02:00
5cf3c6a196 main: nlcache: don't run netlink cleanup if it was never initialized
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-06-18 17:37:14 +02:00
100fab20b6 addons: link: use iproute2 to create custom devices (fixes #156)
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-05-15 17:49:56 +02:00
5890ab714e addons: link: porting 'veth-peer-name' attribute to python3 branch
original commit ported to the python3 branch:

commit bffa619b11ae7aa9e567c26c255c17ac6df2c495
Author: Maximilian Wilhelm <max@rfc2324.org>
Date:   Sat Jan 14 19:08:01 2017 +0100

    Add option 'veth-peer-name' to veth links and ensure proper configuration.

      The option »veth-peer-name« forces an veth peer link to be created with
      a specific interface name. As the interface name of the "local" part of
      the veth link pair already is defined by the name of the interface stanza
      this option is added to, now both sides are clearly named.

      As there is a bidirectional dependency of both link pairs - both cannot
      exist without the other - this presents a problem when setting up all
      interfaces. Depending on which interface is set up first there might be
      a problem when only on dependency is specified. Therefore adding the
      »veth-peer-name« option to both interface of the veth link pair ensures
      that regardless of which side is configured first the peer name will be
      set correctly. This intentionally creates a circular dependency which is
      handled accordingly.

      Fixing the config check for veth link-type while at it :)

    Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-05-14 04:08:04 +02:00
e537a6e6d6 add support for single vxlan device (bridge-vlan-vni-map)
new attribute:

"bridge-vlan-vni-map": {
    "help": "Single vxlan support",
    "example": "bridge-vlan-vni-map 1000-1001=1000-1001",
}

example of config:

auto bridge
iface bridge
      bridge-vlan-aware yes
      bridge-ports vxlan0 swp1
      bridge-stp on
      bridge-vids 1000-1001
      bridge-pvid 1

auto vxlan0
iface vxlan0
      vxlan-local-tunnelip 27.0.0.9
      bridge-learning off
      # vlan 1000-1001 maps to vni 1000-1001
      bridge-vlan-vni-map 1000-1001=1000-1001

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-05-14 02:18:39 +02:00