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

53 Commits

Author SHA1 Message Date
c7c7ce8c4d dhclient: use absolute path for sysfs carrier node
Signed-off-by: Andy Roulin <aroulin@nvidia.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2021-01-25 19:23:12 +01:00
f12bef8ba9 dhclient: check for out variable being None
Fixes: 765075ba392 ("dhclient: wait to start dhcp if carrier is down")
Signed-off-by: Andy Roulin <aroulin@nvidia.com>
2021-01-25 19:20:50 +01:00
1eacb76b3a dhclient: wait to start dhcp if carrier is down
This prevents DHCP requests failures taking time during
boot if the interface isn't up yet. If the interface is
down, dhclient will fail to send packets.

At boot-time, enslaving an interface to vrf flaps it. By
waiting for the interface to come back up before starting
dhclient reduces time to boot.

Reviewed-by: CCR-10987
Closes: CM-32460
Co-developed-by: Nilesh Shinde <nilesh@nvidia.com>
Signed-off-by: Andy Roulin <aroulin@nvidia.com>
2021-01-25 19:20:28 +01:00
3218f49d81 use "except Exception:" instead of "except:"
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-06-24 01:12:24 +02:00
4d3cdf73c9 modulebase: fix Invalid python3 Syntax after merge
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-01-28 12:33:52 +01:00
13d85ea31a addons: dhcp: if mgmt vrf context exec dhclient in default vrf
Ticket: CM-27644

If we are running in mgmt vrf context and vrf is not specified
on the dhcp interface, use ip vrf exec to start dhclient in the
default context

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
2020-01-28 12:04:22 +01:00
bd441a519d python3: pypi support: except ImportError and ModuleNotFoundError
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-12-17 17:25:32 +01:00
e36ad206ac python3: utils.exec_command now returns str and not bytes
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-12-17 17:20:27 +01:00
c46af1c992 python3: logging: the 'warn' method is deprecated, use warning instead
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-12-17 17:19:05 +01:00
f508b51eb1 python3: mstpctlutils: .strip() expects bytes and not a string
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-12-17 17:08:29 +01:00
b38555c4df python3: modulebase: subprocess APIs now return bytes instead of strings
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-12-17 17:00:51 +01:00
3b01ed7618 python3: 2to3 changes
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-12-17 16:55:49 +01:00
35681c0608 python3: shebang update
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-12-17 16:40:10 +01:00
223ba5af1d ifupdown2 2.0.0-1
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-12-17 13:46:18 +01:00
f5c47abf3d LinkUtils: convert ip addrs to string before comparing them
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-09-18 12:48:26 +02:00
f62cfb7b95 addons: dhcp: Policy to specify DUID type to use on dhcpv6 requests
Add a ifupdown2 policy attribute dhcp6-duid to allow user to specify the DUID type
to be used on an IPv6 enabled interface.

Signed-off-by: Rajendra Dendukuri <rajendra.dendukuri@broadcom.com>
2019-07-06 15:14:38 -07:00
ee0075399a addons: addressvirtual: keep macvlan down if link-down specified on lower device
auto vlan1755
iface vlan1755
        address 172.21.7.42/29
	address-virtual 00:00:5E:00:01:41 172.21.7.41/29
	link-down yes
	vlan-id 1755
	vlan-raw-device bridge

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-06-24 15:39:46 +08:00
d1477c4b9f addons: when comparing mac addresses use integer representation
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-06-12 23:26:20 +08:00
f279a8ef8f Merge pull request #111 from svenauhagen/feature/xfrm
This commit adds support for the new IPSec Interface XFRM.
2019-06-07 00:22:39 +08:00
174429766c fix cmd concatenation 2019-06-05 17:11:02 +02:00
ca42da726a This release adds support for the new IPSec Interface XFRM.
It is available since Kernel 4.19 and has two parmeters:

1. XFRM ID to map to an SA/SAs
2. Underlying Interface if you want to take advantage of IPSec Hardware Offload

Otherwise it is treated as a normal interface and not like a tunnel (VTI).

I added two attributes to the interface to configure it and otherwise use it as a normal interface.
One example is:

auto ipsec1
iface ipsec1 inet
	xfrm-physdev lo
	xfrmid 1
2019-06-05 11:05:33 +02:00
848bf7aa85 Fix error message on ifquery when sysctl bridge-stp-user-space
This fix this kind of error:

error: bond0: cmd '/sbin/sysctl net.bridge.bridge-stp-user-space' failed: returned 255 (sysctl: cannot stat /proc/sys/net/bridge/bridge-stp-user-space: No such file or directory
)
error: fwpr103p0: cmd '/sbin/sysctl net.bridge.bridge-stp-user-space' failed: returned 255 (sysctl: cannot stat /proc/sys/net/bridge/bridge-stp-user-space: No such file or directory
)
2019-06-03 11:45:27 +02:00
3e8a915365 linkutils: _bridge_attrs_fill: use sysfs 2019-05-10 06:23:52 +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
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
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
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
df106c519e LinkUtils: tunnel_change: do not purge the cache on tunnel change
Author: Sven Auhagen <Sven.Auhagen@voleatech.de>
2018-12-19 11:48:16 +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
5234020236 ifupdownaddons: LinkUtils: bridge vlan show: add support for new iproute2 format
A newer iproute2 version changed the bridge vlan show output, ifupdown2 relies
on the previous format, we have the convert  data into old format:

{
   "vx-1002": [{
        "vlan": 1002,
        "flags": ["PVID", "Egress Untagged"]
    }],
    "vx-1004": [{
        "vlan": 1004,
        "flags": ["PVID", "Egress Untagged"]
    }]
 }

auto bridge
iface bridge
        bridge-vlan-aware yes
        bridge-ports vx-1000 vx-1001 vx-1002 vx-1003 vx-1004 hostbond3 hostbond4
        bridge-stp on
        bridge-vids 1000-1004
        bridge-pvid 1

auto vx-1002
iface vx-1002
        vxlan-id 1002
        bridge-access 1002
        vxlan-local-tunnelip 27.0.0.15
        bridge-learning off
        bridge-arp-nd-suppress on
        mstpctl-portbpdufilter yes
        mstpctl-bpduguard yes
        mtu 9152

auto hostbond4
iface hostbond4
        bond-slaves swp2 swp3
        bond-mode 802.3ad
        bond-min-links 1
        bond-lacp-rate 1
        mtu 9152
        alias Local Node/s TORS1 and Ports swp32s2 swp32s3 <==> Remote  Node/s HOSTS12 and Ports swp1 swp2
        bridge-pvid 1001

auto swp3
iface swp3
        link-speed 10000
        link-duplex full
        link-autoneg off

auto swp2
iface swp2
        link-speed 10000
        link-duplex full
        link-autoneg off

auto vx-1004
iface vx-1004
        vxlan-id 1004
        bridge-access 1004
        vxlan-local-tunnelip 27.0.0.15
        bridge-learning off
        bridge-arp-nd-suppress on
        mstpctl-portbpdufilter yes
        mstpctl-bpduguard yes
        mtu 9152

auto vx-1003
iface vx-1003
        vxlan-id 1003
        bridge-access 1003
        vxlan-local-tunnelip 27.0.0.15
        bridge-learning off
        bridge-arp-nd-suppress on
        mstpctl-portbpdufilter yes
        mstpctl-bpduguard yes
        mtu 9152

auto hostbond3
iface hostbond3
        bond-slaves swp5 swp6
        bond-mode 802.3ad
        bond-min-links 1
        bond-lacp-rate 1
        mtu 9152
        alias Local Node/s TORS1 and Ports swp32s0 swp32s1 <==> Remote  Node/s HOSTS11 and Ports swp1 swp2
        bridge-pvid 1000

auto swp6
iface swp6
        link-speed 10000
        link-duplex full
        link-autoneg off

auto swp5
iface swp5
        link-speed 10000
        link-duplex full
        link-autoneg off

auto vx-1001
iface vx-1001
        vxlan-id 1001
        bridge-access 1001
        vxlan-local-tunnelip 27.0.0.15
        bridge-learning off
        bridge-arp-nd-suppress on
        mstpctl-portbpdufilter yes
        mstpctl-bpduguard yes
        mtu 9152

auto vx-1000
iface vx-1000
        vxlan-id 1000
        bridge-access 1000
        vxlan-local-tunnelip 27.0.0.15
        bridge-learning off
        bridge-arp-nd-suppress on
        mstpctl-portbpdufilter yes
        mstpctl-bpduguard yes
        mtu 9152

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 15:16:40 -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
535b0c8d4b Fix gretunnels 2018-12-13 14:43:57 -08:00
d00f527807 addons: bridge: read bridge multicast_v4_queriers from sysfs
➜  ~ ifquery -a
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto br0
iface br0
      bridge-ports swp2
      bridge-mcqv4src 100=172.16.100.1 101=172.16.101.1

➜  ~ ifup br0 -v
...
info: executing /sbin/brctl showmcqv4src br0
info: executing /sbin/brctl setmcqv4src br0 100 172.16.100.1
info: executing /sbin/brctl setmcqv4src br0 101 172.16.101.1
...
➜  ~ ifquery br0 -c
auto br0
iface br0                                                           [pass]
      bridge-ports swp2                                           [pass]
      bridge-mcqv4src 100=172.16.100.1 101=172.16.101.1           [pass]

➜  ~

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
80d56a078d ifupdownaddons: mstpctlutils: cache empty 'showportdetail' results
mstpctl might return an empty result on: mstpctl showportdetail bridge json
the cache is not filled with an empty dict so next cache lookup will be a
cache miss and therefore, ifupdown2 thinks we need to fill the cache with fresh
data and will execute showportdetail again (resulting in calling mstpctl cmd
sometime 5 or 6 times in a row).

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
d4019ee902 LinkUtils: addrgen: move disable_ipv6 check before MTU check
if disable_ipv6 is on there's no need to check for the MTU

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
8329d2b8af LinkUtils: check device MTU and /proc/../disable_ipv6 before setting ipv6-addrgen
The minimum IPv6 MTU (ipv6 stack should handle at minmum this size)
is 1280 bytes. If you set the MTU below that then you can't really
have ipv6 addrconf follows the MTU changes and if it sees change
below 1280 then it disables ipv6 on the iface

$ ifquery swp1
auto swp1
iface swp1
      mtu 420

$ ifreload -a
error: swp1: cmd '/bin/ip -force -batch - [link set dev swp1 down
link set dev swp1 addrgenmode eui64
link set dev swp1 up
]' failed: returned 1 (RTNETLINK answers: Address family not supported by protocol
Command failed -:2
)

Reviewed-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
007cae3525 ipv6-addrgen: add ifquery check/running/ifreload support using netlink cache
[13:09:20] root:~ # ifquery -a
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto vlan1903
iface vlan1903
	vlan-id 1903
	vlan-raw-device bridge
	ipv6-addrgen no
	address-virtual-ipv6-addrgen no
	address-virtual 00:00:5e:00:01:a3 2a06:c01:1:1903::1/64 fe80::1/64 185.98.123.1/24

auto bridge
iface bridge
	bridge-ports swp1

