Skip to content

Commit

Permalink
run.py: feature handling and dhcp assignments
Browse files Browse the repository at this point in the history
Signed-off-by: Reto Achermann <achreto@gmail.com>
  • Loading branch information
achreto committed Aug 23, 2023
1 parent ba76131 commit 1b31d6d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 9 deletions.
34 changes: 26 additions & 8 deletions kernel/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def get_network_config(workers):
config['tap{}'.format(2*i)] = {
'mid': i,
'mac': '56:b4:44:e9:62:d{:x}'.format(i),
'ip' : f"172.31.0.1{i}"
}
return config

Expand Down Expand Up @@ -215,8 +216,10 @@ def build_kernel(args):
build_args = ['build', '--target', KERNEL_TARGET]
if args.no_kfeatures:
build_args += ["--no-default-features"]
log(" - enable feature --no-default-features")
for feature in args.kfeatures:
build_args += ['--features', feature]
log(" - enable feature {}".format(feature))
build_args += CARGO_DEFAULT_ARGS
build_args += CARGO_NOSTD_BUILD_ARGS
if args.verbose:
Expand All @@ -233,6 +236,16 @@ def build_user_libraries(args):
build_args += ["--features", "rumprt"]
if args.nic == "virtio-net-pci":
build_args += ["--features", "virtio"]
log(" - enable feature virtio")

for featurelist in args.ufeatures:
for feature in featurelist.split(',') :
if ':' in feature:
mod_part, feature_part = feature.split(':')
if "libvibrio" == mod_part:
log(" - enable feature {}".format(feature_part))
build_args += ['--features', feature_part]

# else: use e1000 / wm0
build_args += CARGO_DEFAULT_ARGS
build_args += CARGO_NOSTD_BUILD_ARGS
Expand All @@ -259,18 +272,21 @@ def build_userspace(args):
if not (USR_PATH / module).exists():
log("User module {} not found, skipping.".format(module))
continue
log("build user-space module {}".format(module))
with local.cwd(USR_PATH / module):
with local.env(RUSTFLAGS=USER_RUSTFLAGS):
with local.env(RUST_TARGET_PATH=USR_PATH.absolute()):
build_args = build_args_default.copy()
for feature in args.ufeatures:
if ':' in feature:
mod_part, feature_part = feature.split(':')
if module == mod_part:
build_args += ['--features', feature_part]
else:
build_args += ['--features', feature]
log("Build user-module {}".format(module))
for featurelist in args.ufeatures:
for feature in featurelist.split(',') :
if ':' in feature:
mod_part, feature_part = feature.split(':')
if module == mod_part:
log(" - enable feature {}".format(feature_part))
build_args += ['--features', feature_part]
else:
log(" - enable feature {}".format(feature))
build_args += ['--features', feature]
if args.verbose:
print("cd {}".format(USR_PATH / module))
print("RUSTFLAGS={} RUST_TARGET_PATH={} cargo ".format(
Expand Down Expand Up @@ -742,8 +758,10 @@ def configure_network(args):
assert args.workers <= MAX_WORKERS, "Too many workers, can't configure network"
sudo[ip[['link', 'add', 'br0', 'type', 'bridge']]]()
sudo[ip[['addr', 'add', NETWORK_INFRA_IP, 'brd', '+', 'dev', 'br0']]]()

for _, ncfg in zip(range(0, args.workers), NETWORK_CONFIG):
sudo[tunctl[['-t', ncfg, '-u', user, '-g', group]]]()
sudo[ip[['link', 'set', 'address', NETWORK_CONFIG[ncfg]['mac'], 'dev', ncfg]]]()
sudo[ip[['link', 'set', ncfg, 'up']]](retcode=(0, 1))
sudo[brctl[['addif', 'br0', ncfg]]]()
sudo[ip[['link', 'set', 'br0', 'up']]](retcode=(0, 1))
Expand Down
32 changes: 31 additions & 1 deletion kernel/tests/dhcpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ option domain-name-servers ns1.example.org, ns2.example.org;
ddns-update-style none;

subnet 172.31.0.0 netmask 255.255.255.0 {
range 172.31.0.12 172.31.0.16;
range 172.31.0.118 172.31.0.118;
option routers 172.31.0.20;
option subnet-mask 255.255.255.0;
default-lease-time 1;
Expand All @@ -20,4 +20,34 @@ host nrk1 {
host nrk2 {
hardware ethernet 56:b4:44:e9:62:d1;
fixed-address 172.31.0.11;
}

host nrk3 {
hardware ethernet 56:b4:44:e9:62:d2;
fixed-address 172.31.0.12;
}

host nrk4 {
hardware ethernet 56:b4:44:e9:62:d3;
fixed-address 172.31.0.13;
}

host nrk5 {
hardware ethernet 56:b4:44:e9:62:d4;
fixed-address 172.31.0.14;
}

host nrk6 {
hardware ethernet 56:b4:44:e9:62:d5;
fixed-address 172.31.0.15;
}

host nrk7 {
hardware ethernet 56:b4:44:e9:62:d6;
fixed-address 172.31.0.16;
}

host nrk8 {
hardware ethernet 56:b4:44:e9:62:d7;
fixed-address 172.31.0.17;
}

0 comments on commit 1b31d6d

Please sign in to comment.