Commit Graph

79 Commits

Author SHA1 Message Date
Julien Fortin
a0522546b8 addons: address: fix merge-indentation issue
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2023-05-10 17:30:27 +02:00
Julien Fortin
86bd267c63 addons: address: process hwaddress before processing ip addresses
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2023-05-04 13:21:55 +02:00
Julien Fortin
421e9573b5 SONAR: fix iface.py: Import only needed names or import the module and then use its members.
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2023-05-04 13:21:55 +02:00
Julien Fortin
e8b9d3ab5d sonarlink: use opposite operator != instead of 'not'
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2023-05-04 13:21:55 +02:00
Julien Fortin
c30ed567a8 SONAR: addons: address: Merge if statement with the enclosing one
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2023-05-04 13:21:55 +02:00
Julien Fortin
7c8627f876 SONAR: Specify an exception class to catch or reraise the exception
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2023-05-04 13:21:55 +02:00
Adrien Banlin
793fb44ab0 distutils: fix dependency and lib replacement
As of now, the distutils is deprecated with removal planned for
python 3.12.

The recommended way is to use setuptools which is an enhanced
alternative to distutils maintained by the python packaging authority.

This commit replace with setuptools the distutil import inserted in the
8126ef0c00 commit.

This commit also update the debian control runtime dependency.