[13:09:25] root:~ # ifup -a -v
info: loading builtin modules from ['/usr/share/ifupdown2/addons']
info: executing /var/lib/ifupdown2/hooks/get_reserved_vlan_range.sh
info: executing /sbin/sysctl net.bridge.bridge-allow-multiple-vlans
info: executing /bin/pidof mstpd
info: executing /bin/ip rule show
info: executing /bin/ip -6 rule show
info: address: using default mtu 1500
info: 'link_master_slave' is set. slave admin state changes will be delayed till the masters admin state change.
info: processing interfaces file /etc/network/interfaces
info: lo: running ops ...
info: netlink: ip link show
info: netlink: ip addr show
info: executing /bin/ip addr help
info: address metric support: KO
info: lo: netlink: ip link set dev lo up
info: reading '/proc/sys/net/mpls/conf/lo/input'
info: reading '/proc/sys/net/ipv4/conf/lo/forwarding'
info: reading '/proc/sys/net/ipv6/conf/lo/forwarding'
info: reading '/proc/sys/net/ipv4/conf/lo/accept_local'
info: executing /bin/systemctl is-enabled vxrd.service
info: eth0: running ops ...
info: executing /sbin/ethtool eth0
info: reading '/sys/class/net/eth0/speed'
info: reading '/sys/class/net/eth0/duplex'
info: eth0: netlink: ip link set dev eth0 up
info: dhclient4 already running on eth0. Not restarting.
info: reading '/proc/sys/net/mpls/conf/eth0/input'
info: reading '/proc/sys/net/ipv4/conf/eth0/forwarding'
info: reading '/proc/sys/net/ipv6/conf/eth0/forwarding'
info: reading '/proc/sys/net/ipv4/conf/eth0/accept_local'
info: swp1: running ops ...
info: executing /sbin/ethtool swp1
info: reading '/sys/class/net/swp1/speed'
info: reading '/sys/class/net/swp1/duplex'
info: executing /sbin/ethtool -s swp1  speed 1000 duplex full
info: reading '/proc/sys/net/mpls/conf/swp1/input'
info: reading '/proc/sys/net/ipv4/conf/swp1/accept_local'
info: bridge: running ops ...
info: bridge: netlink: ip link add bridge type bridge
info: bridge: apply bridge settings
info: bridge: set bridge-ageing 1800
info: bridge: set bridge-hashel 4096
info: bridge: set bridge-hashmax 4096
info: bridge: set bridge-mcstats on
info: reading '/sys/class/net/bridge/bridge/stp_state'
info: bridge: stp state reset, reapplying port settings
info: bridge: netlink: ip link set bridge type bridge with attributes
info: writing '1' to file /proc/sys/net/ipv6/conf/swp1/disable_ipv6
info: executing /bin/ip -force -batch - [link set dev swp1 master bridge
addr flush dev swp1
]
info: bridge: applying bridge port configuration: ['swp1']
info: bridge: swp1: set bridge-portprios 8
info: swp1: netlink: ip link set dev swp1: bridge slave attributes
info: executing /sbin/brctl showmcqv4src bridge
info: bridge: applying bridge configuration specific to ports
info: bridge: processing bridge config for port swp1
info: swp1: netlink: ip link set dev swp1 up
info: bridge: setting bridge mac to port swp1 mac
info: executing /bin/ip link set dev bridge address 90:e2:ba:2c:b1:96
info: executing /sbin/mstpctl showportdetail bridge json
info: executing /sbin/mstpctl showbridge json bridge
info: bridge: applying mstp configuration specific to ports
info: bridge: processing mstp config for port swp1
info: bridge: netlink: ip link set dev bridge up
info: reading '/proc/sys/net/mpls/conf/bridge/input'
info: executing /sbin/sysctl net.ipv4.conf.bridge.forwarding
info: executing /sbin/sysctl net.ipv6.conf.bridge.forwarding
info: executing /bin/ip -force -batch - [link set dev bridge down
link set dev bridge addrgenmode eui64
link set dev bridge up
]
info: reading '/proc/sys/net/ipv4/conf/bridge/accept_local'
info: vlan1903: running ops ...
info: vlan1903: netlink: ip link add link bridge name vlan1903 type vlan id 1903 protocol 802.1q
info: vlan1903: netlink: ip link set dev vlan1903 up
info: reading '/proc/sys/net/mpls/conf/vlan1903/input'
info: reading '/proc/sys/net/ipv4/conf/vlan1903/forwarding'
info: reading '/proc/sys/net/ipv6/conf/vlan1903/forwarding'
info: executing /bin/ip -force -batch - [link set dev vlan1903 down
link set dev vlan1903 addrgenmode none
link set dev vlan1903 up
]
info: vlan1903: netlink: ip link add link vlan1903 name vlan1903-v0 type macvlan mode private
info: executing /sbin/sysctl net.ipv6.conf.vlan1903-v0.accept_dad
info: executing /sbin/sysctl net.ipv6.conf.vlan1903-v0.accept_dad=0
info: executing /sbin/sysctl net.ipv6.conf.vlan1903-v0.dad_transmits
info: executing /sbin/sysctl net.ipv6.conf.vlan1903-v0.dad_transmits=0
info: executing /bin/ip -force -batch - [link set dev vlan1903-v0 addrgenmode none
link set dev vlan1903-v0 down
link set dev vlan1903-v0 address 00:00:5e:00:01:a3
link set dev vlan1903-v0 up
addr add 2a06:c01:1:1903::1/64 dev vlan1903-v0
addr add fe80::1/64 dev vlan1903-v0
addr add 185.98.123.1/24 dev vlan1903-v0
route del 2a06:c01:1:1903::/64 dev vlan1903-v0
route del fe80::/64 dev vlan1903-v0
route add 2a06:c01:1:1903::/64 dev vlan1903-v0 proto kernel metric 9999
route add fe80::/64 dev vlan1903-v0 proto kernel metric 9999
]
info: reading '/proc/sys/net/ipv4/conf/vlan1903/accept_local'
[13:09:29] root:~ #
[13:09:30] root:~ #
[13:09:30] root:~ # ifquery -a -c
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp                                                [pass]

