From fcd05d47fb362ef49971c41d60f34bb1ff0fc9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Tur=C3=A9gano?= Date: Mon, 13 May 2024 18:25:30 +0200 Subject: [PATCH] Debian10 network fix --- packetnetworking/distros/debian/bonded.py | 14 ++++- packetnetworking/distros/debian/conftest.py | 2 +- .../bonded/etc_network_interfaces_debian10.j2 | 62 +++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 packetnetworking/distros/debian/templates/bonded/etc_network_interfaces_debian10.j2 diff --git a/packetnetworking/distros/debian/bonded.py b/packetnetworking/distros/debian/bonded.py index 7ca5958..37eb408 100644 --- a/packetnetworking/distros/debian/bonded.py +++ b/packetnetworking/distros/debian/bonded.py @@ -11,7 +11,19 @@ def build(self): self.build_tasks() def build_tasks(self): - self.task_template("etc/network/interfaces", "bonded/etc_network_interfaces.j2") + if ( + self.metadata.operating_system.distro == "debian" + and self.metadata.operating_system.version == "10" + ): + # Debian10 is failing if we don't configure the net this way + self.task_template( + "etc/network/interfaces", "bonded/etc_network_interfaces_debian10.j2" + ) + else: + self.task_template( + "etc/network/interfaces", "bonded/etc_network_interfaces.j2" + ) + self.task_template("etc/modules", "bonded/etc_modules.j2", write_mode="a") self.tasks.update(generate_persistent_names_udev()) return self.tasks diff --git a/packetnetworking/distros/debian/conftest.py b/packetnetworking/distros/debian/conftest.py index 47c4e11..0a4ac13 100644 --- a/packetnetworking/distros/debian/conftest.py +++ b/packetnetworking/distros/debian/conftest.py @@ -10,7 +10,7 @@ versions = { - "debian": ["10", "11", "12"], + "debian": ["11", "12"], "ubuntu": ["18.04", "20.04", "22.04"], } versions = [[distro, version] for distro in versions for version in versions[distro]] diff --git a/packetnetworking/distros/debian/templates/bonded/etc_network_interfaces_debian10.j2 b/packetnetworking/distros/debian/templates/bonded/etc_network_interfaces_debian10.j2 new file mode 100644 index 0000000..831ba36 --- /dev/null +++ b/packetnetworking/distros/debian/templates/bonded/etc_network_interfaces_debian10.j2 @@ -0,0 +1,62 @@ +auto lo +iface lo inet loopback + +{% for bond in bonds | sort %} + +auto {{ bond }} +iface {{ bond }} inet {% if bond == "bond0" %}static{% else %}manual{% endif %} + + {% if bond == "bond0" %} + {% if ip4pub %} + address {{ ip4pub.address }} + netmask {{ ip4pub.netmask }} + gateway {{ ip4pub.gateway }} + {% else %} + address {{ ip4priv.address }} + netmask {{ ip4priv.netmask }} + gateway {{ ip4priv.gateway }} + {% endif %} + hwaddress {{ interfaces[0].mac }} + dns-nameservers {{ resolvers | sort | join(" ") }} + + {% endif %} + bond-downdelay 200 + bond-miimon 100 + bond-mode {{ net.bonding.mode }} + bond-updelay 200 + bond-xmit_hash_policy layer3+4 + {% if net.bonding.mode == 4 %} + bond-lacp-rate 1 + {% endif %} + bond-slaves {{ bonds[bond] | map(attribute='name') | sort | join(' ') }} +{% if bond == "bond0" %} +{% if ip6pub %} + +iface bond0 inet6 static + address {{ ip6pub.address }} + netmask {{ ip6pub.cidr }} + gateway {{ ip6pub.gateway }} +{% endif %} +{% if ip4pub %} + +auto bond0:0 +iface bond0:0 inet static + address {{ ip4priv.address }} + netmask {{ ip4priv.netmask }} + {% for subnet in private_subnets | sort %} + post-up route add -net {{ subnet }} gw {{ ip4priv.gateway }} + post-down route del -net {{ subnet }} gw {{ ip4priv.gateway }} + {% endfor %} +{% endif %} +{% endif %} +{% endfor %} + +{% for iface in interfaces | sort(attribute="name") %} + +auto {{ iface.name }} +iface {{ iface.name }} inet manual +{% if iface.name != interfaces[0].name %} + pre-up sleep 4 +{% endif %} + bond-master bond0 +{% endfor %}