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

105 Commits

Author SHA1 Message Date
255ffb1fc3 addons: bridge: set bridge mtu on device creation
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-06-06 19:18:29 +08:00
19ee2b1139 addons: address: set default mtu on user defined device (via link-type)
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-06-06 19:17:57 +08:00
c02de75ec0 addons: addressvirtual: fix older vrrp macvlan doesn't get removed
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-06-06 19:17:32 +08:00
61e63e797b 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 <qlyoung@cumulusnetworks.com>
2019-06-06 19:17:12 +08:00
ff1f1df92a addons: batman_adv: Add support to set B.A.T.M.A.N. advanced routing_algo
Add a new attribute for B.A.T.M.A.N. advanced interfaces to control the
  B.A.T.M.A.N. advanced routing algorithm to be used when setting up new
  interfaces. As the routing algorithm must be set before an interface is
  created, it needs special handling and can't be implemented as a common
  attribute. D'oh.

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Tested-by: Annika Wickert <aw@awlnx.space>
2019-05-25 14:16:30 +02:00
3c46320a2b Merge pull request #103 from aderumier/fix-ifquery-speed
Fix ifquery speed
2019-05-22 17:55:14 +08:00
52712b1ace readd support for self.ipforward
if user want to setup default forwarding with a global policy
2019-05-15 07:15:00 +02:00
472db7e6a3 addressvirtual: _query_running : use cache instead glob 2019-05-10 09:42:42 +02:00
c20b7810e4 mstpctl: don't load module if missing /sbin/mstpctl 2019-05-10 09:42:42 +02:00
3e074210cf batman_adv: don't load module if missing batctl 2019-05-10 09:42:42 +02:00
42ef1cce92 don't change interface forwarding value if not defined 2019-05-04 15:12:00 +02:00
9b585f9e67 addons: bridge: down: when ifreload_down_changed=1: purge bridge and upper devices cache
On ifreload (down ops) we need to purge the cache entry of the bridge and its upper devices
to avoid stale values in our cache.

ifup this config, then remove bridge-vids 20, ifreload: since the bridge is removed because
of ifreload_down_changed=1, we need torecreate the vlan bridge.10 and it's configuration, the
cache is stale. We need to clear it to remove the ip 10.10.10.10/32.

auto bridge
iface bridge
      bridge-ports swp1 swp2
      bridge-vids 10 20
      bridge-vlan-aware yes

auto swp1
iface swp1
      link-speed 10000

auto swp2
iface swp2

auto bridge.10
iface bridge.10
      address 10.10.10.10/32

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:56:14 +08:00
92c2d4a9e7 addons: addressvirtual: vrrp: protodown new macvlans
New VRRP macvlan devices should be set into protodown when first
created, to prevent ND traffic and other automatically generated kernel
traffic from being transmitted on the interface and causing downstream
MAC moves.

Reviewed-by: Julien Fortin <julien@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:55:47 +08:00
1b9d23e8a0 addons: bridge: don't disable ipv6 on vlan-aware vxlan-bridge
ipv6 shouldn't be disabled on a bridge vlan aware

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:55:28 +08:00
3832dce663 addons: bridge: get default mcsnoop value when bridge_vxlan is not set
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:55:09 +08:00
32d448a81c addons: addressvirtual: vrrp: set addrgen mode random on VRRP macvlans
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:53:42 +08:00
9f8f3b0d65 addons: bridge: check kernel state for igmp snooping on vxlan brport
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:53:23 +08:00
b994bd3977 addons: addressvirtual: vrrp: fix multiline-merge attribute detection
Now we support the following config:
auto swp1
iface swp1
      vrrp 3 50.0.1.1/24
      vrrp 3 2001:50:0:1::1/64
      vrrp 3 2001:50:0:42::1/64

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:53:01 +08:00
3e112a1c03 addons: addressvirtual: vrrp: fix macvlan name to include vrrp id
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:52:46 +08:00
bd451a4846 addons: addressvirtual: vrrp: remove macvlan device when all ipvX addrs are removed
For each VRRP configuration we create 2 macvlans (ip4 and ip6), if the ip4
is removed from the config we need to remove the associated macvlan (same
for ip6).

