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

Support BESS protocol (for UML) #281

Merged
merged 5 commits into from
Jan 6, 2022

Conversation

AkihiroSuda
Copy link
Member

BESS protocol transferrs L2 packets as AF_UNIX SOCK_SEQPACKET .
BESS protocol has been used by the vector network interfaces of User Mode Linux (UML).

(terminal 1) $ slirp4netns --target-type=bess /tmp/bess.sock
(terminal 2) $ linux.uml vec0:transport=bess,dst=/tmp/bess.sock,depth=128,gro=1 root=/dev/root rootfstype=hostfs init=/bin/bash mem=2G
(terminal 2: UML)$ ip addr add 10.0.2.100/24 dev vec0
(terminal 2: UML)$ ip link set vec0 up
(terminal 2: UML)$ ip route add default via 10.0.2.2

More docs about the User Mode Linux with BESS socket transport: https://www.kernel.org/doc/html/latest/virt/uml/user_mode_linux_howto_v2.html#bess-socket-transport

@AkihiroSuda AkihiroSuda added this to the v1.2.0 milestone Jan 5, 2022
@AkihiroSuda
Copy link
Member Author

cc @giuseppe @elmarco FYI

Copy link
Collaborator

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with BESS but the code LGTM

Just left two minor comments

if (argc - optind < 2) {
goto error;
}
if (argc - optind > 2) {
// not an error, for preventing potential compatibility issue
printf("WARNING: too many arguments\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this go to stderr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been using stdout or printing WARNING messages (why? 😅 )

slirp4netns/main.c

Lines 563 to 604 in f2ae176

case _DEPRECATED_NO_HOST_LOOPBACK:
// There was no tagged release with support for --no-host-loopback.
// So no one will be affected by removal of --no-host-loopback.
printf("WARNING: --no-host-loopback is deprecated and will be "
"removed in future releases, please use "
"--disable-host-loopback instead.\n");
/* FALLTHROUGH */
case DISABLE_HOST_LOOPBACK:
options->disable_host_loopback = true;
break;
case _DEPRECATED_CREATE_SANDBOX:
// There was no tagged release with support for --create-sandbox.
// So no one will be affected by removal of --create-sandbox.
printf("WARNING: --create-sandbox is deprecated and will be "
"removed in future releases, please use "
"--enable-sandbox instead.\n");
/* FALLTHROUGH */
case ENABLE_SANDBOX:
options->enable_sandbox = true;
break;
case ENABLE_SECCOMP:
printf("WARNING: Support for seccomp is experimental\n");
options->enable_seccomp = true;
break;
case NETNS_TYPE:
optarg_netns_type = optarg;
break;
case USERNS_PATH:
optarg_userns_path = optarg;
if (access(optarg_userns_path, F_OK) == -1) {
fprintf(stderr, "userns path doesn't exist: %s\n",
optarg_userns_path);
goto error;
}
break;
case 'a':
optarg_api_socket = optarg;
break;
case '6':
options->enable_ipv6 = true;
printf("WARNING: Support for IPv6 is experimental\n");
break;

main.c Outdated
}

/* Accept a connection, and send its connection to the parent */
printf("Waiting for connection to %s\n", bess_socket);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using both stdout and stderr for diagnostic messages. Should we just stick to stderr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

BESS protocol transferrs L2 packets as AF_UNIX SOCK_SEQPACKET .
BESS protocol has been used by the vector network interfaces of User Mode Linux (UML).

```
(terminal 1) $ slirp4netns --target-type=bess /tmp/bess.sock
(terminal 2) $ linux.uml vec0:transport=bess,dst=/tmp/bess.sock,depth=128,gro=1 root=/dev/root rootfstype=hostfs init=/bin/bash mem=2G
(terminal 2: UML)$ ip addr add 10.0.2.100/24 dev vec0
(terminal 2: UML)$ ip link set vec0 up
(terminal 2: UML)$ ip route add default via 10.0.2.2
```

More docs about the User Mode Linux with BESS socket transport: https://www.kernel.org/doc/html/latest/virt/uml/user_mode_linux_howto_v2.html#bess-socket-transport

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda
Copy link
Member Author

Step 9/19 : RUN  git pull && git checkout ${LIBSLIRP_COMMIT} && meson setup build && ninja -C build install
 ---> Running in f5c0822a3dc4
fatal: unable to access 'https://gitlab.freedesktop.org/slirp/libslirp.git/': The requested URL returned error: 504
The command '/bin/sh -c git pull && git checkout ${LIBSLIRP_COMMIT} && meson setup build && ninja -C build install' returned a non-zero code: 1

😢
https://github.com/rootless-containers/slirp4netns/runs/4723883332?check_suite_focus=true

Use git://git.qemu.org/libslirp.git instead of
https://gitlab.freedesktop.org/slirp/libslirp.git temporarily

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda merged commit 95f3620 into rootless-containers:master Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants