net: support multiple network interfaces#367
Conversation
613db39 to
ae78de2
Compare
99a268f to
992fda3
Compare
nirs
left a comment
There was a problem hiding this comment.
So much nicer with generic names!
| }; | ||
|
|
||
| if fd >= 0 && path.is_some() { | ||
| return -libc::EINVAL; |
There was a problem hiding this comment.
EINVAL without an error message is hard to work with. We have 4 different EINVAL errors for this function. How the user can tell what is the issue?
Can we have libkrun_error() to get the last error message? Probably not in the scope of this change, and I did not check the rest of the code.
There was a problem hiding this comment.
Can we have libkrun_error() to get the last error message? Probably not in the scope of this change, and I did not check the rest of the code.
Yeah, so our error reporting is not great and unfortunately we don't have anything like libkrun_error(), nor do we define our own error codes which would help here. Currently the only way to see what went wrong for example with krun_start_enter is to check the log (which has to be enabled). Not great I know, but that is really something we need to change in v2 API more globally (otherwise it would get really confusing how errors work).
| #define NET_FLAG_VFKIT 1 << 0 | ||
|
|
||
| /* Taken from uapi/linux/virtio_net.h */ | ||
| #define NET_VFLAG_CSUM 1 << 0 |
There was a problem hiding this comment.
If we go with 2 flag arguments let's make the constants and the flags names more clear using "features" and "flags".
#define NET_FEATURE_CSUM 1<<0
...
* "features" - virtio-net features for the network interface.
* "flags" - generic flags for the network interface.
Switching the order because the virtio features are more important and flags are usually the last argument.
There was a problem hiding this comment.
Sounds reasonable to me, I've just changed it.
d5a1281 to
9bd1af1
Compare
So far, we were assuming the microVM will have a single network interface. But we have at least one new usecase (namely, running Android), that requires having multiple interfaces. Refactor the API to support adding mulitple interfaces, while we keep compatibility with the old API. While there, also allow the user to set up the network device flags. Signed-off-by: Sergio Lopez <slp@redhat.com>
Update examples to use the new network config API and avoid use of deprecated functions. Signed-off-by: Sergio Lopez <slp@redhat.com>
|
@mtjhrc could you please take another look? |
| #define MAX_PATH 4096 | ||
| #endif | ||
|
|
||
| #define COMPAT_NET_FLAGS NET_CSUM | NET_GUEST_CSUM | NET_GUEST_TSO4 | NET_GUEST_UFO | NET_HOST_TSO4 | NET_HOST_UFO |
There was a problem hiding this comment.
You forgot to update this to the new constant names
| perror("Error configuring net mode"); | ||
| return -1; | ||
| uint8_t mac[] = {0x5a, 0x94, 0xef, 0xe4, 0x0c, 0xee}; | ||
| if (err = krun_add_net_passt(ctx_id, passt_fd, &mac[0], COMPAT_NET_FLAGS)) { |
There was a problem hiding this comment.
You forgot to update this to the new function name and signature
mtjhrc
left a comment
There was a problem hiding this comment.
Please fix the boot_efi example to not refer to non-existant functions/constants.
Otherwise everything looks good.
Good catch, thanks. I've fixed that and also moved COMPAT_NET_FEATURES to |
With new libkrun if we set the mac address after setting gvproxy path,
the network device is created using a default mac address:
let mac = cfg.mac.unwrap_or([0x5a, 0x94, 0xef, 0xe4, 0x0c, 0xee]);
create_virtio_net(
cfg,
VirtioNetBackend::UnixgramPath(path, true),
mac,
NET_COMPAT_FEATURES,
);
This breaks programs like vment-helper tests and minikube, assuming that
the device will use the mac address set by the tool.
This also breaks krunkit networking when using vment-helper with
offloading. I'm not sure why this happens.
With this change we can build with libkrun main and run a vm with
vment-helper example script or minikube krunkit driver.
I think this should be fixed in libkrun. This seems to be a regression
introduced by containers/libkrun#367. But the
fix in krunki is easy and safe.
With new libkrun if we set the mac address after setting gvproxy path,
the network device is created using a default mac address:
let mac = cfg.mac.unwrap_or([0x5a, 0x94, 0xef, 0xe4, 0x0c, 0xee]);
create_virtio_net(
cfg,
VirtioNetBackend::UnixgramPath(path, true),
mac,
NET_COMPAT_FEATURES,
);
This breaks programs like vment-helper tests and minikube, assuming that
the device will use the mac address set by the tool.
This also breaks krunkit networking when using vment-helper with
offloading. I'm not sure why this happens.
With this change we can build with libkrun main and run a vm with
vment-helper example script or minikube krunkit driver.
I think this should be fixed in libkrun. This seems to be a regression
introduced by containers/libkrun#367. But the
fix in krunki is easy and safe.
Signed-off-by: Nir Soffer <nirsof@gmail.com>
So far, we were assuming the microVM will have a single network interface. But we have at least one new usecase (namely, running Android), that requires having multiple interfaces.
Refactor the API to support adding mulitple interfaces, while we keep compatibility with the old API.
While there, also allow the user to set up the network device flags.