From 82b73dc8d7ad06b7d621d34063db01e88321d7df Mon Sep 17 00:00:00 2001 From: Nicolas Vollmar Date: Sun, 17 Nov 2024 10:47:22 +0100 Subject: [PATCH 1/2] T6884: adds mtu option for container networks --- interface-definitions/container.xml.in | 1 + smoketest/scripts/cli/test_container.py | 16 ++++++++++++++++ src/conf_mode/container.py | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/interface-definitions/container.xml.in b/interface-definitions/container.xml.in index 3dd1b3249d..2441ac410b 100644 --- a/interface-definitions/container.xml.in +++ b/interface-definitions/container.xml.in @@ -501,6 +501,7 @@ #include + #include Prefix which allocated to that network diff --git a/smoketest/scripts/cli/test_container.py b/smoketest/scripts/cli/test_container.py index c03b9eb449..0541384da9 100755 --- a/smoketest/scripts/cli/test_container.py +++ b/smoketest/scripts/cli/test_container.py @@ -224,6 +224,22 @@ def test_no_name_server(self): n = cmd_to_json(f'sudo podman network inspect {net_name}') self.assertEqual(n['dns_enabled'], False) + def test_network_mtu(self): + prefix = '192.0.2.0/24' + base_name = 'ipv4' + net_name = 'NET01' + + self.cli_set(base_path + ['network', net_name, 'prefix', prefix]) + self.cli_set(base_path + ['network', net_name, 'mtu', '1280']) + + name = f'{base_name}-2' + self.cli_set(base_path + ['name', name, 'image', cont_image]) + self.cli_set(base_path + ['name', name, 'network', net_name, 'address', str(ip_interface(prefix).ip + 2)]) + self.cli_commit() + + n = cmd_to_json(f'sudo podman network inspect {net_name}') + self.assertEqual(n['options']['mtu'], '1280') + def test_uid_gid(self): cont_name = 'uid-test' gid = '100' diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py index 14387cbbf6..a7dc33d9d4 100755 --- a/src/conf_mode/container.py +++ b/src/conf_mode/container.py @@ -419,12 +419,18 @@ def generate(container): 'dns_enabled': True, 'ipam_options': { 'driver': 'host-local' + }, + 'options': { + 'mtu': '1500' } } if 'no_name_server' in network_config: tmp['dns_enabled'] = False + if 'mtu' in network_config: + tmp['options']['mtu'] = network_config['mtu'] + for prefix in network_config['prefix']: net = {'subnet': prefix, 'gateway': inc_ip(prefix, 1)} tmp['subnets'].append(net) From f3da16e0da459027c1552b50f8a722cd75050630 Mon Sep 17 00:00:00 2001 From: Nicolas Vollmar Date: Mon, 18 Nov 2024 11:40:09 +0100 Subject: [PATCH 2/2] T6884: enables 16000 mtu --- interface-definitions/container.xml.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface-definitions/container.xml.in b/interface-definitions/container.xml.in index 2441ac410b..bd2ff820da 100644 --- a/interface-definitions/container.xml.in +++ b/interface-definitions/container.xml.in @@ -501,7 +501,7 @@ #include - #include + #include Prefix which allocated to that network