Skip to content

Commit

Permalink
Merge pull request #4195 from nvollmar/T6884
Browse files Browse the repository at this point in the history
T6884: adds mtu option for container networks
  • Loading branch information
dmbaturin authored Nov 19, 2024
2 parents 99f414c + f3da16e commit 8f76c96
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions interface-definitions/container.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@
</properties>
<children>
#include <include/generic-description.xml.i>
#include <include/interface/mtu-68-16000.xml.i>
<leafNode name="prefix">
<properties>
<help>Prefix which allocated to that network</help>
Expand Down
16 changes: 16 additions & 0 deletions smoketest/scripts/cli/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 6 additions & 0 deletions src/conf_mode/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8f76c96

Please sign in to comment.