Skip to content

passt/function: fix for multi-arch #5382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions libvirt/tests/cfg/virtual_network/passt/passt_function.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
iface_attrs = {'model': 'virtio', 'acpi': {'index': '1'}, 'type_name': 'user', 'backend': {'type': 'passt'}, 'source': {'dev': host_iface}}
vm_iface = eno1
vm_ping_outside = pass
s390-virtio:
iface_attrs = {'model': 'virtio', 'type_name': 'user', 'backend': {'type': 'passt'}, 'source': {'dev': host_iface}}
vm_iface = enc1
- ip_portfw:
ipv6_prefix = 128
alias = {'name': 'ua-c87b89ff-b769-4abc-921f-30d42d7aec5b'}
Expand All @@ -30,6 +33,8 @@
vm_iface = eno1
vm_ping_outside = pass
vm_ping_host_public = pass
s390-virtio:
vm_iface = enc1
variants:
- ip_addr:
portForward_0 = {'attrs': {'proto': 'tcp'}, 'ranges': [{'start': '31339', 'to': '41339'}]}
Expand All @@ -54,8 +59,8 @@
portForward_0 = {'attrs': {'proto': 'tcp', 'dev': host_iface}, 'ranges': [{'start': '31339', 'to': '41339'}]}
portForward_1 = {'attrs': {'proto': 'udp', 'dev': host_iface}, 'ranges': [{'start': '2025'}]}
portForwards = [${portForward_0}, ${portForward_1}]
tcp_port_list = [f'*%{vm_iface}:31339']
udp_port_list = [f'0.0.0.0%{vm_iface}:2025', f'[::]%{vm_iface}:2025']
tcp_port_list = [f'*%{host_iface}:31339']
udp_port_list = [f'0.0.0.0%{host_iface}:2025', f'[::]%{host_iface}:2025']
conn_check_args_1 = ('TCP4', host_ip, 31339, 41339, True, None)
conn_check_args_2 = ('TCP6', host_ip_v6, 31339, 41339, True, None)
conn_check_args_3 = ('UDP4', host_ip, 2025, 2025, True, None)
Expand All @@ -65,9 +70,11 @@
portForward_1 = {'attrs': {'proto': 'udp', 'address': host_ip, 'dev': host_iface}, 'ranges': [{'start': '2025'}]}
portForward_2 = {'attrs': {'proto': 'tcp', 'address': host_ip_v6, 'dev': host_iface}, 'ranges': [{'start': '51339'}]}
portForwards = [${portForward_0}, ${portForward_1}, ${portForward_2}]
tcp_port_list = [f'{host_ip}%{vm_iface}:31339', f'[{host_ip_v6}]%{vm_iface}:51339']
udp_port_list = [f'{host_ip}%{vm_iface}:2025']
tcp_port_list = [f'{host_ip}%{host_iface}:31339', f'[{host_ip_v6}]%{host_iface}:51339']
udp_port_list = [f'{host_ip}%{host_iface}:2025']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

conn_check_args_1 = ('TCP4', host_ip, 31339, 41339, True, None)
conn_check_args_2 = ('UDP4', host_ip, 2025, 2025, True, None)
conn_check_args_3 = ('TCP6', host_ip_v6, 51339, 51339, True, None)
iface_attrs = {'model': 'virtio', 'acpi': {'index': '1'}, 'ips': ${ips}, 'backend': ${backend}, 'source': {'dev': host_iface}, 'alias': ${alias}, 'type_name': 'user', 'portForwards': ${portForwards}}
s390-virtio:
iface_attrs = {'model': 'virtio', 'ips': ${ips}, 'backend': ${backend}, 'source': {'dev': host_iface}, 'alias': ${alias}, 'type_name': 'user', 'portForwards': ${portForwards}}
20 changes: 11 additions & 9 deletions libvirt/tests/src/virtual_network/passt/passt_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ def run(test, params, env):
test_passwd)
host_session.close()

host_ip = utils_net.get_host_ip_address(ip_ver='ipv4')
params['host_ip_v6'] = host_ip_v6 = utils_net.get_host_ip_address(
ip_ver='ipv6')
host_iface = params.get('host_iface')
host_iface = host_iface if host_iface else utils_net.get_net_if(
state="UP")[0]
host_ip = utils_net.get_ip_address_by_interface(host_iface, ip_ver='ipv4')
host_ip_v6 = utils_net.get_ip_address_by_interface(host_iface, ip_ver='ipv6')
params['host_ip_v6'] = host_ip_v6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can check the interface xml first, if the "dev" is specified, use it directly. If it is null, try to get the host_iface then. And for the host_ip_v6, if the host interface has 2 global ipv6 addresses(like in your test env.), it will use the more specific one - the one got by dhcp with prefix length as 128. Do we need to add some check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can check the interface xml first, if the "dev" is specified, use it directly.

I don't understand. The host_iface value would be used later to set the dev value l. 86.

if the host interface has 2 global ipv6 addresses(like in your test env.), it will use the more specific one - the one got by dhcp with prefix length as 128. Do we need to add some check here?

At this point, I have a test environment like on x86_64 without dhcp. Therefore the check is not needed IMO.

Copy link
Contributor

@yalzhang yalzhang Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The host_iface value would be used later to set the dev value l. 86.

Oh, sorry, I misunderstood it.

At this point, I have a test environment like on x86_64 without dhcp. Therefore the check is not needed IMO.

Okay, then it should work properly.

params['socket_dir'] = socket_dir = eval(params.get('socket_dir'))
params['proc_checks'] = proc_checks = eval(params.get('proc_checks', '{}'))
vm_iface = params.get('vm_iface', 'eno1')
mtu = params.get('mtu')
outside_ip = params.get('outside_ip')
host_iface = params.get('host_iface')
host_iface = host_iface if host_iface else utils_net.get_net_if(
state="UP")[0]
log_file = f'/run/user/{user_id}/passt.log'
iface_attrs = eval(params.get('iface_attrs'))
iface_attrs['backend']['logFile'] = log_file
Expand Down Expand Up @@ -97,7 +97,7 @@ def run(test, params, env):
test.fail(f'Logfile of passt "{log_file}" not created')

session = vm.wait_for_serial_login(timeout=60)
passt.check_vm_ip(iface_attrs, session, host_iface)
passt.check_vm_ip(iface_attrs, session, host_iface, vm_iface)
passt.check_vm_mtu(session, vm_iface, mtu)
passt.check_default_gw(session)
passt.check_nameserver(session)
Expand All @@ -111,10 +111,12 @@ def run(test, params, env):

firewalld.stop()
LOG.debug(f'Status of firewalld: {firewalld.status()}')
passt.check_connection(vm, vm_iface, ['TCP4', 'TCP6', 'UDP4', 'UDP6'])
passt.check_connection(vm, vm_iface,
['TCP4', 'TCP6', 'UDP4', 'UDP6'],
host_iface)

if 'portForwards' in iface_attrs:
passt.check_portforward(vm, host_ip, params)
passt.check_portforward(vm, host_ip, params, host_iface)

vm_sess = vm.wait_for_serial_login(timeout=60)
vm_sess.cmd('systemctl start firewalld')
Expand Down