Testing Done: remove all ip4 (or ip6) from vrr attribute line

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:50:42 +08:00
43d3655165 addons: ethtool: raise error on ethtool command failure
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:50:24 +08:00
80adb3c144 addons: bridge: add new policy vxlan_bridge_igmp_snooping_enable_port_mcrouter
if igmp snooping is enabled on a vxlan bridge and if the
vxlan_bridge_igmp_snooping_enable_port_mcrouter is turned on, ifupdown2
will automatically enable multicast router on the vxlan brport unless
this attribute was provided by the user. The policy is enabled by default.

The policy can be disabled as follow:
{
    "bridge": {
	"module_globals": {
	    "vxlan_bridge_igmp_snooping_enable_port_mcrouter": "no"
	}
    }
}

auto br0
iface br0
      bridge-ports vx42
      bridge-mcsnoop yes

auto vx42
iface vx42
      vxlan-id 42

$ ifreload -ad
will show that the config is applied

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:50:00 +08:00
e588acb7d8 addons: addressvirtual: create VRRP macvlans in bridge mode
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:49:44 +08:00
68c8d699db addons: addressvirtual: vrrp: base macvlan prefix on parent ifindex
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:49:29 +08:00
8fb6dd67b2 addons: addressvirtual: make sure vrr macvlans names are 15 chars long max
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:49:15 +08:00
709f7942a2 addons: addressvirtual: delete macvlan when vrrp config is removed (ifreload case)
Add a vrrp config under swp intf - ifup, then remove the vrrp config - ifreload
the macvlans are not removed without this patch

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:49:02 +08:00
ec25a08c3a addons: vxlan: add support for vxlan-ttl attribute
New vxlan-ttl attribute: specifies the TTL value to use in outgoing
packets. Valid values: range 1..255 or auto (0)

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:48:36 +08:00
5bc963f0ad addons: addressvirtual: add support for VRRP attribute
syntax: vrrp ID ip[4|6]

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:43:25 +08:00
1d35560dc6 addons: bridge: fix 'NoneType' object has no attribute '__getitem__' error
Fixes #90

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-04-22 10:30:05 +08:00
8d8cd4f438 addons: batman_adv: import and IO api refactoring
The new code base supports installation via pypi so we need to update the
imports statement.
It's also good practice to use the existing IO apis to read/write and execute
sub-commands, those API will do error handling and logging.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-19 07:14:15 +01:00
b1a2d2417b Add addon module for B.A.T.M.A.N. advanced interface configuration. #12
batman wasn't in master-next so it got removed during the last merge
this commit adds it back to master.
See PR #12

From Maximilian Wilhelm:
  This commit adds support for configuring B.A.T.M.A.N. advanced interfaces
  with ifupdown2. B.A.T.M.A.N. advanced is a protocol to build Layer2 based
  mesh networks with. It's supported in the Linux kernel and thus available
  in many Linux environments.

  A configuration could look like this

  auto bat0
  iface bat0
      batman-ifaces eth1 eth2.23
      batman-ifaces-ignore-regex .*_nodes
      batman-hop-penalty 23
      #
      address 192.0.2.42/24

  where »bat0« would be the local connection to the mesh network.

  The interfaces »eth1« and »eth2.23« would be used by the B.A.T.M.A.N. adv.
  protocol to communicate to other member of the mesh network.

  Any interfaces matching the »ifaces-ignore-regex« will be gently ignored
  by ifquery and ifreload as there might be some tunnels or interfaces
  added to the mesh network by other means which should not be removed by
  any subsequent ifreload run.

  The »hop-penalty» parameter set the penalty of this node within the mesh
  network.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>

