RFC: slirp: make it again a standalone project
Subsystems (3)
cover RFC: slirp: make it again a standalone project
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.
I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1> /dev/null 2>&1; then clang-format -i * /dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)
What do you think?
Marc-André Lureau (41):
slirp: move socket pair creation in helper function
glib-compat: add g_spawn_async_with_fds() fallback
slirp: simplify fork_exec()
slirp: remove unused M_TRAILINGSPACE
slirp: use a callback structure to interface with qemu
slirp: add a callback for qemu_chr_fe_write_all()
slirp: add clock_get_ns() callback
slirp: add callbacks for timer
slirp: add a set_nonblock() callback
slirp: remove PROBE_CONN dead-code
slirp: remove FULL_BOLT
slirp: remove the disabled readv()/writev() code path
slirp: remove HAVE_SYS_SIGNAL_H
slirp: remove unused HAVE_SYS_BITYPES_H
slirp: remove NO_UNIX_SOCKETS
slirp: remove unused HAVE_SYS_STROPTS_H
slirp: remove unused HAVE_ARPA_INET_H
slirp: remove unused HAVE_SYS_WAIT_H
slirp: remove unused HAVE_SYS_SELECT_H
slirp: remove HAVE_SYS_IOCTL_H
slirp: remove HAVE_SYS_FILIO_H
slirp: remove unused DECLARE_IOVEC
slirp: remove unused HAVE_INET_ATON
slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent
slirp: replace SIZEOF_CHAR_P with glib equivalent
slirp: replace compile time DO_KEEPALIVE
slirp: remove unused global slirp_instance
slirp: replace error_report() with g_critical()
slirp: improve a bit the debug macros
slirp: replace trace functions with DEBUG calls
slirp: add a callback to log guest errors
slirp: remove unused sbflush()
slirp: replace qemu_notify_event() with a callback
slirp: remove #if notdef dead code
slirp: NULL is defined by glib (at least)
slirp: remove dead TCP_ACK_HACK code
slirp: replace ARRAY_SIZE with G_N_ELEMENTS
net: do not depend on slirp internals
slirp: move QEMU state saving to a separate unit
slirp: replace remaining QEMU dependency
build-sys: add a basic meson build
include/glib-compat.h | 56 ++++++ net/colo.h | 3 +- net/util.h | 55 +++++ slirp/debug.h | 47 ++++- slirp/ip.h | 24 ++- slirp/ip6.h | 8 +- slirp/ip6_icmp.h | 22 +- slirp/libslirp.h | 35 +++- slirp/main.h | 4 - slirp/mbuf.h | 1 - slirp/qtailq.h | 218 ++++++++++++++++++++ slirp/sbuf.h | 3 +- slirp/slirp.h | 58 ++---- slirp/slirp_config.h | 86 -------- slirp/socket.h | 1 + slirp/state.h | 9 + slirp/tcp.h | 4 +- slirp/util.h | 145 +++++++++++++ net/colo-compare.c | 1 + net/colo.c | 1 + net/filter-rewriter.c | 1 + net/slirp.c | 65 +++++- slirp/arp_table.c | 13 +- slirp/bootp.c | 4 +- slirp/cksum.c | 5 +- slirp/dhcpv6.c | 19 +- slirp/dnssearch.c | 1 - slirp/if.c | 6 +- slirp/ip6_icmp.c | 34 ++-- slirp/ip6_input.c | 1 - slirp/ip6_output.c | 2 - slirp/ip_icmp.c | 25 ++- slirp/ip_input.c | 201 ------------------ slirp/ip_output.c | 1 - slirp/mbuf.c | 3 +- slirp/misc.c | 188 +++++++++-------- slirp/ncsi.c | 5 +- slirp/ndp_table.c | 20 +- slirp/sbuf.c | 8 +- slirp/slirp.c | 458 +++--------------------------------------- slirp/socket.c | 72 +++---- slirp/state.c | 394 ++++++++++++++++++++++++++++++++++++ slirp/tcp_input.c | 86 ++------ slirp/tcp_output.c | 3 +- slirp/tcp_subr.c | 21 +- slirp/tcp_timer.c | 3 +- slirp/tftp.c | 18 +- slirp/udp.c | 13 +- slirp/udp6.c | 8 +- slirp/util.c | 176 ++++++++++++++++ stubs/slirp.c | 2 +- Makefile.objs | 1 - slirp/Makefile.objs | 4 +- slirp/meson.build | 48 +++++ slirp/trace-events | 5 - 55 files changed, 1547 insertions(+), 1148 deletions(-) create mode 100644 slirp/qtailq.h delete mode 100644 slirp/slirp_config.h create mode 100644 slirp/state.h create mode 100644 slirp/util.h create mode 100644 slirp/state.c create mode 100644 slirp/util.c create mode 100644 slirp/meson.build delete mode 100644 slirp/trace-events
Signature · 1 line
2.19.1.708.g4ede3d42df
PATCH 1/41 slirp: move socket pair creation in helper function
Originally, the patch was fixing a bunch of issues, but Peter beat me to it with earlier commit "slirp: fork_exec(): create and connect child socket before fork()".
Factor out socket pair creation, to simplify the fork_exec() code. Use the name socketpair_with_oob() since the code is actually similar to what socketpair() would do, except that it uses TCP sockets, for SLIRP to be able to call send with MSG_OOB (since SO_OOBINLINE is set, this could probably be faked instead on regular unix sockets though).
--- slirp/misc.c | 142 +++++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 71 deletions(-)
slirp/misc.c +71 -71
@@ -73,85 +73,92 @@ fork_exec(struct socket *so, const char *ex)#else -/* -* XXX This is ugly -* We create and bind a socket, then fork off to another -* process, which connects to this socket, after which we -* exec the wanted program. If something (strange) happens, -* the accept() call could block us forever. -*/ +static int +slirp_socketpair_with_oob (int sv[2 ]) +{ +struct sockaddr_in addr = { + .sin_family =AF_INET , + .sin_port =0 , + .sin_addr.s_addr =INADDR_ANY , + }; +socklen_t addrlen =sizeof (addr); +int ret, s; + + sv[1 ] =-1 ; + s =qemu_socket (AF_INET ,SOCK_STREAM ,0 ); +if (s <0 ||bind (s, (struct sockaddr *)&addr, addrlen) <0 || +listen (s,1 ) <0 || +getsockname (s, (struct sockaddr *)&addr, &addrlen) <0 ) { + goto err; + } + + sv[1 ] =qemu_socket (AF_INET ,SOCK_STREAM ,0 ); +if (sv[1 ] <0 ) { + goto err; + } +/* +* This connect won't block because we've already listen()ed on +* the server end (even though we won't accept() the connection +* until later on). +*/ +do { + ret =connect (sv[1 ], (struct sockaddr *)&addr, addrlen); + }while (ret <0 && errno ==EINTR ); +if (ret <0 ) { + goto err; + } + +do { + sv[0 ] =accept (s, (struct sockaddr *)&addr, &addrlen); + }while (sv[0 ] <0 && errno ==EINTR ); +if (sv[0 ] <0 ) { + goto err; + } + +closesocket (s); +return 0 ; + +err: +error_report ("Error: slirp_socketpair(): %s" ,strerror (errno)); +if (s >=0 ) { +closesocket (s); + } +if (sv[1 ] >=0 ) { +closesocket (sv[1 ]); + } +return -1 ; +} +int fork_exec (struct socket *so,const char *ex) { -int s, cs; -struct sockaddr_in addr, csaddr; -socklen_t addrlen =sizeof (addr); -socklen_t csaddrlen =sizeof (csaddr); -int opt;char **argv; -int ret; +int opt, c, sp[2 ];pid_t pid;DEBUG_CALL ("fork_exec" );DEBUG_ARG ("so = %p" , so);DEBUG_ARG ("ex = %p" , ex); - addr.sin_family =AF_INET ; - addr.sin_port =0 ; - addr.sin_addr.s_addr =INADDR_ANY ; - - s =qemu_socket (AF_INET ,SOCK_STREAM ,0 ); -if (s <0 ||bind (s, (struct sockaddr *)&addr, addrlen) <0 || -listen (s,1 ) <0 ) { -error_report ("Error: inet socket: %s" ,strerror (errno)); -if (s >=0 ) { -closesocket (s); - } +if (slirp_socketpair_with_oob (sp) <0 ) {return 0 ; } -if (getsockname (s, (struct sockaddr *)&csaddr, &csaddrlen) <0 ) { -closesocket (s); -return 0 ; - } - cs =qemu_socket (AF_INET ,SOCK_STREAM ,0 ); -if (cs <0 ) { -closesocket (s); -return 0 ; - } - csaddr.sin_addr = loopback_addr; -/* -* This connect won't block because we've already listen()ed on -* the server end (even though we won't accept() the connection -* until later on). -*/ -do { - ret =connect (cs, (struct sockaddr *)&csaddr, csaddrlen); - }while (ret <0 && errno ==EINTR ); -if (ret <0 ) { -closesocket (s); -closesocket (cs); -return 0 ; - } - pid =fork ();switch (pid) {case -1 :error_report ("Error: fork failed: %s" ,strerror (errno)); -closesocket (cs); -close (s); +closesocket (sp[0 ]); +closesocket (sp[1 ]);return 0 ;case 0 : -setsid (); - -/* Set the DISPLAY */ -close (s); -dup2 (cs,0 ); -dup2 (cs,1 ); -dup2 (cs,2 ); -for (s =getdtablesize () -1 ; s >=3 ; s--) -close (s); +setsid (); +dup2 (sp[1 ],0 ); +dup2 (sp[1 ],1 ); +dup2 (sp[1 ],2 ); +for (c =getdtablesize () -1 ; c >=3 ; c--) +close (c); argv =g_strsplit (ex," " ,-1 );execvp (argv[0 ], (char **)argv);
@@ -163,19 +170,12 @@ fork_exec(struct socket *so, const char *ex)exit (1 );default : + so->s = sp[0 ]; +closesocket (sp[1 ]);qemu_add_child_watch (pid); -closesocket (cs); -/* -* This should never block, because we already connect()ed -* on the child end before we forked. -*/ -do { - so->s =accept (s, (struct sockaddr *)&addr, &addrlen); - }while (so->s <0 && errno ==EINTR ); -closesocket (s); -socket_set_fast_reuse (so->s); - opt =1 ; -qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); +socket_set_fast_reuse (so->s); + opt =1 ; +qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));qemu_set_nonblock (so->s);return 1 ; }
Signature · 1 line
2.19.1.708.g4ede3d42df
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 01/41] slirp: move socket pair creation in helper function
Hello,
Marc-André Lureau, le mer. 14 nov. 2018 16:36:03 +0400, a ecrit:
Quoted 11 lines
Originally, the patch was fixing a bunch of issues, but Peter beat me to it with earlier commit "slirp:
fork_exec(): create and connect child socket beforefork()".Factor out socket pair creation, to simplify the
fork_exec()code. Use the namesocketpair_with_oob()since the code is actually similar to whatsocketpair()would do, except that it uses TCP sockets, for SLIRP to be able to call send withMSG_OOB(sinceSO_OOBINLINEis set, this could probably be faked instead on regular unix sockets though).Signed-off-by Marc-André Lureau <[email protected]>
Applied to my tree, thanks!
Samuel
PATCH 2/41 glib-compat: add g_spawn_async_with_fds() fallback
In reply to Marc-André Lureau--- include/glib-compat.h | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
include/glib-compat.h +56 -0
@@ -83,6 +83,62 @@ static inline gboolean g_strv_contains_qemu(const gchar *const *strv, }#define g_strv_contains (a, b) g_strv_contains_qemu(a, b) +#if !GLIB_CHECK_VERSION (2 ,58 ,0 ) +typedef struct QemuGSpawnFds { +GSpawnChildSetupFunc child_setup; +gpointer user_data; +gint stdin_fd; +gint stdout_fd; +gint stderr_fd; +}QemuGSpawnFds ; + +static inline void +qemu_gspawn_fds_setup (gpointer user_data) +{ +QemuGSpawnFds *q = (QemuGSpawnFds *)user_data; + +dup2 (q->stdin_fd,0 ); +dup2 (q->stdout_fd,1 ); +dup2 (q->stderr_fd,2 ); + q->child_setup (q->user_data); +} +#endif + +static inline gboolean +g_spawn_async_with_fds_qemu (const gchar *working_directory, +gchar **argv, +gchar **envp, +GSpawnFlags flags, +GSpawnChildSetupFunc child_setup, +gpointer user_data, +GPid *child_pid, +gint stdin_fd, +gint stdout_fd, +gint stderr_fd, +GError **error) +{ +#if GLIB_CHECK_VERSION (2 ,58 ,0 ) +return g_spawn_async_with_fds (working_directory, argv, envp, flags, + child_setup, user_data, + child_pid, stdin_fd, stdout_fd, stderr_fd, + error); +#else +QemuGSpawnFds setup = { + .child_setup = child_setup, + .user_data = user_data, + .stdin_fd = stdin_fd, + .stdout_fd = stdout_fd, + .stderr_fd = stderr_fd, + }; + +return g_spawn_async (working_directory, argv, envp, flags, + qemu_gspawn_fds_setup, &setup, + child_pid, error); +#endif +} + +#define g_spawn_async_with_fds (wd, argv, env, f, c, d, p, ifd, ofd, efd, err) \ + g_spawn_async_with_fds_qemu(wd, argv, env, f, c, d, p, ifd, ofd, efd, err)#if defined(_WIN32) && !GLIB_CHECK_VERSION (2 ,50 ,0 )/*
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 02/41] glib-compat: add g_spawn_async_with_fds() fallback
Marc-André Lureau, le mer. 14 nov. 2018 16:36:04 +0400, a ecrit:
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>
include/glib-compat.h maintainers, may I keep this in my slirp tree, to be pushed to master when appropriate?
Samuel
Quoted 74 lines
--- include/glib-compat.h | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)include/glib-compat.h +56
-0@@ -83,6 +83,62 @@ static inline gboolean g_strv_contains_qemu(const gchar *const *strv, }#define g_strv_contains (a, b) g_strv_contains_qemu(a, b) +#if !GLIB_CHECK_VERSION (2 ,58 ,0 ) +typedef struct QemuGSpawnFds { +GSpawnChildSetupFunc child_setup; +gpointer user_data; +gint stdin_fd; +gint stdout_fd; +gint stderr_fd; +}QemuGSpawnFds ; + +static inline void +qemu_gspawn_fds_setup (gpointer user_data) +{ +QemuGSpawnFds *q = (QemuGSpawnFds *)user_data; + +dup2 (q->stdin_fd,0 ); +dup2 (q->stdout_fd,1 ); +dup2 (q->stderr_fd,2 ); + q->child_setup (q->user_data); +} +#endif + +static inline gboolean +g_spawn_async_with_fds_qemu (const gchar *working_directory, +gchar **argv, +gchar **envp, +GSpawnFlags flags, +GSpawnChildSetupFunc child_setup, +gpointer user_data, +GPid *child_pid, +gint stdin_fd, +gint stdout_fd, +gint stderr_fd, +GError **error) +{ +#if GLIB_CHECK_VERSION (2 ,58 ,0 ) +return g_spawn_async_with_fds (working_directory, argv, envp, flags, + child_setup, user_data, + child_pid, stdin_fd, stdout_fd, stderr_fd, + error); +#else +QemuGSpawnFds setup = { + .child_setup = child_setup, + .user_data = user_data, + .stdin_fd = stdin_fd, + .stdout_fd = stdout_fd, + .stderr_fd = stderr_fd, + }; + +return g_spawn_async (working_directory, argv, envp, flags, + qemu_gspawn_fds_setup, &setup, + child_pid, error); +#endif +} + +#define g_spawn_async_with_fds (wd, argv, env, f, c, d, p, ifd, ofd, efd, err) \ + g_spawn_async_with_fds_qemu(wd, argv, env, f, c, d, p, ifd, ofd, efd, err)#if defined(_WIN32) && !GLIB_CHECK_VERSION (2 ,50 ,0 )/* Signature · 1 line
2.19.1.708.g4ede3d42df
Signature · 4 lines
Samuel bien sûr que ça convient mieux à tout le monde enfin, dans la mesure où tout le monde c'est comme moi -+- le consensus, c'est facile -+-
Re: [Qemu-devel] [PATCH for-3.2 02/41] glib-compat: add g_spawn_async_with_fds() fallback
Quoted 7 lines · Samuel Thibault
Marc-André Lureau, le mer. 14 nov. 2018 16:36:04 +0400, a ecrit:
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Samuel Thibault <[email protected]>
include/glib-compat.hmaintainers, may I keep this in my slirp tree, to be pushed to master when appropriate?
$ scripts/get_maintainer.pl -f include/glib-compat.h get_maintainer.pl: No maintainers found [...]
... so I'd say yes, please just go ahead and queue this :-)
Thomas
Quoted 75 lines
Quoted 74 lines
--- include/glib-compat.h | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)include/glib-compat.h +56
-0@@ -83,6 +83,62 @@ static inline gboolean g_strv_contains_qemu(const gchar *const *strv, }#define g_strv_contains (a, b) g_strv_contains_qemu(a, b) +#if !GLIB_CHECK_VERSION (2 ,58 ,0 ) +typedef struct QemuGSpawnFds { +GSpawnChildSetupFunc child_setup; +gpointer user_data; +gint stdin_fd; +gint stdout_fd; +gint stderr_fd; +}QemuGSpawnFds ; + +static inline void +qemu_gspawn_fds_setup (gpointer user_data) +{ +QemuGSpawnFds *q = (QemuGSpawnFds *)user_data; + +dup2 (q->stdin_fd,0 ); +dup2 (q->stdout_fd,1 ); +dup2 (q->stderr_fd,2 ); + q->child_setup (q->user_data); +} +#endif + +static inline gboolean +g_spawn_async_with_fds_qemu (const gchar *working_directory, +gchar **argv, +gchar **envp, +GSpawnFlags flags, +GSpawnChildSetupFunc child_setup, +gpointer user_data, +GPid *child_pid, +gint stdin_fd, +gint stdout_fd, +gint stderr_fd, +GError **error) +{ +#if GLIB_CHECK_VERSION (2 ,58 ,0 ) +return g_spawn_async_with_fds (working_directory, argv, envp, flags, + child_setup, user_data, + child_pid, stdin_fd, stdout_fd, stderr_fd, + error); +#else +QemuGSpawnFds setup = { + .child_setup = child_setup, + .user_data = user_data, + .stdin_fd = stdin_fd, + .stdout_fd = stdout_fd, + .stderr_fd = stderr_fd, + }; + +return g_spawn_async (working_directory, argv, envp, flags, + qemu_gspawn_fds_setup, &setup, + child_pid, error); +#endif +} + +#define g_spawn_async_with_fds (wd, argv, env, f, c, d, p, ifd, ofd, efd, err) \ + g_spawn_async_with_fds_qemu(wd, argv, env, f, c, d, p, ifd, ofd, efd, err)#if defined(_WIN32) && !GLIB_CHECK_VERSION (2 ,50 ,0 )/* Signature · 1 line
2.19.1.708.g4ede3d42df
PATCH 3/41 slirp: simplify fork_exec()
In reply to Marc-André LureauUse g_spawn_async_with_fds() to setup the child.
GSpawn handles reaping the child, and closing parent file descriptors.
--- slirp/misc.c | 75 +++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 39 deletions(-)
slirp/misc.c +36 -39
@@ -129,56 +129,53 @@ err:return -1 ; } +static void +fork_exec_child_setup (gpointer data) +{ +setsid (); +} +int fork_exec (struct socket *so,const char *ex) { -char **argv; -int opt, c, sp[2 ]; -pid_t pid; +GError *err =NULL ; +char **argv; +int opt, sp[2 ]; -DEBUG_CALL ("fork_exec" ); -DEBUG_ARG ("so = %p" , so); -DEBUG_ARG ("ex = %p" , ex); +DEBUG_CALL ("fork_exec" ); +DEBUG_ARG ("so = %p" , so); +DEBUG_ARG ("ex = %p" , ex);if (slirp_socketpair_with_oob (sp) <0 ) {return 0 ; } - pid =fork (); -switch (pid) { -case -1 : -error_report ("Error: fork failed: %s" ,strerror (errno)); -closesocket (sp[0 ]); -closesocket (sp[1 ]); -return 0 ; - -case 0 : -setsid (); -dup2 (sp[1 ],0 ); -dup2 (sp[1 ],1 ); -dup2 (sp[1 ],2 ); -for (c =getdtablesize () -1 ; c >=3 ; c--) -close (c); + argv =g_strsplit (ex," " ,-1 ); +g_spawn_async_with_fds (NULL /* cwd */ , + argv, +NULL /* env */ , +G_SPAWN_SEARCH_PATH , + fork_exec_child_setup,NULL /* data */ , +NULL /* child_pid */ , + sp[1 ], sp[1 ], sp[1 ], + &err); +g_strfreev (argv); - argv =g_strsplit (ex," " ,-1 ); -execvp (argv[0 ], (char **)argv); - -/* Ooops, failed, let's tell the user why */ -fprintf (stderr,"Error: execvp of %s failed: %s\n" , - argv[0 ],strerror (errno)); -close (0 );close (1 );close (2 );/* XXX */ -exit (1 ); +if (err) { +error_report ("%s" , err->message); +g_error_free (err); +closesocket (sp[0 ]); +closesocket (sp[1 ]); +return 0 ; + } -default : - so->s = sp[0 ]; -closesocket (sp[1 ]); -qemu_add_child_watch (pid); -socket_set_fast_reuse (so->s); - opt =1 ; -qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); -qemu_set_nonblock (so->s); -return 1 ; - } + so->s = sp[0 ]; +closesocket (sp[1 ]); +socket_set_fast_reuse (so->s); + opt =1 ; +qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); +qemu_set_nonblock (so->s); +return 1 ; }#endif
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 03/41] slirp: simplify fork_exec()
Quoted 3 lines · Marc-André Lureau
Use
g_spawn_async_with_fds()to setup the child.GSpawn handles reaping the child, and closing parent file descriptors.
The g_spawn* family of APIs is portable to Win32, which the current fork/exec code in slirp is not.
So I'm curious if this conversion is sufficient to make this part of slirp work on Win32, or if further portability problems remain. If it does work on Win32, then you can also delete the stub fork_exec() impl the code currently has.
Quoted 107 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/misc.c | 75 +++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 39 deletions(-)slirp/misc.c +36
-39@@ -129,56 +129,53 @@ err:return -1 ; } +static void +fork_exec_child_setup (gpointer data) +{ +setsid (); +} +int fork_exec (struct socket *so,const char *ex) { -char **argv; -int opt, c, sp[2 ]; -pid_t pid; +GError *err =NULL ; +char **argv; +int opt, sp[2 ]; -DEBUG_CALL ("fork_exec" ); -DEBUG_ARG ("so = %p" , so); -DEBUG_ARG ("ex = %p" , ex); +DEBUG_CALL ("fork_exec" ); +DEBUG_ARG ("so = %p" , so); +DEBUG_ARG ("ex = %p" , ex);if (slirp_socketpair_with_oob (sp) <0 ) {return 0 ; } - pid =fork (); -switch (pid) { -case -1 : -error_report ("Error: fork failed: %s" ,strerror (errno)); -closesocket (sp[0 ]); -closesocket (sp[1 ]); -return 0 ; - -case 0 : -setsid (); -dup2 (sp[1 ],0 ); -dup2 (sp[1 ],1 ); -dup2 (sp[1 ],2 ); -for (c =getdtablesize () -1 ; c >=3 ; c--) -close (c); + argv =g_strsplit (ex," " ,-1 ); +g_spawn_async_with_fds (NULL /* cwd */ , + argv, +NULL /* env */ , +G_SPAWN_SEARCH_PATH , + fork_exec_child_setup,NULL /* data */ , +NULL /* child_pid */ , + sp[1 ], sp[1 ], sp[1 ], + &err); +g_strfreev (argv); - argv =g_strsplit (ex," " ,-1 ); -execvp (argv[0 ], (char **)argv); - -/* Ooops, failed, let's tell the user why */ -fprintf (stderr,"Error: execvp of %s failed: %s\n" , - argv[0 ],strerror (errno)); -close (0 );close (1 );close (2 );/* XXX */ -exit (1 ); +if (err) { +error_report ("%s" , err->message); +g_error_free (err); +closesocket (sp[0 ]); +closesocket (sp[1 ]); +return 0 ; + } -default : - so->s = sp[0 ]; -closesocket (sp[1 ]); -qemu_add_child_watch (pid); -socket_set_fast_reuse (so->s); - opt =1 ; -qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); -qemu_set_nonblock (so->s); -return 1 ; - } + so->s = sp[0 ]; +closesocket (sp[1 ]); +socket_set_fast_reuse (so->s); + opt =1 ; +qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); +qemu_set_nonblock (so->s); +return 1 ; }#endif Signature · 1 line
2.19.1.708.g4ede3d42df
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [Qemu-devel] [PATCH for-3.2 03/41] slirp: simplify fork_exec()
Hello,
Daniel P. Berrangé, le mer. 14 nov. 2018 14:22:34 +0000, a ecrit:
Quoted 5 lines · Marc-André Lureau
Quoted 3 lines
Use
g_spawn_async_with_fds()to setup the child.GSpawn handles reaping the child, and closing parent file descriptors.
Quoted 7 lines
The g_spawn* family of APIs is portable to Win32, which the current fork/exec code in slirp is not.
So I'm curious if this conversion is sufficient to make this part of slirp work on Win32, or if further portability problems remain. If it does work on Win32, then you can also delete the stub
fork_exec()impl the code currently has.
Mmm, I don't think any portability issue remains. SO_OOBINLINE is used in other places, the rest is portable. There is the setsid() call which may just not make sense on Windows, but we could just disable it there.
I have pushed to
https://people.debian.org/~sthibault/qemu.git slirp-2-win
what it could look like. I don't have a windows box off hand, could somebody try it to confirm that it builds?
Samuel
Re: [Qemu-devel] [PATCH for-3.2 03/41] slirp: simplify fork_exec()
Quoted 10 lines · Samuel Thibault
Mmm, I don't think any portability issue remains.
SO_OOBINLINEis used in other places, the rest is portable. There is thesetsid()call which may just not make sense on Windows, but we could just disable it there.I have pushed to
https://people.debian.org/~sthibault/qemu.git slirp-2-win
what it could look like. I don't have a windows box off hand, could somebody try it to confirm that it builds?
You could try 'make docker-test-mingw@fedora' to at least try building for a Windows environment (but that doesn't say much about testing the resulting binary).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 03/41] slirp: simplify fork_exec()
In reply to Marc-André LureauMarc-André Lureau, le mer. 14 nov. 2018 16:36:05 +0400, a ecrit:
Quoted 5 lines
Use
g_spawn_async_with_fds()to setup the child.GSpawn handles reaping the child, and closing parent file descriptors.
Signed-off-by Marc-André Lureau <[email protected]>
Applied to my slirp-2 tree, thanks!
Samuel
PATCH 4/41 slirp: remove unused M_TRAILINGSPACE
In reply to Marc-André Lureau--- slirp/mbuf.h | 1 - 1 file changed, 1 deletion(-)
slirp/mbuf.h +0 -1
@@ -72,7 +72,6 @@* How much free room there is */ #define M_FREEROOM (m) (M_ROOM(m) - (m)->m_len) -#define M_TRAILINGSPACE M_FREEROOMstruct mbuf {/* XXX should union some of these! */
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 04/41] slirp: remove unused M_TRAILINGSPACE
Quoted 4 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/mbuf.h | 1 - 1 file changed, 1 deletion(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 04/41] slirp: remove unused M_TRAILINGSPACE
Daniel P. Berrangé, le mer. 14 nov. 2018 13:32:57 +0000, a ecrit:
Quoted 7 lines · Marc-André Lureau
Quoted 4 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/mbuf.h | 1 - 1 file changed, 1 deletion(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 5/41 slirp: use a callback structure to interface with qemu
In reply to Marc-André LureauThis will bring slirp a bit forward to the state of an independent project.
This could be squashed with earlier submitted "slirp: associate slirp_output".
--- slirp/libslirp.h | 7 +++++-- slirp/slirp.h | 2 +- net/slirp.c | 6 +++++- slirp/ncsi.c | 2 +- slirp/slirp.c | 10 +++++----- 5 files changed, 17 insertions(+), 10 deletions(-)
slirp/libslirp.h +5 -2
@@ -5,7 +5,10 @@typedef struct Slirp Slirp ; -typedef void (*slirp_output )(void *opaque,const uint8_t *pkt,int pkt_len); +typedef struct SlirpCb { +void (*output)(void *opaque,const uint8_t *pkt,int pkt_len); +}SlirpCb ; + Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vnetmask, struct in_addr vhost,
@@ -17,7 +20,7 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vdhcp_start, struct in_addr vnameserver, struct in6_addr vnameserver6, const char **vdnssearch, const char *vdomainname, - slirp_output output, + const SlirpCb *callbacks, void *opaque);void slirp_cleanup (Slirp *slirp);
slirp/slirp.h +1 -1
@@ -220,7 +220,7 @@ struct Slirp {GRand *grand;QEMUTimer *ra_timer; -slirp_output output; +const SlirpCb *cb;void *opaque; };
net/slirp.c +5 -1
@@ -140,6 +140,10 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; +static SlirpCb slirp_cb = { + .output = net_slirp_output, +}; + static int net_slirp_init(NetClientState *peer, const char *model, const char *name, int restricted, bool ipv4, const char *vnetwork, const char *vhost,
@@ -379,7 +383,7 @@ static int net_slirp_init(NetClientState *peer, const char *model, vhostname, tftp_server_name, tftp_export, bootfile, dhcp, dns, ip6_dns, dnssearch, vdomainname, - net_slirp_output, s); + &slirp_cb, s);QTAILQ_INSERT_TAIL (&slirp_stacks, s, entry);for (config = slirp_configs; config; config = config->next) {
slirp/ncsi.c +1 -1
@@ -163,5 +163,5 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) *pchecksum =htonl (checksum); ncsi_rsp_len +=4 ; - slirp->output (slirp->opaque, ncsi_reply,ETH_HLEN + ncsi_rsp_len); + slirp->cb->output (slirp->opaque, ncsi_reply,ETH_HLEN + ncsi_rsp_len); }
slirp/slirp.c +5 -5
@@ -288,14 +288,14 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vdhcp_start, struct in_addr vnameserver, struct in6_addr vnameserver6, const char **vdnssearch, const char *vdomainname, - slirp_output output, + const SlirpCb *callbacks, void *opaque) { Slirp *slirp = g_malloc0(sizeof(Slirp));slirp_init_once (); - slirp->output = output; + slirp->cb = callbacks; slirp->grand =g_rand_new (); slirp->restricted = restricted;
@@ -843,7 +843,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) rah->ar_sip = ah->ar_tip;memcpy (rah->ar_tha, ah->ar_sha,ETH_ALEN ); rah->ar_tip = ah->ar_sip; - slirp->output (slirp->opaque, arp_reply,sizeof (arp_reply)); + slirp->cb->output (slirp->opaque, arp_reply,sizeof (arp_reply)); }break ;case ARPOP_REPLY :
@@ -943,7 +943,7 @@ static int if_encap4(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh,/* target IP */ rah->ar_tip = iph->ip_dst.s_addr; slirp->client_ipaddr = iph->ip_dst; - slirp->output (slirp->opaque, arp_req,sizeof (arp_req)); + slirp->cb->output (slirp->opaque, arp_req,sizeof (arp_req)); ifm->resolution_requested = true;/* Expire request and drop outgoing packet after 1 second */
@@ -1029,7 +1029,7 @@ int if_encap(Slirp *slirp, struct mbuf *ifm) eh->h_dest[0 ], eh->h_dest[1 ], eh->h_dest[2 ], eh->h_dest[3], eh->h_dest[4], eh->h_dest[5]));memcpy (buf +sizeof (struct ethhdr ), ifm->m_data, ifm->m_len); - slirp->output (slirp->opaque, buf, ifm->m_len +ETH_HLEN ); + slirp->cb->output (slirp->opaque, buf, ifm->m_len +ETH_HLEN );return 1 ; }
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 05/41] slirp: use a callback structure to interface with qemu
Quoted 58 lines · Marc-André Lureau
This will bring slirp a bit forward to the state of an independent project.
This could be squashed with earlier submitted "slirp: associate
slirp_output".Signed-off-by Marc-André Lureau <[email protected]>--- slirp/libslirp.h | 7 +++++-- slirp/slirp.h | 2 +- net/slirp.c | 6 +++++- slirp/ncsi.c | 2 +- slirp/slirp.c | 10 +++++----- 5 files changed, 17 insertions(+), 10 deletions(-)slirp/libslirp.h +5
-2@@ -5,7 +5,10 @@typedef struct Slirp Slirp ; -typedef void (*slirp_output )(void *opaque,const uint8_t *pkt,int pkt_len); +typedef struct SlirpCb { +void (*output)(void *opaque,const uint8_t *pkt,int pkt_len); +}SlirpCb ; + Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vnetmask, struct in_addr vhost,@@ -17,7 +20,7 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vdhcp_start, struct in_addr vnameserver, struct in6_addr vnameserver6, const char **vdnssearch, const char *vdomainname, - slirp_output output, + const SlirpCb *callbacks, void *opaque);void slirp_cleanup (Slirp *slirp);slirp/slirp.h +1
-1@@ -220,7 +220,7 @@ struct Slirp {GRand *grand;QEMUTimer *ra_timer; -slirp_output output; +const SlirpCb *cb;void *opaque; };net/slirp.c +0
-0
net/slirp.c static NetClientInfo net_slirp_info = { · line 143
Quoted 4 lines
net/slirp.c +1
-0@@ -140,6 +140,10 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; +static SlirpCb slirp_cb = {
const ^
With the const qualifier:
Quoted 75 lines
net/slirp.c +4
-1+ .output = net_slirp_output, +}; + static int net_slirp_init(NetClientState *peer, const char *model, const char *name, int restricted, bool ipv4, const char *vnetwork, const char *vhost,@@ -379,7 +383,7 @@ static int net_slirp_init(NetClientState *peer, const char *model, vhostname, tftp_server_name, tftp_export, bootfile, dhcp, dns, ip6_dns, dnssearch, vdomainname, - net_slirp_output, s); + &slirp_cb, s);QTAILQ_INSERT_TAIL (&slirp_stacks, s, entry);for (config = slirp_configs; config; config = config->next) {slirp/ncsi.c +1
-1@@ -163,5 +163,5 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) *pchecksum =htonl (checksum); ncsi_rsp_len +=4 ; - slirp->output (slirp->opaque, ncsi_reply,ETH_HLEN + ncsi_rsp_len); + slirp->cb->output (slirp->opaque, ncsi_reply,ETH_HLEN + ncsi_rsp_len); }slirp/slirp.c +5
-5@@ -288,14 +288,14 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vdhcp_start, struct in_addr vnameserver, struct in6_addr vnameserver6, const char **vdnssearch, const char *vdomainname, - slirp_output output, + const SlirpCb *callbacks, void *opaque) { Slirp *slirp = g_malloc0(sizeof(Slirp));slirp_init_once (); - slirp->output = output; + slirp->cb = callbacks; slirp->grand =g_rand_new (); slirp->restricted = restricted;@@ -843,7 +843,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) rah->ar_sip = ah->ar_tip;memcpy (rah->ar_tha, ah->ar_sha,ETH_ALEN ); rah->ar_tip = ah->ar_sip; - slirp->output (slirp->opaque, arp_reply,sizeof (arp_reply)); + slirp->cb->output (slirp->opaque, arp_reply,sizeof (arp_reply)); }break ;case ARPOP_REPLY :@@ -943,7 +943,7 @@ static int if_encap4(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh,/* target IP */ rah->ar_tip = iph->ip_dst.s_addr; slirp->client_ipaddr = iph->ip_dst; - slirp->output (slirp->opaque, arp_req,sizeof (arp_req)); + slirp->cb->output (slirp->opaque, arp_req,sizeof (arp_req)); ifm->resolution_requested = true;/* Expire request and drop outgoing packet after 1 second */ @@ -1029,7 +1029,7 @@ int if_encap(Slirp *slirp, struct mbuf *ifm) eh->h_dest[0 ], eh->h_dest[1 ], eh->h_dest[2 ], eh->h_dest[3], eh->h_dest[4], eh->h_dest[5]));memcpy (buf +sizeof (struct ethhdr ), ifm->m_data, ifm->m_len); - slirp->output (slirp->opaque, buf, ifm->m_len +ETH_HLEN ); + slirp->cb->output (slirp->opaque, buf, ifm->m_len +ETH_HLEN );return 1 ; }
Re: [Qemu-devel] [PATCH for-3.2 05/41] slirp: use a callback structure to interface with qemu
In reply to Marc-André Lureauslirp/libslirp.h line 10
Quoted 4 lines · Marc-André Lureau
slirp/libslirp.h +3
-1-typedef void (*slirp_output )(void *opaque,const uint8_t *pkt,int pkt_len); +typedef struct SlirpCb { +void (*output)(void *opaque,const uint8_t *pkt,int pkt_len); +}SlirpCb ;
Please include doc comments for each SlirpCb callback introduced by this series. Otherwise it will be hard for other people to use libslirp.
Stefan
Re: [Qemu-devel] [PATCH for-3.2 05/41] slirp: use a callback structure to interface with qemu
Philippe Mathieu-Daudé, le mer. 14 nov. 2018 14:10:15 +0100, a ecrit:
Quoted 2 lines
With the const qualifier:
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Stefan Hajnoczi, le mer. 14 nov. 2018 14:30:14 +0000, a ecrit:
Quoted 8 lines · Marc-André Lureau
slirp/libslirp.h line 10
Quoted 4 lines
slirp/libslirp.h +3
-1-typedef void (*slirp_output )(void *opaque,const uint8_t *pkt,int pkt_len); +typedef struct SlirpCb { +void (*output)(void *opaque,const uint8_t *pkt,int pkt_len); +}SlirpCb ;Please include doc comments for each SlirpCb callback introduced by this series. Otherwise it will be hard for other people to use libslirp.
I have added both and pushed to my tree, thanks!
Samuel
PATCH 6/41 slirp: add a callback for qemu_chr_fe_write_all()
In reply to Marc-André LureauReplace strong dependency on QEMU.
--- slirp/libslirp.h | 1 + net/slirp.c | 6 ++++++ slirp/slirp.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-)
slirp/libslirp.h +1 -0
@@ -7,6 +7,7 @@ typedef struct Slirp Slirp;typedef struct SlirpCb {void (*output)(void *opaque,const uint8_t *pkt,int pkt_len); +int (*chr_write_all)(void *chr,const void *buf,size_t len); }SlirpCb ;
net/slirp.c +6 -0
@@ -140,8 +140,14 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; +static int net_slirp_chr_write_all (void *chr,const void *buf,size_t len) +{ +return qemu_chr_fe_write_all (chr, buf, len); +} +static SlirpCb slirp_cb = { .output = net_slirp_output, + .chr_write_all = net_slirp_chr_write_all, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/slirp.c +1 -1
@@ -1099,7 +1099,7 @@ ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags)if (so->s ==-1 && so->chardev) {/* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ -qemu_chr_fe_write_all (so->chardev, buf, len); + so->slirp->cb->chr_write_all (so->chardev, buf, len);return len; }
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 06/41] slirp: add a callback for qemu_chr_fe_write_all()
Quoted 48 lines · Marc-André Lureau
Replace strong dependency on QEMU.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/libslirp.h | 1 + net/slirp.c | 6 ++++++ slirp/slirp.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-)slirp/libslirp.h +1
-0@@ -7,6 +7,7 @@ typedef struct Slirp Slirp;typedef struct SlirpCb {void (*output)(void *opaque,const uint8_t *pkt,int pkt_len); +int (*chr_write_all)(void *chr,const void *buf,size_t len); }SlirpCb ;net/slirp.c +6
-0@@ -140,8 +140,14 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; +static int net_slirp_chr_write_all (void *chr,const void *buf,size_t len) +{ +return qemu_chr_fe_write_all (chr, buf, len); +} +static SlirpCb slirp_cb = { .output = net_slirp_output, + .chr_write_all = net_slirp_chr_write_all, };static int net_slirp_init(NetClientState *peer, const char *model,
slirp/slirp.c +0
-0
slirp/slirp.c ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags) · line 1105
Quoted 8 lines
slirp/slirp.c +1
-1@@ -1099,7 +1099,7 @@ ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags)if (so->s ==-1 && so->chardev) {/* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ -qemu_chr_fe_write_all (so->chardev, buf, len); + so->slirp->cb->chr_write_all (so->chardev, buf, len);return len; }
Rather than this, I would split out add_exec's do_pty==3 case to a new function add_guestfwd, and pass the function pointer to add_guestfwd. Then:
1) add_guestfwd can store the function pointer in struct ex_list,
2) tcp_ctl can store the ex_ptr in struct socket directly, instead of storing ex_ptr->ex_exec (that is the chardev field becomes "struct ex_list *guestfwd" or something)
3) slirp_send can use so->chardev to retrieve both the function pointer and the void* (renaming it to so->exec maybe)
Paolo
Re: [Qemu-devel] [PATCH for-3.2 06/41] slirp: add a callback for qemu_chr_fe_write_all()
Hi
Quoted 62 lines · Paolo Bonzini
Quoted 48 lines · Marc-André Lureau
Replace strong dependency on QEMU.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/libslirp.h | 1 + net/slirp.c | 6 ++++++ slirp/slirp.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-)slirp/libslirp.h +1
-0@@ -7,6 +7,7 @@ typedef struct Slirp Slirp;typedef struct SlirpCb {void (*output)(void *opaque,const uint8_t *pkt,int pkt_len); +int (*chr_write_all)(void *chr,const void *buf,size_t len); }SlirpCb ;net/slirp.c +6
-0@@ -140,8 +140,14 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; +static int net_slirp_chr_write_all (void *chr,const void *buf,size_t len) +{ +return qemu_chr_fe_write_all (chr, buf, len); +} +static SlirpCb slirp_cb = { .output = net_slirp_output, + .chr_write_all = net_slirp_chr_write_all, };static int net_slirp_init(NetClientState *peer, const char *model,
slirp/slirp.c +0
-0slirp/slirp.c ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags) · line 1105
Quoted 8 lines
slirp/slirp.c +1
-1@@ -1099,7 +1099,7 @@ ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags)if (so->s ==-1 && so->chardev) {/* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ -qemu_chr_fe_write_all (so->chardev, buf, len); + so->slirp->cb->chr_write_all (so->chardev, buf, len);return len; }Rather than this, I would split out add_exec's do_pty==3 case to a new function
add_guestfwd, and pass the function pointer toadd_guestfwd. Then:
Quoted 8 lines
1)
add_guestfwdcan store the function pointer in structex_list,2)
tcp_ctlcan store theex_ptrin struct socket directly, instead of storingex_ptr->ex_exec(that is the chardev field becomes "structex_list*guestfwd" or something)3)
slirp_sendcan useso->chardevto retrieve both the function pointer and the void* (renaming it toso->execmaybe)
Ok, please check the upcoming series, patch "slirp: generalize guestfwd with a callback based approach". I think it is what you propose here.
thanks
PATCH 7/41 slirp: add clock_get_ns() callback
In reply to Marc-André Lureau--- slirp/libslirp.h | 6 ++++++ net/slirp.c | 19 +++++++++++++++++++ slirp/if.c | 2 +- slirp/ip6_icmp.c | 6 ++++-- slirp/slirp.c | 11 ++++++----- 5 files changed, 36 insertions(+), 8 deletions(-)
slirp/libslirp.h +6 -0
@@ -5,9 +5,15 @@typedef struct Slirp Slirp ; +typedef enum SlirpClockType { +SLIRP_CLOCK_VIRTUAL , +SLIRP_CLOCK_REALTIME , +}SlirpClockType ; +typedef struct SlirpCb {void (*output)(void *opaque,const uint8_t *pkt,int pkt_len);int (*chr_write_all)(void *chr,const void *buf,size_t len); +int64_t (*clock_get_ns)(SlirpClockType type); }SlirpCb ;
net/slirp.c +19 -0
@@ -145,9 +145,28 @@ static int net_slirp_chr_write_all(void *chr, const void *buf, size_t len)return qemu_chr_fe_write_all (chr, buf, len); } +static QEMUClockType slirp_clock_to_qemu (SlirpClockType type) +{ +switch (type) { +case SLIRP_CLOCK_VIRTUAL : +return QEMU_CLOCK_VIRTUAL ; +case SLIRP_CLOCK_REALTIME : +return QEMU_CLOCK_REALTIME ; + } + +g_warn_if_reached (); +return QEMU_CLOCK_REALTIME ; +} + +static int64_t net_slirp_clock_get_ns (SlirpClockType type) +{ +return qemu_clock_get_ns (slirp_clock_to_qemu (type)); +} +static SlirpCb slirp_cb = { .output = net_slirp_output, .chr_write_all = net_slirp_chr_write_all, + .clock_get_ns = net_slirp_clock_get_ns, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/if.c +1 -1
@@ -150,7 +150,7 @@ diddit:*/ void if_start (Slirp *slirp) { -uint64_t now =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); +uint64_t now = slirp->cb->clock_get_ns (SLIRP_CLOCK_REALTIME );bool from_batchq = false;struct mbuf *ifm, *ifm_next, *ifqt;
slirp/ip6_icmp.c +4 -2
@@ -17,7 +17,8 @@ static void ra_timer_handler(void *opaque) {Slirp *slirp = opaque;timer_mod (slirp->ra_timer, -qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL ) + NDP_Interval); + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval);ndp_send_ra (slirp); }
@@ -31,7 +32,8 @@ void icmp6_init(Slirp *slirp)SCALE_MS ,QEMU_TIMER_ATTR_EXTERNAL , ra_timer_handler, slirp);timer_mod (slirp->ra_timer, -qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL ) + NDP_Interval); + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval); }void icmp6_cleanup (Slirp *slirp)
slirp/slirp.c +6 -5
@@ -571,15 +571,15 @@ void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout)void slirp_pollfds_poll (GArray *pollfds,int select_error) { -Slirp *slirp; +Slirp *slirp =QTAILQ_FIRST (&slirp_instances);struct socket *so, *so_next;int ret; -if (QTAILQ_EMPTY (&slirp_instances)) { +if (!slirp) {return ; } - curtime =qemu_clock_get_ms (QEMU_CLOCK_REALTIME ); + curtime = slirp->cb->clock_get_ns (SLIRP_CLOCK_REALTIME ) /SCALE_MS ; QTAILQ_FOREACH(slirp, &slirp_instances, entry) {/*
@@ -947,7 +947,8 @@ static int if_encap4(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh, ifm->resolution_requested = true;/* Expire request and drop outgoing packet after 1 second */ - ifm->expiration_date =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ) +1000000000ULL ; + ifm->expiration_date = slirp->cb->clock_get_ns (SLIRP_CLOCK_REALTIME ) + +1000000000ULL ; }return 0 ; }else {
@@ -974,7 +975,7 @@ static int if_encap6(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh,ndp_send_ns (slirp, ip6h->ip_dst); ifm->resolution_requested = true; ifm->expiration_date = -qemu_clock_get_ns (QEMU_CLOCK_REALTIME ) +1000000000ULL ; + slirp->cb->clock_get_ns (SLIRP_CLOCK_REALTIME ) +1000000000ULL ; }return 0 ; }else {
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 07/41] slirp: add clock_get_ns() callback
Quoted 14 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/libslirp.h | 6 ++++++ net/slirp.c | 19 +++++++++++++++++++ slirp/if.c | 2 +- slirp/ip6_icmp.c | 6 ++++-- slirp/slirp.c | 11 ++++++----- 5 files changed, 36 insertions(+), 8 deletions(-)slirp/libslirp.h +0
-0
slirp/libslirp.h line 10
Quoted 6 lines
slirp/libslirp.h +3
-0@@ -5,9 +5,15 @@typedef struct Slirp Slirp ; +typedef enum SlirpClockType { + SLIRP_CLOCK_VIRTUAL, + SLIRP_CLOCK_REALTIME,
The more I look at this, the more I think that SLIRP_CLOCK_REALTIME is wrong and it should also be using SLIRP_CLOCK_VIRTUAL. It's used to put a cap on the amount of time the guest has to reply to an ARP request, and of course the guest cannot process it if it's paused. So this can be simpler, because SlirpClockType can disappear completely.
Paolo
Quoted 122 lines
slirp/libslirp.h +3
-0+} SlirpClockType; +typedef struct SlirpCb {void (*output)(void *opaque,const uint8_t *pkt,int pkt_len);int (*chr_write_all)(void *chr,const void *buf,size_t len); +int64_t (*clock_get_ns)(SlirpClockType type); }SlirpCb ;net/slirp.c +19
-0@@ -145,9 +145,28 @@ static int net_slirp_chr_write_all(void *chr, const void *buf, size_t len)return qemu_chr_fe_write_all (chr, buf, len); } +static QEMUClockType slirp_clock_to_qemu (SlirpClockType type) +{ +switch (type) { +case SLIRP_CLOCK_VIRTUAL : +return QEMU_CLOCK_VIRTUAL ; +case SLIRP_CLOCK_REALTIME : +return QEMU_CLOCK_REALTIME ; + } + +g_warn_if_reached (); +return QEMU_CLOCK_REALTIME ; +} + +static int64_t net_slirp_clock_get_ns (SlirpClockType type) +{ +return qemu_clock_get_ns (slirp_clock_to_qemu (type)); +} +static SlirpCb slirp_cb = { .output = net_slirp_output, .chr_write_all = net_slirp_chr_write_all, + .clock_get_ns = net_slirp_clock_get_ns, }; static int net_slirp_init(NetClientState *peer, const char *model,slirp/if.c +1
-1@@ -150,7 +150,7 @@ diddit:*/ void if_start (Slirp *slirp) { -uint64_t now =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); +uint64_t now = slirp->cb->clock_get_ns (SLIRP_CLOCK_REALTIME );bool from_batchq = false;struct mbuf *ifm, *ifm_next, *ifqt;slirp/ip6_icmp.c +4
-2@@ -17,7 +17,8 @@ static void ra_timer_handler(void *opaque) {Slirp *slirp = opaque;timer_mod (slirp->ra_timer, -qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL ) + NDP_Interval); + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval);ndp_send_ra (slirp); }@@ -31,7 +32,8 @@ void icmp6_init(Slirp *slirp)SCALE_MS ,QEMU_TIMER_ATTR_EXTERNAL , ra_timer_handler, slirp);timer_mod (slirp->ra_timer, -qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL ) + NDP_Interval); + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval); }void icmp6_cleanup (Slirp *slirp)slirp/slirp.c +6
-5@@ -571,15 +571,15 @@ void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout)void slirp_pollfds_poll (GArray *pollfds,int select_error) { -Slirp *slirp; +Slirp *slirp =QTAILQ_FIRST (&slirp_instances);struct socket *so, *so_next;int ret; -if (QTAILQ_EMPTY (&slirp_instances)) { +if (!slirp) {return ; } - curtime =qemu_clock_get_ms (QEMU_CLOCK_REALTIME ); + curtime = slirp->cb->clock_get_ns (SLIRP_CLOCK_REALTIME ) /SCALE_MS ; QTAILQ_FOREACH(slirp, &slirp_instances, entry) {/* @@ -947,7 +947,8 @@ static int if_encap4(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh, ifm->resolution_requested = true;/* Expire request and drop outgoing packet after 1 second */ - ifm->expiration_date =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ) +1000000000ULL ; + ifm->expiration_date = slirp->cb->clock_get_ns (SLIRP_CLOCK_REALTIME ) + +1000000000ULL ; }return 0 ; }else {@@ -974,7 +975,7 @@ static int if_encap6(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh,ndp_send_ns (slirp, ip6h->ip_dst); ifm->resolution_requested = true; ifm->expiration_date = -qemu_clock_get_ns (QEMU_CLOCK_REALTIME ) +1000000000ULL ; + slirp->cb->clock_get_ns (SLIRP_CLOCK_REALTIME ) +1000000000ULL ; }return 0 ; }else {
Re: [Qemu-devel] [PATCH for-3.2 07/41] slirp: add clock_get_ns() callback
Paolo Bonzini, le jeu. 15 nov. 2018 13:54:02 +0100, a ecrit:
Quoted 18 lines · Marc-André Lureau
Quoted 17 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/libslirp.h | 6 ++++++ net/slirp.c | 19 +++++++++++++++++++ slirp/if.c | 2 +- slirp/ip6_icmp.c | 6 ++++-- slirp/slirp.c | 11 ++++++----- 5 files changed, 36 insertions(+), 8 deletions(-)slirp/libslirp.h +0
-0@@ -5,9 +5,15 @@typedef struct Slirp Slirp ;
Quoted 9 lines
slirp/libslirp.h line 10
Quoted 3 lines
slirp/libslirp.h +3
-0+typedef enum SlirpClockType { + SLIRP_CLOCK_VIRTUAL, + SLIRP_CLOCK_REALTIME,The more I look at this, the more I think that
SLIRP_CLOCK_REALTIMEis wrong and it should also be usingSLIRP_CLOCK_VIRTUAL. It's used to put a cap on the amount of time the guest has to reply to an ARP request, and of course the guest cannot process it if it's paused. So this can be simpler, because SlirpClockType can disappear completely.
Mmm, I'd tend to agree indeed.
(it's also used for TCP timers, but the same reasoning applies)
We'd need to check that turning them to VIRTUAL does work fine.
Samuel
PATCH 8/41 slirp: add callbacks for timer
In reply to Marc-André Lureau--- slirp/libslirp.h | 6 ++++++ slirp/slirp.h | 2 +- net/slirp.c | 23 +++++++++++++++++++++++ slirp/ip6_icmp.c | 21 ++++++++++----------- 4 files changed, 40 insertions(+), 12 deletions(-)
slirp/libslirp.h +6 -0
@@ -10,10 +10,16 @@ typedef enum SlirpClockType {SLIRP_CLOCK_REALTIME , } SlirpClockType; +typedef void (*SlirpTimerCb )(void *opaque); +typedef struct SlirpCb {void (*output)(void *opaque,const uint8_t *pkt,int pkt_len);int (*chr_write_all)(void *chr,const void *buf,size_t len);int64_t (*clock_get_ns)(SlirpClockType type); +void *(*timer_new)(SlirpClockType type,int scale, +SlirpTimerCb cb,void *opaque); +void (*timer_free)(void *timer); +void (*timer_mod)(void *timer,int64_t expire_timer); }SlirpCb ;
slirp/slirp.h +1 -1
@@ -218,7 +218,7 @@ struct Slirp {NdpTable ndp_table;GRand *grand; -QEMUTimer *ra_timer; +void *ra_timer;const SlirpCb *cb;void *opaque;
net/slirp.c +23 -0
@@ -163,10 +163,33 @@ static int64_t net_slirp_clock_get_ns(SlirpClockType type)return qemu_clock_get_ns (slirp_clock_to_qemu (type)); } +static void *net_slirp_timer_new (SlirpClockType type, +int scale, +SlirpTimerCb cb,void *opaque) +{ +return timer_new_full (NULL ,slirp_clock_to_qemu (type), + scale,QEMU_TIMER_ATTR_EXTERNAL , + cb, opaque); +} + +static void net_slirp_timer_free (void *timer) +{ +timer_del (timer); +timer_free (timer); +} + +static void net_slirp_timer_mod (void *timer,int64_t expire_timer) +{ +timer_mod (timer, expire_timer); +} +static SlirpCb slirp_cb = { .output = net_slirp_output, .chr_write_all = net_slirp_chr_write_all, .clock_get_ns = net_slirp_clock_get_ns, + .timer_new = net_slirp_timer_new, + .timer_free = net_slirp_timer_free, + .timer_mod = net_slirp_timer_mod, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/ip6_icmp.c +10 -11
@@ -16,9 +16,10 @@static void ra_timer_handler (void *opaque) {Slirp *slirp = opaque; -timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + - NDP_Interval); + + slirp->cb->timer_mod (slirp->ra_timer, + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval);ndp_send_ra (slirp); }
@@ -28,12 +29,11 @@ void icmp6_init(Slirp *slirp)return ; } - slirp->ra_timer =timer_new_full (NULL ,QEMU_CLOCK_VIRTUAL , -SCALE_MS ,QEMU_TIMER_ATTR_EXTERNAL , - ra_timer_handler, slirp); -timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + - NDP_Interval); + slirp->ra_timer = slirp->cb->timer_new (SLIRP_CLOCK_VIRTUAL ,SCALE_MS , + ra_timer_handler, slirp); + slirp->cb->timer_mod (slirp->ra_timer, + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval); }void icmp6_cleanup (Slirp *slirp)
@@ -42,8 +42,7 @@ void icmp6_cleanup(Slirp *slirp)return ; } -timer_del (slirp->ra_timer); -timer_free (slirp->ra_timer); + slirp->cb->timer_free (slirp->ra_timer); } static void icmp6_send_echoreply(struct mbuf *m, Slirp *slirp, struct ip6 *ip,
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 08/41] slirp: add callbacks for timer
Quoted 14 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/libslirp.h | 6 ++++++ slirp/slirp.h | 2 +- net/slirp.c | 23 +++++++++++++++++++++++ slirp/ip6_icmp.c | 21 ++++++++++----------- 4 files changed, 40 insertions(+), 12 deletions(-)slirp/libslirp.h +0
-0@@ -10,10 +10,16 @@ typedef enum SlirpClockType { SLIRP_CLOCK_REALTIME,
slirp/libslirp.h typedef enum SlirpClockType { · line 20
Quoted 10 lines
slirp/libslirp.h +4
-0} SlirpClockType; +typedef void (*SlirpTimerCb )(void *opaque); + typedef struct SlirpCb { void (*output)(void *opaque, const uint8_t *pkt, int pkt_len); int (*chr_write_all)(void *chr, const void *buf, size_t len); int64_t (*clock_get_ns)(SlirpClockType type); + void *(*timer_new)(SlirpClockType type, int scale, + SlirpTimerCb cb, void *opaque);
Same here wrt SlirpClockType; and nicely, scale is always nanoseconds so it can be removed.
Paolo
Quoted 103 lines
slirp/libslirp.h +2
-0+void (*timer_free)(void *timer); +void (*timer_mod)(void *timer,int64_t expire_timer); } SlirpCb;slirp/slirp.h +1
-1@@ -218,7 +218,7 @@ struct Slirp {NdpTable ndp_table;GRand *grand; -QEMUTimer *ra_timer; +void *ra_timer;const SlirpCb *cb;void *opaque;net/slirp.c +23
-0@@ -163,10 +163,33 @@ static int64_t net_slirp_clock_get_ns(SlirpClockType type)return qemu_clock_get_ns (slirp_clock_to_qemu (type)); } +static void *net_slirp_timer_new (SlirpClockType type, +int scale, +SlirpTimerCb cb,void *opaque) +{ +return timer_new_full (NULL ,slirp_clock_to_qemu (type), + scale,QEMU_TIMER_ATTR_EXTERNAL , + cb, opaque); +} + +static void net_slirp_timer_free (void *timer) +{ +timer_del (timer); +timer_free (timer); +} + +static void net_slirp_timer_mod (void *timer,int64_t expire_timer) +{ +timer_mod (timer, expire_timer); +} +static SlirpCb slirp_cb = { .output = net_slirp_output, .chr_write_all = net_slirp_chr_write_all, .clock_get_ns = net_slirp_clock_get_ns, + .timer_new = net_slirp_timer_new, + .timer_free = net_slirp_timer_free, + .timer_mod = net_slirp_timer_mod, }; static int net_slirp_init(NetClientState *peer, const char *model,slirp/ip6_icmp.c +10
-11@@ -16,9 +16,10 @@static void ra_timer_handler (void *opaque) {Slirp *slirp = opaque; -timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + - NDP_Interval); + + slirp->cb->timer_mod (slirp->ra_timer, + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval);ndp_send_ra (slirp); }@@ -28,12 +29,11 @@ void icmp6_init(Slirp *slirp)return ; } - slirp->ra_timer =timer_new_full (NULL ,QEMU_CLOCK_VIRTUAL , -SCALE_MS ,QEMU_TIMER_ATTR_EXTERNAL , - ra_timer_handler, slirp); -timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + - NDP_Interval); + slirp->ra_timer = slirp->cb->timer_new (SLIRP_CLOCK_VIRTUAL ,SCALE_MS , + ra_timer_handler, slirp); + slirp->cb->timer_mod (slirp->ra_timer, + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval); }void icmp6_cleanup (Slirp *slirp)@@ -42,8 +42,7 @@ void icmp6_cleanup(Slirp *slirp)return ; } -timer_del (slirp->ra_timer); -timer_free (slirp->ra_timer); + slirp->cb->timer_free (slirp->ra_timer); } static void icmp6_send_echoreply(struct mbuf *m, Slirp *slirp, struct ip6 *ip,
Re: [Qemu-devel] [PATCH for-3.2 08/41] slirp: add callbacks for timer
Hi
Quoted 18 lines · Paolo Bonzini
Quoted 16 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/libslirp.h | 6 ++++++ slirp/slirp.h | 2 +- net/slirp.c | 23 +++++++++++++++++++++++ slirp/ip6_icmp.c | 21 ++++++++++----------- 4 files changed, 40 insertions(+), 12 deletions(-)slirp/libslirp.h +0
-0@@ -10,10 +10,16 @@ typedef enum SlirpClockType { SLIRP_CLOCK_REALTIME, } SlirpClockType;
Quoted 11 lines
slirp/libslirp.h typedef enum SlirpClockType { · line 20
Quoted 8 lines
slirp/libslirp.h +4
-0+typedef void (*SlirpTimerCb )(void *opaque); + typedef struct SlirpCb { void (*output)(void *opaque, const uint8_t *pkt, int pkt_len); int (*chr_write_all)(void *chr, const void *buf, size_t len); int64_t (*clock_get_ns)(SlirpClockType type); + void *(*timer_new)(SlirpClockType type, int scale, + SlirpTimerCb cb, void *opaque);Same here wrt SlirpClockType; and nicely, scale is always nanoseconds so it can be removed.
ack, done
Quoted 107 lines
Paolo
Quoted 103 lines
slirp/libslirp.h +2
-0+void (*timer_free)(void *timer); +void (*timer_mod)(void *timer,int64_t expire_timer); } SlirpCb;slirp/slirp.h +1
-1@@ -218,7 +218,7 @@ struct Slirp {NdpTable ndp_table;GRand *grand; -QEMUTimer *ra_timer; +void *ra_timer;const SlirpCb *cb;void *opaque;net/slirp.c +23
-0@@ -163,10 +163,33 @@ static int64_t net_slirp_clock_get_ns(SlirpClockType type)return qemu_clock_get_ns (slirp_clock_to_qemu (type)); } +static void *net_slirp_timer_new (SlirpClockType type, +int scale, +SlirpTimerCb cb,void *opaque) +{ +return timer_new_full (NULL ,slirp_clock_to_qemu (type), + scale,QEMU_TIMER_ATTR_EXTERNAL , + cb, opaque); +} + +static void net_slirp_timer_free (void *timer) +{ +timer_del (timer); +timer_free (timer); +} + +static void net_slirp_timer_mod (void *timer,int64_t expire_timer) +{ +timer_mod (timer, expire_timer); +} +static SlirpCb slirp_cb = { .output = net_slirp_output, .chr_write_all = net_slirp_chr_write_all, .clock_get_ns = net_slirp_clock_get_ns, + .timer_new = net_slirp_timer_new, + .timer_free = net_slirp_timer_free, + .timer_mod = net_slirp_timer_mod, }; static int net_slirp_init(NetClientState *peer, const char *model,slirp/ip6_icmp.c +10
-11@@ -16,9 +16,10 @@static void ra_timer_handler (void *opaque) {Slirp *slirp = opaque; -timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + - NDP_Interval); + + slirp->cb->timer_mod (slirp->ra_timer, + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval);ndp_send_ra (slirp); }@@ -28,12 +29,11 @@ void icmp6_init(Slirp *slirp)return ; } - slirp->ra_timer =timer_new_full (NULL ,QEMU_CLOCK_VIRTUAL , -SCALE_MS ,QEMU_TIMER_ATTR_EXTERNAL , - ra_timer_handler, slirp); -timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + - NDP_Interval); + slirp->ra_timer = slirp->cb->timer_new (SLIRP_CLOCK_VIRTUAL ,SCALE_MS , + ra_timer_handler, slirp); + slirp->cb->timer_mod (slirp->ra_timer, + slirp->cb->clock_get_ns (SLIRP_CLOCK_VIRTUAL ) /SCALE_MS + + NDP_Interval); }void icmp6_cleanup (Slirp *slirp)@@ -42,8 +42,7 @@ void icmp6_cleanup(Slirp *slirp)return ; } -timer_del (slirp->ra_timer); -timer_free (slirp->ra_timer); + slirp->cb->timer_free (slirp->ra_timer); } static void icmp6_send_echoreply(struct mbuf *m, Slirp *slirp, struct ip6 *ip,
PATCH 9/41 slirp: add a set_nonblock() callback
In reply to Marc-André Lureauqemu_set_nonblock() does some event registration with the main loop on win32, let's have a callback.
--- slirp/libslirp.h | 1 + net/slirp.c | 1 + slirp/misc.c | 2 +- slirp/tcp_subr.c | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-)
slirp/libslirp.h +1 -0
@@ -20,6 +20,7 @@ typedef struct SlirpCb { SlirpTimerCb cb, void *opaque);void (*timer_free)(void *timer);void (*timer_mod)(void *timer,int64_t expire_timer); +void (*set_nonblock)(int fd); } SlirpCb;
net/slirp.c +1 -0
@@ -190,6 +190,7 @@ static SlirpCb slirp_cb = { .timer_new = net_slirp_timer_new, .timer_free = net_slirp_timer_free, .timer_mod = net_slirp_timer_mod, + .set_nonblock = qemu_set_nonblock, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/misc.c +1 -1
@@ -174,7 +174,7 @@ fork_exec(struct socket *so, const char *ex)socket_set_fast_reuse (so->s); opt =1 ;qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); -qemu_set_nonblock (so->s); + so->slirp->cb->set_nonblock (so->s); return 1; }#endif
slirp/tcp_subr.c +2 -2
@@ -412,7 +412,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)int opt, s=so->s;struct sockaddr_storage addr; -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt));
@@ -484,7 +484,7 @@ void tcp_connect(struct socket *inso)tcp_close (sototcpcb (so));/* This will sofree() as well */ return ; } -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 09/41] slirp: add a set_nonblock() callback
Quoted 4 lines · Marc-André Lureau
qemu_set_nonblock()does some event registration with the main loop on win32, let's have a callback.Signed-off-by Marc-André Lureau <[email protected]>
Perhaps a better interface would be register_poll_fd, which is called before a file descriptor can be returned to slirp_pollfds_fill? And perhaps a dual unregister_poll_fd, which QEMU would leave empty, to be called before closing the file descriptor.
Paolo
Quoted 67 lines
--- slirp/libslirp.h | 1 + net/slirp.c | 1 + slirp/misc.c | 2 +- slirp/tcp_subr.c | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-)slirp/libslirp.h +1
-0@@ -20,6 +20,7 @@ typedef struct SlirpCb { SlirpTimerCb cb, void *opaque);void (*timer_free)(void *timer);void (*timer_mod)(void *timer,int64_t expire_timer); +void (*set_nonblock)(int fd); } SlirpCb;net/slirp.c +1
-0@@ -190,6 +190,7 @@ static SlirpCb slirp_cb = { .timer_new = net_slirp_timer_new, .timer_free = net_slirp_timer_free, .timer_mod = net_slirp_timer_mod, + .set_nonblock = qemu_set_nonblock, }; static int net_slirp_init(NetClientState *peer, const char *model,slirp/misc.c +1
-1@@ -174,7 +174,7 @@ fork_exec(struct socket *so, const char *ex)socket_set_fast_reuse (so->s); opt =1 ;qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); -qemu_set_nonblock (so->s); + so->slirp->cb->set_nonblock (so->s); return 1; }#endif slirp/tcp_subr.c +2
-2@@ -412,7 +412,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)int opt, s=so->s;struct sockaddr_storage addr; -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt));@@ -484,7 +484,7 @@ void tcp_connect(struct socket *inso)tcp_close (sototcpcb (so));/* This will sofree() as well */ return ; } -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));
Re: [Qemu-devel] [PATCH for-3.2 09/41] slirp: add a set_nonblock() callback
Hi
Quoted 11 lines · Paolo Bonzini
Quoted 4 lines · Marc-André Lureau
qemu_set_nonblock()does some event registration with the main loop on win32, let's have a callback.Signed-off-by Marc-André Lureau <[email protected]>Perhaps a better interface would be
register_poll_fd, which is called before a file descriptor can be returned toslirp_pollfds_fill? And perhaps a dualunregister_poll_fd, which QEMU would leave empty, to be called before closing the file descriptor.
That sounds like a good idea, but I think it will bring more issues as qemu_fd_register() doing WSAEventSelect will put the socket in nonblocking mode anyway, and we don't have/need qemu_fd_unregister() yet:
https://msdn.microsoft.com/de-de/library/windows/desktop/ms738573(v=vs.85).aspx
"The WSAAsyncSelect and WSAEventSelect functions automatically set a socket to nonblocking mode. If WSAAsyncSelect or WSAEventSelect has been issued on a socket, then any attempt to use ioctlsocket to set the socket back to blocking mode will fail with WSAEINVAL. To set the socket back to blocking mode, an application must first disable WSAAsyncSelect by calling WSAAsyncSelect with the lEvent parameter equal to zero, or disable WSAEventSelect by calling WSAEventSelect with the lNetworkEvents parameter equal to zero."
I will stick to the set_nonblock() callback for now.
thanks
Quoted 71 lines
Paolo
Quoted 67 lines
--- slirp/libslirp.h | 1 + net/slirp.c | 1 + slirp/misc.c | 2 +- slirp/tcp_subr.c | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-)slirp/libslirp.h +1
-0@@ -20,6 +20,7 @@ typedef struct SlirpCb { SlirpTimerCb cb, void *opaque);void (*timer_free)(void *timer);void (*timer_mod)(void *timer,int64_t expire_timer); +void (*set_nonblock)(int fd); } SlirpCb;net/slirp.c +1
-0@@ -190,6 +190,7 @@ static SlirpCb slirp_cb = { .timer_new = net_slirp_timer_new, .timer_free = net_slirp_timer_free, .timer_mod = net_slirp_timer_mod, + .set_nonblock = qemu_set_nonblock, }; static int net_slirp_init(NetClientState *peer, const char *model,slirp/misc.c +1
-1@@ -174,7 +174,7 @@ fork_exec(struct socket *so, const char *ex)socket_set_fast_reuse (so->s); opt =1 ;qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); -qemu_set_nonblock (so->s); + so->slirp->cb->set_nonblock (so->s); return 1; }#endif slirp/tcp_subr.c +2
-2@@ -412,7 +412,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)int opt, s=so->s;struct sockaddr_storage addr; -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt));@@ -484,7 +484,7 @@ void tcp_connect(struct socket *inso)tcp_close (sototcpcb (so));/* This will sofree() as well */ return ; } -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [PATCH for-3.2 09/41] slirp: add a set_nonblock() callback
Quoted 14 lines · Marc-André Lureau
Hi
Quoted 11 lines · Paolo Bonzini
Quoted 4 lines · Marc-André Lureau
qemu_set_nonblock()does some event registration with the main loop on win32, let's have a callback.Signed-off-by Marc-André Lureau <[email protected]>Perhaps a better interface would be
register_poll_fd, which is called before a file descriptor can be returned toslirp_pollfds_fill? And perhaps a dualunregister_poll_fd, which QEMU would leave empty, to be called before closing the file descriptor.
Quoted 4 lines
That sounds like a good idea, but I think it will bring more issues as
qemu_fd_register()doing WSAEventSelect will put the socket in nonblocking mode anyway, and we don't have/needqemu_fd_unregister()yet:
Right, I was more thinking of other possible future clients of SLIRP. But what you have now surely is fine.
(One possible way to work around the problem could be to put the socket in non-blocking mode in SLIRP, since that is OS-dependent but not client-dependent. Then we can document that the register/unregister_fd API is called with sockets that are already in non-blocking mode. That complicates the code a bit in order to have a nicer API).
Paolo
Quoted 89 lines
https://msdn.microsoft.com/de-de/library/windows/desktop/ms738573(v=vs.85).aspx
"The WSAAsyncSelect and WSAEventSelect functions automatically set a socket to nonblocking mode. If WSAAsyncSelect or WSAEventSelect has been issued on a socket, then any attempt to use ioctlsocket to set the socket back to blocking mode will fail with WSAEINVAL. To set the socket back to blocking mode, an application must first disable WSAAsyncSelect by calling WSAAsyncSelect with the lEvent parameter equal to zero, or disable WSAEventSelect by calling WSAEventSelect with the lNetworkEvents parameter equal to zero."I will stick to the
set_nonblock()callback for now.thanks
Quoted 71 lines
Paolo
Quoted 67 lines
--- slirp/libslirp.h | 1 + net/slirp.c | 1 + slirp/misc.c | 2 +- slirp/tcp_subr.c | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-)slirp/libslirp.h +1
-0@@ -20,6 +20,7 @@ typedef struct SlirpCb { SlirpTimerCb cb, void *opaque);void (*timer_free)(void *timer);void (*timer_mod)(void *timer,int64_t expire_timer); +void (*set_nonblock)(int fd); } SlirpCb;net/slirp.c +1
-0@@ -190,6 +190,7 @@ static SlirpCb slirp_cb = { .timer_new = net_slirp_timer_new, .timer_free = net_slirp_timer_free, .timer_mod = net_slirp_timer_mod, + .set_nonblock = qemu_set_nonblock, }; static int net_slirp_init(NetClientState *peer, const char *model,slirp/misc.c +1
-1@@ -174,7 +174,7 @@ fork_exec(struct socket *so, const char *ex)socket_set_fast_reuse (so->s); opt =1 ;qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); -qemu_set_nonblock (so->s); + so->slirp->cb->set_nonblock (so->s); return 1; }#endif slirp/tcp_subr.c +2
-2@@ -412,7 +412,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)int opt, s=so->s;struct sockaddr_storage addr; -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt));@@ -484,7 +484,7 @@ void tcp_connect(struct socket *inso)tcp_close (sototcpcb (so));/* This will sofree() as well */ return ; } -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));
Re: [Qemu-devel] [PATCH for-3.2 09/41] slirp: add a set_nonblock() callback
In reply to Paolo BonziniHi
Quoted 11 lines · Paolo Bonzini
Quoted 4 lines · Marc-André Lureau
qemu_set_nonblock()does some event registration with the main loop on win32, let's have a callback.Signed-off-by Marc-André Lureau <[email protected]>Perhaps a better interface would be
register_poll_fd, which is called before a file descriptor can be returned toslirp_pollfds_fill? And perhaps a dualunregister_poll_fd, which QEMU would leave empty, to be called before closing the file descriptor.
done
thanks
Quoted 71 lines
Paolo
Quoted 67 lines
--- slirp/libslirp.h | 1 + net/slirp.c | 1 + slirp/misc.c | 2 +- slirp/tcp_subr.c | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-)slirp/libslirp.h +1
-0@@ -20,6 +20,7 @@ typedef struct SlirpCb { SlirpTimerCb cb, void *opaque);void (*timer_free)(void *timer);void (*timer_mod)(void *timer,int64_t expire_timer); +void (*set_nonblock)(int fd); } SlirpCb;net/slirp.c +1
-0@@ -190,6 +190,7 @@ static SlirpCb slirp_cb = { .timer_new = net_slirp_timer_new, .timer_free = net_slirp_timer_free, .timer_mod = net_slirp_timer_mod, + .set_nonblock = qemu_set_nonblock, }; static int net_slirp_init(NetClientState *peer, const char *model,slirp/misc.c +1
-1@@ -174,7 +174,7 @@ fork_exec(struct socket *so, const char *ex)socket_set_fast_reuse (so->s); opt =1 ;qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); -qemu_set_nonblock (so->s); + so->slirp->cb->set_nonblock (so->s); return 1; }#endif slirp/tcp_subr.c +2
-2@@ -412,7 +412,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)int opt, s=so->s;struct sockaddr_storage addr; -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt));@@ -484,7 +484,7 @@ void tcp_connect(struct socket *inso)tcp_close (sototcpcb (so));/* This will sofree() as well */ return ; } -qemu_set_nonblock (s); + so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ;qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));
PATCH 10/41 slirp: remove PROBE_CONN dead-code
In reply to Marc-André LureauNobody cares for over 14y. Somebody can revert or rewrite if interested by that.
--- slirp/slirp_config.h | 4 ---- slirp/slirp.c | 41 ----------------------------------------- 2 files changed, 45 deletions(-)
slirp/slirp_config.h +0 -4
@@ -2,10 +2,6 @@* User definable configuration options */ -/* Define if you want the connection to be probed */ -/* XXX Not working yet, so ignore this for now */ -#undef PROBE_CONN -/* Define to 1 if you want KEEPALIVE timers */ #define DO_KEEPALIVE 0
slirp/slirp.c +0 -41
47 lines not on this page · raw message
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 10/41] slirp: remove PROBE_CONN dead-code
Quoted 4 lines · Marc-André Lureau
Nobody cares for over 14y. Somebody can revert or rewrite if interested by that.
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 73 lines
--- slirp/slirp_config.h | 4 ---- slirp/slirp.c | 41 ----------------------------------------- 2 files changed, 45 deletions(-)slirp/slirp_config.h +0
-4@@ -2,10 +2,6 @@* User definable configuration options */ -/* Define if you want the connection to be probed */ -/* XXX Not working yet, so ignore this for now */ -#undef PROBE_CONN -/* Define to 1 if you want KEEPALIVE timers */ #define DO_KEEPALIVE 0slirp/slirp.c +0
-41@@ -699,47 +699,6 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error) } } } - -/* -* Probe a still-connecting, non-blocking socket -* to check if it's still alive -*/ -#ifdef PROBE_CONN -if (so->so_state &SS_ISFCONNECTING ) { - ret =qemu_recv (so->s, &ret,0 ,0 ); - -if (ret <0 ) { -/* XXX */ -if (errno ==EAGAIN || errno ==EWOULDBLOCK || - errno ==EINPROGRESS || errno ==ENOTCONN ) { -continue ;/* Still connecting, continue */ - } - -/* else failed */ - so->so_state &=SS_PERSISTENT_MASK ; - so->so_state |=SS_NOFDREF ; - -/* tcp_input will take care of it */ - }else { - ret =send (so->s, &ret,0 ,0 ); -if (ret <0 ) { -/* XXX */ -if (errno ==EAGAIN || errno ==EWOULDBLOCK || - errno ==EINPROGRESS || errno ==ENOTCONN ) { -continue ; - } -/* else failed */ - so->so_state &=SS_PERSISTENT_MASK ; - so->so_state |=SS_NOFDREF ; - }else { - so->so_state &= ~SS_ISFCONNECTING ; - } - - } -tcp_input ((struct mbuf *)NULL ,sizeof (struct ip ), so, - so->so_ffamily); - }/* SS_ISFCONNECTING */ -#endif }/*
Re: [Qemu-devel] [PATCH for-3.2 10/41] slirp: remove PROBE_CONN dead-code
In reply to Marc-André LureauQuoted 8 lines · Marc-André Lureau
Nobody cares for over 14y. Somebody can revert or rewrite if interested by that.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 4 ---- slirp/slirp.c | 41 ----------------------------------------- 2 files changed, 45 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 10/41] slirp: remove PROBE_CONN dead-code
Philippe Mathieu-Daudé, le mer. 14 nov. 2018 14:12:04 +0100, a ecrit:
Quoted 7 lines · Marc-André Lureau
Quoted 4 lines
Nobody cares for over 14y. Somebody can revert or rewrite if interested by that.
Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Daniel P. Berrangé, le mer. 14 nov. 2018 13:33:28 +0000, a ecrit:
Quoted 1 line
Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
Samuel
PATCH 11/41 slirp: remove FULL_BOLT
In reply to Marc-André LureauLooking at git history, this looks like something from the past, when there was a tty layer. Let's remove it.
--- slirp/slirp_config.h | 7 ------- slirp/if.c | 2 -- 2 files changed, 9 deletions(-)
slirp/slirp_config.h +0 -7
@@ -5,13 +5,6 @@/* Define to 1 if you want KEEPALIVE timers */ #define DO_KEEPALIVE 0 -/* Define this if you want slirp to write to the tty as fast as it can */ -/* This should only be set if you are using load-balancing, slirp does a */ -/* pretty good job on single modems already, and seting this will make */ -/* interactive sessions less responsive */ -/* XXXXX Talk about having fast modem as unit 0 */ -#undef FULL_BOLT -/*********************************************************/ /* * Autoconf defined configuration options
slirp/if.c +0 -2
@@ -131,12 +131,10 @@ diddit: } } -#ifndef FULL_BOLT /* * This prevents us from malloc()ing too many mbufs */ if_start (ifm->slirp); -#endif }/*
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 11/41] slirp: remove FULL_BOLT
Quoted 8 lines · Marc-André Lureau
Looking at git history, this looks like something from the past, when there was a tty layer. Let's remove it.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 7 ------- slirp/if.c | 2 -- 2 files changed, 9 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 11/41] slirp: remove FULL_BOLT
Daniel P. Berrangé, le mer. 14 nov. 2018 13:46:02 +0000, a ecrit:
Quoted 11 lines · Marc-André Lureau
Quoted 8 lines
Looking at git history, this looks like something from the past, when there was a tty layer. Let's remove it.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 7 ------- slirp/if.c | 2 -- 2 files changed, 9 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 12/41 slirp: remove the disabled readv()/writev() code path
In reply to Marc-André LureauThe soread() function may be used on datagram sockets, and would provide different behaviour if HAVE_READV was set, on empty datagrams. This looks like a minor optimization, that never has been a strong goal for slirp.
--- slirp/slirp_config.h | 3 --- slirp/socket.c | 15 --------------- 2 files changed, 18 deletions(-)
slirp/slirp_config.h +0 -3
@@ -29,9 +29,6 @@/* Define if the machine is big endian */ //#undef HOST_WORDS_BIGENDIAN -/* Define if you have readv */ -#undef HAVE_READV -/* Define if iovec needs to be declared */ #undef DECLARE_IOVEC#ifdef _WIN32
slirp/socket.c +0 -15
@@ -187,12 +187,7 @@ soread(struct socket *so)*/ sopreprbuf (so, iov, &n); -#ifdef HAVE_READV - nn =readv (so->s, (struct iovec *)iov, n); -DEBUG_MISC ((dfd," ... read nn = %d bytes\n" , nn)); -#else nn =qemu_recv (so->s, iov[0 ].iov_base, iov[0 ].iov_len,0 ); -#endif if (nn <=0 ) {if (nn <0 && (errno ==EINTR || errno ==EAGAIN ))return 0 ;
@@ -226,7 +221,6 @@ soread(struct socket *so) } } -#ifndef HAVE_READV /* * If there was no error, try and read the second time round * We read again if n = 2 (ie, there's another part of the buffer)
@@ -244,7 +238,6 @@ soread(struct socket *so) }DEBUG_MISC ((dfd," ... read nn = %d bytes\n" , nn)); -#endif /* Update fields */ sb->sb_cc += nn;
@@ -452,13 +445,7 @@ sowrite(struct socket *so) }/* Check if there's urgent data to send, and if so, send it */ -#ifdef HAVE_READV - nn =writev (so->s, (const struct iovec *)iov, n); - -DEBUG_MISC ((dfd," ... wrote nn = %d bytes\n" , nn)); -#else nn =slirp_send (so, iov[0 ].iov_base, iov[0 ].iov_len,0 ); -#endif /* This should never happen, but people tell me it does *shrug* */ if (nn <0 && (errno ==EAGAIN || errno ==EINTR ))return 0 ;
@@ -467,7 +454,6 @@ sowrite(struct socket *so) goto err_disconnected; } -#ifndef HAVE_READV if (n ==2 && nn == iov[0 ].iov_len) {int ret; ret =slirp_send (so, iov[1 ].iov_base, iov[1 ].iov_len,0 );
@@ -475,7 +461,6 @@ sowrite(struct socket *so) nn += ret; }DEBUG_MISC ((dfd," ... wrote nn = %d bytes\n" , nn)); -#endif /* Update sbuf */ sb->sb_cc -= nn;
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 12/41] slirp: remove the disabled readv()/writev() code path
Quoted 10 lines · Marc-André Lureau
The
soread()function may be used on datagram sockets, and would provide different behaviour ifHAVE_READVwas set, on empty datagrams. This looks like a minor optimization, that never has been a strong goal for slirp.Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 3 --- slirp/socket.c | 15 --------------- 2 files changed, 18 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 12/41] slirp: remove the disabled readv()/writev() code path
Daniel P. Berrangé, le mer. 14 nov. 2018 13:46:46 +0000, a ecrit:
Quoted 6 lines · Marc-André Lureau
Quoted 5 lines
The
soread()function may be used on datagram sockets, and would provide different behaviour ifHAVE_READVwas set, on empty datagrams. This looks like a minor optimization, that never has been a strong goal for slirp.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 3 --- slirp/socket.c | 15 --------------- 2 files changed, 18 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 13/41 slirp: remove HAVE_SYS_SIGNAL_H
In reply to Marc-André Lureau--- slirp/slirp.h | 3 --- slirp/slirp_config.h | 3 --- 2 files changed, 6 deletions(-)
slirp/slirp.h +0 -3
@@ -35,9 +35,6 @@ typedef char *caddr_t;#ifndef NO_UNIX_SOCKETS #include <sys/un.h> #endif -#ifdef HAVE_SYS_SIGNAL_H -# include <sys/signal.h> -#endif #ifndef _WIN32#include <sys/socket.h> #endif
slirp/slirp_config.h +0 -3
@@ -50,9 +50,6 @@#define HAVE_ARPA_INET_H #endif -/* Define if you have sys/signal.h */ -#undef HAVE_SYS_SIGNAL_H -/* Define if you have sys/stropts.h */ #undef HAVE_SYS_STROPTS_H
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 13/41] slirp: remove HAVE_SYS_SIGNAL_H
Quoted 5 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 3 --- slirp/slirp_config.h | 3 --- 2 files changed, 6 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 13/41] slirp: remove HAVE_SYS_SIGNAL_H
Daniel P. Berrangé, le mer. 14 nov. 2018 13:47:32 +0000, a ecrit:
Quoted 8 lines · Marc-André Lureau
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 3 --- slirp/slirp_config.h | 3 --- 2 files changed, 6 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 14/41 slirp: remove unused HAVE_SYS_BITYPES_H
In reply to Marc-André Lureau--- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 3 --- 2 files changed, 7 deletions(-)
slirp/slirp.h +0 -4
@@ -19,10 +19,6 @@ typedef char *caddr_t;# endif #endif -#ifdef HAVE_SYS_BITYPES_H -# include <sys/bitypes.h> -#endif -#ifndef _WIN32#include <sys/uio.h> #endif
slirp/slirp_config.h +0 -3
@@ -23,9 +23,6 @@#define HAVE_SYS_FILIO_H #endif -/* Define if you have sys/bitypes.h */ -#undef HAVE_SYS_BITYPES_H -/* Define if the machine is big endian */ //#undef HOST_WORDS_BIGENDIAN
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 14/41] slirp: remove unused HAVE_SYS_BITYPES_H
Quoted 5 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 3 --- 2 files changed, 7 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 14/41] slirp: remove unused HAVE_SYS_BITYPES_H
Daniel P. Berrangé, le mer. 14 nov. 2018 13:47:57 +0000, a ecrit:
Quoted 8 lines · Marc-André Lureau
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 3 --- 2 files changed, 7 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 15/41 slirp: remove NO_UNIX_SOCKETS
In reply to Marc-André Lureau--- slirp/slirp.h | 3 --- slirp/slirp_config.h | 6 ------ 2 files changed, 9 deletions(-)
slirp/slirp.h +0 -3
@@ -28,9 +28,6 @@ typedef char *caddr_t;#include <arpa/inet.h> #endif -#ifndef NO_UNIX_SOCKETS -#include <sys/un.h> -#endif #ifndef _WIN32#include <sys/socket.h> #endif
slirp/slirp_config.h +0 -6
@@ -58,9 +58,3 @@#ifndef _WIN32#define HAVE_INET_ATON #endif - -/* Define if you DON'T have unix-domain sockets */ -#undef NO_UNIX_SOCKETS -#ifdef _WIN32 -#define NO_UNIX_SOCKETS -#endif
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 15/41] slirp: remove NO_UNIX_SOCKETS
Quoted 5 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 3 --- slirp/slirp_config.h | 6 ------ 2 files changed, 9 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 15/41] slirp: remove NO_UNIX_SOCKETS
Daniel P. Berrangé, le mer. 14 nov. 2018 13:48:37 +0000, a ecrit:
Quoted 8 lines · Marc-André Lureau
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 3 --- slirp/slirp_config.h | 6 ------ 2 files changed, 9 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 16/41 slirp: remove unused HAVE_SYS_STROPTS_H
In reply to Marc-André Lureau--- slirp/slirp.h | 5 ----- slirp/slirp_config.h | 3 --- 2 files changed, 8 deletions(-)
slirp/slirp.h +0 -5
@@ -54,11 +54,6 @@ typedef char *caddr_t;#define remque slirp_remque#define quehead slirp_quehead -#ifdef HAVE_SYS_STROPTS_H -#include <sys/stropts.h> -#endif - -#include "debug.h" #include "qemu/queue.h"
slirp/slirp_config.h +0 -3
@@ -47,9 +47,6 @@#define HAVE_ARPA_INET_H #endif -/* Define if you have sys/stropts.h */ -#undef HAVE_SYS_STROPTS_H -/* Define to sizeof(char *) */ #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 16/41] slirp: remove unused HAVE_SYS_STROPTS_H
Quoted 5 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 5 ----- slirp/slirp_config.h | 3 --- 2 files changed, 8 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 16/41] slirp: remove unused HAVE_SYS_STROPTS_H
Daniel P. Berrangé, le mer. 14 nov. 2018 13:49:08 +0000, a ecrit:
Quoted 8 lines · Marc-André Lureau
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 5 ----- slirp/slirp_config.h | 3 --- 2 files changed, 8 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 17/41 slirp: remove unused HAVE_ARPA_INET_H
In reply to Marc-André Lureau--- slirp/slirp_config.h | 6 ------ 1 file changed, 6 deletions(-)
slirp/slirp_config.h +0 -6
@@ -41,12 +41,6 @@#define HAVE_SYS_SELECT_H #endif -/* Define if you have arpa/inet.h */ -#undef HAVE_ARPA_INET_H -#ifndef _WIN32 -#define HAVE_ARPA_INET_H -#endif -/* Define to sizeof(char *) */ #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 17/41] slirp: remove unused HAVE_ARPA_INET_H
Quoted 4 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 6 ------ 1 file changed, 6 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 17/41] slirp: remove unused HAVE_ARPA_INET_H
Daniel P. Berrangé, le mer. 14 nov. 2018 13:50:01 +0000, a ecrit:
Quoted 7 lines · Marc-André Lureau
Quoted 4 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 6 ------ 1 file changed, 6 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 18/41 slirp: remove unused HAVE_SYS_WAIT_H
In reply to Marc-André Lureau--- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 3 --- 2 files changed, 7 deletions(-)
slirp/slirp.h +0 -4
@@ -40,10 +40,6 @@ typedef char *caddr_t;# include <sys/select.h> #endif -#ifdef HAVE_SYS_WAIT_H -# include <sys/wait.h> -#endif -#ifdef HAVE_SYS_FILIO_H # include <sys/filio.h> #endif
slirp/slirp_config.h +0 -3
@@ -32,9 +32,6 @@#define DECLARE_IOVEC #endif -/* Define if you have a POSIX.1 sys/wait.h */ -#undef HAVE_SYS_WAIT_H -/* Define if you have sys/select.h */ #undef HAVE_SYS_SELECT_H#ifndef _WIN32
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 18/41] slirp: remove unused HAVE_SYS_WAIT_H
Quoted 5 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 3 --- 2 files changed, 7 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 18/41] slirp: remove unused HAVE_SYS_WAIT_H
Daniel P. Berrangé, le mer. 14 nov. 2018 13:50:33 +0000, a ecrit:
Quoted 8 lines · Marc-André Lureau
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 3 --- 2 files changed, 7 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 19/41 slirp: remove unused HAVE_SYS_SELECT_H
In reply to Marc-André Lureau--- slirp/main.h | 4 ---- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 6 ------ 3 files changed, 14 deletions(-)
slirp/main.h +0 -4
@@ -8,10 +8,6 @@#ifndef SLIRP_MAIN_H #define SLIRP_MAIN_H -#ifdef HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif -extern u_int curtime;extern struct in_addr loopback_addr;extern unsigned long loopback_mask;
slirp/slirp.h +0 -4
@@ -36,10 +36,6 @@ typedef char *caddr_t;# include <sys/ioctl.h> #endif -#ifdef HAVE_SYS_SELECT_H -# include <sys/select.h> -#endif -#ifdef HAVE_SYS_FILIO_H # include <sys/filio.h> #endif
slirp/slirp_config.h +0 -6
@@ -32,12 +32,6 @@#define DECLARE_IOVEC #endif -/* Define if you have sys/select.h */ -#undef HAVE_SYS_SELECT_H -#ifndef _WIN32 -#define HAVE_SYS_SELECT_H -#endif -/* Define to sizeof(char *) */ #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 19/41] slirp: remove unused HAVE_SYS_SELECT_H
Quoted 6 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/main.h | 4 ---- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 6 ------ 3 files changed, 14 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 19/41] slirp: remove unused HAVE_SYS_SELECT_H
Daniel P. Berrangé, le mer. 14 nov. 2018 13:51:01 +0000, a ecrit:
Quoted 9 lines · Marc-André Lureau
Quoted 6 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/main.h | 4 ---- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 6 ------ 3 files changed, 14 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 20/41 slirp: remove HAVE_SYS_IOCTL_H
In reply to Marc-André Lureau--- slirp/slirp.h | 2 +- slirp/slirp_config.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
slirp/slirp.h +1 -1
@@ -32,7 +32,7 @@ typedef char *caddr_t;#include <sys/socket.h> #endif -#if defined(HAVE_SYS_IOCTL_H ) +#ifndef _WIN32# include <sys/ioctl.h> #endif
slirp/slirp_config.h +0 -6
@@ -11,12 +11,6 @@* You shouldn't need to touch any of these */ -/* Define if you have sys/ioctl.h */ -#undef HAVE_SYS_IOCTL_H -#ifndef _WIN32 -#define HAVE_SYS_IOCTL_H -#endif -/* Define if you have sys/filio.h */ #undef HAVE_SYS_FILIO_H#ifdef __APPLE__
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 20/41] slirp: remove HAVE_SYS_IOCTL_H
Quoted 5 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 2 +- slirp/slirp_config.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 20/41] slirp: remove HAVE_SYS_IOCTL_H
Daniel P. Berrangé, le mer. 14 nov. 2018 13:51:29 +0000, a ecrit:
Quoted 8 lines · Marc-André Lureau
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 2 +- slirp/slirp_config.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 21/41 slirp: remove HAVE_SYS_FILIO_H
In reply to Marc-André Lureau--- slirp/slirp.h | 2 +- slirp/slirp_config.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
slirp/slirp.h +1 -1
@@ -36,7 +36,7 @@ typedef char *caddr_t;# include <sys/ioctl.h> #endif -#ifdef HAVE_SYS_FILIO_H +#ifdef __APPLE__# include <sys/filio.h> #endif
slirp/slirp_config.h +0 -6
@@ -11,12 +11,6 @@* You shouldn't need to touch any of these */ -/* Define if you have sys/filio.h */ -#undef HAVE_SYS_FILIO_H -#ifdef __APPLE__ -#define HAVE_SYS_FILIO_H -#endif -/* Define if the machine is big endian */ //#undef HOST_WORDS_BIGENDIAN
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 21/41] slirp: remove HAVE_SYS_FILIO_H
Quoted 5 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 2 +- slirp/slirp_config.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 21/41] slirp: remove HAVE_SYS_FILIO_H
Daniel P. Berrangé, le mer. 14 nov. 2018 13:52:12 +0000, a ecrit:
Quoted 8 lines · Marc-André Lureau
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 2 +- slirp/slirp_config.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 22/41 slirp: remove unused DECLARE_IOVEC
In reply to Marc-André LureauIt's actually qemu configure CONFIG_IOVEC that is being used.
--- slirp/slirp_config.h | 6 ------ 1 file changed, 6 deletions(-)
slirp/slirp_config.h +0 -6
@@ -14,12 +14,6 @@/* Define if the machine is big endian */ //#undef HOST_WORDS_BIGENDIAN -/* Define if iovec needs to be declared */ -#undef DECLARE_IOVEC -#ifdef _WIN32 -#define DECLARE_IOVEC -#endif -/* Define to sizeof(char *) */ #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 22/41] slirp: remove unused DECLARE_IOVEC
Quoted 1 line · Marc-André Lureau
It's actually qemu configure
CONFIG_IOVECthat is being used.
That makes it sound like slirp is using CONFIG_IOVEC, but AFAICT that's only used by QEMU's osdep code.
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 6 ------ 1 file changed, 6 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 22/41] slirp: remove unused DECLARE_IOVEC
Daniel P. Berrangé, le mer. 14 nov. 2018 13:53:31 +0000, a ecrit:
Quoted 7 lines · Marc-André Lureau
Quoted 1 line
It's actually qemu configure
CONFIG_IOVECthat is being used.That makes it sound like slirp is using
CONFIG_IOVEC, but AFAICT that's only used by QEMU's osdep code.Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 6 ------ 1 file changed, 6 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 23/41 slirp: remove unused HAVE_INET_ATON
In reply to Marc-André Lureau--- slirp/slirp_config.h | 6 ------ 1 file changed, 6 deletions(-)
slirp/slirp_config.h +0 -6
@@ -16,9 +16,3 @@/* Define to sizeof(char *) */ #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8) - -/* Define if you have inet_aton */ -#undef HAVE_INET_ATON -#ifndef _WIN32 -#define HAVE_INET_ATON -#endif
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 23/41] slirp: remove unused HAVE_INET_ATON
Quoted 4 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 6 ------ 1 file changed, 6 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 23/41] slirp: remove unused HAVE_INET_ATON
Daniel P. Berrangé, le mer. 14 nov. 2018 13:54:33 +0000, a ecrit:
Quoted 7 lines · Marc-André Lureau
Quoted 4 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp_config.h | 6 ------ 1 file changed, 6 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 24/41 slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent
In reply to Marc-André LureauOne more step towards making the project independent from QEMU.
--- slirp/ip.h | 8 +++++--- slirp/ip6.h | 3 ++- slirp/ip6_icmp.h | 6 +++--- slirp/slirp_config.h | 3 --- slirp/tcp.h | 4 +++- 5 files changed, 13 insertions(+), 11 deletions(-)
slirp/ip.h +5 -3
@@ -33,7 +33,9 @@#ifndef IP_H #define IP_H -#ifdef HOST_WORDS_BIGENDIAN +#include <glib.h> + +#if G_BYTE_ORDER ==G_BIG_ENDIAN # undef NTOHL# undef NTOHS# undef HTONL
@@ -69,7 +71,7 @@ typedef uint32_t n_long; /* long as received from the net */* Structure of an internet header, naked of options. */ struct ip { -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t ip_v:4 ,/* version */ ip_hl:4 ;/* header length */ #else
@@ -135,7 +137,7 @@ struct ip_timestamp {uint8_t ipt_code;/* IPOPT_TS */ uint8_t ipt_len;/* size of structure (variable) */ uint8_t ipt_ptr;/* index of current entry */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t ipt_oflw:4, /* overflow counter */ ipt_flg:4; /* flags, see below */#else
slirp/ip6.h +2 -1
@@ -6,6 +6,7 @@#ifndef SLIRP_IP6_H #define SLIRP_IP6_H +#include <glib.h> #include "net/eth.h" #define ALLNODES_MULTICAST { .s6_addr = \
@@ -113,7 +114,7 @@ static inline void in6_compute_ethaddr(struct in6_addr ip,* Structure of an internet header, naked of options. */ struct ip6 { -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint32_t ip_v:4 ,/* version */ ip_tc_hi:4, /* traffic class */
slirp/ip6_icmp.h +3 -3
@@ -34,7 +34,7 @@ struct ndp_rs { /* Router Solicitation Message */struct ndp_ra {/* Router Advertisement Message */ uint8_t chl;/* Cur Hop Limit */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t M:1 , O:1,
@@ -56,7 +56,7 @@ struct ndp_ns { /* Neighbor Solicitation Message */ }QEMU_PACKED ;struct ndp_na {/* Neighbor Advertisement Message */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint32_t R:1 ,/* Router Flag */ S:1, /* Solicited Flag */
@@ -125,7 +125,7 @@ struct ndpopt {#define ndpopt_linklayer ndpopt_body.linklayer_addrstruct prefixinfo {/* Prefix Information */ uint8_t prefix_length; -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t L:1 , A:1 , reserved1:6 ;#else uint8_t reserved1:6 , A:1 , L:1 ;
slirp/slirp_config.h +0 -3
@@ -11,8 +11,5 @@* You shouldn't need to touch any of these */ -/* Define if the machine is big endian */ -//#undef HOST_WORDS_BIGENDIAN -/* Define to sizeof(char *) */ #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
slirp/tcp.h +3 -1
@@ -33,6 +33,8 @@#ifndef TCP_H #define TCP_H +#include <glib.h> +typedef uint32_t tcp_seq ;#define PR_SLOWHZ 2/* 2 slow timeouts per second (approx) */
@@ -51,7 +53,7 @@ struct tcphdr {uint16_t th_dport;/* destination port */ tcp_seq th_seq;/* sequence number */ tcp_seq th_ack;/* acknowledgement number */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t th_off:4, /* data offset */ th_x2:4; /* (unused) */#else
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 24/41] slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent
Quoted 3 lines · Marc-André Lureau
One more step towards making the project independent from QEMU.
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 129 lines
--- slirp/ip.h | 8 +++++--- slirp/ip6.h | 3 ++- slirp/ip6_icmp.h | 6 +++--- slirp/slirp_config.h | 3 --- slirp/tcp.h | 4 +++- 5 files changed, 13 insertions(+), 11 deletions(-)slirp/ip.h +5
-3@@ -33,7 +33,9 @@#ifndef IP_H #define IP_H -#ifdef HOST_WORDS_BIGENDIAN +#include <glib.h> + +#if G_BYTE_ORDER ==G_BIG_ENDIAN # undef NTOHL# undef NTOHS# undef HTONL@@ -69,7 +71,7 @@ typedef uint32_t n_long; /* long as received from the net */* Structure of an internet header, naked of options. */ struct ip { -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t ip_v:4 ,/* version */ ip_hl:4 ;/* header length */ #else @@ -135,7 +137,7 @@ struct ip_timestamp {uint8_t ipt_code;/* IPOPT_TS */ uint8_t ipt_len;/* size of structure (variable) */ uint8_t ipt_ptr;/* index of current entry */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t ipt_oflw:4, /* overflow counter */ ipt_flg:4; /* flags, see below */#else slirp/ip6.h +2
-1@@ -6,6 +6,7 @@#ifndef SLIRP_IP6_H #define SLIRP_IP6_H +#include <glib.h> #include "net/eth.h" #define ALLNODES_MULTICAST { .s6_addr = \@@ -113,7 +114,7 @@ static inline void in6_compute_ethaddr(struct in6_addr ip,* Structure of an internet header, naked of options. */ struct ip6 { -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint32_t ip_v:4 ,/* version */ ip_tc_hi:4, /* traffic class */slirp/ip6_icmp.h +3
-3@@ -34,7 +34,7 @@ struct ndp_rs { /* Router Solicitation Message */struct ndp_ra {/* Router Advertisement Message */ uint8_t chl;/* Cur Hop Limit */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t M:1 , O:1,@@ -56,7 +56,7 @@ struct ndp_ns { /* Neighbor Solicitation Message */ }QEMU_PACKED ;struct ndp_na {/* Neighbor Advertisement Message */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint32_t R:1 ,/* Router Flag */ S:1, /* Solicited Flag */@@ -125,7 +125,7 @@ struct ndpopt {#define ndpopt_linklayer ndpopt_body.linklayer_addrstruct prefixinfo {/* Prefix Information */ uint8_t prefix_length; -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t L:1 , A:1 , reserved1:6 ;#else uint8_t reserved1:6 , A:1 , L:1 ;slirp/slirp_config.h +0
-3@@ -11,8 +11,5 @@* You shouldn't need to touch any of these */ -/* Define if the machine is big endian */ -//#undef HOST_WORDS_BIGENDIAN -/* Define to sizeof(char *) */ #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)slirp/tcp.h +3
-1@@ -33,6 +33,8 @@#ifndef TCP_H #define TCP_H +#include <glib.h> +typedef uint32_t tcp_seq ;#define PR_SLOWHZ 2/* 2 slow timeouts per second (approx) */ @@ -51,7 +53,7 @@ struct tcphdr {uint16_t th_dport;/* destination port */ tcp_seq th_seq;/* sequence number */ tcp_seq th_ack;/* acknowledgement number */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t th_off:4, /* data offset */ th_x2:4; /* (unused) */#else
Re: [Qemu-devel] [PATCH for-3.2 24/41] slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent
In reply to Marc-André LureauQuoted 16 lines · Marc-André Lureau
One more step towards making the project independent from QEMU.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/ip.h | 8 +++++--- slirp/ip6.h | 3 ++- slirp/ip6_icmp.h | 6 +++--- slirp/slirp_config.h | 3 --- slirp/tcp.h | 4 +++- 5 files changed, 13 insertions(+), 11 deletions(-)slirp/ip.h +0
-0
slirp/ip.h line 38
Quoted 7 lines
slirp/ip.h +3
-1@@ -33,7 +33,9 @@#ifndef IP_H #define IP_H -#ifdef HOST_WORDS_BIGENDIAN +#include <glib.h> + +#if G_BYTE_ORDER ==G_BIG_ENDIAN
This is a example of legacy cruft in QEMU that we should just clean up across the entire codebase. Obviously it made sense when first added to QEMU, but there's no sense in duplicating what's provided by glib now it is a mandatory dependency.
I'm fine with you just changing slirp in this patch to avoid getting bogged down in debate, but I'd strongly encourage a followup to clean the rest of QEMU too
Quoted 112 lines
slirp/ip.h +2
-2# undef NTOHL# undef NTOHS# undef HTONL@@ -69,7 +71,7 @@ typedef uint32_t n_long; /* long as received from the net */* Structure of an internet header, naked of options. */ struct ip { -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t ip_v:4 ,/* version */ ip_hl:4 ;/* header length */ #else @@ -135,7 +137,7 @@ struct ip_timestamp {uint8_t ipt_code;/* IPOPT_TS */ uint8_t ipt_len;/* size of structure (variable) */ uint8_t ipt_ptr;/* index of current entry */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t ipt_oflw:4, /* overflow counter */ ipt_flg:4; /* flags, see below */#else slirp/ip6.h +2
-1@@ -6,6 +6,7 @@#ifndef SLIRP_IP6_H #define SLIRP_IP6_H +#include <glib.h> #include "net/eth.h" #define ALLNODES_MULTICAST { .s6_addr = \@@ -113,7 +114,7 @@ static inline void in6_compute_ethaddr(struct in6_addr ip,* Structure of an internet header, naked of options. */ struct ip6 { -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint32_t ip_v:4 ,/* version */ ip_tc_hi:4, /* traffic class */slirp/ip6_icmp.h +3
-3@@ -34,7 +34,7 @@ struct ndp_rs { /* Router Solicitation Message */struct ndp_ra {/* Router Advertisement Message */ uint8_t chl;/* Cur Hop Limit */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t M:1 , O:1,@@ -56,7 +56,7 @@ struct ndp_ns { /* Neighbor Solicitation Message */ }QEMU_PACKED ;struct ndp_na {/* Neighbor Advertisement Message */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint32_t R:1 ,/* Router Flag */ S:1, /* Solicited Flag */@@ -125,7 +125,7 @@ struct ndpopt {#define ndpopt_linklayer ndpopt_body.linklayer_addrstruct prefixinfo {/* Prefix Information */ uint8_t prefix_length; -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t L:1 , A:1 , reserved1:6 ;#else uint8_t reserved1:6 , A:1 , L:1 ;slirp/slirp_config.h +0
-3@@ -11,8 +11,5 @@* You shouldn't need to touch any of these */ -/* Define if the machine is big endian */ -//#undef HOST_WORDS_BIGENDIAN -/* Define to sizeof(char *) */ #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)slirp/tcp.h +3
-1@@ -33,6 +33,8 @@#ifndef TCP_H #define TCP_H +#include <glib.h> +typedef uint32_t tcp_seq ;#define PR_SLOWHZ 2/* 2 slow timeouts per second (approx) */ @@ -51,7 +53,7 @@ struct tcphdr {uint16_t th_dport;/* destination port */ tcp_seq th_seq;/* sequence number */ tcp_seq th_ack;/* acknowledgement number */ -#ifdef HOST_WORDS_BIGENDIAN +#if G_BYTE_ORDER ==G_BIG_ENDIAN uint8_t th_off:4, /* data offset */ th_x2:4; /* (unused) */#else Signature · 1 line
2.19.1.708.g4ede3d42df
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 24/41] slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent
Philippe Mathieu-Daudé, le mer. 14 nov. 2018 14:14:16 +0100, a ecrit:
Quoted 6 lines · Marc-André Lureau
Quoted 3 lines
One more step towards making the project independent from QEMU.
Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Daniel P. Berrangé, le mer. 14 nov. 2018 13:32:29 +0000, a ecrit:
Quoted 1 line
Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
Samuel
PATCH 25/41 slirp: replace SIZEOF_CHAR_P with glib equivalent
In reply to Marc-André Lureau--- slirp/ip.h | 2 +- slirp/slirp_config.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-)
slirp/ip.h +1 -1
@@ -177,7 +177,7 @@ struct ip_timestamp {#define IP_MSS 576/* default maximum segment size */ -#if SIZEOF_CHAR_P == 4 +#if GLIB_SIZEOF_VOID_P == 4 struct mbuf_ptr { struct mbuf *mptr; uint32_t dummy;
slirp/slirp_config.h +0 -3
@@ -10,6 +10,3 @@* Autoconf defined configuration options * You shouldn't need to touch any of these */ - -/* Define to sizeof(char *) */ -#define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 25/41] slirp: replace SIZEOF_CHAR_P with glib equivalent
Quoted 1 line · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 30 lines
--- slirp/ip.h | 2 +- slirp/slirp_config.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-)slirp/ip.h +1
-1@@ -177,7 +177,7 @@ struct ip_timestamp {#define IP_MSS 576/* default maximum segment size */ -#if SIZEOF_CHAR_P == 4 +#if GLIB_SIZEOF_VOID_P == 4 struct mbuf_ptr { struct mbuf *mptr; uint32_t dummy;slirp/slirp_config.h +0
-3@@ -10,6 +10,3 @@* Autoconf defined configuration options * You shouldn't need to touch any of these */ - -/* Define to sizeof(char *) */ -#define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 25/41] slirp: replace SIZEOF_CHAR_P with glib equivalent
Philippe Mathieu-Daudé, le mer. 14 nov. 2018 14:14:35 +0100, a ecrit:
Quoted 4 lines · Marc-André Lureau
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Applied to my tree, thanks!
PATCH 26/41 slirp: replace compile time DO_KEEPALIVE
In reply to Marc-André LureauUse a global variable instead (similar to slirp_debug)
--- slirp/slirp.h | 6 +++--- slirp/slirp_config.h | 12 ------------ slirp/slirp.c | 3 +++ slirp/tcp_input.c | 2 +- slirp/tcp_timer.c | 2 +- 5 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 slirp/slirp_config.h
slirp/slirp.h +3 -3
@@ -1,8 +1,6 @@#ifndef SLIRP_H #define SLIRP_H -#include "slirp_config.h" -#ifdef _WIN32typedef char *caddr_t ;
@@ -219,7 +217,9 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len);#include <netdb.h> #endif -#define SO_OPTIONS DO_KEEPALIVE + +extern bool slirp_do_keepalive; +#define TCP_MAXIDLE (TCPTV_KEEPCNT * TCPTV_KEEPINTVL)/* dnssearch.c */
slirp/slirp_config.h deleted +0 -12
@@ -1,12 +0,0 @@ -/* -* User definable configuration options -*/ - -/* Define to 1 if you want KEEPALIVE timers */ -#define DO_KEEPALIVE 0 - -/*********************************************************/ -/* -* Autoconf defined configuration options -* You shouldn't need to touch any of these -*/
slirp/slirp.c +3 -0
@@ -35,6 +35,9 @@#include <net/if.h> #endif +/* Define to 1 if you want KEEPALIVE timers */ +bool slirp_do_keepalive; +/* host loopback address */ struct in_addr loopback_addr;/* host loopback network mask */
slirp/tcp_input.c +1 -1
@@ -481,7 +481,7 @@ findso:* Reset idle time and keep-alive timer. */ tp->t_idle =0 ; -if (SO_OPTIONS ) +if (slirp_do_keepalive) tp->t_timer[TCPT_KEEP ] =TCPTV_KEEPINTVL ;else tp->t_timer[TCPT_KEEP ] =TCPTV_KEEP_IDLE ;
slirp/tcp_timer.c +1 -1
@@ -262,7 +262,7 @@ tcp_timers(register struct tcpcb *tp, int timer)if (tp->t_state <TCPS_ESTABLISHED ) goto dropit; -if ((SO_OPTIONS ) && tp->t_state <=TCPS_CLOSE_WAIT ) { +if (slirp_do_keepalive && tp->t_state <=TCPS_CLOSE_WAIT ) {if (tp->t_idle >=TCPTV_KEEP_IDLE +TCP_MAXIDLE ) goto dropit;/*
Signature · 1 line
2.19.1.708.g4ede3d42df
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 26/41] slirp: replace compile time DO_KEEPALIVE
Marc-André Lureau, le mer. 14 nov. 2018 16:36:28 +0400, a ecrit:
Quoted 3 lines
Use a global variable instead (similar to
slirp_debug)Signed-off-by Marc-André Lureau <[email protected]>
Applied to my tree, thanks!
PATCH 27/41 slirp: remove unused global slirp_instance
In reply to Marc-André Lureau--- slirp/slirp.h | 2 -- 1 file changed, 2 deletions(-)
slirp/slirp.h +0 -2
@@ -199,8 +199,6 @@ struct Slirp {void *opaque; }; -extern Slirp *slirp_instance; -#ifndef NULL #define NULL (void *)0#endif
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 27/41] slirp: remove unused global slirp_instance
Quoted 4 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 2 -- 1 file changed, 2 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 27/41] slirp: remove unused global slirp_instance
Daniel P. Berrangé, le mer. 14 nov. 2018 13:55:18 +0000, a ecrit:
Quoted 7 lines · Marc-André Lureau
Quoted 4 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 2 -- 1 file changed, 2 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 28/41 slirp: replace error_report() with g_critical()
In reply to Marc-André LureauReduce dependency on QEMU. QEMU could use a custom log handler if it wants to redirect/filter it.
--- slirp/ip6_icmp.c | 2 +- slirp/misc.c | 4 ++-- slirp/slirp.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-)
slirp/ip6_icmp.c +1 -1
@@ -418,7 +418,7 @@ void icmp6_input(struct mbuf *m)icmp6_send_echoreply (m, slirp, ip, icmp); }else {/* TODO */ -error_report ("external icmpv6 not supported yet" ); +g_critical ("external icmpv6 not supported yet" ); }break ;
slirp/misc.c +2 -2
@@ -119,7 +119,7 @@ slirp_socketpair_with_oob(int sv[2])return 0 ; err: -error_report ("Error: slirp_socketpair(): %s" ,strerror (errno)); +g_critical ("slirp_socketpair(): %s" ,strerror (errno));if (s >=0 ) {closesocket (s); }
@@ -162,7 +162,7 @@ fork_exec(struct socket *so, const char *ex)g_strfreev (argv);if (err) { -error_report ("%s" , err->message); +g_critical ("fork_exec: %s" , err->message);g_error_free (err);closesocket (sp[0 ]);closesocket (sp[1 ]);
slirp/slirp.c +3 -3
@@ -1215,8 +1215,8 @@ static int sbuf_tmp_post_load(void *opaque, int version) }if (tmp->woff >= requested_len || tmp->roff >= requested_len) { -error_report ("invalid sbuf offsets r/w=%u/%u len=%u" , - tmp->roff, tmp->woff, requested_len); +g_critical ("invalid sbuf offsets r/w=%u/%u len=%u" , + tmp->roff, tmp->woff, requested_len);return -EINVAL ; }
@@ -1324,7 +1324,7 @@ static int ss_family_post_load(void *opaque, int version_id) tss->parent->ss.ss_family =AF_INET6 ;break ;default : -error_report ("invalid ss_family type %x" , tss->portable_family); +g_critical ("invalid ss_family type %x" , tss->portable_family);return -EINVAL ; }
Signature · 1 line
2.19.1.708.g4ede3d42df
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 28/41] slirp: replace error_report() with g_critical()
Marc-André Lureau, le mer. 14 nov. 2018 16:36:30 +0400, a ecrit:
Quoted 4 lines
Reduce dependency on QEMU. QEMU could use a custom log handler if it wants to redirect/filter it.
Signed-off-by Marc-André Lureau <[email protected]>
Applied to my tree, thanks!
PATCH 29/41 slirp: improve a bit the debug macros
In reply to Marc-André LureauLet them accept multiple arguments. Simplify the inner argument handling of DEBUG_ARGS/DEBUG_MISC_DEBUG_ERROR.
--- slirp/debug.h | 47 ++++++++++++++++++++++++++++++++++++---------- slirp/arp_table.c | 12 ++++++------ slirp/bootp.c | 3 +-- slirp/cksum.c | 4 ++-- slirp/dhcpv6.c | 11 +++++------ slirp/ip6_icmp.c | 2 +- slirp/ip_icmp.c | 18 +++++++++--------- slirp/mbuf.c | 2 +- slirp/ndp_table.c | 18 +++++++++--------- slirp/slirp.c | 12 ++++++------ slirp/socket.c | 32 +++++++++++++++---------------- slirp/tcp_input.c | 15 +++++++-------- slirp/tcp_output.c | 2 +- slirp/tcp_subr.c | 4 ++-- slirp/udp.c | 6 +++--- slirp/udp6.c | 6 +++--- 16 files changed, 109 insertions(+), 85 deletions(-)
slirp/debug.h +37 -10
@@ -17,18 +17,45 @@extern int slirp_debug; -#define DEBUG_CALL (x) if (slirp_debug & DBG_CALL) { fprintf(dfd, "%s...\n", x); fflush(dfd); } -#define DEBUG_ARG (x, y) if (slirp_debug & DBG_CALL) { fputc(' ', dfd); fprintf(dfd, x, y); fputc('\n', dfd); fflush(dfd); } -#define DEBUG_ARGS (x) if (slirp_debug & DBG_CALL) { fprintf x ; fflush(dfd); } -#define DEBUG_MISC (x) if (slirp_debug & DBG_MISC) { fprintf x ; fflush(dfd); } -#define DEBUG_ERROR (x) if (slirp_debug & DBG_ERROR) {fprintf x ; fflush(dfd); } +#define DEBUG_CALL (fmt, ...) do { \ + if (slirp_debug & DBG_CALL) { \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fprintf(dfd, "...\n"); \ + fflush(dfd); \ + } \ +} while (0) + +#define DEBUG_ARG (fmt, ...) do { \ + if (slirp_debug & DBG_CALL) { \ + fputc(' ', dfd); \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fputc('\n', dfd); \ + fflush(dfd); \ + } \ +} while (0) + +#define DEBUG_ARGS (fmt, ...) DEBUG_ARG(fmt, ##__VA_ARGS__) + +#define DEBUG_MISC (fmt, ...) do { \ + if (slirp_debug & DBG_MISC) { \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fflush(dfd); \ + } \ +} while (0) + +#define DEBUG_ERROR (fmt, ...) do { \ + if (slirp_debug & DBG_ERROR) { \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fflush(dfd); \ + } \ +} while (0)#else -#define DEBUG_CALL (x) -#define DEBUG_ARG (x, y) -#define DEBUG_ARGS (x) -#define DEBUG_MISC (x) -#define DEBUG_ERROR (x) +#define DEBUG_CALL (fmt, ...) +#define DEBUG_ARG (fmt, ...) +#define DEBUG_ARGS (fmt, ...) +#define DEBUG_MISC (fmt, ...) +#define DEBUG_ERROR (fmt, ...)#endif
slirp/arp_table.c +6 -6
@@ -34,9 +34,9 @@ void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN])DEBUG_CALL ("arp_table_add" );DEBUG_ARG ("ip = %s" ,inet_ntoa ((struct in_addr ){.s_addr = ip_addr})); -DEBUG_ARGS ((dfd," hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , - ethaddr[0 ], ethaddr[1 ], ethaddr[2 ], - ethaddr[3 ], ethaddr[4 ], ethaddr[5 ])); +DEBUG_ARGS (" hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , + ethaddr[0 ], ethaddr[1 ], ethaddr[2 ], + ethaddr[3 ], ethaddr[4 ], ethaddr[5 ]);if (ip_addr ==0 || ip_addr ==0xffffffff || ip_addr == broadcast_addr) {/* Do not register broadcast addresses */
@@ -79,9 +79,9 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,for (i =0 ; i <ARP_TABLE_SIZE ; i++) {if (arptbl->table[i].ar_sip == ip_addr) {memcpy (out_ethaddr, arptbl->table[i].ar_sha,ETH_ALEN ); -DEBUG_ARGS ((dfd," found hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , - out_ethaddr[0 ], out_ethaddr[1 ], out_ethaddr[2 ], - out_ethaddr[3 ], out_ethaddr[4 ], out_ethaddr[5 ])); +DEBUG_ARGS (" found hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , + out_ethaddr[0 ], out_ethaddr[1 ], out_ethaddr[2 ], + out_ethaddr[3 ], out_ethaddr[4 ], out_ethaddr[5 ]);return 1 ; } }
slirp/bootp.c +1 -2
@@ -37,8 +37,7 @@static const uint8_t rfc1533_cookie[] = {RFC1533_COOKIE };#ifdef DEBUG -#define DPRINTF (fmt, ...) \ -do if (slirp_debug & DBG_CALL) { fprintf(dfd, fmt, ## __VA_ARGS__); fflush(dfd); } while (0) +#define DPRINTF (fmt, ...) DEBUG_CALL(fmt, ##__VA_ARGS__)#else #define DPRINTF (fmt, ...) do{}while(0)#endif
slirp/cksum.c +2 -2
@@ -124,8 +124,8 @@ int cksum(struct mbuf *m, int len) cont:#ifdef DEBUG if (len) { -DEBUG_ERROR ((dfd,"cksum: out of data\n" )); -DEBUG_ERROR ((dfd," len = %d\n" , len)); +DEBUG_ERROR ("cksum: out of data\n" ); +DEBUG_ERROR (" len = %d\n" , len); }#endif if (mlen ==-1 ) {
slirp/dhcpv6.c +5 -6
@@ -92,14 +92,14 @@ static int dhcpv6_parse_info_request(uint8_t *odata, int olen, ri->want_boot_url = true;break ;default : -DEBUG_MISC ((dfd,"dhcpv6: Unsupported option request %d\n" , - req_opt)); +DEBUG_MISC ("dhcpv6: Unsupported option request %d\n" , + req_opt); } }break ;default : -DEBUG_MISC ((dfd,"dhcpv6 info req: Unsupported option %d, len=%d\n" , - option, len)); +DEBUG_MISC ("dhcpv6 info req: Unsupported option %d, len=%d\n" , + option, len); } odata += len +4 ;
@@ -203,7 +203,6 @@ void dhcpv6_input(struct sockaddr_in6 *srcsas, struct mbuf *m)dhcpv6_info_request (m->slirp, srcsas, xid, &data[4 ], data_len -4 );break ;default : -DEBUG_MISC ((dfd,"dhcpv6_input: Unsupported message type 0x%x\n" , - data[0 ])); +DEBUG_MISC ("dhcpv6_input: Unsupported message type 0x%x\n" , data[0 ]); } }
slirp/ip6_icmp.c +1 -1
@@ -77,7 +77,7 @@ void icmp6_send_error(struct mbuf *m, uint8_t type, uint8_t code) struct ip6 *ip = mtod(m, struct ip6 *);DEBUG_CALL ("icmp6_send_error" ); -DEBUG_ARGS ((dfd," type = %d, code = %d\n" , type, code)); +DEBUG_ARGS (" type = %d, code = %d\n" , type, code);if (IN6_IS_ADDR_MULTICAST (&ip->ip_src) ||in6_zero (&ip->ip_src)) {
slirp/ip_icmp.c +9 -9
@@ -99,8 +99,8 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen)if (sendto (so->s, m->m_data + hlen, m->m_len - hlen,0 , (struct sockaddr *)&addr,sizeof (addr)) ==-1 ) { -DEBUG_MISC ((dfd,"icmp_input icmp sendto tx errno = %d-%s\n" , - errno,strerror (errno))); +DEBUG_MISC ("icmp_input icmp sendto tx errno = %d-%s\n" , + errno,strerror (errno));icmp_send_error (m,ICMP_UNREACH ,ICMP_UNREACH_NET ,0 ,strerror (errno));icmp_detach (so); }
@@ -165,8 +165,8 @@ icmp_input(struct mbuf *m, int hlen)return ; }if (udp_attach (so,AF_INET ) ==-1 ) { -DEBUG_MISC ((dfd,"icmp_input udp_attach errno = %d-%s\n" , - errno,strerror (errno))); +DEBUG_MISC ("icmp_input udp_attach errno = %d-%s\n" , + errno,strerror (errno));sofree (so);m_free (m); goto end_error;
@@ -188,8 +188,8 @@ icmp_input(struct mbuf *m, int hlen)if (sendto (so->s, icmp_ping_msg,strlen (icmp_ping_msg),0 , (struct sockaddr *)&addr,sockaddr_size (&addr)) ==-1 ) { -DEBUG_MISC ((dfd,"icmp_input udp sendto tx errno = %d-%s\n" , - errno,strerror (errno))); +DEBUG_MISC ("icmp_input udp sendto tx errno = %d-%s\n" , + errno,strerror (errno));icmp_send_error (m,ICMP_UNREACH ,ICMP_UNREACH_NET ,0 ,strerror (errno));udp_detach (so); }
@@ -257,7 +257,7 @@ icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize, {char bufa[20 ], bufb[20 ];strcpy (bufa,inet_ntoa (ip->ip_src));strcpy (bufb,inet_ntoa (ip->ip_dst)); -DEBUG_MISC ((dfd," %.16s to %.16s\n" , bufa, bufb)); +DEBUG_MISC (" %.16s to %.16s\n" , bufa, bufb); }#endif if (ip->ip_off &IP_OFFMASK ) goto end_error;/* Only reply to fragment 0 */
@@ -457,8 +457,8 @@ void icmp_receive(struct socket *so) }else { error_code =ICMP_UNREACH_HOST ; } -DEBUG_MISC ((dfd," udp icmp rx errno = %d-%s\n" , errno, -strerror (errno))); +DEBUG_MISC (" udp icmp rx errno = %d-%s\n" , errno, +strerror (errno));icmp_send_error (so->so_m,ICMP_UNREACH , error_code,0 ,strerror (errno)); }else {icmp_reflect (so->so_m);
slirp/mbuf.c +1 -1
@@ -232,7 +232,7 @@ dtom(Slirp *slirp, void *dat) } } -DEBUG_ERROR ((dfd,"dtom failed" )); +DEBUG_ERROR ("dtom failed" );return (struct mbuf *)0 ; }
slirp/ndp_table.c +9 -9
@@ -19,9 +19,9 @@ void ndp_table_add(Slirp *slirp, struct in6_addr ip_addr,inet_ntop (AF_INET6 , &(ip_addr), addrstr,INET6_ADDRSTRLEN );DEBUG_ARG ("ip = %s" , addrstr);#endif -DEBUG_ARGS ((dfd," hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , - ethaddr[0 ], ethaddr[1 ], ethaddr[2 ], - ethaddr[3 ], ethaddr[4 ], ethaddr[5 ])); +DEBUG_ARGS (" hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , + ethaddr[0 ], ethaddr[1 ], ethaddr[2 ], + ethaddr[3 ], ethaddr[4 ], ethaddr[5 ]);if (IN6_IS_ADDR_MULTICAST (&ip_addr) ||in6_zero (&ip_addr)) {/* Do not register multicast or unspecified addresses */
@@ -69,18 +69,18 @@ bool ndp_table_search(Slirp *slirp, struct in6_addr ip_addr, out_ethaddr[3 ] = ip_addr.s6_addr[13 ]; out_ethaddr[4 ] = ip_addr.s6_addr[14 ]; out_ethaddr[5 ] = ip_addr.s6_addr[15 ]; -DEBUG_ARGS ((dfd," multicast addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , - out_ethaddr[0 ], out_ethaddr[1 ], out_ethaddr[2 ], - out_ethaddr[3 ], out_ethaddr[4 ], out_ethaddr[5 ])); +DEBUG_ARGS (" multicast addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , + out_ethaddr[0 ], out_ethaddr[1 ], out_ethaddr[2 ], + out_ethaddr[3 ], out_ethaddr[4 ], out_ethaddr[5 ]);return 1 ; }for (i =0 ; i <NDP_TABLE_SIZE ; i++) {if (in6_equal (&ndp_table->table[i].ip_addr, &ip_addr)) {memcpy (out_ethaddr, ndp_table->table[i].eth_addr,ETH_ALEN ); -DEBUG_ARGS ((dfd," found hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , - out_ethaddr[0 ], out_ethaddr[1 ], out_ethaddr[2 ], - out_ethaddr[3 ], out_ethaddr[4 ], out_ethaddr[5 ])); +DEBUG_ARGS (" found hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , + out_ethaddr[0 ], out_ethaddr[1 ], out_ethaddr[2 ], + out_ethaddr[3 ], out_ethaddr[4 ], out_ethaddr[5 ]);return 1 ; } }
slirp/slirp.c +6 -6
@@ -985,12 +985,12 @@ int if_encap(Slirp *slirp, struct mbuf *ifm) }memcpy (eh->h_dest, ethaddr,ETH_ALEN ); -DEBUG_ARGS ((dfd," src = %02x:%02x:%02x:%02x:%02x:%02x\n" , - eh->h_source[0 ], eh->h_source[1 ], eh->h_source[2 ], - eh->h_source[3 ], eh->h_source[4 ], eh->h_source[5 ])); -DEBUG_ARGS ((dfd," dst = %02x:%02x:%02x:%02x:%02x:%02x\n" , - eh->h_dest[0 ], eh->h_dest[1 ], eh->h_dest[2 ], - eh->h_dest[3 ], eh->h_dest[4 ], eh->h_dest[5 ])); +DEBUG_ARGS (" src = %02x:%02x:%02x:%02x:%02x:%02x\n" , + eh->h_source[0 ], eh->h_source[1 ], eh->h_source[2 ], + eh->h_source[3 ], eh->h_source[4 ], eh->h_source[5 ]); +DEBUG_ARGS (" dst = %02x:%02x:%02x:%02x:%02x:%02x\n" , + eh->h_dest[0 ], eh->h_dest[1 ], eh->h_dest[2 ], + eh->h_dest[3 ], eh->h_dest[4 ], eh->h_dest[5 ]);memcpy (buf +sizeof (struct ethhdr ), ifm->m_data, ifm->m_len); slirp->cb->output (slirp->opaque, buf, ifm->m_len +ETH_HLEN );return 1 ;
slirp/socket.c +16 -16
@@ -208,7 +208,7 @@ soread(struct socket *so) } } -DEBUG_MISC ((dfd," --- soread() disconnected, nn = %d, errno = %d-%s\n" , nn, errno,strerror (errno))); +DEBUG_MISC (" --- soread() disconnected, nn = %d, errno = %d-%s\n" , nn, errno,strerror (errno));sofcantrcvmore (so); if (err == ECONNRESET || err == ECONNREFUSED
@@ -237,7 +237,7 @@ soread(struct socket *so) nn += ret; } -DEBUG_MISC ((dfd," ... read nn = %d bytes\n" , nn)); +DEBUG_MISC (" ... read nn = %d bytes\n" , nn);/* Update fields */ sb->sb_cc += nn;
@@ -370,7 +370,7 @@ sosendoob(struct socket *so) n =slirp_send (so, buff, len, (MSG_OOB ));/* |MSG_DONTWAIT)); */ #ifdef DEBUG if (n != len) { -DEBUG_ERROR ((dfd,"Didn't send all data urgently XXXXX\n" )); +DEBUG_ERROR ("Didn't send all data urgently XXXXX\n" ); }#endif }
@@ -379,7 +379,7 @@ sosendoob(struct socket *so)return n; } so->so_urgc -= n; -DEBUG_MISC ((dfd," ---2 sent %d bytes urgent data, %d urgent bytes left\n" , n, so->so_urgc)); +DEBUG_MISC (" ---2 sent %d bytes urgent data, %d urgent bytes left\n" , n, so->so_urgc); sb->sb_cc -= n; sb->sb_rptr += n;
@@ -460,7 +460,7 @@ sowrite(struct socket *so)if (ret >0 ) nn += ret; } -DEBUG_MISC ((dfd," ... wrote nn = %d bytes\n" , nn)); +DEBUG_MISC (" ... wrote nn = %d bytes\n" , nn);/* Update sbuf */ sb->sb_cc -= nn;
@@ -478,8 +478,8 @@ sowrite(struct socket *so)return nn; err_disconnected: -DEBUG_MISC ((dfd," --- sowrite disconnected, so->so_state = %x, errno = %d\n" , - so->so_state, errno)); +DEBUG_MISC (" --- sowrite disconnected, so->so_state = %x, errno = %d\n" , + so->so_state, errno);sofcantsendmore (so);tcp_sockclosed (sototcpcb (so));return -1 ;
@@ -512,8 +512,8 @@ sorecvfrom(struct socket *so)if (errno ==EHOSTUNREACH ) code=ICMP_UNREACH_HOST ;else if (errno ==ENETUNREACH ) code=ICMP_UNREACH_NET ; -DEBUG_MISC ((dfd," udp icmp rx errno = %d-%s\n" , - errno,strerror (errno))); +DEBUG_MISC (" udp icmp rx errno = %d-%s\n" , + errno,strerror (errno));icmp_send_error (so->so_m,ICMP_UNREACH , code,0 ,strerror (errno)); }else {icmp_reflect (so->so_m);
@@ -564,8 +564,8 @@ sorecvfrom(struct socket *so) m->m_len =recvfrom (so->s, m->m_data, len,0 , (struct sockaddr *)&addr, &addrlen); -DEBUG_MISC ((dfd," did recvfrom %d, errno = %d-%s\n" , - m->m_len, errno,strerror (errno))); +DEBUG_MISC (" did recvfrom %d, errno = %d-%s\n" , + m->m_len, errno,strerror (errno));if (m->m_len<0 ) {/* Report error as ICMP */ switch (so->so_lfamily) {
@@ -579,7 +579,7 @@ sorecvfrom(struct socket *so) code =ICMP_UNREACH_NET ; } -DEBUG_MISC ((dfd," rx error, tx icmp ICMP_UNREACH:%i\n" , code)); +DEBUG_MISC (" rx error, tx icmp ICMP_UNREACH:%i\n" , code);icmp_send_error (so->so_m,ICMP_UNREACH , code,0 ,strerror (errno));break ;case AF_INET6 :
@@ -591,7 +591,7 @@ sorecvfrom(struct socket *so) code =ICMP6_UNREACH_NO_ROUTE ; } -DEBUG_MISC ((dfd," rx error, tx icmp6 ICMP_UNREACH:%i\n" , code)); +DEBUG_MISC (" rx error, tx icmp6 ICMP_UNREACH:%i\n" , code);icmp6_send_error (so->so_m,ICMP6_UNREACH , code);break ;default :
@@ -839,9 +839,9 @@ void sotranslate_out(struct socket *so, struct sockaddr_storage *addr) } } -DEBUG_MISC ((dfd," addr.sin_port=%d, " -"addr.sin_addr.s_addr=%.16s\n" , -ntohs (sin->sin_port),inet_ntoa (sin->sin_addr))); +DEBUG_MISC (" addr.sin_port=%d, " +"addr.sin_addr.s_addr=%.16s\n" , +ntohs (sin->sin_port),inet_ntoa (sin->sin_addr));break ;case AF_INET6 :
slirp/tcp_input.c +7 -8
@@ -236,8 +236,8 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af)Slirp *slirp;DEBUG_CALL ("tcp_input" ); -DEBUG_ARGS ((dfd," m = %p iphlen = %2d inso = %p\n" , - m, iphlen, inso)); +DEBUG_ARGS (" m = %p iphlen = %2d inso = %p\n" , + m, iphlen, inso);/* * If called with m == 0, then we're continuing the connect
@@ -662,8 +662,8 @@ findso: (errno != EINPROGRESS) && (errno != EWOULDBLOCK) ) {uint8_t code; -DEBUG_MISC ((dfd," tcp fconnect errno = %d-%s\n" , - errno,strerror (errno))); +DEBUG_MISC (" tcp fconnect errno = %d-%s\n" , + errno,strerror (errno));if (errno ==ECONNREFUSED ) {/* ACK the SYN, send RST to refuse the connection */ tcp_respond(tp, ti, m, ti->ti_seq + 1, (tcp_seq) 0,
@@ -1032,8 +1032,7 @@ trimthenstep6:if (SEQ_LEQ (ti->ti_ack, tp->snd_una)) {if (ti->ti_len ==0 && tiwin == tp->snd_wnd) { -DEBUG_MISC ((dfd," dup ack m = %p so = %p\n" , - m, so)); +DEBUG_MISC (" dup ack m = %p so = %p\n" , m, so);/* * If we have outstanding data (other than * a window probe), this is a completely
@@ -1411,7 +1410,7 @@ tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)int opt, optlen;DEBUG_CALL ("tcp_dooptions" ); -DEBUG_ARGS ((dfd," tp = %p cnt=%i\n" , tp, cnt)); +DEBUG_ARGS (" tp = %p cnt=%i\n" , tp, cnt);for (; cnt >0 ; cnt -= optlen, cp += optlen) { opt = cp[0 ];
@@ -1611,7 +1610,7 @@ tcp_mss(struct tcpcb *tp, u_int offer) (mss - (TCP_RCVSPACE % mss)) : 0)); -DEBUG_MISC ((dfd," returning mss = %d\n" , mss)); +DEBUG_MISC (" returning mss = %d\n" , mss);return mss; }
slirp/tcp_output.c +1 -1
@@ -92,7 +92,7 @@ again: flags = tcp_outflags[tp->t_state]; -DEBUG_MISC ((dfd," --- tcp_output flags = 0x%x\n" ,flags)); +DEBUG_MISC (" --- tcp_output flags = 0x%x\n" , flags);/* * If in persist timeout with window of 0, send 1 byte.
slirp/tcp_subr.c +2 -2
@@ -420,7 +420,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)qemu_setsockopt (s,IPPROTO_TCP ,TCP_NODELAY , &opt,sizeof (opt)); addr = so->fhost.ss; - DEBUG_CALL(" connect()ing") +DEBUG_CALL (" connect()ing" );sotranslate_out (so, &addr);/* We don't care what port we get */
@@ -964,7 +964,7 @@ int tcp_ctl(struct socket *so) so->chardev = ex_ptr->ex_chardev;return 1 ; } -DEBUG_MISC ((dfd," executing %s\n" , ex_ptr->ex_exec)); +DEBUG_MISC (" executing %s\n" , ex_ptr->ex_exec);return fork_exec (so, ex_ptr->ex_exec); } }
slirp/udp.c +3 -3
@@ -172,8 +172,8 @@ udp_input(register struct mbuf *m, int iphlen)*/ so =socreate (slirp);if (udp_attach (so,AF_INET ) ==-1 ) { -DEBUG_MISC ((dfd," udp_attach errno = %d-%s\n" , - errno,strerror (errno))); +DEBUG_MISC (" udp_attach errno = %d-%s\n" , + errno,strerror (errno));sofree (so); goto bad; }
@@ -209,7 +209,7 @@ udp_input(register struct mbuf *m, int iphlen) m->m_len += iphlen; m->m_data -= iphlen; *ip=save_ip; -DEBUG_MISC ((dfd,"udp tx errno = %d-%s\n" ,errno,strerror (errno))); +DEBUG_MISC ("udp tx errno = %d-%s\n" , errno,strerror (errno));icmp_send_error (m,ICMP_UNREACH ,ICMP_UNREACH_NET ,0 ,strerror (errno)); goto bad;
slirp/udp6.c +3 -3
@@ -92,8 +92,8 @@ void udp6_input(struct mbuf *m)/* If there's no socket for this packet, create one. */ so =socreate (slirp);if (udp_attach (so,AF_INET6 ) ==-1 ) { -DEBUG_MISC ((dfd," udp6_attach errno = %d-%s\n" , - errno,strerror (errno))); +DEBUG_MISC (" udp6_attach errno = %d-%s\n" , + errno,strerror (errno));sofree (so); goto bad; }
@@ -119,7 +119,7 @@ void udp6_input(struct mbuf *m) m->m_len += iphlen; m->m_data -= iphlen; *ip = save_ip; -DEBUG_MISC ((dfd,"udp tx errno = %d-%s\n" , errno,strerror (errno))); +DEBUG_MISC ("udp tx errno = %d-%s\n" , errno,strerror (errno));icmp6_send_error (m,ICMP6_UNREACH ,ICMP6_UNREACH_NO_ROUTE ); goto bad; }
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 29/41] slirp: improve a bit the debug macros
Quoted 58 lines · Marc-André Lureau
Let them accept multiple arguments. Simplify the inner argument handling of DEBUG_ARGS/DEBUG_MISC_DEBUG_ERROR.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/debug.h | 47 ++++++++++++++++++++++++++++++++++++---------- slirp/arp_table.c | 12 ++++++------ slirp/bootp.c | 3 +-- slirp/cksum.c | 4 ++-- slirp/dhcpv6.c | 11 +++++------ slirp/ip6_icmp.c | 2 +- slirp/ip_icmp.c | 18 +++++++++--------- slirp/mbuf.c | 2 +- slirp/ndp_table.c | 18 +++++++++--------- slirp/slirp.c | 12 ++++++------ slirp/socket.c | 32 +++++++++++++++---------------- slirp/tcp_input.c | 15 +++++++-------- slirp/tcp_output.c | 2 +- slirp/tcp_subr.c | 4 ++-- slirp/udp.c | 6 +++--- slirp/udp6.c | 6 +++--- 16 files changed, 109 insertions(+), 85 deletions(-)slirp/debug.h +22
-5@@ -17,18 +17,45 @@extern int slirp_debug; -#define DEBUG_CALL (x) if (slirp_debug & DBG_CALL) { fprintf(dfd, "%s...\n", x); fflush(dfd); } -#define DEBUG_ARG (x, y) if (slirp_debug & DBG_CALL) { fputc(' ', dfd); fprintf(dfd, x, y); fputc('\n', dfd); fflush(dfd); } -#define DEBUG_ARGS (x) if (slirp_debug & DBG_CALL) { fprintf x ; fflush(dfd); } -#define DEBUG_MISC (x) if (slirp_debug & DBG_MISC) { fprintf x ; fflush(dfd); } -#define DEBUG_ERROR (x) if (slirp_debug & DBG_ERROR) {fprintf x ; fflush(dfd); } +#define DEBUG_CALL (fmt, ...) do { \ + if (slirp_debug & DBG_CALL) { \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fprintf(dfd, "...\n"); \ + fflush(dfd); \ + } \ +} while (0) + +#define DEBUG_ARG (fmt, ...) do { \ + if (slirp_debug & DBG_CALL) { \ + fputc(' ', dfd); \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fputc('\n', dfd); \ + fflush(dfd); \ + } \ +} while (0) + +#define DEBUG_ARGS (fmt, ...) DEBUG_ARG(fmt, ##__VA_ARGS__) + +#define DEBUG_MISC (fmt, ...) do { \ + if (slirp_debug & DBG_MISC) { \ + fprintf(dfd, fmt, ##__VA_ARGS__); \
slirp/debug.h line 51
Quoted 10 lines
slirp/debug.h +10
-0+fflush (dfd); \ + } \ +} while (0) + +#define DEBUG_ERROR (fmt, ...) do { \ + if (slirp_debug & DBG_ERROR) { \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fflush(dfd); \ + } \ +} while (0)
I tend to think it would be nicer to change these to use g_debug, and #define G_LOG_DOMAIN "libslirp" in the .c files.
This would allow apps to intercept the debug messages via a custom log handler.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [Qemu-devel] [PATCH for-3.2 29/41] slirp: improve a bit the debug macros
Hi
Quoted 75 lines · Daniel P. Berrangé
Quoted 58 lines · Marc-André Lureau
Let them accept multiple arguments. Simplify the inner argument handling of DEBUG_ARGS/DEBUG_MISC_DEBUG_ERROR.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/debug.h | 47 ++++++++++++++++++++++++++++++++++++---------- slirp/arp_table.c | 12 ++++++------ slirp/bootp.c | 3 +-- slirp/cksum.c | 4 ++-- slirp/dhcpv6.c | 11 +++++------ slirp/ip6_icmp.c | 2 +- slirp/ip_icmp.c | 18 +++++++++--------- slirp/mbuf.c | 2 +- slirp/ndp_table.c | 18 +++++++++--------- slirp/slirp.c | 12 ++++++------ slirp/socket.c | 32 +++++++++++++++---------------- slirp/tcp_input.c | 15 +++++++-------- slirp/tcp_output.c | 2 +- slirp/tcp_subr.c | 4 ++-- slirp/udp.c | 6 +++--- slirp/udp6.c | 6 +++--- 16 files changed, 109 insertions(+), 85 deletions(-)slirp/debug.h +22
-5@@ -17,18 +17,45 @@extern int slirp_debug; -#define DEBUG_CALL (x) if (slirp_debug & DBG_CALL) { fprintf(dfd, "%s...\n", x); fflush(dfd); } -#define DEBUG_ARG (x, y) if (slirp_debug & DBG_CALL) { fputc(' ', dfd); fprintf(dfd, x, y); fputc('\n', dfd); fflush(dfd); } -#define DEBUG_ARGS (x) if (slirp_debug & DBG_CALL) { fprintf x ; fflush(dfd); } -#define DEBUG_MISC (x) if (slirp_debug & DBG_MISC) { fprintf x ; fflush(dfd); } -#define DEBUG_ERROR (x) if (slirp_debug & DBG_ERROR) {fprintf x ; fflush(dfd); } +#define DEBUG_CALL (fmt, ...) do { \ + if (slirp_debug & DBG_CALL) { \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fprintf(dfd, "...\n"); \ + fflush(dfd); \ + } \ +} while (0) + +#define DEBUG_ARG (fmt, ...) do { \ + if (slirp_debug & DBG_CALL) { \ + fputc(' ', dfd); \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fputc('\n', dfd); \ + fflush(dfd); \ + } \ +} while (0) + +#define DEBUG_ARGS (fmt, ...) DEBUG_ARG(fmt, ##__VA_ARGS__) + +#define DEBUG_MISC (fmt, ...) do { \ + if (slirp_debug & DBG_MISC) { \ + fprintf(dfd, fmt, ##__VA_ARGS__); \slirp/debug.h line 51
Quoted 10 lines
slirp/debug.h +10
-0+fflush (dfd); \ + } \ +} while (0) + +#define DEBUG_ERROR (fmt, ...) do { \ + if (slirp_debug & DBG_ERROR) { \ + fprintf(dfd, fmt, ##__VA_ARGS__); \ + fflush(dfd); \ + } \ +} while (0)I tend to think it would be nicer to change these to use
g_debug, and #defineG_LOG_DOMAIN"libslirp" in the .c files.
Quoted 2 lines
This would allow apps to intercept the debug messages via a custom log handler.
Yes, even better would be structured logging, but it requires glib 2.50
One issue with the replacement is that we may want to keep the slirp_debug filtering. If not, then we lose the classification. Second issue is that slirp issues several debug calls and write \n in the end. This is something you can't do with g_log. So it would need some debug calls rewrite.
I would like to see this clean up patch applied before we decide how to replace it with glog.
And yes, we should have a Slirp G_LOG_DOMAIN (I meant to do that, and forgot)
Quoted 7 lines
Regards,
Daniel
--|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 29/41] slirp: improve a bit the debug macros
In reply to Marc-André LureauMarc-André Lureau, le mer. 14 nov. 2018 16:36:31 +0400, a ecrit:
Quoted 4 lines
Let them accept multiple arguments. Simplify the inner argument handling of DEBUG_ARGS/DEBUG_MISC_DEBUG_ERROR.
Signed-off-by Marc-André Lureau <[email protected]>
Applied to my tree, thanks!
PATCH 30/41 slirp: replace trace functions with DEBUG calls
In reply to Marc-André LureauRemove a dependency on QEMU. Use the existing logging facilities.
--- slirp/tftp.c | 7 ++++--- Makefile.objs | 1 - slirp/trace-events | 5 ----- 3 files changed, 4 insertions(+), 9 deletions(-) delete mode 100644 slirp/trace-events
slirp/tftp.c +4 -3
@@ -26,7 +26,6 @@#include "slirp.h" #include "qemu-common.h" #include "qemu/cutils.h" -#include "trace.h" static inline int tftp_session_in_use (struct tftp_session *spt) {
@@ -205,7 +204,8 @@ static void tftp_send_error(struct tftp_session *spt,struct mbuf *m;struct tftp_t *tp; -trace_slirp_tftp_error (msg); +DEBUG_ERROR ("tftp error msg: %s" , msg); + m =m_get (spt->slirp);if (!m) {
@@ -325,7 +325,8 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,break ; } } -trace_slirp_tftp_rrq (req_fname); + +DEBUG_MISC ("tftp rrq file: %s" , req_fname);/* check mode */ if ((pktlen - k) <6 ) {
Makefile.objs +0 -1
@@ -251,7 +251,6 @@ trace-events-subdirs += net trace-events-subdirs += qapi trace-events-subdirs += qom trace-events-subdirs += scsi -trace-events-subdirs += slirp trace-events-subdirs += target/arm trace-events-subdirs += target/i386 trace-events-subdirs += target/mips
slirp/trace-events deleted +0 -5
@@ -1,5 +0,0 @@ -# See docs/devel/tracing.txt for syntax documentation. - -# slirp/tftp.c -slirp_tftp_rrq(const char *file) "file: %s" -slirp_tftp_error(const char *file) "msg: %s"
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 30/41] slirp: replace trace functions with DEBUG calls
Marc-André Lureau, le mer. 14 nov. 2018 16:36:32 +0400, a ecrit:
Quoted 1 line
Remove a dependency on QEMU. Use the existing logging facilities.
I'm hesitating on this one: this is not really a debugging print (as in qemu debugging), but a real user debugging print. We do want to compile this in without DEBUG defined.
Samuel
PATCH 31/41 slirp: add a callback to log guest errors
In reply to Marc-André Lureau--- slirp/libslirp.h | 1 + net/slirp.c | 7 +++++++ slirp/dhcpv6.c | 6 +++--- slirp/ip6_icmp.c | 7 +++---- 4 files changed, 14 insertions(+), 7 deletions(-)
slirp/libslirp.h +1 -0
@@ -21,6 +21,7 @@ typedef struct SlirpCb {void (*timer_free)(void *timer);void (*timer_mod)(void *timer,int64_t expire_timer);void (*set_nonblock)(int fd); +void (*guest_error)(const char *msg); } SlirpCb;
net/slirp.c +7 -0
@@ -23,6 +23,7 @@*/ #include "qemu/osdep.h" +#include "qemu/log.h" #include "net/slirp.h"
@@ -183,6 +184,11 @@ static void net_slirp_timer_mod(void *timer, int64_t expire_timer)timer_mod (timer, expire_timer); } +static void net_slirp_guest_error (const char *msg) +{ +qemu_log_mask (LOG_GUEST_ERROR ,"%s" , msg); +} +static SlirpCb slirp_cb = { .output = net_slirp_output, .chr_write_all = net_slirp_chr_write_all,
@@ -191,6 +197,7 @@ static SlirpCb slirp_cb = { .timer_free = net_slirp_timer_free, .timer_mod = net_slirp_timer_mod, .set_nonblock = qemu_set_nonblock, + .guest_error = net_slirp_guest_error, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/dhcpv6.c +3 -3
@@ -50,7 +50,7 @@ struct requested_infos {* the odata region, thus the caller must keep odata valid as long as it * needs to access the requested_infos struct. */ -static int dhcpv6_parse_info_request (uint8_t *odata,int olen, +static int dhcpv6_parse_info_request (Slirp *slirp,uint8_t *odata,int olen,struct requested_infos *ri) {int i, req_opt;
@@ -61,7 +61,7 @@ static int dhcpv6_parse_info_request(uint8_t *odata, int olen,int len = odata[2 ] <<8 | odata[3 ];if (len +4 > olen) { -qemu_log_mask (LOG_GUEST_ERROR ,"Guest sent bad DHCPv6 packet!\n" ); + slirp->cb->guest_error ("Guest sent bad DHCPv6 packet!" );return -E2BIG ; }
@@ -121,7 +121,7 @@ static void dhcpv6_info_request(Slirp *slirp, struct sockaddr_in6 *srcsas,struct mbuf *m;uint8_t *resp; -if (dhcpv6_parse_info_request (odata, olen, &ri) <0 ) { +if (dhcpv6_parse_info_request (slirp, odata, olen, &ri) <0 ) {return ; }
slirp/ip6_icmp.c +3 -4
@@ -343,8 +343,7 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, struct ip6 *ip,case ICMP6_NDP_RA :DEBUG_CALL (" type = Router Advertisement" ); -qemu_log_mask (LOG_GUEST_ERROR , -"Warning: guest sent NDP RA, but shouldn't" ); + slirp->cb->guest_error ("Warning: guest sent NDP RA, but shouldn't" );break ;case ICMP6_NDP_NS :
@@ -377,8 +376,8 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, struct ip6 *ip,case ICMP6_NDP_REDIRECT :DEBUG_CALL (" type = Redirect" ); -qemu_log_mask (LOG_GUEST_ERROR , -"Warning: guest sent NDP REDIRECT, but shouldn't" ); + slirp->cb->guest_error ( +"Warning: guest sent NDP REDIRECT, but shouldn't" );break ; } }
Signature · 1 line
2.19.1.708.g4ede3d42df
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 31/41] slirp: add a callback to log guest errors
Marc-André Lureau, le mer. 14 nov. 2018 16:36:33 +0400, a ecrit:
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>
Applied to my tree, thanks!
PATCH 32/41 slirp: remove unused sbflush()
In reply to Marc-André Lureau--- slirp/sbuf.h | 1 - 1 file changed, 1 deletion(-)
slirp/sbuf.h +0 -1
@@ -8,7 +8,6 @@#ifndef SBUF_H #define SBUF_H -#define sbflush (sb) sbdrop((sb),(sb)->sb_cc)#define sbspace (sb) ((sb)->sb_datalen - (sb)->sb_cc) struct sbuf {
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 32/41] slirp: remove unused sbflush()
Quoted 4 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/sbuf.h | 1 - 1 file changed, 1 deletion(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 32/41] slirp: remove unused sbflush()
Daniel P. Berrangé, le mer. 14 nov. 2018 14:05:33 +0000, a ecrit:
Quoted 7 lines · Marc-André Lureau
Quoted 4 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/sbuf.h | 1 - 1 file changed, 1 deletion(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 33/41 slirp: replace qemu_notify_event() with a callback
In reply to Marc-André LureauUse a "slirp socket" helper function to call the callback when sbdrop() returns true.
--- slirp/libslirp.h | 1 + slirp/sbuf.h | 2 +- slirp/socket.h | 1 + net/slirp.c | 1 + slirp/sbuf.c | 6 ++++-- slirp/socket.c | 7 +++++++ slirp/tcp_input.c | 6 +++--- 7 files changed, 18 insertions(+), 6 deletions(-)
slirp/libslirp.h +1 -0
@@ -22,6 +22,7 @@ typedef struct SlirpCb {void (*timer_mod)(void *timer,int64_t expire_timer);void (*set_nonblock)(int fd);void (*guest_error)(const char *msg); +void (*notify)(void ); } SlirpCb;
slirp/sbuf.h +1 -1
@@ -21,7 +21,7 @@ struct sbuf { };void sbfree (struct sbuf *); -void sbdrop (struct sbuf *,int ); +bool sbdrop (struct sbuf *,int );void sbreserve (struct sbuf *,int );void sbappend (struct socket *,struct mbuf *);void sbcopy (struct sbuf *,int ,int ,char *);
slirp/socket.h +1 -0
@@ -154,6 +154,7 @@ int soreadbuf(struct socket *so, const char *buf, int size);void sotranslate_out (struct socket *,struct sockaddr_storage *);void sotranslate_in (struct socket *,struct sockaddr_storage *);void sotranslate_accept (struct socket *); +void sodrop (struct socket *,int num);#endif /* SLIRP_SOCKET_H */
net/slirp.c +1 -0
@@ -198,6 +198,7 @@ static SlirpCb slirp_cb = { .timer_mod = net_slirp_timer_mod, .set_nonblock = qemu_set_nonblock, .guest_error = net_slirp_guest_error, + .notify = qemu_notify_event, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/sbuf.c +4 -2
@@ -17,7 +17,7 @@ sbfree(struct sbuf *sb)free (sb->sb_data); } -void +bool sbdrop (struct sbuf *sb,int num) {int limit = sb->sb_datalen /2 ;
@@ -34,8 +34,10 @@ sbdrop(struct sbuf *sb, int num) sb->sb_rptr -= sb->sb_datalen;if (sb->sb_cc < limit && sb->sb_cc + num >= limit) { -qemu_notify_event (); +return true; } + +return false; }void
slirp/socket.c +7 -0
@@ -928,3 +928,10 @@ void sotranslate_accept(struct socket *so)break ; } } + +void sodrop (struct socket *s,int num) +{ +if (sbdrop (&s->so_snd, num)) { + s->slirp->cb->notify (); + } +}
slirp/tcp_input.c +3 -3
@@ -527,7 +527,7 @@ findso: SEQ_GT(ti->ti_ack, tp->t_rtseq))tcp_xmit_timer (tp, tp->t_rtt); acked = ti->ti_ack - tp->snd_una; -sbdrop (&so->so_snd, acked); +sodrop (so, acked); tp->snd_una = ti->ti_ack;m_free (m);
@@ -1140,10 +1140,10 @@ trimthenstep6: }if (acked > so->so_snd.sb_cc) { tp->snd_wnd -= so->so_snd.sb_cc; -sbdrop (&so->so_snd, (int )so->so_snd.sb_cc); +sodrop (so, (int )so->so_snd.sb_cc); ourfinisacked =1 ; }else { -sbdrop (&so->so_snd, acked); +sodrop (so, acked); tp->snd_wnd -= acked; ourfinisacked =0 ; }
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 33/41] slirp: replace qemu_notify_event() with a callback
Marc-André Lureau, le mer. 14 nov. 2018 16:36:35 +0400, a ecrit:
Quoted 2 lines
Use a "slirp socket" helper function to call the callback when
sbdrop()returns true.
It's really far from clear what this should be doing :)
I'd say find out how to rephrase 86073017e384 ("slirp: Signal free input buffer space to io-thread") in a generic way.
Samuel
PATCH 34/41 slirp: remove #if notdef dead code
In reply to Marc-André Lureau--- slirp/ip_input.c | 200 ---------------------------------------------- slirp/tcp_input.c | 39 --------- 2 files changed, 239 deletions(-)
slirp/ip_input.c +0 -200
@@ -447,206 +447,6 @@ ip_slowtimo(Slirp *slirp) } } -/* -* Do option processing on a datagram, -* possibly discarding it if bad options are encountered, -* or forwarding it if source-routed. -* Returns 1 if packet has been forwarded/freed, -* 0 if the packet should be processed further. -*/ - -#ifdef notdef - -int -ip_dooptions (m) -struct mbuf *m; -{ - register struct ip *ip = mtod(m, struct ip *); - registeru_char *cp; - registerstruct ip_timestamp *ipt; - registerstruct in_ifaddr *ia; -int opt, optlen, cnt, off, code, type, forward =0 ; -struct in_addr *sin, dst; -typedef uint32_t n_time ; -n_time ntime; - - dst = ip->ip_dst; - cp = (u_char *)(ip +1 ); - cnt = (ip->ip_hl <<2 ) -sizeof (struct ip ); -for (; cnt >0 ; cnt -= optlen, cp += optlen) { - opt = cp[IPOPT_OPTVAL ]; -if (opt ==IPOPT_EOL ) -break ; -if (opt ==IPOPT_NOP ) - optlen =1 ; -else { - optlen = cp[IPOPT_OLEN ]; -if (optlen <=0 || optlen > cnt) { - code = &cp[IPOPT_OLEN ] - (u_char *)ip; - goto bad; - } - } -switch (opt) { - -default : -break ; - -/* -* Source routing with record. -* Find interface with current destination address. -* If none on this machine then drop if strictly routed, -* or do nothing if loosely routed. -* Record interface address and bring up next address -* component. If strictly routed make sure next -* address is on directly accessible net. -*/ -case IPOPT_LSRR : -case IPOPT_SSRR : -if ((off = cp[IPOPT_OFFSET ]) <IPOPT_MINOFF ) { - code = &cp[IPOPT_OFFSET ] - (u_char *)ip; - goto bad; - } - ipaddr.sin_addr = ip->ip_dst; - ia = (struct in_ifaddr *) -ifa_ifwithaddr ((struct sockaddr *)&ipaddr); -if (ia ==0 ) { -if (opt ==IPOPT_SSRR ) { - type =ICMP_UNREACH ; - code =ICMP_UNREACH_SRCFAIL ; - goto bad; - } -/* -* Loose routing, and not at next destination -* yet; nothing to do except forward. -*/ -break ; - } - off--;/* 0 origin */ -if (off > optlen -sizeof (struct in_addr )) { -/* -* End of source route. Should be for us. -*/ -save_rte (cp, ip->ip_src); -break ; - } -/* -* locate outgoing interface -*/ -bcopy ((caddr_t)(cp + off), (caddr_t)&ipaddr.sin_addr, -sizeof (ipaddr.sin_addr)); -if (opt ==IPOPT_SSRR ) { -#define INA struct in_ifaddr * -#define SA struct sockaddr * -if ((ia = (INA )ifa_ifwithdstaddr ((SA )&ipaddr)) ==0 ) - ia = (INA )ifa_ifwithnet ((SA )&ipaddr); - }else - ia =ip_rtaddr (ipaddr.sin_addr); -if (ia ==0 ) { - type =ICMP_UNREACH ; - code =ICMP_UNREACH_SRCFAIL ; - goto bad; - } - ip->ip_dst = ipaddr.sin_addr; -bcopy ((caddr_t)&(IA_SIN (ia)->sin_addr), - (caddr_t)(cp + off),sizeof (struct in_addr )); - cp[IPOPT_OFFSET ] +=sizeof (struct in_addr ); -/* -* Let ip_intr's mcast routing check handle mcast pkts -*/ - forward = !IN_MULTICAST (ntohl (ip->ip_dst.s_addr)); -break ; - -case IPOPT_RR : -if ((off = cp[IPOPT_OFFSET ]) <IPOPT_MINOFF ) { - code = &cp[IPOPT_OFFSET ] - (u_char *)ip; - goto bad; - } -/* -* If no space remains, ignore. -*/ - off--;/* 0 origin */ -if (off > optlen -sizeof (struct in_addr )) -break ; -bcopy ((caddr_t)(&ip->ip_dst), (caddr_t)&ipaddr.sin_addr, -sizeof (ipaddr.sin_addr)); -/* -* locate outgoing interface; if we're the destination, -* use the incoming interface (should be same). -*/ -if ((ia = (INA )ifa_ifwithaddr ((SA )&ipaddr)) ==0 && - (ia =ip_rtaddr (ipaddr.sin_addr)) ==0 ) { - type =ICMP_UNREACH ; - code =ICMP_UNREACH_HOST ; - goto bad; - } -bcopy ((caddr_t)&(IA_SIN (ia)->sin_addr), - (caddr_t)(cp + off),sizeof (struct in_addr )); - cp[IPOPT_OFFSET ] +=sizeof (struct in_addr ); -break ; - -case IPOPT_TS : - code = cp - (u_char *)ip; - ipt = (struct ip_timestamp *)cp; -if (ipt->ipt_len <5 ) - goto bad; -if (ipt->ipt_ptr > ipt->ipt_len -sizeof (int32_t )) { -if (++ipt->ipt_oflw ==0 ) - goto bad; -break ; - } - sin = (struct in_addr *)(cp + ipt->ipt_ptr -1 ); -switch (ipt->ipt_flg) { - -case IPOPT_TS_TSONLY : -break ; - -case IPOPT_TS_TSANDADDR : -if (ipt->ipt_ptr +sizeof (n_time) + -sizeof (struct in_addr ) > ipt->ipt_len) - goto bad; - ipaddr.sin_addr = dst; - ia = (INA)ifaof_ i f p foraddr((SA)&ipaddr, - m->m_pkthdr.rcvif); -if (ia ==0 ) -continue ; -bcopy ((caddr_t)&IA_SIN (ia)->sin_addr, - (caddr_t )sin,sizeof (struct in_addr )); - ipt->ipt_ptr +=sizeof (struct in_addr ); -break ; - -case IPOPT_TS_PRESPEC : -if (ipt->ipt_ptr +sizeof (n_time) + -sizeof (struct in_addr ) > ipt->ipt_len) - goto bad; -bcopy ((caddr_t )sin, (caddr_t)&ipaddr.sin_addr, -sizeof (struct in_addr )); -if (ifa_ifwithaddr ((SA )&ipaddr) ==0 ) -continue ; - ipt->ipt_ptr +=sizeof (struct in_addr ); -break ; - -default : - goto bad; - } - ntime =iptime (); -bcopy ((caddr_t)&ntime, (caddr_t )cp + ipt->ipt_ptr -1 , -sizeof (n_time)); - ipt->ipt_ptr +=sizeof (n_time); - } - } -if (forward) { -ip_forward (m,1 ); -return (1 ); - } -return (0 ); -bad: -icmp_send_error (m, type, code,0 ,0 ); - -return (1 ); -} - -#endif /* notdef */ -/* * Strip out IP options, at higher * level protocol in the kernel.
slirp/tcp_input.c +0 -39
@@ -1441,45 +1441,6 @@ tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti) } } - -/* -* Pull out of band byte out of a segment so -* it doesn't appear in the user's data queue. -* It is still reflected in the segment length for -* sequencing purposes. -*/ - -#ifdef notdef - -void -tcp_pulloutofband (so, ti, m) -struct socket *so; -struct tcpiphdr *ti; - registerstruct mbuf *m; -{ -int cnt = ti->ti_urp -1 ; - -while (cnt >=0 ) { -if (m->m_len > cnt) { -char *cp =mtod (m, caddr_t) + cnt; -struct tcpcb *tp =sototcpcb (so); - - tp->t_iobc = *cp; - tp->t_oobflags |=TCPOOB_HAVEDATA ; -memcpy (sp, cp+1 , (unsigned )(m->m_len - cnt -1 )); - m->m_len--; -return ; - } - cnt -= m->m_len; - m = m->m_next;/* XXX WRONG! Fix it! */ -if (m ==0 ) -break ; - } -panic ("tcp_pulloutofband" ); -} - -#endif /* notdef */ -/* * Collect new round-trip time estimate * and update averages and current timeout.
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 34/41] slirp: remove #if notdef dead code
Quoted 5 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/ip_input.c | 200 ---------------------------------------------- slirp/tcp_input.c | 39 --------- 2 files changed, 239 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 34/41] slirp: remove #if notdef dead code
Daniel P. Berrangé, le mer. 14 nov. 2018 14:07:38 +0000, a ecrit:
Quoted 8 lines · Marc-André Lureau
Quoted 5 lines
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/ip_input.c | 200 ---------------------------------------------- slirp/tcp_input.c | 39 --------- 2 files changed, 239 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 35/41 slirp: NULL is defined by glib (at least)
In reply to Marc-André Lureau--- slirp/slirp.h | 4 ---- 1 file changed, 4 deletions(-)
slirp/slirp.h +0 -4
@@ -199,10 +199,6 @@ struct Slirp {void *opaque; }; -#ifndef NULL -#define NULL (void *)0 -#endif -void if_start (Slirp *);int get_dns_addr (struct in_addr *pdns_addr);
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 35/41] slirp: NULL is defined by glib (at least)
NULL is defined in stddef.h for at least 15 years AFAICT, so even glib shouldn't bother to define it :-) So I'd suggest changing $subject to just defer to stddef.h
Quoted 4 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 4 ---- 1 file changed, 4 deletions(-)
Quoted 20 lines
slirp/slirp.h +0
-4@@ -199,10 +199,6 @@ struct Slirp {void *opaque; }; -#ifndef NULL -#define NULL (void *)0 -#endif -void if_start (Slirp *);int get_dns_addr (struct in_addr *pdns_addr);Signature · 1 line
2.19.1.708.g4ede3d42df
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 35/41] slirp: NULL is defined by glib (at least)
Daniel P. Berrangé, le mer. 14 nov. 2018 14:11:34 +0000, a ecrit:
Quoted 11 lines
NULL is defined in
stddef.hfor at least 15 years AFAICT, so even glib shouldn't bother to define it :-) So I'd suggest changing $subject to just defer tostddef.hQuoted 4 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/slirp.h | 4 ---- 1 file changed, 4 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 36/41 slirp: remove dead TCP_ACK_HACK code
In reply to Marc-André LureauUntouched since original introduction in 2004.
--- slirp/tcp_input.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
slirp/tcp_input.c +1 -22
@@ -60,27 +60,6 @@* Set DELACK for segments received in order, but ack immediately * when segments are out of order (so fast retransmit can work). */ -#ifdef TCP_ACK_HACK -#define TCP_REASS (tp, ti, m, so, flags) {\ - if ((ti)->ti_seq == (tp)->rcv_nxt && \ - tcpfrag_list_empty(tp) && \ - (tp)->t_state == TCPS_ESTABLISHED) {\ - if (ti->ti_flags & TH_PUSH) \ - tp->t_flags |= TF_ACKNOW; \ - else \ - tp->t_flags |= TF_DELACK; \ - (tp)->rcv_nxt += (ti)->ti_len; \ - flags = (ti)->ti_flags & TH_FIN; \ - if (so->so_emu) { \ - if (tcp_emu((so),(m))) sbappend((so), (m)); \ - } else \ - sbappend((so), (m)); \ - } else {\ - (flags) = tcp_reass((tp), (ti), (m)); \ - tp->t_flags |= TF_ACKNOW; \ - } \ -} -#else #define TCP_REASS (tp, ti, m, so, flags) { \ if ((ti)->ti_seq == (tp)->rcv_nxt && \ tcpfrag_list_empty(tp) && \
@@ -97,7 +76,7 @@ tp->t_flags |=TF_ACKNOW ; \ } \ } -#endif +static void tcp_dooptions (struct tcpcb *tp,u_char *cp,int cnt,struct tcpiphdr *ti);static void tcp_xmit_timer (registerstruct tcpcb *tp,int rtt);
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 36/41] slirp: remove dead TCP_ACK_HACK code
Quoted 6 lines · Marc-André Lureau
Untouched since original introduction in 2004.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/tcp_input.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 36/41] slirp: remove dead TCP_ACK_HACK code
Daniel P. Berrangé, le mer. 14 nov. 2018 14:12:06 +0000, a ecrit:
Quoted 9 lines · Marc-André Lureau
Quoted 6 lines
Untouched since original introduction in 2004.
Signed-off-by Marc-André Lureau <[email protected]>--- slirp/tcp_input.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 37/41 slirp: replace ARRAY_SIZE with G_N_ELEMENTS
In reply to Marc-André LureauDo not require QEMU macro.
--- slirp/ncsi.c | 2 +- slirp/tftp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
slirp/ncsi.c +1 -1
@@ -128,7 +128,7 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)memset (reh->h_source,0xff ,ETH_ALEN ); reh->h_proto =htons (ETH_P_NCSI ); -for (i =0 ; i <ARRAY_SIZE (ncsi_rsp_handlers); i++) { +for (i =0 ; i <G_N_ELEMENTS (ncsi_rsp_handlers); i++) {if (ncsi_rsp_handlers[i].type == nh->type +0x80 ) { handler = &ncsi_rsp_handlers[i];break ;
slirp/tftp.c +2 -2
@@ -360,7 +360,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,return ; } -while (k < pktlen && nb_options <ARRAY_SIZE (option_name)) { +while (k < pktlen && nb_options <G_N_ELEMENTS (option_name)) {const char *key, *value; key = &tp->x.tp_buf[k];
@@ -404,7 +404,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas, }if (nb_options >0 ) { -assert (nb_options <=ARRAY_SIZE (option_name)); +assert (nb_options <=G_N_ELEMENTS (option_name));tftp_send_oack (spt, option_name, option_value, nb_options, tp);return ; }
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 37/41] slirp: replace ARRAY_SIZE with G_N_ELEMENTS
Quoted 3 lines · Marc-André Lureau
Do not require QEMU macro.
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 41 lines
--- slirp/ncsi.c | 2 +- slirp/tftp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)slirp/ncsi.c +1
-1@@ -128,7 +128,7 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)memset (reh->h_source,0xff ,ETH_ALEN ); reh->h_proto =htons (ETH_P_NCSI ); -for (i =0 ; i <ARRAY_SIZE (ncsi_rsp_handlers); i++) { +for (i =0 ; i <G_N_ELEMENTS (ncsi_rsp_handlers); i++) {if (ncsi_rsp_handlers[i].type == nh->type +0x80 ) { handler = &ncsi_rsp_handlers[i];break ;slirp/tftp.c +2
-2@@ -360,7 +360,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,return ; } -while (k < pktlen && nb_options <ARRAY_SIZE (option_name)) { +while (k < pktlen && nb_options <G_N_ELEMENTS (option_name)) {const char *key, *value; key = &tp->x.tp_buf[k];@@ -404,7 +404,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas, }if (nb_options >0 ) { -assert (nb_options <=ARRAY_SIZE (option_name)); +assert (nb_options <=G_N_ELEMENTS (option_name));tftp_send_oack (spt, option_name, option_value, nb_options, tp);return ; }
Re: [Qemu-devel] [PATCH for-3.2 37/41] slirp: replace ARRAY_SIZE with G_N_ELEMENTS
In reply to Marc-André LureauQuoted 1 line · Marc-André Lureau
Do not require QEMU macro.
As with the endian thing, we should really purge ARRAY_SIZE from the entire QEMU codebase and just defer to glib. ARRAY_SIZE made sense before glib was a hard dep in QEMU, but there's no reason beyond bike shed colour choice to preserve it now.
I'm fine with this patch being targetted to slirp to avoid getting dragged into a broader discussion, but I'd encourage the global cleanup. I've personally used G_N_ELEMENTS in all QEMU code I've been writing since its more familiar from glib than a QEMU specific macro name.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 37/41] slirp: replace ARRAY_SIZE with G_N_ELEMENTS
Philippe Mathieu-Daudé, le mer. 14 nov. 2018 14:17:56 +0100, a ecrit:
Quoted 6 lines · Marc-André Lureau
Quoted 3 lines
Do not require QEMU macro.
Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Daniel P. Berrangé, le mer. 14 nov. 2018 14:15:15 +0000, a ecrit:
Quoted 1 line
Reviewed-by Daniel P. Berrangé <[email protected]>
Applied to my tree, thanks!
PATCH 38/41 net: do not depend on slirp internals
In reply to Marc-André LureauOnly slirp/libslirp.h should be included.
Instead of using some slirp declarations and utility functions directly, let's copy them in net/util.h.
--- net/colo.h | 3 +-- net/util.h | 55 +++++++++++++++++++++++++++++++++++++++++++ net/colo-compare.c | 1 + net/colo.c | 1 + net/filter-rewriter.c | 1 + net/slirp.c | 2 +- stubs/slirp.c | 2 +- 7 files changed, 61 insertions(+), 4 deletions(-)
net/colo.h +1 -2
@@ -15,10 +15,9 @@#ifndef QEMU_COLO_PROXY_H #define QEMU_COLO_PROXY_H -#include "slirp/slirp.h" #include "qemu/jhash.h" #include "qemu/timer.h" -#include "slirp/tcp.h" +#include "net/eth.h" #define HASHTABLE_MAX_SIZE 16384
net/util.h +55 -0
61 lines not on this page · raw message
net/colo-compare.c +1 -0
@@ -30,6 +30,7 @@#include "net/colo-compare.h" #include "migration/colo.h" #include "migration/migration.h" +#include "util.h" #define TYPE_COLO_COMPARE "colo-compare"#define COLO_COMPARE (obj) \
net/colo.c +1 -0
@@ -15,6 +15,7 @@#include "qemu/osdep.h" #include "trace.h" #include "colo.h" +#include "util.h" uint32_t connection_key_hash (const void *opaque) {
net/filter-rewriter.c +1 -0
@@ -22,6 +22,7 @@#include "net/checksum.h" #include "net/colo.h" #include "migration/colo.h" +#include "util.h" #define FILTER_COLO_REWRITER (obj) \ OBJECT_CHECK(RewriterState, (obj), TYPE_FILTER_REWRITER)
net/slirp.c +1 -1
@@ -38,12 +38,12 @@#include "qemu/error-report.h" #include "qemu/sockets.h" #include "slirp/libslirp.h" -#include "slirp/ip6.h" #include "chardev/char-fe.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" +#include "util.h" static int get_str_sep (char *buf,int buf_size,const char **pp,int sep) {
stubs/slirp.c +1 -1
@@ -1,7 +1,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/host-utils.h" -#include "slirp/slirp.h" +#include "slirp/libslirp.h" void slirp_pollfds_fill (GArray *pollfds,uint32_t *timeout) {
Signature · 1 line
2.19.1.708.g4ede3d42df
Re: [Qemu-devel] [PATCH for-3.2 38/41] net: do not depend on slirp internals
Quoted 4 lines · Marc-André Lureau
Only
slirp/libslirp.hshould be included.Instead of using some slirp declarations and utility functions directly, let's copy them in
net/util.h.
Nice cleanup! Can this single patch be applied out of this RFC series?
Quoted 2 lines
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 160 lines
--- net/colo.h | 3 +-- net/util.h | 55 +++++++++++++++++++++++++++++++++++++++++++ net/colo-compare.c | 1 + net/colo.c | 1 + net/filter-rewriter.c | 1 + net/slirp.c | 2 +- stubs/slirp.c | 2 +- 7 files changed, 61 insertions(+), 4 deletions(-)net/colo.h +1
-2@@ -15,10 +15,9 @@#ifndef QEMU_COLO_PROXY_H #define QEMU_COLO_PROXY_H -#include "slirp/slirp.h" #include "qemu/jhash.h" #include "qemu/timer.h" -#include "slirp/tcp.h" +#include "net/eth.h" #define HASHTABLE_MAX_SIZE 16384net/util.h +55
-0@@ -26,6 +26,61 @@#define QEMU_NET_UTIL_H +/* +* Structure of an internet header, naked of options. +*/ +struct ip { +#ifdef HOST_WORDS_BIGENDIAN +uint8_t ip_v:4 ,/* version */ + ip_hl:4 ;/* header length */ +#else +uint8_t ip_hl:4 ,/* header length */ + ip_v:4 ;/* version */ +#endif +uint8_t ip_tos;/* type of service */ +uint16_t ip_len;/* total length */ +uint16_t ip_id;/* identification */ +uint16_t ip_off;/* fragment offset field */ +#define IP_DF 0x4000/* don't fragment flag */ +#define IP_MF 0x2000/* more fragments flag */ +#define IP_OFFMASK 0x1fff/* mask for fragmenting bits */ +uint8_t ip_ttl;/* time to live */ +uint8_t ip_p;/* protocol */ +uint16_t ip_sum;/* checksum */ +struct in_addr ip_src, ip_dst;/* source and dest address */ +}QEMU_PACKED ; + +static inline bool in6_equal_net (const struct in6_addr *a, +const struct in6_addr *b, +int prefix_len) +{ +if (memcmp (a, b, prefix_len /8 ) !=0 ) { +return 0 ; + } + +if (prefix_len %8 ==0 ) { +return 1 ; + } + +return a->s6_addr[prefix_len /8 ] >> (8 - (prefix_len %8 )) + == b->s6_addr[prefix_len /8 ] >> (8 - (prefix_len %8 )); +} + +#define TCPS_CLOSED 0/* closed */ +#define TCPS_LISTEN 1/* listening for connection */ +#define TCPS_SYN_SENT 2/* active, have sent syn */ +#define TCPS_SYN_RECEIVED 3/* have send and received syn */ +/* states < TCPS_ESTABLISHED are those where connections not established */ +#define TCPS_ESTABLISHED 4/* established */ +#define TCPS_CLOSE_WAIT 5/* rcvd fin, waiting for close */ +/* states > TCPS_CLOSE_WAIT are those where user has closed */ +#define TCPS_FIN_WAIT_1 6/* have closed, sent fin */ +#define TCPS_CLOSING 7/* closed xchd FIN; await FIN ACK */ +#define TCPS_LAST_ACK 8/* had fin and close; await FIN ACK */ +/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ +#define TCPS_FIN_WAIT_2 9/* have closed, fin is acked */ +#define TCPS_TIME_WAIT 10/* in 2*msl quiet wait after close */ +int net_parse_macaddr (uint8_t *macaddr,const char *p);#endif /* QEMU_NET_UTIL_H */ net/colo-compare.c +1
-0@@ -30,6 +30,7 @@#include "net/colo-compare.h" #include "migration/colo.h" #include "migration/migration.h" +#include "util.h" #define TYPE_COLO_COMPARE "colo-compare"#define COLO_COMPARE (obj) \net/colo.c +1
-0@@ -15,6 +15,7 @@#include "qemu/osdep.h" #include "trace.h" #include "colo.h" +#include "util.h" uint32_t connection_key_hash (const void *opaque) {net/filter-rewriter.c +1
-0@@ -22,6 +22,7 @@#include "net/checksum.h" #include "net/colo.h" #include "migration/colo.h" +#include "util.h" #define FILTER_COLO_REWRITER (obj) \ OBJECT_CHECK(RewriterState, (obj), TYPE_FILTER_REWRITER)net/slirp.c +1
-1@@ -38,12 +38,12 @@#include "qemu/error-report.h" #include "qemu/sockets.h" #include "slirp/libslirp.h" -#include "slirp/ip6.h" #include "chardev/char-fe.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" +#include "util.h" static int get_str_sep (char *buf,int buf_size,const char **pp,int sep) {stubs/slirp.c +1
-1@@ -1,7 +1,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/host-utils.h" -#include "slirp/slirp.h" +#include "slirp/libslirp.h" void slirp_pollfds_fill (GArray *pollfds,uint32_t *timeout) {
Samuel Thibault
AppliedRe: [Qemu-devel] [PATCH for-3.2 38/41] net: do not depend on slirp internals
Philippe Mathieu-Daudé, le mer. 14 nov. 2018 14:21:36 +0100, a ecrit:
Quoted 4 lines
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Applied to my tree, thanks!
Re: [Qemu-devel] [PATCH for-3.2 38/41] net: do not depend on slirp internals
In reply to Marc-André LureauQuoted 6 lines · Marc-André Lureau
Only
slirp/libslirp.hshould be included.Instead of using some slirp declarations and utility functions directly, let's copy them in
net/util.h.Signed-off-by Marc-André Lureau <[email protected]>
Quoted 9 lines
--- net/colo.h | 3 +-- net/util.h | 55 +++++++++++++++++++++++++++++++++++++++++++ net/colo-compare.c | 1 + net/colo.c | 1 + net/filter-rewriter.c | 1 + net/slirp.c | 2 +- stubs/slirp.c | 2 +- 7 files changed, 61 insertions(+), 4 deletions(-)
Can you merge net/util.h and net/eth.h?
Thanks,
Paolo
PATCH 39/41 slirp: move QEMU state saving to a separate unit
In reply to Marc-André LureauMake state saving optional: this will allow to build SLIRP without QEMU. (eventually, the vmstate helpers will be extracted, so an external project & process could save its state)
--- slirp/slirp.h | 3 + slirp/state.h | 9 + slirp/slirp.c | 371 ++--------------------------------------- slirp/state.c | 394 ++++++++++++++++++++++++++++++++++++++++++++ slirp/Makefile.objs | 4 +- 5 files changed, 420 insertions(+), 361 deletions(-) create mode 100644 slirp/state.h create mode 100644 slirp/state.c
slirp/slirp.h +3 -0
@@ -270,4 +270,7 @@ int tcp_emu(struct socket *, struct mbuf *);int tcp_ctl (struct socket *);struct tcpcb *tcp_drop (struct tcpcb *tp,int err); +struct socket * +slirp_find_ctl_socket (Slirp *slirp,struct in_addr guest_addr,int guest_port); +#endif
slirp/state.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef SLIRP_STATE_H_ +#define SLIRP_STATE_H_ + +#include "libslirp.h" + +void slirp_state_register (Slirp *slirp); +void slirp_state_unregister (Slirp *slirp); + +#endif /* SLIRP_STATE_H_ */
slirp/slirp.c +11 -360
404 lines not on this page · raw message
slirp/state.c new file +394 -0
394 lines not on this page · raw message
slirp/Makefile.objs +3 -1
@@ -2,4 +2,6 @@ common-obj-y = cksum.o if.o ip_icmp.o ip6_icmp.o ip6_input.o ip6_output.o \ ip_input.o ip_output.o dnssearch.o dhcpv6.o common-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o common-obj-y += tcp_subr.o tcp_timer.o udp.o udp6.o bootp.o tftp.o arp_table.o \ - ndp_table.o ncsi.o + ndp_table.o ncsi.o state.o + +slirp.o-cflags := -DWITH_STATE=1
Signature · 1 line
2.19.1.708.g4ede3d42df
PATCH 40/41 slirp: replace remaining QEMU dependency
In reply to Marc-André LureauIntroduce utility header/object, and replace remaining qemu functions with SLIRP helpers.
--- slirp/ip.h | 14 +-- slirp/ip6.h | 5 +- slirp/ip6_icmp.h | 16 ++-- slirp/libslirp.h | 12 ++- slirp/qtailq.h | 218 ++++++++++++++++++++++++++++++++++++++++++++ slirp/slirp.h | 12 +-- slirp/util.h | 145 +++++++++++++++++++++++++++++ slirp/arp_table.c | 1 - slirp/bootp.c | 1 - slirp/cksum.c | 1 - slirp/dhcpv6.c | 2 - slirp/dnssearch.c | 1 - slirp/if.c | 2 - slirp/ip6_icmp.c | 4 - slirp/ip6_input.c | 1 - slirp/ip6_output.c | 2 - slirp/ip_icmp.c | 7 +- slirp/ip_input.c | 1 - slirp/ip_output.c | 1 - slirp/mbuf.c | 1 - slirp/misc.c | 21 ++--- slirp/ncsi.c | 1 - slirp/ndp_table.c | 2 - slirp/sbuf.c | 2 - slirp/slirp.c | 8 -- slirp/socket.c | 18 ++-- slirp/tcp_input.c | 1 - slirp/tcp_output.c | 1 - slirp/tcp_subr.c | 13 ++- slirp/tcp_timer.c | 1 - slirp/tftp.c | 7 +- slirp/udp.c | 7 +- slirp/udp6.c | 2 - slirp/util.c | 176 +++++++++++++++++++++++++++++++++++ slirp/Makefile.objs | 2 +- 35 files changed, 606 insertions(+), 103 deletions(-) create mode 100644 slirp/qtailq.h create mode 100644 slirp/util.h create mode 100644 slirp/util.c
slirp/ip.h +7 -7
@@ -89,7 +89,7 @@ struct ip {uint8_t ip_p;/* protocol */ uint16_t ip_sum;/* checksum */ struct in_addr ip_src,ip_dst;/* source and dest address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;#define IP_MAXPACKET 65535/* maximum packet size */
@@ -151,7 +151,7 @@ struct ip_timestamp {n_long ipt_time; } ipt_ta[1 ]; } ipt_timestamp; -}QEMU_PACKED ; +}SLIRP_PACKED ;/* flag bits for ipt_flg */ #define IPOPT_TS_TSONLY 0/* timestamps only */
@@ -181,11 +181,11 @@ struct ip_timestamp {struct mbuf_ptr {struct mbuf *mptr;uint32_t dummy; -}QEMU_PACKED ; +}SLIRP_PACKED ;#else struct mbuf_ptr {struct mbuf *mptr; -}QEMU_PACKED ; +}SLIRP_PACKED ;#endif struct qlink {void *next, *prev;
@@ -201,7 +201,7 @@ struct ipovly {uint16_t ih_len;/* protocol length */ struct in_addr ih_src;/* source internet address */ struct in_addr ih_dst;/* destination internet address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;/* * Ip reassembly queue structure. Each fragment
@@ -217,7 +217,7 @@ struct ipq {uint8_t ipq_p;/* protocol of this fragment */ uint16_t ipq_id;/* sequence id for reassembly */ struct in_addr ipq_src,ipq_dst; -}QEMU_PACKED ; +}SLIRP_PACKED ;/* * Ip header, when holding a fragment.
@@ -227,7 +227,7 @@ struct ipq {struct ipasfrag {struct qlink ipf_link;struct ip ipf_ip; -}QEMU_PACKED ; +}SLIRP_PACKED ;#define ipf_off ipf_ip.ip_off#define ipf_tos ipf_ip.ip_tos
slirp/ip6.h +2 -3
@@ -7,7 +7,6 @@#define SLIRP_IP6_H #include <glib.h> -#include "net/eth.h" #define ALLNODES_MULTICAST { .s6_addr = \ { 0xff, 0x02, 0x00, 0x00,\
@@ -133,7 +132,7 @@ struct ip6 {uint8_t ip_nh;/* next header */ uint8_t ip_hl;/* hop limit */ struct in6_addr ip_src, ip_dst;/* source and dest address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;/* * IPv6 pseudo-header used by upper-layer protocols
@@ -145,7 +144,7 @@ struct ip6_pseudohdr {uint16_t ih_zero_hi;/* zero */ uint8_t ih_zero_lo;/* zero */ uint8_t ih_nh; /* next header */ -}QEMU_PACKED ; +}SLIRP_PACKED ;#endif
slirp/ip6_icmp.h +8 -8
@@ -48,12 +48,12 @@ struct ndp_ra { /* Router Advertisement Message */uint16_t lifetime;/* Router Lifetime */ uint32_t reach_time;/* Reachable Time */ uint32_t retrans_time;/* Retrans Timer */ -}QEMU_PACKED ; +}SLIRP_PACKED ;struct ndp_ns {/* Neighbor Solicitation Message */ uint32_t reserved;struct in6_addr target;/* Target Address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;struct ndp_na {/* Neighbor Advertisement Message */ #if G_BYTE_ORDER ==G_BIG_ENDIAN
@@ -72,13 +72,13 @@ struct ndp_na { /* Neighbor Advertisement Message */ reserved_lo:24 ;#endif struct in6_addr target;/* Target Address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;struct ndp_redirect {uint32_t reserved;struct in6_addr target;/* Target Address */ struct in6_addr dest;/* Destination Address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;/* * Structure of an icmpv6 header.
@@ -103,7 +103,7 @@ struct icmp6 {#define icmp6_nns icmp6_body.ndp_ns#define icmp6_nna icmp6_body.ndp_na#define icmp6_redirect icmp6_body.ndp_redirect -}QEMU_PACKED ; +}SLIRP_PACKED ;#define ICMP6_MINLEN 4#define ICMP6_ERROR_MINLEN 8
@@ -134,16 +134,16 @@ struct ndpopt {uint32_t pref_lt;/* Preferred Lifetime */ uint32_t reserved2;struct in6_addr prefix; - }QEMU_PACKED prefixinfo; + }SLIRP_PACKED prefixinfo;#define ndpopt_prefixinfo ndpopt_body.prefixinfostruct rdnss {uint16_t reserved;uint32_t lifetime;struct in6_addr addr; - } QEMU_PACKED rdnss; + } SLIRP_PACKED rdnss;#define ndpopt_rdnss ndpopt_body.rdnss } ndpopt_body; -}QEMU_PACKED ; +}SLIRP_PACKED ;/* NDP options type */ #define NDPOPT_LINKLAYER_SOURCE 1/* Source Link-Layer Address */
slirp/libslirp.h +11 -1
@@ -1,7 +1,17 @@#ifndef LIBSLIRP_H #define LIBSLIRP_H -#include "qemu-common.h" +#include <glib.h> +#include <stdint.h> +#include <stdbool.h> + +#ifdef _WIN32 +#include <winsock2.h> +#include <in6addr.h> +#else +#include <netinet/in.h> +#include <arpa/inet.h> +#endif typedef struct Slirp Slirp ;
slirp/qtailq.h new file +218 -0
218 lines not on this page · raw message
slirp/slirp.h +5 -7
@@ -5,8 +5,8 @@typedef char *caddr_t ; -# include <windows.h> # include <winsock2.h> +# include <windows.h> # include <ws2tcpip.h> # include <sys/timeb.h> # include <iphlpapi.h>
@@ -45,10 +45,8 @@ typedef char *caddr_t;#define quehead slirp_quehead#include "debug.h" - -#include "qemu/queue.h" -#include "qemu/sockets.h" -#include "net/eth.h" +#include "util.h" +#include "qtailq.h" #include "libslirp.h" #include "ip.h"
@@ -93,7 +91,7 @@ struct slirp_arphdr {uint32_t ar_sip;/* sender IP address */ unsigned char ar_tha[ETH_ALEN ];/* target hardware address */ uint32_t ar_tip;/* target IP address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;#define ARP_TABLE_SIZE 16
@@ -110,7 +108,7 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,struct ndpentry {unsigned char eth_addr[ETH_ALEN ];/* sender hardware address */ struct in6_addr ip_addr;/* sender IP address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;#define NDP_TABLE_SIZE 16
slirp/util.h new file +145 -0
145 lines not on this page · raw message
slirp/arp_table.c +0 -1
@@ -22,7 +22,6 @@* THE SOFTWARE. */ -#include "qemu/osdep.h" #include "slirp.h" void arp_table_add (Slirp *slirp,uint32_t ip_addr,uint8_t ethaddr[ETH_ALEN ])
slirp/bootp.c +0 -1
@@ -21,7 +21,6 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu/osdep.h" #include "slirp.h" #if defined(_WIN32)
slirp/cksum.c +0 -1
@@ -30,7 +30,6 @@* in_cksum.c,v 1.2 1994/08/02 07:48:16 davidg Exp */ -#include "qemu/osdep.h" #include "slirp.h" /*
slirp/dhcpv6.c +0 -2
@@ -20,8 +20,6 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#include "qemu/osdep.h" -#include "qemu/log.h" #include "slirp.h" #include "dhcpv6.h"
slirp/dnssearch.c +0 -1
@@ -22,7 +22,6 @@* THE SOFTWARE. */ -#include "qemu/osdep.h" #include "slirp.h" static const uint8_t RFC3397_OPT_DOMAIN_SEARCH =119 ;
slirp/if.c +0 -2
@@ -5,9 +5,7 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" -#include "qemu/timer.h" static void ifs_insque (struct mbuf *ifm,struct mbuf *ifmhead)
slirp/ip6_icmp.c +0 -4
@@ -3,12 +3,8 @@* Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip6_icmp.h" -#include "qemu/timer.h" -#include "qemu/error-report.h" -#include "qemu/log.h" #define NDP_Interval g_rand_int_range(slirp->grand, \ NDP_MinRtrAdvInterval, NDP_MaxRtrAdvInterval)
slirp/ip6_input.c +0 -1
@@ -3,7 +3,6 @@* Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip6_icmp.h"
slirp/ip6_output.c +0 -2
@@ -3,8 +3,6 @@* Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne. */ -#include "qemu/osdep.h" -#include "qemu-common.h" #include "slirp.h" /* Number of packets queued before we start sending
slirp/ip_icmp.c +3 -4
@@ -30,7 +30,6 @@* ip_icmp.c,v 1.7 1995/05/30 08:09:42 rgrimes Exp */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip_icmp.h"
@@ -79,7 +78,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen) struct ip *ip = mtod(m, struct ip *);struct sockaddr_in addr; - so->s =qemu_socket (AF_INET ,SOCK_DGRAM ,IPPROTO_ICMP ); + so->s =slirp_socket (AF_INET ,SOCK_DGRAM ,IPPROTO_ICMP );if (so->s ==-1 ) {return -1 ; }
@@ -110,7 +109,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen)void icmp_detach (struct socket *so) { -closesocket (so->s); +slirp_closesocket (so->s);sofree (so); }
@@ -420,7 +419,7 @@ void icmp_receive(struct socket *so) icp = mtod(m, struct icmp *); id = icp->icmp_id; - len =qemu_recv (so->s, icp,M_ROOM (m),0 ); + len =slirp_recv (so->s, icp,M_ROOM (m),0 );/* * The behavior of reading SOCK_DGRAM+IPPROTO_ICMP sockets is inconsistent * between host OSes. On Linux, only the ICMP header and payload is
slirp/ip_input.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip_icmp.h"
slirp/ip_output.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" /* Number of packets queued before we start sending
slirp/mbuf.c +0 -1
@@ -15,7 +15,6 @@* the flags */ -#include "qemu/osdep.h" #include "slirp.h" #define MBUF_THRESH 30
slirp/misc.c +9 -12
@@ -5,11 +5,8 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" #include "libslirp.h" -#include "qemu/error-report.h" -#include "qemu/main-loop.h" #ifdef DEBUG int slirp_debug =DBG_CALL |DBG_MISC |DBG_ERROR ;
@@ -85,14 +82,14 @@ slirp_socketpair_with_oob(int sv[2])int ret, s; sv[1 ] =-1 ; - s =qemu_socket (AF_INET ,SOCK_STREAM ,0 ); + s =slirp_socket (AF_INET ,SOCK_STREAM ,0 );if (s <0 ||bind (s, (struct sockaddr *)&addr, addrlen) <0 ||listen (s,1 ) <0 ||getsockname (s, (struct sockaddr *)&addr, &addrlen) <0 ) { goto err; } - sv[1 ] =qemu_socket (AF_INET ,SOCK_STREAM ,0 ); + sv[1 ] =slirp_socket (AF_INET ,SOCK_STREAM ,0 );if (sv[1 ] <0 ) { goto err; }
@@ -115,16 +112,16 @@ slirp_socketpair_with_oob(int sv[2]) goto err; } -closesocket (s); +slirp_closesocket (s);return 0 ; err:g_critical ("slirp_socketpair(): %s" ,strerror (errno));if (s >=0 ) { -closesocket (s); +slirp_closesocket (s); }if (sv[1 ] >=0 ) { -closesocket (sv[1 ]); +slirp_closesocket (sv[1 ]); }return -1 ; }
@@ -164,16 +161,16 @@ fork_exec(struct socket *so, const char *ex)if (err) {g_critical ("fork_exec: %s" , err->message);g_error_free (err); -closesocket (sp[0 ]); -closesocket (sp[1 ]); +slirp_closesocket (sp[0 ]); +slirp_closesocket (sp[1 ]);return 0 ; } so->s = sp[0 ]; -closesocket (sp[1 ]); +slirp_closesocket (sp[1 ]);socket_set_fast_reuse (so->s); opt =1 ; -qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); +slirp_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); so->slirp->cb->set_nonblock (so->s);return 1 ; }
slirp/ncsi.c +0 -1
@@ -6,7 +6,6 @@* This code is licensed under the GPL version 2 or later. See the * COPYING file in the top-level directory. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ncsi-pkt.h"
slirp/ndp_table.c +0 -2
@@ -3,8 +3,6 @@* Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne. */ -#include "qemu/osdep.h" -#include "qemu-common.h" #include "slirp.h" void ndp_table_add(Slirp *slirp, struct in6_addr ip_addr,
slirp/sbuf.c +0 -2
@@ -5,9 +5,7 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" -#include "qemu/main-loop.h" static void sbappendsb (struct sbuf *sb,struct mbuf *m);
slirp/slirp.c +0 -8
@@ -21,15 +21,7 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "qemu/timer.h" -#include "qemu/error-report.h" -#include "chardev/char-fe.h" -#include "migration/register.h" #include "slirp.h" -#include "hw/hw.h" -#include "qemu/cutils.h" #ifdef WITH_STATE #include "state.h"
slirp/socket.c +8 -10
@@ -5,8 +5,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" -#include "qemu-common.h" #include "slirp.h" #include "ip_icmp.h" #ifdef __sun__
@@ -187,7 +185,7 @@ soread(struct socket *so)*/ sopreprbuf (so, iov, &n); - nn =qemu_recv (so->s, iov[0 ].iov_base, iov[0 ].iov_len,0 ); + nn =slirp_recv (so->s, iov[0 ].iov_base, iov[0 ].iov_len,0 );if (nn <=0 ) {if (nn <0 && (errno ==EINTR || errno ==EAGAIN ))return 0 ;
@@ -203,7 +201,7 @@ soread(struct socket *so)if (getpeername (so->s, paddr, &alen) <0 ) { err = errno; }else { -getsockopt (so->s,SOL_SOCKET ,SO_ERROR , +slirp_getsockopt (so->s,SOL_SOCKET ,SO_ERROR , &err, &elen); } }
@@ -232,7 +230,7 @@ soread(struct socket *so)*/ if (n ==2 && nn == iov[0 ].iov_len) {int ret; - ret =qemu_recv (so->s, iov[1 ].iov_base, iov[1 ].iov_len,0 ); + ret =slirp_recv (so->s, iov[1 ].iov_base, iov[1 ].iov_len,0 );if (ret >0 ) nn += ret; }
@@ -553,7 +551,7 @@ sorecvfrom(struct socket *so)*/ len =M_FREEROOM (m);/* if (so->so_fport != htons(53)) { */ -ioctlsocket (so->s,FIONREAD , &n); +slirp_ioctlsocket (so->s,FIONREAD , &n);if (n > len) { n = (m->m_data - m->m_dat) + m->m_len + n +1 ;
@@ -718,14 +716,14 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, addr.sin_addr.s_addr = haddr; addr.sin_port = hport; -if (((s =qemu_socket (AF_INET ,SOCK_STREAM ,0 )) <0 ) || +if (((s =slirp_socket (AF_INET ,SOCK_STREAM ,0 )) <0 ) || (socket_set_fast_reuse (s) <0 ) || (bind (s,(struct sockaddr *)&addr,sizeof (addr)) <0 ) || (listen (s,1 ) <0 )) {int tmperrno = errno;/* Don't clobber the real reason we failed */ if (s >=0 ) { -closesocket (s); +slirp_closesocket (s); }sofree (so);/* Restore the real errno */
@@ -736,9 +734,9 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,#endif return NULL ; } -qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); +slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); opt =1 ; -qemu_setsockopt (s,IPPROTO_TCP ,TCP_NODELAY , &opt,sizeof (int )); +slirp_setsockopt (s,IPPROTO_TCP ,TCP_NODELAY , &opt,sizeof (int ));getsockname (s,(struct sockaddr *)&addr,&addrlen); so->so_ffamily =AF_INET ;
slirp/tcp_input.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip_icmp.h"
slirp/tcp_output.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" static const u_char tcp_outflags[TCP_NSTATES ] = {
slirp/tcp_subr.c +6 -7
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" /* patchable/settable parameters for tcp */
@@ -337,7 +336,7 @@ tcp_close(struct tcpcb *tp)/* clobber input socket cache if we're closing the cached connection */ if (so == slirp->tcp_last_so) slirp->tcp_last_so = &slirp->tcb; -closesocket (so->s); +slirp_closesocket (so->s);sbfree (&so->so_rcv);sbfree (&so->so_snd);sofree (so);
@@ -407,7 +406,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)DEBUG_CALL ("tcp_fconnect" );DEBUG_ARG ("so = %p" , so); - ret = so->s =qemu_socket (af,SOCK_STREAM ,0 ); + ret = so->s =slirp_socket (af,SOCK_STREAM ,0 );if (ret >=0 ) {int opt, s=so->s;struct sockaddr_storage addr;
@@ -415,9 +414,9 @@ int tcp_fconnect(struct socket *so, unsigned short af) so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ; -qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt)); +slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt)); opt =1 ; -qemu_setsockopt (s,IPPROTO_TCP ,TCP_NODELAY , &opt,sizeof (opt)); +slirp_setsockopt (s,IPPROTO_TCP ,TCP_NODELAY , &opt,sizeof (opt)); addr = so->fhost.ss;DEBUG_CALL (" connect()ing" );
@@ -487,7 +486,7 @@ void tcp_connect(struct socket *inso) so->slirp->cb->set_nonblock (s);socket_set_fast_reuse (s); opt =1 ; -qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); +slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));socket_set_nodelay (s); so->fhost.ss = addr;
@@ -496,7 +495,7 @@ void tcp_connect(struct socket *inso)/* Close the accept() socket, set right state */ if (inso->so_state &SS_FACCEPTONCE ) {/* If we only accept once, close the accept() socket */ -closesocket (so->s); +slirp_closesocket (so->s);/* Don't select it yet, even though we have an FD */ /* if it's not FACCEPTONCE, it's already NOFDREF */
slirp/tcp_timer.c +0 -1
@@ -30,7 +30,6 @@* tcp_timer.c,v 1.2 1994/08/02 07:49:10 davidg Exp */ -#include "qemu/osdep.h" #include "slirp.h" static struct tcpcb *tcp_timers (registerstruct tcpcb *tp,int timer);
slirp/tftp.c +4 -3
@@ -22,10 +22,11 @@* THE SOFTWARE. */ -#include "qemu/osdep.h" #include "slirp.h" -#include "qemu-common.h" -#include "qemu/cutils.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> static inline int tftp_session_in_use (struct tftp_session *spt) {
slirp/udp.c +3 -4
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip_icmp.h"
@@ -282,7 +281,7 @@ int udp_output(struct socket *so, struct mbuf *m,int udp_attach (struct socket *so,unsigned short af) { - so->s =qemu_socket (af,SOCK_DGRAM ,0 ); + so->s =slirp_socket (af,SOCK_DGRAM ,0 );if (so->s !=-1 ) { so->so_expire = curtime +SO_EXPIRE ;insque (so, &so->slirp->udb);
@@ -293,7 +292,7 @@ udp_attach(struct socket *so, unsigned short af)void udp_detach (struct socket *so) { -closesocket (so->s); +slirp_closesocket (so->s);sofree (so); }
@@ -328,7 +327,7 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,socklen_t addrlen =sizeof (struct sockaddr_in ); so =socreate (slirp); - so->s =qemu_socket (AF_INET ,SOCK_DGRAM ,0 ); + so->s =slirp_socket (AF_INET ,SOCK_DGRAM ,0 );if (so->s <0 ) {sofree (so);return NULL ;
slirp/udp6.c +0 -2
@@ -3,8 +3,6 @@* Guillaume Subiron */ -#include "qemu/osdep.h" -#include "qemu-common.h" #include "slirp.h" #include "udp.h" #include "dhcpv6.h"
slirp/util.c new file +176 -0
176 lines not on this page · raw message
slirp/Makefile.objs +1 -1
@@ -2,6 +2,6 @@ common-obj-y = cksum.o if.o ip_icmp.o ip6_icmp.o ip6_input.o ip6_output.o \ ip_input.o ip_output.o dnssearch.o dhcpv6.o common-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o common-obj-y += tcp_subr.o tcp_timer.o udp.o udp6.o bootp.o tftp.o arp_table.o \ - ndp_table.o ncsi.o state.o + ndp_table.o ncsi.o state.o util.o slirp.o-cflags := -DWITH_STATE=1
Signature · 1 line
2.19.1.708.g4ede3d42df
PATCH 41/41 build-sys: add a basic meson build
In reply to Marc-André LureauThis is a minimal file to build a libslirp shared library.
It has been tested to build on Linux and with mingw64 cross-compilation.
--- slirp/meson.build | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 slirp/meson.build
slirp/meson.build new file +48 -0
@@ -0,0 +1,48 @@ +project('slirp', 'c', version : '3.1') + +add_global_arguments('-std=gnu99', language : 'c') + +host_system = host_machine.system() + +glib_dep = dependency('glib-2.0') + +cc = meson.get_compiler('c') + +platform_deps = [] + +if host_system == 'windows' + platform_deps += [ + cc.find_library('ws2_32'), + cc.find_library('iphlpapi') + ] +endif + +shared_library('slirp', + 'arp_table.c', + 'bootp.c', + 'cksum.c', + 'dhcpv6.c', + 'dnssearch.c', + 'if.c', + 'ip6_icmp.c', + 'ip6_input.c', + 'ip6_output.c', + 'ip_icmp.c', + 'ip_input.c', + 'ip_output.c', + 'mbuf.c', + 'misc.c', + 'ncsi.c', + 'ndp_table.c', + 'sbuf.c', + 'slirp.c', + 'socket.c', + 'tcp_input.c', + 'tcp_output.c', + 'tcp_subr.c', + 'tcp_timer.c', + 'tftp.c', + 'udp.c', + 'udp6.c', + 'util.c', + dependencies : [glib_dep, platform_deps])
Signature · 1 line
2.19.1.708.g4ede3d42df
Quoted 20 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
Quoted 6 lines
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)What do you think?
Has the slirp code been improved to be generally useful? I still got it filed under "friends don't let friends use that, except for testing"...
Quoted 24 lines · Markus Armbruster
Quoted 22 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
The subproject could created by preserving git tags, and cleaning up the code style, this way:
Quoted 7 lines
Quoted 4 lines
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)What do you think?
Has the slirp code been improved to be generally useful? I still got it filed under "friends don't let friends use that, except for testing"...
SLIRP may or may not be bad internally -- I don't know -- but it provides an unbeatable feature that nothing else replaces: no setup, no root network access. We use it all over the place.
The idea of these patches is to move SLIRP into a separate project and have it run as a separate process. This solves IMHO two problems:
qemu maintainers don't seem to like it, as demonstrated above, and if there are any security problems them we can nail down the SLIRP external process so it has literally no access to the host except for the handful of network socket system calls it needs.
Rich.
Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Quoted 24 lines · Markus Armbruster
Quoted 22 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
The subproject could created by preserving git tags, and cleaning up the code style, this way:
Quoted 7 lines
Quoted 4 lines
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)What do you think?
Has the slirp code been improved to be generally useful? I still got it filed under "friends don't let friends use that, except for testing"...
The slirp code is already used in a lot of other projects:
- WinUAE
(https://github.com/tonioni/WinUAE/tree/master/slirp)
- Previous
(https://sourceforge.net/p/previous/code/HEAD/tree/trunk/src/slirp/)
- BasiliskII
(https://github.com/cebix/macemu/tree/master/BasiliskII/src/slirp)
- Bochs
(https://sourceforge.net/p/bochs/code/HEAD/tree/trunk/bochs/iodev/network/slirp/)
... and likely many more. AFAIK they all (or at least most) have been forked from the QEMU code at one point in time and diverged, i.e. they likely missed the bug fixes and new features that have been added in QEMU (like IPv6). So yes, IMHO it makes a lot of sense to try to make a separate library out of the slirp code again, especially if we could convince the other projects to use it, too, and to collaborate on that version.
Thomas
Quoted 28 lines · Thomas Huth
Quoted 27 lines · Markus Armbruster
Quoted 25 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
What do you think?
Has the slirp code been improved to be generally useful? I still got it filed under "friends don't let friends use that, except for testing"...
The slirp code is already used in a lot of other projects:
The issue I have with SLIRP isn't that it solves a useless problem (au contraire!), it's that it's a useless solution. Okay, that's an unfair exaggeration, it's not useless, I just wouldn't trust it in production, unless it has improved significantly since I last looked at it.
Quoted 13 lines
- WinUAE
(https://github.com/tonioni/WinUAE/tree/master/slirp)- Previous
(https://sourceforge.net/p/previous/code/HEAD/tree/trunk/src/slirp/)- BasiliskII
(https://github.com/cebix/macemu/tree/master/BasiliskII/src/slirp)- Bochs
(https://sourceforge.net/p/bochs/code/HEAD/tree/trunk/bochs/iodev/network/slirp/)
Quoted 7 lines
... and likely many more. AFAIK they all (or at least most) have been forked from the QEMU code at one point in time and diverged, i.e. they likely missed the bug fixes and new features that have been added in QEMU (like IPv6). So yes, IMHO it makes a lot of sense to try to make a separate library out of the slirp code again, especially if we could convince the other projects to use it, too, and to collaborate on that version.
No objections to spinning it out, as long as it comes with a fair assessment of its limitations.
Turning it into a proper project might even improve its chances to get improved towards production quality, compared to its current existence as a corner of QEMU next to nobody wants to touch.
Quoted 35 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 33 lines · Thomas Huth
Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
Quoted 6 lines
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)What do you think?
Has the slirp code been improved to be generally useful? I still got it filed under "friends don't let friends use that, except for testing"...
Quoted 6 lines
Quoted 1 line
The slirp code is already used in a lot of other projects:
The issue I have with SLIRP isn't that it solves a useless problem (au contraire!), it's that it's a useless solution. Okay, that's an unfair exaggeration, it's not useless, I just wouldn't trust it in production, unless it has improved significantly since I last looked at it.
It's now used as a critical part of 'rootless-containers' - i.e. running containers with no priviledges; see:
https://github.com/rootless-containers/slirp4netns/
Dave
Quoted 21 lines
Quoted 13 lines
- WinUAE
(https://github.com/tonioni/WinUAE/tree/master/slirp)- Previous
(https://sourceforge.net/p/previous/code/HEAD/tree/trunk/src/slirp/)- BasiliskII
(https://github.com/cebix/macemu/tree/master/BasiliskII/src/slirp)- Bochs
(https://sourceforge.net/p/bochs/code/HEAD/tree/trunk/bochs/iodev/network/slirp/)
Quoted 7 lines
... and likely many more. AFAIK they all (or at least most) have been forked from the QEMU code at one point in time and diverged, i.e. they likely missed the bug fixes and new features that have been added in QEMU (like IPv6). So yes, IMHO it makes a lot of sense to try to make a separate library out of the slirp code again, especially if we could convince the other projects to use it, too, and to collaborate on that version.
Quoted 7 lines
No objections to spinning it out, as long as it comes with a fair assessment of its limitations.
Turning it into a proper project might even improve its chances to get improved towards production quality, compared to its current existence as a corner of QEMU next to nobody wants to touch.
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 4 lines · Markus Armbruster
The issue I have with SLIRP isn't that it solves a useless problem (au contraire!), it's that it's a useless solution. Okay, that's an unfair exaggeration, it's not useless, I just wouldn't trust it in production, unless it has improved significantly since I last looked at it.
It's used by virt-builder, virt-customize, virt-v2v, etc., in some cases in production. Of course those uses are not completely general purpose (it'll be things like running very specific, known ‘yum install’ commands from the guest), and we test it quite a bit.
Rich.
Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Quoted 32 lines · Markus Armbruster
Quoted 30 lines · Thomas Huth
Quoted 29 lines · Markus Armbruster
Quoted 26 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)What do you think?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Has the slirp code been improved to be generally useful? I still got it filed under "friends don't let friends use that, except for testing"...
The slirp code is already used in a lot of other projects:
The issue I have with SLIRP isn't that it solves a useless problem (au contraire!), it's that it's a useless solution.
Ouch, that was completely arrogant and inappropriate. It's far away from being useless, and Samuel is doing a very good job in picking up all the patches and fixes that have been posted in the past months. Have you had a look at the changelog at all before you wrote that sentence?
Quoted 3 lines
Okay, that's an unfair
exaggeration, it's not useless, I just wouldn't trust it in production, unless it has improved significantly since I last looked at it.
Nobody said that the slirp code would suddenly be perfect, but if it's getting even more traction and attention as a separate library (since other projects might contribute their fixes back "upstream" in that case), it could really get a solid building block for a lot of emulators and similar software.
Thomas
Quoted 36 lines · Thomas Huth
Quoted 35 lines · Markus Armbruster
Quoted 33 lines · Thomas Huth
Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
Quoted 6 lines
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)What do you think?
Has the slirp code been improved to be generally useful? I still got it filed under "friends don't let friends use that, except for testing"...
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
The slirp code is already used in a lot of other projects:
The issue I have with SLIRP isn't that it solves a useless problem (au contraire!), it's that it's a useless solution.
Ouch, that was completely arrogant and inappropriate. It's far away from being useless,
... as I immediately admit ...
Quoted 3 lines
and Samuel is doing a very good job in picking up all the
patches and fixes that have been posted in the past months. Have you had a look at the changelog at all before you wrote that sentence?
... right in the next sentence:
Quoted 3 lines
Quoted 3 lines
Okay, that's an unfair
exaggeration, it's not useless, I just wouldn't trust it in production, unless it has improved significantly since I last looked at it.
If my joke offended Samuel, or anyone, I offer my sincere apologies.
Quoted 5 lines
Nobody said that the slirp code would suddenly be perfect, but if it's getting even more traction and attention as a separate library (since other projects might contribute their fixes back "upstream" in that case), it could really get a solid building block for a lot of emulators and similar software.
[...]
Quoted 6 lines · I'm afraid we're in violent agreement there. I
Quoted 6 lines
No objections to spinning it out, as long as it comes with a fair assessment of its limitations.
Turning it into a proper project might even improve its chances to get improved towards production quality, compared to its current existence as a corner of QEMU next to nobody wants to touch.
Quoted 60 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 36 lines · Thomas Huth
Quoted 35 lines · Markus Armbruster
Quoted 33 lines · Thomas Huth
Quoted 31 lines · Markus Armbruster
Quoted 20 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
Quoted 6 lines
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)What do you think?
Has the slirp code been improved to be generally useful? I still got it filed under "friends don't let friends use that, except for testing"...
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
The slirp code is already used in a lot of other projects:
The issue I have with SLIRP isn't that it solves a useless problem (au contraire!), it's that it's a useless solution.
Ouch, that was completely arrogant and inappropriate. It's far away from being useless,
... as I immediately admit ...
Quoted 3 lines
and Samuel is doing a very good job in picking up all the
patches and fixes that have been posted in the past months. Have you had a look at the changelog at all before you wrote that sentence?... right in the next sentence:
Quoted 3 lines
Quoted 3 lines
Okay, that's an unfair
exaggeration, it's not useless, I just wouldn't trust it in production, unless it has improved significantly since I last looked at it.If my joke offended Samuel, or anyone, I offer my sincere apologies.
Quoted 15 lines
Quoted 5 lines
Nobody said that the slirp code would suddenly be perfect, but if it's getting even more traction and attention as a separate library (since other projects might contribute their fixes back "upstream" in that case), it could really get a solid building block for a lot of emulators and similar software.
[...]
Quoted 6 lines · I'm afraid we're in violent agreement there. I
Quoted 6 lines
No objections to spinning it out, as long as it comes with a fair assessment of its limitations.
Turning it into a proper project might even improve its chances to get improved towards production quality, compared to its current existence as a corner of QEMU next to nobody wants to touch.
One thought is that it might actually be the best standalone stack around at the moment; I mean while I'm seeing people objecting to bits of SLIRP, I'm not seeing anyone saying
'Why don't you just use ....'
Dave
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 5 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
At least half of the patches in this series are deleting unused or unreachable code. I'd suggest you send all of those as a non-RFC series, as they are things we could merge straight away regardless of whether/when slirp becomes a separate library.
Quoted 9 lines
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.
More recently there is this fun project which just pulled in the QEMU code and chopped out everything todo with slirp:
https://github.com/rootless-containers/slirp4netns
If the libslirp you propose can satisfy their integration needs it would be a positive validation of the need for & benefit of a standalone libslirp.
Quoted 3 lines
I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
A sub-module sounds ok in short term, but from a distro packaging POV, I think there'd be strong pressure to unbundle it as quickly as possible, even immediately. A lack of stable ABI would not be ideal, but it is not a show stopper either - it would just mean relatively frequent rebuilds for soname changes which is something that happens quite a bit already for other deps we have in Fedora:
$ grep soname qemu.spec - Rebuild for libiscsi changed soname again - Rebuild for changed Xen sonames - Rebuild to pick up changed libxen* sonames - Rebuild for libiscsi soname bump - Rebuild for changed xen soname
Quoted 4 lines
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)
FWIW, when I split the libvirt python binding out of the main libvirt repo, I needed a few more commands to fully clean the git repo, otherwise the git repo size was still enourmous despite having very few files left. At the time I ran this:
$ git clone libvirt libvirt-python $ cd libvirt-python $ git filter-branch --subdirectory-filter python --tag-name-filter cat -- --all $ git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d $ git reflog expire --expire=now --all $ git gc --prune=now
https://www.redhat.com/archives/libvir-list/2013-September/msg00413.html
Quoted 1 line
What do you think?
I think it sounds worthwhile given the number of times this has come up before and the fact that people are forking QEMU already to get access to slirp code.
A standalone project could potentially draw in more contributors who are otherwise put off by it being part of the bigger QEMU project, and/or unable to even use it as part of QEMU. This could ultimately improve slirp's quality.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 6 lines · Daniel P. Berrangé
Quoted 5 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
Marc-André, thanks for working on this!
Quoted 15 lines
At least half of the patches in this series are deleting unused or unreachable code. I'd suggest you send all of those as a non-RFC series, as they are things we could merge straight away regardless of whether/when slirp becomes a separate library.
Quoted 9 lines
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.
Quoted 4 lines
More recently there is this fun project which just pulled in the QEMU code and chopped out everything todo with slirp:
to give a little bit of background on slirp4netns:
slirp4netns is used for setting up the network in a network namespace without requiring root privileges.
It is already used by Podman and Buildah to set up the network for rootless containers, so they won't be limited to run in the host network namespace or require a suid helper.
Coincidentally just today I was working on a slirp4netns change for spawning a QEMU process instead of using the forked version. I'd prefer to not rely on the slirp forked version, but this costs the access to the underlying knobs. With a separate libslirp project, this is not needed anymore.
One change I am aware of in the forked version is the possibility to tweak the MTU and AFAIK this is the only blocker from adopting libslirp immediately.
Akihiro, is there anything more that could block slirp4netns from just using libslirp once it is available?
Regards,
Giuseppe
Quoted 1 line
One change I am aware of in the forked version is the possibility
to tweak the MTU and AFAIK this is the only blocker from adopting libslirp immediately.
Quoted 1 line
Akihiro, is there anything more that could block slirp4netns from
just using libslirp once it is available?
No, the only blocker is MTU (which significantly improves the bandwidth from 1.07 Gbps to 9.21 Gbps :
https://github.com/rootless-containers/slirp4netns/tree/19ec5cf6b8f562ebaed6d4004c8b172907ea6adb#benchmarks
)
In future I think we want to support checksum offloading and multiqueue/multithread, but these can be experimented and discussed after we get support for the standalone libslirp.
https://github.com/rootless-containers/slirp4netns/issues/16
https://github.com/rootless-containers/slirp4netns/issues/17
2018年11月16日(金) 0:49 Giuseppe Scrivano <[email protected]>:
Quoted 58 lines
Quoted 6 lines · Daniel P. Berrangé
Quoted 5 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent
library.
Marc-André, thanks for working on this!
Quoted 9 lines
At least half of the patches in this series are deleting unused or unreachable code. I'd suggest you send all of those as a non-RFC series, as they are things we could merge straight away regardless of whether/when slirp becomes a separate library.
Quoted 4 lines
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the
past.
Quoted 10 lines
Quoted 5 lines
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.More recently there is this fun project which just pulled in the QEMU code and chopped out everything todo with slirp:
to give a little bit of background on slirp4netns:
slirp4netns is used for setting up the network in a network namespace without requiring root privileges.
It is already used by Podman and Buildah to set up the network for rootless containers, so they won't be limited to run in the host network namespace or require a suid helper.
Coincidentally just today I was working on a slirp4netns change for spawning a QEMU process instead of using the forked version. I'd prefer to not rely on the slirp forked version, but this costs the access to the underlying knobs. With a separate libslirp project, this is not needed anymore.
One change I am aware of in the forked version is the possibility to tweak the MTU and AFAIK this is the only blocker from adopting libslirp immediately.
Akihiro, is there anything more that could block slirp4netns from just using libslirp once it is available?Regards,
Giuseppe
Quoted 20 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
Quoted 6 lines
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)What do you think?
Great idea!
Maybe in the future there will be a tests too. Right now my impression is that slirp isn't hardened and suitable for production use cases (i.e. security). But with some love (and testing!) I think that could change.
Quoted 26 lines · Stefan Hajnoczi
Quoted 25 lines · Marc-André Lureau
Hi,
Based-on: https://people.debian.org/~sthibault/qemu.git/ slirp branch
This series goal is to allow building libslirp as an independent library.
While looking at making SLIRP a seperate running process, I thought that having an independent library from QEMU would be a first step.
There has been some attempts to make slirp a seperate project in the past.
(https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg01092.html)
Unfortunately, they forked from QEMU and didn't provide enough compatibility for QEMU to make use of it (in particular, vmstate handling was removed, they lost git history etc). Furthermore, they are not maintained as far as I can see.I would propose to make slirp a seperate project, that can initially be used by QEMU as a submodule, keeping Makefile.objs until a proper shared library with stability guarantees etc is ready..
The subproject could created by preserving git tags, and cleaning up the code style, this way:
git filter-branch --tree-filter "if ls * 1>
/dev/null2>&1; then clang-format -i */dev/null; fi " -f --subdirectory-filter "slirp" --prune-empty --tag-name-filter cat -- --all (my clang-format https://gist.github.com/elmarco/cb20c8d92007df0e2fb8a2404678ac73)
Quoted 7 lines
Quoted 1 line
What do you think?
Great idea!
Maybe in the future there will be a tests too. Right now my impression is that slirp isn't hardened and suitable for production use cases (i.e. security). But with some love (and testing!) I think that could change.
With Marc-André's desire to move it to a separate process, it is the kind of thing where seccomp could actually do a fairly good job as it would be a narrow enough piece of functionality that you can put some meaningful constraints around it.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 2 lines · Daniel P. Berrangé
Quoted 1 line · Stefan Hajnoczi
On Wed, Nov 14, 2018 at 04:36:02PM +0400, Marc-André Lureau wrote:
[...]
Quoted 9 lines
Quoted 4 lines
Maybe in the future there will be a tests too. Right now my impression is that slirp isn't hardened and suitable for production use cases (i.e. security). But with some love (and testing!) I think that could change.
With Marc-André's desire to move it to a separate process, it is the kind of thing where seccomp could actually do a fairly good job as it would be a narrow enough piece of functionality that you can put some meaningful constraints around it.
It will also become easier to fuzz.