auto vlan1903
iface vlan1903                                                      [pass]
	vlan-raw-device bridge                                      [pass]
	vlan-id 1903                                                [pass]
	ipv6-addrgen no                                             [pass]
	address-virtual 00:00:5e:00:01:a3 2a06:c01:1:1903::1/64 fe80::1/64 185.98.123.1/24     [pass]
	address-virtual-ipv6-addrgen no                             [pass]

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

[13:09:33] root:~ #
[13:09:35] root:~ #
[13:09:35] root:~ # ifquery -a -r
auto vlan1903-v0
iface vlan1903-v0
	ipv6-addrgen off
	address 185.98.123.1/24
	address 2a06:c01:1:1903::1/64

auto vlan1903
iface vlan1903
	vlan-id 1903
	vlan-protocol 802.1Q
	vlan-raw-device bridge
	ipv6-addrgen off
	address-virtual 00:00:5e:00:01:a3 185.98.123.1/242a06:c01:1:1903::1/64
	address-virtual-ipv6-addrgen off

auto bridge
iface bridge
	bridge-vlan-stats off
	bridge-mcstats 1
	bridge-ports swp1
	bridge-stp yes
	mstpctl-portp2p  swp1=auto
	mstpctl-treeportcost  swp1=20000
	mstpctl-portautoedge  swp1=yes

auto swp1
iface swp1

auto eth0
iface eth0 inet dhcp

auto lo
iface lo inet loopback
	mtu 65536

[13:09:38] root:~ # ip -d link show vlan1903
20: vlan1903@bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
    link/ether 90:e2:ba:2c:b1:96 brd ff:ff:ff:ff:ff:ff promiscuity 1
    vlan protocol 802.1Q id 1903 <REORDER_HDR> addrgenmode none
[13:09:50] root:~ # ip -d link show vlan1903-v0
21: vlan1903-v0@vlan1903: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
    link/ether 00:00:5e:00:01:a3 brd ff:ff:ff:ff:ff:ff promiscuity 0
    macvlan  mode private addrgenmode none
[13:09:53] root:~ #
[13:09:56] root:~ # ip link set dev vlan1903-v0 addrgenmode eui64
[13:10:23] root:~ # ifquery -a -c
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp                                                [pass]

auto vlan1903
iface vlan1903                                                      [fail]
	vlan-raw-device bridge                                      [pass]
	vlan-id 1903                                                [pass]
	ipv6-addrgen no                                             [pass]
	address-virtual 00:00:5e:00:01:a3 2a06:c01:1:1903::1/64 fe80::1/64 185.98.123.1/24     [pass]
	address-virtual-ipv6-addrgen no                             [fail]

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

[13:10:29] root:~ # ifquery -a -r
auto vlan1903-v0
iface vlan1903-v0
	address 185.98.123.1/24
	address 2a06:c01:1:1903::1/64

auto vlan1903
iface vlan1903
	vlan-id 1903
	vlan-protocol 802.1Q
	vlan-raw-device bridge
	ipv6-addrgen off
	address-virtual 00:00:5e:00:01:a3 185.98.123.1/242a06:c01:1:1903::1/64
	address-virtual-ipv6-addrgen on

auto bridge
iface bridge
	bridge-vlan-stats off
	bridge-mcstats 1
	bridge-ports swp1
	bridge-stp yes
	mstpctl-portp2p  swp1=auto
	mstpctl-treeportcost  swp1=20000
	mstpctl-portautoedge  swp1=yes

auto swp1
iface swp1

auto eth0
iface eth0 inet dhcp

auto lo
iface lo inet loopback
	mtu 65536

[13:10:33] root:~ #

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
c4cc1f86f1 addons: addressvirtual: flush macvlan addr cache when setting addrgenmode
When setting addrgenmode it is necessary to flap the macvlan
device. After flapping the device we also need to re-add all
the user configuration. The best way to add the user config
is to flush our internal address cache.

[10:12:10] root:~ # ifquery vlan1000
auto vlan1000
iface vlan1000
	address 192.168.10.1/24
	address fc00:10::1/64
	address-virtual 00:00:5e:00:01:01 192.168.10.1/24 fc00:10::1/64 fe80::1/64
	vlan-id 1000
	vlan-raw-device bridge

[10:12:15] root:~ # ifup -a
[10:12:24] root:~ # echo $?
0
[10:12:26] root:~ # ifquery vlan1000 -c
auto vlan1000
iface vlan1000                                                      [pass]
	vlan-raw-device bridge                                      [pass]
	vlan-id 1000                                                [pass]
	address 192.168.10.1/24                                     [pass]
	address fc00:10::1/64                                       [pass]
	address-virtual 00:00:5e:00:01:01 192.168.10.1/24 fc00:10::1/64 fe80::1/64     [pass]