Author: Maximilian Wilhelm <max@rfc2324.org>
2018-12-19 07:12:58 +01:00
6039c4d778 addons: tunnel: fix tunnel creation (#80)- master branch refactoring
During the recent merge between master and master-next the changes introduced
by PR #80 were lost. This commit adds them back with some refactoring to use
the new netlink cache.

Co-authored-by: Maximilian Wilhelm <max@sdn.clinic>
Co-authored-by: Julien Fortin <julien@cumulusnetworks.com>

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-18 17:05:30 +01:00
5a4147c4c1 netlink: add tunnel device support in ipcmd cache
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-18 15:58:11 +01:00
e7206159ed addons: vrf: fix link-down yes on vrf slaves
because of a typo (use of wrong object) we weren't looking at the correct
ifaceobj for LINK_DOWN lookup. In some cases we didn't honor link-down yes
on VRF slaves

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 15:18:00 -08:00
b067bba9b9 addons: vxlan: if device exists check that it's a vxlan (link_kind)
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 15:17:46 -08:00
6328de59d2 addons: ethtool: FEC: translate None and NotSupported values to link-fec off
$ /sbin/ethtool --show-fec swp42
FEC parameters for swp42:
FEC encodings   : None
$ ifquery swp42
auto swp42
iface swp42
      link-fec off

$ ifreload -av |& grep ethtool
info: executing /sbin/ethtool swp42
info: executing /sbin/ethtool --show-fec swp42
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 15:17:23 -08:00
2229ca6371 addons: bridge: add "None" check (string) for unsupported bridge attr on some systems
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
a0b4ad9c9b addons: vxlan: modinfo: remove vxlan-port validval
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
05a596d020 addons: bridge: modinfo: bridge-portmcfl remove validrange attribute
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
fc0026de84 addons: ethtool: fec: only use and compare lowercase data
on --show-fec ethtool seems to return fec in uppercase while
we only advertise lowercase validvals. We should only deal
and compare lowercase values for running, config and default

root@host:/home/cumulus# /sbin/ethtool --show-fec swp29
FEC parameters for swp29:
FEC encodings   : RS
root@host:/home/cumulus#

testing:
set: link-fec rs
ifup/ifreloads

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
0c4237d58d addons: bond: catch exception and log.info on modprobe failure
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
9d50518591 addons: address: new l3_intf_default_gateway_set_onlink policy closes #54
As shown in the following example, ifupdown1 sets the default route with the
onlink attribute. This patch will add this capability to ifupdown2 controlled
by a policy variable in the address module: "l3_intf_default_gateway_set_onlink"
default to on

[19:16:07] root:~ # cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
      address 78.46.193.234/32
      gateway 172.31.1.1
[19:16:19] root:~ # ifup -a -v
ifup: configuring interface enp0s3=enp0s3 (inet)
...
/bin/ip addr add 78.46.193.234/255.255.255.255 broadcast 78.46.193.234	  dev enp0s3 label enp0s3
/bin/ip link set dev enp0s3   up
/bin/ip route add default via 172.31.1.1  dev enp0s3 onlink
...
[19:16:21] root:~ # ip route show
default via 172.31.1.1 dev enp0s3 onlink
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15
169.254.0.0/16 dev enp0s3 scope link metric 1000
[19:16:21] root:~ #

$ cat /etc/network/ifupdown2/policy.d/address.json
{
    "address": {
	"module_globals": {
	    "l3_intf_default_gateway_set_onlink": "yes"
	}
    }
}
$ ifquery swp1
auto swp1
iface swp1 inet static
	address 78.46.193.234/32
	gateway 172.31.1.1

$ ifreload -av |& grep "route add default"
info: executing /bin/ip route add default via 172.31.1.1 proto kernel dev swp1 onlink
$
$
$ emacs -nw /etc/network/ifupdown2/policy.d/address.json
$ cat /etc/network/ifupdown2/policy.d/address.json
{
    "address": {
	"module_globals": {
	    "l3_intf_default_gateway_set_onlink": "no"
	}
    }
}
$ ifdown -a -X eth0
$ ifreload -av |& grep "route add default"
info: executing /bin/ip route add default via 172.31.1.1 proto kernel dev swp1
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
2185a10865 addons: address: remplace sysctl calls with /proc/ read/write
Ticket: CM-21809
Reviewed By: Roopa
Testing Done:

<% num_vlans = 2048 %>
% for i in range(2,10):
%   for j in range(2,num_vlans+2):
auto br${i}_${j}
iface br${i}_${j}
      bridge-ports swp${i}.${j}
      bridge-vlan-aware no
      bridge-stp no
      bridge-learning swp${i}.${j}=off
%   endfor
% endfor

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
3fb83a7ab6 addons: vxlan: attr vxlan-port: add DRYRUN check
-n sets DRYRUN flags, when DRYRUN is set many functions return True
(like link_exists), in this case vxlanattrs is set to False because
not cached. But since link_exists=True we still try to access it like
a dictionary.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
cd890b06e4 addons: address: don't reset ip addrgen on dhcp intf
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
8b57a467ca addons: address: add l3_intf_arp_accept policy to control ARP_ACCEPT
$ cat /var/lib/ifupdown2/policy.d/address.json | grep l3_intf_arp_accept
      "l3_intf_arp_accept": "0"
$ ifreload -ad |& grep arp
debug: bridge: init: arp_nd_suppress_only_on_vxlan=True
info: writing '0' to file /proc/sys/net/ipv4/conf/br0/arp_accept
$
$
$ emacs -nw /var/lib/ifupdown2/policy.d/address.json
$
$ cat /var/lib/ifupdown2/policy.d/address.json | grep l3_intf_arp_accept
      "l3_intf_arp_accept": "1"
$
$ ifreload -ad |& grep arp
debug: bridge: init: arp_nd_suppress_only_on_vxlan=True
info: writing '1' to file /proc/sys/net/ipv4/conf/br0/arp_accept
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
c3175b312b addons: addressvirtual: ifquery -r doesn't display link-local address
The issue here lies with how we query the cache to get the ips addresses
configured on the macvlan. A few months ago we added support for link scope
addresses in the cache, since the kernel may add it's own link addresse to
some interfaces we need to filter them out when querying the cache (because
we just want to get the list of IPs managed by ifupdown2). To perform this
filtering we need to look at the current user configuration (/e/n/i) but we
also need to look at past configuration. To perform this filtering we need
to provide the API LinkUtils:get_running_addrs a special parameter for
address-virtual (we need an ifaceobj).

$ ifquery -a
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto vlan1000
iface vlan1000
	address 192.168.10.2/24
	address fc00:10::2/64
	address-virtual 00:00:5e:00:01:01 192.168.10.1/24 fc00:10::1/64 fe80::1/64
	address-virtual-ipv6-addrgen off
	vlan-id 1000
	vlan-raw-device bridge
	vrf blue

auto bridge
iface bridge
	bridge-ports swp1

auto blue
iface blue
	vrf-table auto

$ ifreload -a
$ echo $?
0
$ ifquery -a -c
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp                                                [pass]

auto vlan1000
iface vlan1000                                                      [pass]
	vlan-raw-device bridge                                      [pass]
	vlan-id 1000                                                [pass]
	vrf blue                                                    [pass]
	address 192.168.10.2/24                                     [pass]
	address fc00:10::2/64                                       [pass]
	address-virtual 00:00:5e:00:01:01 192.168.10.1/24 fc00:10::1/64 fe80::1/64     [pass]
	address-virtual-ipv6-addrgen off                            [pass]

auto bridge
iface bridge                                                        [pass]
	bridge-ports swp1                                           [pass]

auto blue
iface blue                                                          [pass]
	vrf-table 1001                                              [pass]

$ ifquery -r vlan1000
auto vlan1000
iface vlan1000
	vlan-id 1000
	vlan-protocol 802.1Q
	vlan-raw-device bridge
	address 192.168.10.2/24
	address fc00:10::2/64
	address-virtual 00:00:5e:00:01:01 192.168.10.1/24 fe80::1/64 fc00:10::1/64
	address-virtual-ipv6-addrgen off

$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
d665f4f10e adodns: bridge: bridge-[port]mcrouter enhance modinfo helper
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
0d6edae700 addons: vxlan: fix vxlan-port example type
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
b306a8b6e3 addons: address: up_ipv6_addrgen: add PERFMODE check
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00