Skip to content

Commit b2b1cf9

Browse files
committed
contest: hw: add local prefix support for container tests
Construct a /96 out of the /64 we have in the DB. Put it in env. The only real config we need is to make sure remote gets a route installed so that it doesn't try to resolve L2 directly. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 12af8be commit b2b1cf9

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

contest/hw/hw_worker.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ def _ensure_addr(ifname, addr, **kwargs):
127127
_ip(f'addr add {addr} dev {ifname}', **kwargs)
128128

129129

130+
def _install_prefix_route(ifname, prefix, local_v6, **kwargs):
131+
"""
132+
Install a route on remote with a nexthop so that remote doesn't try
133+
to resolve the L2 for all the containers, just sends the traffic to us.
134+
"""
135+
_ip(f'-6 route add {prefix} via {local_v6} dev {ifname}', **kwargs)
136+
137+
130138
def _collect_device_info(ifname):
131139
"""Collect devlink device info for the test interface.
132140
@@ -207,6 +215,9 @@ def setup_test_interfaces(test_dir):
207215
_ensure_addr(remote_ifname, env['REMOTE_V4'], **peer_kwargs)
208216
if env.get('REMOTE_V6'):
209217
_ensure_addr(remote_ifname, env['REMOTE_V6'], **peer_kwargs)
218+
if env.get('LOCAL_PREFIX_V6'):
219+
_install_prefix_route(remote_ifname, env['LOCAL_PREFIX_V6'],
220+
env['LOCAL_V6'], **peer_kwargs)
210221

211222
# Wait for peer to be reachable
212223
peer_ip = env.get('REMOTE_V4', '').split('/')[0]

contest/hw/lib/deployer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ def deploy_artifacts(_config, machine_ips, reservation_id, nic_info, tree_path,
157157
config_lines = []
158158
config_lines.append(f'NETIF={nic_info.get("ifname", "")}')
159159
config_lines.append(f'LOCAL_V4={nic_info.get("ip4addr", "")}')
160-
config_lines.append(f'LOCAL_V6={nic_info.get("ip6addr", "")}')
160+
161+
ipv6=nic_info.get("ip6addr", "")
162+
config_lines.append(f'LOCAL_V6={ipv6}')
163+
if ipv6:
164+
local_pfx=ipv6.split("::")[0] + "::2:0:0/96"
165+
config_lines.append(f'LOCAL_PREFIX_V6={local_pfx}')
161166

162167
peer = nic_info.get('peer')
163168
if peer:

0 commit comments

Comments
 (0)