[10:12:30] root:~ # ip -6 -o addr show vlan1000-v0
48: vlan1000-v0    inet6 fc00:10::1/64 scope global \       valid_lft forever preferred_lft forever
48: vlan1000-v0    inet6 fe80::200:5eff:fe00:101/64 scope link \       valid_lft forever preferred_lft forever
48: vlan1000-v0    inet6 fe80::1/64 scope link \       valid_lft forever preferred_lft forever
[10:12:33] root:~ #
[10:12:34] root:~ #
[10:12:34] root:~ # ifquery vlan1000
auto vlan1000
iface vlan1000
	address 192.168.10.1/24
	address fc00:10::1/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

[10:12:39] root:~ #
[10:12:41] root:~ # ifreload -a -d
...
debug: vlan1000: up : running module addressvirtual
debug: vlan1000-v0: reset address cache <<<<<<<<<<<<<<<<<<<<<< without this reset ifupdown2 would be in a broken state
info: vlan1000: checking route entry ...
info: executing /bin/ip route get 192.168.10.0/24
info: netlink: ip link show dev vlan1000
info: netlink: ip link show dev vlan1000-v0
info: vlan1000-v0: netlink: ip link set dev vlan1000-v0 up
info: executing /bin/ip -force -batch - [link set dev vlan1000-v0 down
link set dev vlan1000-v0 addrgenmode none
link set dev vlan1000-v0 up
addr add 192.168.10.1/24 dev vlan1000-v0
addr add fc00:10::1/64 dev vlan1000-v0
addr add fe80::1/64 dev vlan1000-v0
]
...
[10:12:50] root:~ #
[10:12:51] root:~ # ip -6 -o addr show vlan1000-v0
48: vlan1000-v0    inet6 fc00:10::1/64 scope global \       valid_lft forever preferred_lft forever
48: vlan1000-v0    inet6 fe80::1/64 scope link \       valid_lft forever preferred_lft forever
[10:12:53] root:~ # ifquery vlan1000 -c
auto vlan1000
iface vlan1000                                                      [pass]
	vlan-raw-device bridge                                      [pass]
	vlan-id 1000                                                [pass]
	address 192.168.10.1/24                                     [pass]
	address fc00:10::1/64                                       [pass]
	address-virtual 00:00:5e:00:01:01 192.168.10.1/24 fc00:10::1/64 fe80::1/64     [pass]

[10:13:03] root:~ # echo $?
0
[10:13:04] root:~ #

