Skip to content

Commit 1b31d6d

Browse files
committed
run.py: feature handling and dhcp assignments
Signed-off-by: Reto Achermann <[email protected]>
1 parent ba76131 commit 1b31d6d

File tree

2 files changed

+57
-9
lines changed

2 files changed

+57
-9
lines changed

kernel/run.py

+26-8
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def get_network_config(workers):
4949
config['tap{}'.format(2*i)] = {
5050
'mid': i,
5151
'mac': '56:b4:44:e9:62:d{:x}'.format(i),
52+
'ip' : f"172.31.0.1{i}"
5253
}
5354
return config
5455

@@ -215,8 +216,10 @@ def build_kernel(args):
215216
build_args = ['build', '--target', KERNEL_TARGET]
216217
if args.no_kfeatures:
217218
build_args += ["--no-default-features"]
219+
log(" - enable feature --no-default-features")
218220
for feature in args.kfeatures:
219221
build_args += ['--features', feature]
222+
log(" - enable feature {}".format(feature))
220223
build_args += CARGO_DEFAULT_ARGS
221224
build_args += CARGO_NOSTD_BUILD_ARGS
222225
if args.verbose:
@@ -233,6 +236,16 @@ def build_user_libraries(args):
233236
build_args += ["--features", "rumprt"]
234237
if args.nic == "virtio-net-pci":
235238
build_args += ["--features", "virtio"]
239+
log(" - enable feature virtio")
240+
241+
for featurelist in args.ufeatures:
242+
for feature in featurelist.split(',') :
243+
if ':' in feature:
244+
mod_part, feature_part = feature.split(':')
245+
if "libvibrio" == mod_part:
246+
log(" - enable feature {}".format(feature_part))
247+
build_args += ['--features', feature_part]
248+
236249
# else: use e1000 / wm0
237250
build_args += CARGO_DEFAULT_ARGS
238251
build_args += CARGO_NOSTD_BUILD_ARGS
@@ -259,18 +272,21 @@ def build_userspace(args):
259272
if not (USR_PATH / module).exists():
260273
log("User module {} not found, skipping.".format(module))
261274
continue
275+
log("build user-space module {}".format(module))
262276
with local.cwd(USR_PATH / module):
263277
with local.env(RUSTFLAGS=USER_RUSTFLAGS):
264278
with local.env(RUST_TARGET_PATH=USR_PATH.absolute()):
265279
build_args = build_args_default.copy()
266-
for feature in args.ufeatures:
267-
if ':' in feature:
268-
mod_part, feature_part = feature.split(':')
269-
if module == mod_part:
270-
build_args += ['--features', feature_part]
271-
else:
272-
build_args += ['--features', feature]
273-
log("Build user-module {}".format(module))
280+
for featurelist in args.ufeatures:
281+
for feature in featurelist.split(',') :
282+
if ':' in feature:
283+
mod_part, feature_part = feature.split(':')
284+
if module == mod_part:
285+
log(" - enable feature {}".format(feature_part))
286+
build_args += ['--features', feature_part]
287+
else:
288+
log(" - enable feature {}".format(feature))
289+
build_args += ['--features', feature]
274290
if args.verbose:
275291
print("cd {}".format(USR_PATH / module))
276292
print("RUSTFLAGS={} RUST_TARGET_PATH={} cargo ".format(
@@ -742,8 +758,10 @@ def configure_network(args):
742758
assert args.workers <= MAX_WORKERS, "Too many workers, can't configure network"
743759
sudo[ip[['link', 'add', 'br0', 'type', 'bridge']]]()
744760
sudo[ip[['addr', 'add', NETWORK_INFRA_IP, 'brd', '+', 'dev', 'br0']]]()
761+
745762
for _, ncfg in zip(range(0, args.workers), NETWORK_CONFIG):
746763
sudo[tunctl[['-t', ncfg, '-u', user, '-g', group]]]()
764+
sudo[ip[['link', 'set', 'address', NETWORK_CONFIG[ncfg]['mac'], 'dev', ncfg]]]()
747765
sudo[ip[['link', 'set', ncfg, 'up']]](retcode=(0, 1))
748766
sudo[brctl[['addif', 'br0', ncfg]]]()
749767
sudo[ip[['link', 'set', 'br0', 'up']]](retcode=(0, 1))

kernel/tests/dhcpd.conf

+31-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ option domain-name-servers ns1.example.org, ns2.example.org;
55
ddns-update-style none;
66

77
subnet 172.31.0.0 netmask 255.255.255.0 {
8-
range 172.31.0.12 172.31.0.16;
8+
range 172.31.0.118 172.31.0.118;
99
option routers 172.31.0.20;
1010
option subnet-mask 255.255.255.0;
1111
default-lease-time 1;
@@ -20,4 +20,34 @@ host nrk1 {
2020
host nrk2 {
2121
hardware ethernet 56:b4:44:e9:62:d1;
2222
fixed-address 172.31.0.11;
23+
}
24+
25+
host nrk3 {
26+
hardware ethernet 56:b4:44:e9:62:d2;
27+
fixed-address 172.31.0.12;
28+
}
29+
30+
host nrk4 {
31+
hardware ethernet 56:b4:44:e9:62:d3;
32+
fixed-address 172.31.0.13;
33+
}
34+
35+
host nrk5 {
36+
hardware ethernet 56:b4:44:e9:62:d4;
37+
fixed-address 172.31.0.14;
38+
}
39+
40+
host nrk6 {
41+
hardware ethernet 56:b4:44:e9:62:d5;
42+
fixed-address 172.31.0.15;
43+
}
44+
45+
host nrk7 {
46+
hardware ethernet 56:b4:44:e9:62:d6;
47+
fixed-address 172.31.0.16;
48+
}
49+
50+
host nrk8 {
51+
hardware ethernet 56:b4:44:e9:62:d7;
52+
fixed-address 172.31.0.17;
2353
}

0 commit comments

Comments
 (0)