Skip to content
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

Add downscript to fix free_machine targets #201

Merged
merged 5 commits into from
Nov 22, 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
1 change: 1 addition & 0 deletions images/Dockerfile.vms
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM docker.io/library/debian:bookworm-backports
RUN apt update && \
apt-get --no-install-recommends install --yes \
iproute2 \
procps \
python3 \
qemu-utils \
qemu-system-x86 \
Expand Down
4 changes: 2 additions & 2 deletions scripts/manage_vms.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _kill_vm_process(machine_uuid):
return

pid = fields[0]
os.kill(int(pid), signal.SIGKILL)
os.kill(int(pid), signal.SIGTERM)


@staticmethod
Expand Down Expand Up @@ -139,7 +139,7 @@ def _start_vm(machine):
cmd.append('-device')
cmd.append(f'virtio-net-pci,netdev=hn{i},mac={mac},romfile=')
cmd.append(f'-netdev')
cmd.append(f'tap,id=hn{i},ifname=tap{i},script=/mini-lab/mirror_tap_to_lan.sh,downscript=no')
cmd.append(f'tap,id=hn{i},ifname=tap{i},script=/mini-lab/mirror_tap_to_lan.sh,downscript=/mini-lab/remove_mirror.sh')

cmd.append("&")

Expand Down
15 changes: 15 additions & 0 deletions scripts/remove_mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Script is taken from https://netdevops.me/2021/transparently-redirecting-packetsframes-between-interfaces/
# Read it for better understanding

set -o errexit

TAP_IF=$1
# get interface index number up to 3 digits (everything after first three chars)
# tap0 -> 0
# tap123 -> 123
INDEX=${TAP_IF:3:3}

tc qdisc del dev $TAP_IF ingress
tc qdisc del dev lan$INDEX ingress