Reviewed-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
9b653c8542 addons: bridge: fix check_valid_bridge for DRYRUN mode
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:43:57 -08:00
77054f7f5f addons: ppp: Add support for master-next
This commit fixes the ppp addon for the new master-next branch.
2018-12-13 14:43:57 -08:00
f40c629470 addons: tunnel: fix tunnel v4 to v6 change 2018-12-13 14:42:35 -08:00
33ebe60a9d addons: tunnel: add support for vti, ip6gre, ipip6, ip6ip6, vti6 tunnels 2018-12-13 14:42:35 -08:00
b2a87fe8eb addons: tunnel: Add support for GRETAP tunnels. (#34)
This commit adds support to configure and check gretap tunnels. An example
  configuration could look like this:

    iface tap0 inet tunnel
        mode gretap
        local 10.132.255.3
        endpoint 10.132.255.1
        ttl 64
        mtu 1400
        tunnel-physdev eth0
        #
        address 10.10.0.1/2

  ifup will happily configure the interface (which it does even without this
  patch) and ifquery now can successfully validate the configure interface:

    cr03.in.ffho.net:~# ifquery -c tap0
    iface tap0 inet tunnel                   [[ OK ]]
        tunnel-physdev eth0                  [[ OK ]]
        endpoint 10.132.255.1                [[ OK ]]
        local 10.132.255.3                   [[ OK ]]
        mode gretap                          [[ OK ]]
        ttl 64                               [[ OK ]]
        mtu 1400                             [[ OK ]]
        address 10.10.0.1/24                 [[ OK ]]

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
2018-12-13 14:42:35 -08:00
22aa65c782 Add support GRE/SIT tunnels. (#20)
This commit adds support for configuring GRE/IPIP/SIT tunnel interfaces as know
from previous versions of ifupdown. Currently only configuration checks for GRE
and SIT tunnels are implemented.

A tunnel interface configuration could look like this:

auto gre42
iface gre42 inet tunnel
        mode     gre
        local    198.51.100.1
        endpoint 203.0.113.2
	#
	# optional tunnel attributes
        ttl      64
        mtu      1400
	tunnel-physdev eth0
        #
        address  192.0.2.42/31
        address  2001:db8:d0c:23::42/64

auto he-ipv6
iface he-ipv6 inet tunnel
	mode sit
	endpoint 203.0.113.6
	local    198.51.100.66
	#
	# optional tunnel attributes
	ttl 255
	mtu 1466
	tunnel-physdev vrf_external
	#
	address 2001:db8:666::2/64

Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
2018-12-13 14:42:35 -08:00
3fc54eef3d addons: address: new attribute: ipv6-addrgen [on/off]
[14:49:15] root:~ # ifquery swp2
auto swp2
iface swp2

[14:49:18] root:~ # ip addr show swp2
4: swp2: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 90:e2:ba:2c:b2:95 brd ff:ff:ff:ff:ff:ff
[14:49:20] root:~ # ifup swp2
[14:49:23] root:~ # ip addr show swp2
4: swp2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 90:e2:ba:2c:b2:95 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::92e2:baff:fe2c:b295/64 scope link
       valid_lft forever preferred_lft forever
[14:49:25] root:~ #
[14:49:32] root:~ # nano /etc/network/interfaces
[14:49:34] root:~ # ifquery swp2
auto swp2
iface swp2
        ipv6-addrgen off

[14:49:41] root:~ # ifup -v swp2 |& grep addrgen
link set dev swp2 addrgenmode none
[14:49:57] root:~ # ip addr show swp2
4: swp2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 90:e2:ba:2c:b2:95 brd ff:ff:ff:ff:ff:ff
[14:50:01] root:~ #
[14:50:09] root:~ #
[14:50:09] root:~ # ifup -v swp2
info: executing /bin/ip -force -batch - [link set dev swp2 down
link set dev swp2 addrgenmode none
link set dev swp2 up
]
info: reading '/proc/sys/net/ipv4/conf/swp2/accept_local'
[14:50:13] root:~ #

Reviewed-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:42:35 -08:00
a382b488e9 backport: "Add support for setting phys-dev for VXLAN interfaces."
backporting the following commit to master-next:

commit eb92e5efff776602081b8bbd2cc74462293c4b79
Author: Maximilian Wilhelm <max@rfc2324.org>
Date:   Thu Oct 6 19:22:06 2016 +0200

    Add support for setting phys-dev for VXLAN interfaces.

      Add interface configuration option »vxlan-physdev« to set »dev« attribute
            of VXLAN interfaces and a check for the running configuration.

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

This backport also:
 - adds support for ifquery --running
 - uses the netlink cache
 - includes some pep8 fixes

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

Co-authored-by: Julien Fortin <julien@cumulusnetworks.com>
Co-authored-by: Maximilian Wilhelm <max@rfc2324.org>
2018-12-13 14:42:35 -08:00
dfaa8a2d19 addressvirtual: address: add default metric to ip4 and ip6 (if available)
Reviewed-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:42:35 -08:00
aa895ecddf addons: addressvirtual: if device is VRF slave check vrf route table
auto bridge
iface bridge
      bridge-vlan-aware yes
      bridge-ports swp2

auto bridge.2
iface bridge.2
      address 10.254.1.2/24
      address 2a03:25e0:254:1::2/64
      address-virtual 00:00:5e:00:01:01 10.254.1.1/24 2a03:25e0:254:1::1/64 fe80::1/64
      vrf blue

auto blue
iface blue
      vrf-table auto

$ ifreload -a -v
...
info: executing /bin/ip route get 10.254.1.0/24 vrf blue
...
$

Reviewed-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 14:42:35 -08:00
d486dd0df0 ifupdown2 2.0.0 release
This is a major update coming all at once from master-next branch
master-next branch was started with --orphan option which is basically a new
branch without history.

The major changes are:
    - repackaging
    - cleanup the directory tree
    - rewritte setup.py to allow install from deb file or pypi (pip install)
    - add a Makefile to make things (like building a deb) easier
    - review all debian files

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 11:43:32 -08:00