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

bump libslirp to v4.9.0 #351

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
libslirp_commit: [master, v4.8.0, v4.7.0, v4.1.0]
libslirp_commit: [master, v4.9.0, v4.8.0, v4.1.0]
steps:
- uses: actions/checkout@v2
- run: docker build -t slirp4netns-tests --build-arg LIBSLIRP_COMMIT -f Dockerfile.tests .
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.artifact
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --platform=amd64,arm64,arm,s390x,ppc64le,riscv64 \
# -f Dockerfile.artifact .

ARG LIBSLIRP_COMMIT=v4.8.0
ARG LIBSLIRP_COMMIT=v4.9.0
ARG UBUNTU_VERSION=jammy-20240125
ARG XX_VERSION=1.2.1@sha256:8879a398dedf0aadaacfbd332b29ff2f84bc39ae6d4e9c0a1109db27ac5ba012
ARG REPRO_SOURCES_LIST_VERSION=v0.1.0
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.buildtests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG LIBSLIRP_COMMIT=v4.8.0
ARG LIBSLIRP_COMMIT=v4.9.0

# Alpine
FROM alpine:3 AS buildtest-alpine3-static
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG LIBSLIRP_COMMIT=v4.8.0
ARG LIBSLIRP_COMMIT=v4.9.0

FROM ubuntu:22.04 AS build
ENV DEBIAN_FRONTEND=noninteractive
Expand Down
36 changes: 36 additions & 0 deletions slirp4netns.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ static void libslirp_register_poll_fd(int fd, void *opaque)
*/
}

#if SLIRP_CONFIG_VERSION_MAX >= 6 /* libslirp v4.9.0 */
static void libslirp_register_poll_socket(slirp_os_socket sock, void *opaque)
{
libslirp_register_poll_fd((int)sock, opaque);
}
#endif

/* implements SlirpCb.unregister_poll_fd */
static void libslirp_unregister_poll_fd(int fd, void *opaque)
{
Expand All @@ -106,6 +113,13 @@ static void libslirp_unregister_poll_fd(int fd, void *opaque)
*/
}

#if SLIRP_CONFIG_VERSION_MAX >= 6 /* libslirp v4.9.0 */
static void libslirp_unregister_poll_socket(slirp_os_socket sock, void *opaque)
{
libslirp_unregister_poll_fd((int)sock, opaque);
}
#endif

/* implements SlirpCb.notify */
static void libslirp_notify(void *opaque)
{
Expand Down Expand Up @@ -161,6 +175,14 @@ static int libslirp_add_poll(int fd, int events, void *opaque)
return idx;
}

#if SLIRP_CONFIG_VERSION_MAX >= 6 /* libslirp v4.9.0 */
static int libslirp_add_poll_socket(slirp_os_socket sock, int events,
void *opaque)
{
return libslirp_add_poll((int)sock, events, opaque);
}
#endif

static int libslirp_gio_to_poll(int events)
{
int ret = 0;
Expand Down Expand Up @@ -243,8 +265,13 @@ static const SlirpCb libslirp_cb = {
.timer_new = libslirp_timer_new,
.timer_free = libslirp_timer_free,
.timer_mod = libslirp_timer_mod,
#if SLIRP_CONFIG_VERSION_MAX >= 6 /* libslirp v4.9.0 */
.register_poll_socket = libslirp_register_poll_socket,
.unregister_poll_socket = libslirp_unregister_poll_socket,
#else
.register_poll_fd = libslirp_register_poll_fd,
.unregister_poll_fd = libslirp_unregister_poll_fd,
#endif
.notify = libslirp_notify,
};

Expand Down Expand Up @@ -292,6 +319,10 @@ Slirp *create_slirp(void *opaque, struct slirp4netns_config *s4nn)
cfg.version = 3;
cfg.disable_dns = true;
}
#endif
#if SLIRP_CONFIG_VERSION_MAX >= 6 /* libslirp v4.9.0 */
/* For slirp_os_socket callbacks */
cfg.version = 6;
#endif
slirp = slirp_new(&cfg, &libslirp_cb, opaque);
if (slirp == NULL) {
Expand Down Expand Up @@ -372,7 +403,12 @@ int do_slirp(int tapfd, int readyfd, int exitfd, const char *api_socket,
GPollFD *pollfds_data;
uint32_t timeout = -1; /* msec */
g_array_set_size(pollfds, n_fds);
#if SLIRP_CONFIG_VERSION_MAX >= 6 /* libslirp v4.9.0 */
slirp_pollfds_fill_socket(slirp, &timeout, libslirp_add_poll_socket,
pollfds);
#else
slirp_pollfds_fill(slirp, &timeout, libslirp_add_poll, pollfds);
#endif
update_ra_timeout(&timeout, &opaque);
pollfds_data = (GPollFD *)pollfds->data;
do {
Expand Down