distutils: https://docs.python.org/3/library/distutils.html
setuptools: https://setuptools.pypa.io/en/latest/
2022-05-31 14:57:12 +02:00
Julien Fortin
63155c61d3 addons: address: ifquery-running: add hwaddress support
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2022-05-27 12:00:25 +02:00
Julien Fortin
8126ef0c00 addons: address: policy: l3_intf_arp_accept accept arp_accept value
the policy l3_intf_arp_accept now accepts boolean value True(1)/False(0) as well
as normal arp_accept values

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2022-05-27 11:58:34 +02:00
Julien Fortin
4e0f16d0cf addons: address: clear stale svi fdb entries when svi mac is changed
Three issues:
- when `hwaddress` is removed from an SVI (on top of a bridge), the svi
mac is not resetted back to the bridge mac: fixed
- when `hwaddress` is used on an svi, stale fdb enties were added with the
bridge mac: fixed
- on ifdown we were leaving a leftover fdb entry on the deleted svi: fixed

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2022-05-26 12:04:17 +02:00
Julien Fortin
e90c33ca6a addons: address: log error but continue when adding addresses (fixes #130)
Signed-off-by: bauen1 <j2468h@gmail.com>
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2022-05-24 22:05:16 +02:00
Julien Fortin
cccf76e4c0 addons: address: dad-interval: adding log.info before sleep (#232)
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2022-04-29 16:20:17 +02:00
Adrien Banlin
21a7bd2d91 address: check interface exists before settling dad 2022-04-08 16:00:25 +02:00
Adrien Banlin
eb6ad1f78a addons: address: update modinfo for dad attributes
Help infos came from the ifupdown (original) manual.
2022-04-08 16:00:25 +02:00
Adrien Banlin
d594fb86ca addons: address: up: wait on dad when needed 2022-04-08 16:00:25 +02:00
Adrien Banlin
b99c724a89 addons: address: add a settle dad method
_settle_dad will allow ifupdown2 to wait on ipv6 dad tentative.
2022-04-08 16:00:25 +02:00
Adrien Banlin
beaffab603 addons: address: disable dad on no attempts 2022-04-05 14:46:13 +02:00
Adrien Banlin
f4764e0f96 addons: address: add dad handling module global
Upon ipv6_dad_handling_enabled module global parameter set to true, the
address addon will handle ipv6 dad tentatives by either
* set nodad when adding an ipv6 address
* waiting for dad to finish or warn of a timeout

This handling should be quick close to the ifupdown process.
2022-04-05 14:46:13 +02:00
Julien Fortin
3fd6c20143
Revert "Dad handling" 2022-03-25 14:29:51 +01:00
Adrien Banlin
cccdaa46a8 addons: address: update modinfo for dad attributes
Help infos came from the ifupdown (original) manual.
2022-03-25 13:12:51 +01:00
Adrien Banlin
06a49cda4f addons: address: up: wait on dad when needed 2022-03-25 13:12:51 +01:00
Adrien Banlin
aa121e105e addons: address: add a settle dad method
_settle_dad will allow ifupdown2 to wait on ipv6 dad tentative.
2022-03-25 13:12:51 +01:00
Adrien Banlin
33c30d13b1 addons: address: disable dad on no attempts 2022-03-25 12:36:41 +01:00
Adrien Banlin
98743cb1ff addons: address: get new dad attributes
dad-attempts and dad-interval can now be taken from the interfaces
file.

Those attributes names came from ifupdown (original).
2022-03-25 12:30:27 +01:00
Julien Fortin
9a6a305084 cleanups - upstream sync
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-07-02 18:20:42 +02:00
Julien Fortin
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
Julien Fortin
1db0cb7acc addons: address: remove stale fdb entry for svi (when hwaddress is used)
As seen in the example below we are seeing a corner case, first the user
/e/n/i is configured without 'hwaddress', then it is used to fix the svi
mac address. The current code only checks for the statemanager for old
'hwaddress' attribute but couldn't find any. Now we save the mac addr
before updating it, so we can later clear it from the fdb.

$ cat a
auto eth0
iface eth0 inet dhcp

auto bridge
iface bridge
        bridge-vlan-aware yes
        bridge-ports vx-1000
        bridge-stp on
        bridge-vids 1000 1002 1004 1006 1008
        bridge-pvid 1

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

auto vlan1000
iface vlan1000
        address 45.0.0.2/24
        vlan-id 1000
        vlan-raw-device bridge
        address-virtual 00:00:5e:00:01:01 45.0.0.1/24
        vrf vrf1

auto vrf1
iface vrf1
        vrf-table auto

$
$
$ cat b
auto eth0
iface eth0 inet dhcp

auto bridge
iface bridge
        bridge-vlan-aware yes
        bridge-ports vx-1000
        bridge-stp on
        bridge-vids 1000 1002 1004 1006 1008
        bridge-pvid 1

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

auto vlan1000
iface vlan1000
        address 45.0.0.2/24
        hwaddress 00:02:00:aa:aa:aa
        vlan-id 1000
        vlan-raw-device bridge
        address-virtual 00:00:5e:00:01:01 45.0.0.1/24
        vrf vrf1

auto vrf1
iface vrf1
        vrf-table auto

$
$
$ rm /etc/network/interfaces ; ln -s `pwd`/a /etc/network/interfaces ; ifreload -a ; rm /etc/network/interfaces ; ln -s `pwd`/b /etc/network/interfaces ; (ifreload -av |& grep vlan | grep 1000)
info: bridge: netlink: bridge vlan add vid 1000 dev bridge
info: vlan1000: netlink: ip link set dev vlan1000 down
info: vlan1000: netlink: ip link set dev vlan1000 address 00:02:00:aa:aa:aa
info: vlan1000: netlink: ip link set dev vlan1000 up
info: writing '1' to file /proc/sys/net/ipv4/conf/vlan1000/arp_accept
info: executing /sbin/bridge fdb del 4a:b3:1e:45:bf:bf dev bridge vlan 1000  self
info: executing /sbin/bridge fdb replace 00:02:00:aa:aa:aa dev bridge vlan 1000  self
info: executing /sbin/bridge fdb replace 00:00:5e:00:01:01 dev bridge vlan 1000  self
$

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 16:13:49 +02:00
Julien Fortin
20eab2b13e addons: address: new policy: check_l3_svi_ip_forwarding
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 16:12:11 +02:00
Julien Fortin
0b34071bf8 addons: address: warn user if L3-SVI is configured with "ip-forward off"
Context:
"user accidentally disabled ip4 and ip6 forwarding on the L3-SVI for all VRF's.
we should add a check in ifupdown2 to warn user this is a bad config (symmetric
routing will not work if routing is disabled in this way)."

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 16:10:28 +02:00
Julien Fortin
01a655366b addons: address: raise exception when detecting an invalid ip address
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
2021-06-30 15:37:12 +02:00
Julien Fortin
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
Julien Fortin
909377598e addons: mtu: policy: accept integer value for mtu in policy file
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2021-01-25 19:11:01 +01:00
Julien Fortin
190cf3e6eb addons: address: enable ipv6 before adding new address
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2021-01-25 19:10:05 +01:00
Julien Fortin
69825bb495 addons: bridge: enable forwarding on dhcp bridges (fixes: #179)
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-11-18 14:19:48 +01:00
Julien Fortin
3218f49d81 use "except Exception:" instead of "except:"
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-06-24 01:12:24 +02:00
Alexandre Derumier
8994bdd39a address: don't process_mtu for openvswitch interfaces
Openvswitch already manage mtu if ovs-mtu is defined.
(Ovs manage mtu in userland, and sync mtu for some interfaces in kernel).

If mtu is changed by address module, before the ovs userland mtu,
this give packets drop.
2020-06-05 08:07:04 +02:00
Julien Fortin
580a567b25 addressvirtual: fix argument of type 'IPv4Network' is not iterable
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-05-13 20:41:28 +02:00
Julien Fortin
a3df9e6930 addons: address: mtu: set bridge mtu with policy default
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-05-13 20:24:12 +02:00
Julien Fortin
16de4e7988 Merge branch 'master' into python3
* master:
  addons: address: process MTU before addrgen and adddresses
  ifupdownmain: support for marking interfaces as mgmt interfaces
  addons: bridge: fix TypeError: sequence item 0: expected string, int found
  addons: bridge: set bridge MTU after bridge creation addons: bridge: get bridge MTU from address policy not bridge
  addons: mstpctl: check mstpctl-stp and bridge-stp and fix bridge cache update
  lib: nlcache: fix dry_run exception
  addons: address: add support for a separate default mtu policy for eth interfaces
  debian: changelog: new 2.0.2-1 entry
  addons: ethtool: add support for "ethtool_ignore_errors" policy
  LinkUtils: mac_str_to_int: fix string to int conversion
  addons: dhcp: if mgmt vrf context exec dhclient in default vrf
2020-03-26 03:02:53 +01:00
Julien Fortin
2c152f8396 addons: address: process MTU before addrgen and adddresses
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-03-26 01:04:30 +01:00
Roopa Prabhu
866c818344 addons: address: add support for a separate default mtu policy for eth interfaces
New module global policy mgmt_intf_mtu for mgmt interace mtu:
$cat /var/lib/ifupdown2/policy.d/address.json
{
    "address": {
        "module_globals": {
            "enable_l3_iface_forwarding_checks": "yes",
            "vlan_aware_bridge_address_support": "no",
            "l3_intf_arp_accept": "1",
            "mgmt_intf_mtu": "1500"
        },
        "defaults": {
            "mtu": "9216",
            "ip-forward": "on",
            "ip6-forward": "on"
        }
    }
}

If not specified mgmt_intf_mtu becomes equal to the mtu from defaults
section.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-03-26 00:02:58 +01:00
Julien Fortin
499d05970e
Merge pull request #151 from aderumier/fix-forwarding-3
don't change interface forwarding value if not defined
2020-02-24 23:50:23 +01:00
Alexandre Derumier
34de87120a don't change interface forwarding value if not defined
classic ifupdown don't change forwarding value if not defined in /etc/network/interfaces (don't even support it).

Currently ifupdown2 behaviour is to turn forwarding off when not defined. (and break sysctl manual enabling (net.ipv4.ip_forward = 1, net.ipv4.conf.all.forwarding = 1, net.ipv4.conf.default.forwarding = 1
on restart or reload).

Better to not change value when not defined, and keep user manual config.
2020-02-24 15:45:19 +01:00
Julien Fortin
cbda6ddacb addons: address: add support for a separate default mtu policy for eth interfaces
New module global policy mgmt_intf_mtu for mgmt interace mtu:

$ cat /var/lib/ifupdown2/policy.d/address.json
{
    "address": {
        "module_globals": {
            "enable_l3_iface_forwarding_checks": "yes",
            "vlan_aware_bridge_address_support": "no",
            "l3_intf_arp_accept": "1",
            "mgmt_intf_mtu": "1500"
        },
        "defaults": {
            "mtu": "9216",
            "ip-forward": "on",
            "ip6-forward": "on"
        }
    }
}

If not specified mgmt_intf_mtu becomes equal to the mtu from defaults
section.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
2020-02-24 14:26:31 +01:00
Julien Fortin
a3f9506e37 python3: addons: address: update IPNetwork call after master-next merge
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-01-21 09:34:57 +01:00
Julien Fortin
4955b6017a Merge branch 'master-next' into python3
* master-next:
  addons: address: convert ip addresses from statemanager to IPNetwork objects
  main: add extra log info to output the exit status
2020-01-21 09:33:20 +01:00
Julien Fortin
67c84dad3f addons: address: convert ip addresses from statemanager to IPNetwork objects
Ticket: CM-27841
Reviewed By: Roopa
Testing Done: tests from the CM

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-01-21 09:30:26 +01:00
Julien Fortin
0e936c3ffa python3: replacing ipaddr with custom ipnetwork.IPNetwork object
As mentioned in a previous commit:
python3 ipaddress behave differently from python2-ipaddr, this is
a serious problem for us since it breaks most of the ip addresses
code.

>>> import ipaddress
>>> ipaddress.ip_network("10.10.10.242/10", False)
IPv4Network('10.0.0.0/10')

This is a problem for us, so we need to use a custom IPNetwork object.
Our custom IPNetwork object uses ipaddress.IPAddress under the hood

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2020-01-08 11:09:08 +01:00
Julien Fortin
45864399b0 Revert "python3: ipaddress is now part of the standard library (removing python-ipaddr)"
This reverts commit 5dded70eaa.
2019-12-17 17:35:51 +01:00
Julien Fortin
5dded70eaa python3: ipaddress is now part of the standard library (removing python-ipaddr)
IPNetwork doesn't exists anymore and is replaced by ip_network. IPv?Network (4 and 6)
objects take an optional argument "strict" that defaults to True. If strict is set
and the ip address has the host bit set it will raise an exception. This is bad
for ifupdown2, so we need to replace all calls to IPNetwork and IPv?Network with
function who will set strict to False. That way we can limit the number of changes
for this patch.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2019-12-17 17:27:51 +01:00