Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.

Commit d165003

Browse files
committed
run.py: always create a bridge and run dhcp on the bridge
Signed-off-by: Reto Achermann <achreto@gmail.com>
1 parent b504b8f commit d165003

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

kernel/run.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -749,20 +749,26 @@ def configure_network(args):
749749
sudo[ip[['link', 'set', '{}'.format(tap), 'down']]](retcode=(0, 1))
750750
sudo[ip[['link', 'del', '{}'.format(tap)]]](retcode=(0, 1))
751751

752-
# Need to find out how to set default=True in case workers are >0 in `args`
753-
if (not 'workers' in args) or ('workers' in args and args.workers <= 1):
754-
sudo[tunctl[['-t', args.tap, '-u', user, '-g', group]]]()
755-
sudo[ifconfig[args.tap, NETWORK_INFRA_IP]]()
756-
sudo[ip[['link', 'set', args.tap, 'up']]](retcode=(0, 1))
757-
else:
758-
assert args.workers <= MAX_WORKERS, "Too many workers, can't configure network"
759-
sudo[ip[['link', 'add', 'br0', 'type', 'bridge']]]()
760-
sudo[ip[['addr', 'add', NETWORK_INFRA_IP, 'brd', '+', 'dev', 'br0']]]()
761-
for _, ncfg in zip(range(0, args.workers), NETWORK_CONFIG):
762-
sudo[tunctl[['-t', ncfg, '-u', user, '-g', group]]]()
763-
sudo[ip[['link', 'set', ncfg, 'up']]](retcode=(0, 1))
764-
sudo[brctl[['addif', 'br0', ncfg]]]()
765-
sudo[ip[['link', 'set', 'br0', 'up']]](retcode=(0, 1))
752+
753+
# figure out how many workers we have
754+
workers = 1
755+
if 'workers' in args:
756+
workers = args.workers
757+
758+
# create the bridge
759+
sudo[ip[['link', 'add', 'br0', 'type', 'bridge']]]()
760+
sudo[ip[['addr', 'add', NETWORK_INFRA_IP, 'brd', '+', 'dev', 'br0']]]()
761+
762+
# add a network interface for every worker there is
763+
for _, ncfg in zip(range(0, workers), NETWORK_CONFIG):
764+
sudo[tunctl[['-t', ncfg, '-u', user, '-g', group]]]()
765+
sudo[ip[['link', 'set', ncfg, 'up']]](retcode=(0, 1))
766+
sudo[brctl[['addif', 'br0', ncfg]]]()
767+
768+
# set the link up
769+
sudo[ip[['link', 'set', 'br0', 'up']]](retcode=(0, 1))
770+
771+
sudo[brctl[['setageing', 'br0', 600]]]()
766772

767773

768774
def configure_dcm_scheduler(args):

kernel/testutils/src/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::runner_args::RunnerArgs;
1717
///
1818
/// # Depends on
1919
/// - `tests/dhcpd.conf`: config file contains match of MAC to IP
20-
pub const DHCP_ACK_MATCH: &'static str = "DHCPACK on 172.31.0.10 to 56:b4:44:e9:62:d0 via tap0";
20+
pub const DHCP_ACK_MATCH: &'static str = "DHCPACK on 172.31.0.10 to 56:b4:44:e9:62:d0 via br0";
2121
pub const DHCP_ACK_MATCH_NRK2: &'static str = "DHCPACK on 172.31.0.11 to 56:b4:44:e9:62:d1 via br0";
2222

2323
/// Default shmem region size (in MB)
@@ -219,7 +219,7 @@ pub fn spawn_dcm(cfg: Option<DCMConfig>) -> Result<rexpect::session::PtySession>
219219

220220
/// Spawns a DHCP server on our host using most common interface: tap0
221221
pub fn spawn_dhcpd() -> Result<rexpect::session::PtyReplSession> {
222-
spawn_dhcpd_with_interface("tap0".to_string())
222+
spawn_dhcpd_with_interface("br0".to_string())
223223
}
224224

225225
/// Spawns a DHCP server on our host

0 commit comments

Comments
 (0)