slirp updates
Subsystems (2)
The following changes since commit e85c577158a2e8e252414959da9ef15c12eec63d:
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2018-12-17' into staging (2018-12-18 14:31:06 +0000)
are available in the Git repository at:
https://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
for you to fetch changes up to 4c2b5ca1b5dd42bb96e954db7a46ebe39fd24620:
slirp: Mark debugging calls as unlikely (2018-12-18 23:44:35 +0100)
----------------------------------------------------------------
Abstract away slirp toward a libslirp
Gerd Hoffmann (1):
slirp: add tftp tracing
Marc-André Lureau (61):
slirp: associate slirp_output callback with the Slirp context
slirp: remove do_pty from fork_exec()
slirp: replace ex_pty with ex_chardev
slirp: use a dedicated field for chardev pointer
slirp: remove unused EMU_RSH
slirp: rename /extra/chardev
slirp: move internal function declarations
slirp: remove Monitor dependency, return a string for info
slirp: fix slirp_add_exec() leaks
slirp: replace the poor-man string split with g_strsplit()
slirp: remove dead declarations
slirp: move socket pair creation in helper function
slirp: remove unused M_TRAILINGSPACE
slirp: use a callback structure to interface with qemu
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: add a callback to log guest errors
slirp: remove #if notdef dead code
slirp: remove unused sbflush()
slirp: NULL is defined by stddef.h
slirp: remove dead TCP_ACK_HACK code
slirp: replace ARRAY_SIZE with G_N_ELEMENTS
net: do not depend on slirp internals
glib-compat: add g_spawn_async_with_fds() fallback
slirp: simplify fork_exec()
slirp: replace error_report() with g_critical()
slirp: drop <Vista compatibility
slirp: rename exec_list
slirp: use virtual time for packet expiration
slirp: replace a fprintf with g_critical()
slirp: replace some fprintf() with DEBUG_MISC
slirp: replace a DEBUG block with WITH_ICMP_ERROR_MSG
slirp: no need to make DPRINTF conditional on DEBUG
slirp: always build with debug statements
slirp: introduce SLIRP_DEBUG environment variable
slirp: use %p for pointers format
slirp: remove remaining DEBUG blocks
slirp: replace DEBUG_ARGS with DEBUG_ARG
slirp: factor out guestfwd addition checks
slirp: add clock_get_ns() callback
build-sys: use a seperate slirp-obj-y && slirp.mo
slirp: set G_LOG_DOMAIN
slirp: call into g_debug() for DEBUG macros
Samuel Thibault (2):
slirp: Enable fork_exec support on Windows
slirp: Mark debugging calls as unlikely
----------------------------------------------------------------
Gerd Hoffmann (1):
slirp: add tftp tracing
Marc-André Lureau (61):
slirp: associate slirp_output callback with the Slirp context
slirp: remove do_pty from fork_exec()
slirp: replace ex_pty with ex_chardev
slirp: use a dedicated field for chardev pointer
slirp: remove unused EMU_RSH
slirp: rename /extra/chardev
slirp: move internal function declarations
slirp: remove Monitor dependency, return a string for info
slirp: fix slirp_add_exec() leaks
slirp: replace the poor-man string split with g_strsplit()
slirp: remove dead declarations
slirp: move socket pair creation in helper function
slirp: remove unused M_TRAILINGSPACE
slirp: use a callback structure to interface with qemu
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: add a callback to log guest errors
slirp: remove #if notdef dead code
slirp: remove unused sbflush()
slirp: NULL is defined by stddef.h
slirp: remove dead TCP_ACK_HACK code
slirp: replace ARRAY_SIZE with G_N_ELEMENTS
net: do not depend on slirp internals
glib-compat: add g_spawn_async_with_fds() fallback
slirp: simplify fork_exec()
slirp: replace error_report() with g_critical()
slirp: drop <Vista compatibility
slirp: rename exec_list
slirp: use virtual time for packet expiration
slirp: replace a fprintf with g_critical()
slirp: replace some fprintf() with DEBUG_MISC
slirp: replace a DEBUG block with WITH_ICMP_ERROR_MSG
slirp: no need to make DPRINTF conditional on DEBUG
slirp: always build with debug statements
slirp: introduce SLIRP_DEBUG environment variable
slirp: use %p for pointers format
slirp: remove remaining DEBUG blocks
slirp: replace DEBUG_ARGS with DEBUG_ARG
slirp: factor out guestfwd addition checks
slirp: add clock_get_ns() callback
build-sys: use a seperate slirp-obj-y && slirp.mo
slirp: set G_LOG_DOMAIN
slirp: call into g_debug() for DEBUG macros
Samuel Thibault (2):
slirp: Enable fork_exec support on Windows
slirp: Mark debugging calls as unlikely
Makefile.objs | 4 +- Makefile.target | 5 +- include/glib-compat.h | 56 ++++++++++ net/colo-compare.c | 11 +- net/colo.c | 1 + net/colo.h | 7 +- net/filter-rewriter.c | 9 +- net/slirp.c | 61 +++++------ net/util.h | 55 ++++++++++ slirp/Makefile.objs | 37 ++++++- slirp/arp_table.c | 12 +-- slirp/bootp.c | 10 +- slirp/cksum.c | 8 +- slirp/debug.h | 47 +++++---- slirp/dhcpv6.c | 17 ++- slirp/if.c | 4 +- slirp/ip.h | 10 +- slirp/ip6.h | 3 +- slirp/ip6_icmp.c | 27 +++-- slirp/ip6_icmp.h | 6 +- slirp/ip6_input.c | 2 +- slirp/ip6_output.c | 4 +- slirp/ip_icmp.c | 31 +++--- slirp/ip_input.c | 200 ----------------------------------- slirp/libslirp.h | 27 +++-- slirp/main.h | 33 ------ slirp/mbuf.c | 2 +- slirp/mbuf.h | 1 - slirp/misc.c | 286 ++++++++++++++++++++------------------------------ slirp/misc.h | 13 ++- slirp/ncsi.c | 4 +- slirp/ndp_table.c | 32 +++--- slirp/sbuf.h | 1 - slirp/slirp.c | 177 +++++++++++++++---------------- slirp/slirp.h | 45 ++------ slirp/slirp_config.h | 86 --------------- slirp/socket.c | 53 +++------- slirp/socket.h | 2 +- slirp/tcp.h | 4 +- slirp/tcp_input.c | 84 ++------------- slirp/tcp_output.c | 2 +- slirp/tcp_subr.c | 17 ++- slirp/tcp_timer.c | 2 +- slirp/tftp.c | 7 +- slirp/trace-events | 5 + slirp/udp.c | 5 +- slirp/udp6.c | 11 +- stubs/slirp.c | 2 +- 48 files changed, 595 insertions(+), 933 deletions(-) delete mode 100644 slirp/slirp_config.h create mode 100644 slirp/trace-events
[Qemu-devel] [PULL 05/64] slirp: remove unused EMU_RSH
From: Marc-André Lureau <[email protected]>
EMU_RSH handling was dropped in commit0d62c4cfe21752df4c1d6e2c2398f15d5eaa794a.
The assignment, and subsequent free() of ex_ptr->ex_exec to so->extra looks unsafe (double free is likely to occur).
--- slirp/misc.h | 1 - slirp/slirp.c | 2 -- slirp/socket.c | 4 ---- slirp/tcp_subr.c | 1 - 4 files changed, 8 deletions(-)
slirp/misc.h +0 -1
@@ -26,7 +26,6 @@ struct ex_list {#define EMU_REALAUDIO 0x5#define EMU_RLOGIN 0x6#define EMU_IDENT 0x7 -#define EMU_RSH 0x8#define EMU_NOCONNECT 0x10/* Don't connect */
slirp/slirp.c +0 -2
@@ -1499,8 +1499,6 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) }if (!ex_ptr)return -EINVAL ; - - so->extra = (void *)ex_ptr->ex_exec; }return vmstate_load_state (f, &vmstate_slirp, slirp, version_id);
slirp/socket.c +0 -4
@@ -89,10 +89,6 @@ sofree(struct socket *so)soqfree (so, &slirp->if_fastq);soqfree (so, &slirp->if_batchq); -if (so->so_emu==EMU_RSH && so->extra) { -sofree (so->extra); - so->extra=NULL ; - }if (so == slirp->tcp_last_so) { slirp->tcp_last_so = &slirp->tcb; }else if (so == slirp->udp_last_so) {
slirp/tcp_subr.c +0 -1
@@ -541,7 +541,6 @@ static const struct tos_t tcptos[] = { {0, 23, IPTOS_LOWDELAY, 0}, /* telnet */ {0, 80, IPTOS_THROUGHPUT, 0}, /* WWW */ {0, 513, IPTOS_LOWDELAY, EMU_RLOGIN|EMU_NOCONNECT}, /* rlogin */ - {0, 514, IPTOS_LOWDELAY, EMU_RSH|EMU_NOCONNECT}, /* shell */ {0, 544, IPTOS_LOWDELAY, EMU_KSH}, /* kshell */ {0, 543, IPTOS_LOWDELAY, 0}, /* klogin */ {0, 6667, IPTOS_THROUGHPUT, EMU_IRC}, /* IRC */
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 01/64] slirp: associate slirp_output callback with the Slirp context
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Let's make the slirp interface a bit more library-like. Associate the slirp_output() with a Slirp context.
--- net/slirp.c | 5 +++-- slirp/libslirp.h | 9 +++++---- slirp/ncsi.c | 2 +- slirp/slirp.c | 11 +++++++---- slirp/slirp.h | 1 + 5 files changed, 17 insertions(+), 11 deletions(-)
net/slirp.c +3 -2
@@ -99,7 +99,7 @@ static void slirp_smb_cleanup(SlirpState *s);static inline void slirp_smb_cleanup (SlirpState *s) { }#endif -void slirp_output (void *opaque,const uint8_t *pkt,int pkt_len) +static void net_slirp_output (void *opaque,const uint8_t *pkt,int pkt_len) {SlirpState *s = opaque;
@@ -378,7 +378,8 @@ static int net_slirp_init(NetClientState *peer, const char *model, ipv6, ip6_prefix, vprefix6_len, ip6_host, vhostname, tftp_server_name, tftp_export, bootfile, dhcp, - dns, ip6_dns, dnssearch, vdomainname, s); + dns, ip6_dns, dnssearch, vdomainname, + net_slirp_output, s);QTAILQ_INSERT_TAIL (&slirp_stacks, s, entry);for (config = slirp_configs; config; config = config->next) {
slirp/libslirp.h +5 -4
@@ -5,6 +5,8 @@typedef struct Slirp Slirp ; +typedef void (*slirp_output )(void *opaque,const uint8_t *pkt,int pkt_len); +int get_dns_addr (struct in_addr *pdns_addr);int get_dns6_addr (struct in6_addr *pdns6_addr,uint32_t *scope_id);
@@ -17,7 +19,9 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, const char *tftp_path, const char *bootfile, struct in_addr vdhcp_start, struct in_addr vnameserver, struct in6_addr vnameserver6, const char **vdnssearch, - const char *vdomainname, void *opaque); + const char *vdomainname, + slirp_output output, + void *opaque);void slirp_cleanup (Slirp *slirp);void slirp_pollfds_fill (GArray *pollfds,uint32_t *timeout);
@@ -26,9 +30,6 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error);void slirp_input (Slirp *slirp,const uint8_t *pkt,int pkt_len); -/* you must provide the following functions: */ -void slirp_output (void *opaque,const uint8_t *pkt,int pkt_len); -int slirp_add_hostfwd (Slirp *slirp,int is_udp,struct in_addr host_addr,int host_port,struct in_addr guest_addr,int guest_port);
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->output (slirp->opaque, ncsi_reply,ETH_HLEN + ncsi_rsp_len); }
slirp/slirp.c +7 -4
@@ -287,12 +287,15 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, const char *tftp_path, const char *bootfile, struct in_addr vdhcp_start, struct in_addr vnameserver, struct in6_addr vnameserver6, const char **vdnssearch, - const char *vdomainname, void *opaque) + const char *vdomainname, + slirp_output output, + void *opaque) { Slirp *slirp = g_malloc0(sizeof(Slirp));slirp_init_once (); + slirp->output = output; slirp->grand =g_rand_new (); slirp->restricted = restricted;
@@ -832,7 +835,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->output (slirp->opaque, arp_reply,sizeof (arp_reply)); }break ;case ARPOP_REPLY :
@@ -932,7 +935,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->output (slirp->opaque, arp_req,sizeof (arp_req)); ifm->resolution_requested = true;/* Expire request and drop outgoing packet after 1 second */
@@ -1018,7 +1021,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->output (slirp->opaque, buf, ifm->m_len +ETH_HLEN );return 1 ; }
slirp/slirp.h +1 -0
@@ -220,6 +220,7 @@ struct Slirp {GRand *grand;QEMUTimer *ra_timer; +slirp_output output;void *opaque; };
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 02/64] slirp: remove do_pty from fork_exec()
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
QEMU uses fork_exec() with do_pty values 0 or 3.
Let's clean up some unused code.
--- slirp/misc.c | 55 ++++++++++++++---------------------------------- slirp/misc.h | 2 +- slirp/tcp_subr.c | 4 +--- 3 files changed, 18 insertions(+), 43 deletions(-)
slirp/misc.c +16 -39
@@ -63,7 +63,7 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec,#ifdef _WIN32int -fork_exec (struct socket *so,const char *ex,int do_pty) +fork_exec (struct socket *so,const char *ex) {/* not implemented */ return 0 ;
@@ -77,13 +77,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty)* process, which connects to this socket, after which we * exec the wanted program. If something (strange) happens, * the accept() call could block us forever. -* -* do_pty = 0 Fork/exec inetd style -* do_pty = 1 Fork/exec using slirp.telnetd -* do_ptr = 2 Fork/exec using pty */ int -fork_exec (struct socket *so,const char *ex,int do_pty) +fork_exec (struct socket *so,const char *ex) {int s, cs;struct sockaddr_in addr, csaddr;
@@ -100,26 +96,20 @@ fork_exec(struct socket *so, const char *ex, int do_pty)DEBUG_CALL ("fork_exec" );DEBUG_ARG ("so = %p" , so);DEBUG_ARG ("ex = %p" , ex); -DEBUG_ARG ("do_pty = %x" , do_pty); - -if (do_pty ==2 ) { -return 0 ; - }else { - addr.sin_family =AF_INET ; - addr.sin_port =0 ; - addr.sin_addr.s_addr =INADDR_ANY ; -if ((s =qemu_socket (AF_INET ,SOCK_STREAM ,0 )) <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); - } + addr.sin_family =AF_INET ; + addr.sin_port =0 ; + addr.sin_addr.s_addr =INADDR_ANY ; -return 0 ; - } - } + 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); + } +return 0 ; + }if (getsockname (s, (struct sockaddr *)&csaddr, &csaddrlen) <0 ) {closesocket (s);
@@ -166,13 +156,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty) i =0 ; bptr =g_strdup (ex);/* No need to free() this */ -if (do_pty ==1 ) { -/* Setup "slirp.telnetd -x" */ - argv[i++] ="slirp.telnetd" ; - argv[i++] ="-x" ; - argv[i++] = bptr; - } else - do { + do { /* Change the string into argv[] */ curarg = bptr; while (*bptr != ' ' && *bptr != (char)0)
@@ -180,7 +164,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty) c = *bptr; *bptr++ = (char )0 ; argv[i++] =g_strdup (curarg); - }while (c); + }while (c); argv[i] =NULL ;execvp (argv[0 ], (char **)argv);
@@ -206,13 +190,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty) opt =1 ;qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));qemu_set_nonblock (so->s); - -/* Append the telnet options now */ -if (so->so_m !=NULL && do_pty ==1 ) { -sbappend (so, so->so_m); - so->so_m =NULL ; - } -return 1 ; } }
slirp/misc.h +1 -1
@@ -53,6 +53,6 @@ struct slirp_quehead {void slirp_insque (void *,void *);void slirp_remque (void *);int add_exec (struct ex_list **,int ,char *,struct in_addr ,int ); -int fork_exec (struct socket *so,const char *ex,int do_pty); +int fork_exec (struct socket *so,const char *ex);#endif
slirp/tcp_subr.c +1 -3
@@ -951,7 +951,6 @@ int tcp_ctl(struct socket *so)Slirp *slirp = so->slirp;struct sbuf *sb = &so->so_snd;struct ex_list *ex_ptr; -int do_pty;DEBUG_CALL ("tcp_ctl" );DEBUG_ARG ("so = %p" , so);
@@ -966,9 +965,8 @@ int tcp_ctl(struct socket *so) so->extra = (void *)ex_ptr->ex_exec;return 1 ; } - do_pty = ex_ptr->ex_pty;DEBUG_MISC ((dfd," executing %s\n" , ex_ptr->ex_exec)); -return fork_exec (so, ex_ptr->ex_exec, do_pty); +return fork_exec (so, ex_ptr->ex_exec); } } }
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 03/64] slirp: replace ex_pty with ex_chardev
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
do_pty == 3 means to talk to a chardev.
--- slirp/misc.c | 2 +- slirp/misc.h | 2 +- slirp/slirp.c | 4 ++-- slirp/tcp_subr.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
slirp/misc.c +1 -1
@@ -53,7 +53,7 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, *ex_ptr = g_new(struct ex_list, 1); (*ex_ptr)->ex_fport = port; (*ex_ptr)->ex_addr = addr; - (*ex_ptr)->ex_pty = do_pty; + (*ex_ptr)->ex_chardev = do_pty ==3 ; (*ex_ptr)->ex_exec = (do_pty ==3 ) ? exec :g_strdup (exec); (*ex_ptr)->ex_next = tmp_ptr;return 0 ;
slirp/misc.h +1 -1
@@ -9,7 +9,7 @@#define MISC_H struct ex_list { -int ex_pty;/* Do we want a pty? */ +int ex_chardev;struct in_addr ex_addr;/* Server address */ int ex_fport;/* Port to telnet to */ const char *ex_exec;/* Command line of what to exec */
slirp/slirp.c +2 -2
@@ -1455,7 +1455,7 @@ static void slirp_state_save(QEMUFile *f, void *opaque)struct ex_list *ex_ptr;for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) -if (ex_ptr->ex_pty ==3 ) { +if (ex_ptr->ex_chardev) {struct socket *so; so =slirp_find_ctl_socket (slirp, ex_ptr->ex_addr,ntohs (ex_ptr->ex_fport));
@@ -1490,7 +1490,7 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id)return -EINVAL ; }for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { -if (ex_ptr->ex_pty ==3 && +if (ex_ptr->ex_chardev && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr && so->so_fport == ex_ptr->ex_fport) {break ;
slirp/tcp_subr.c +1 -1
@@ -960,7 +960,7 @@ int tcp_ctl(struct socket *so)for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {if (ex_ptr->ex_fport == so->so_fport && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) { -if (ex_ptr->ex_pty ==3 ) { +if (ex_ptr->ex_chardev) { so->s =-1 ; so->extra = (void *)ex_ptr->ex_exec;return 1 ;
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 04/64] slirp: use a dedicated field for chardev pointer
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Let's not mix command line and chardev pointers.
--- net/slirp.c | 8 ++++---- slirp/libslirp.h | 2 +- slirp/misc.c | 11 +++++++---- slirp/misc.h | 4 ++-- slirp/slirp.c | 5 +++-- slirp/tcp_subr.c | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-)
net/slirp.c +4 -4
@@ -709,8 +709,8 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, CONFIG_SMBD_COMMAND, s->smb_dir, smb_conf);g_free (smb_conf); -if (slirp_add_exec (s->slirp,0 , smb_cmdline, &vserver_addr,139 ) <0 || -slirp_add_exec (s->slirp,0 , smb_cmdline, &vserver_addr,445 ) <0 ) { +if (slirp_add_exec (s->slirp,NULL , smb_cmdline, &vserver_addr,139 ) <0 || +slirp_add_exec (s->slirp,NULL , smb_cmdline, &vserver_addr,445 ) <0 ) {slirp_smb_cleanup (s);g_free (smb_cmdline);error_setg (errp,"Conflicting/invalid smbserver address" );
@@ -774,7 +774,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)snprintf (buf,sizeof (buf),"guestfwd.tcp.%d" , port);if ((strlen (p) >4 ) && !strncmp (p,"cmd:" ,4 )) { -if (slirp_add_exec (s->slirp,0 , &p[4 ], &server, port) <0 ) { +if (slirp_add_exec (s->slirp,NULL , &p[4 ], &server, port) <0 ) {error_setg (errp,"Conflicting/invalid host:port in guest " "forwarding rule '%s'" , config_str);return -1 ;
@@ -801,7 +801,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)return -1 ; } -if (slirp_add_exec (s->slirp,3 , &fwd->hd, &server, port) <0 ) { +if (slirp_add_exec (s->slirp, &fwd->hd,NULL , &server, port) <0 ) {error_setg (errp,"Conflicting/invalid host:port in guest " "forwarding rule '%s'" , config_str);g_free (fwd);
slirp/libslirp.h +1 -1
@@ -35,7 +35,7 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr guest_addr, int guest_port);int slirp_remove_hostfwd (Slirp *slirp,int is_udp,struct in_addr host_addr,int host_port); -int slirp_add_exec (Slirp *slirp,int do_pty,const void *args, +int slirp_add_exec (Slirp *slirp,void *chardev,const char *cmdline,struct in_addr *guest_addr,int guest_port);void slirp_connection_info (Slirp *slirp,Monitor *mon);
slirp/misc.c +7 -4
@@ -37,7 +37,7 @@ remque(void *a) element->qh_rlink =NULL ; } -int add_exec (struct ex_list **ex_ptr,int do_pty,char *exec, +int add_exec (struct ex_list **ex_ptr,void *chardev,const char *cmdline,struct in_addr addr,int port) {struct ex_list *tmp_ptr;
@@ -50,11 +50,14 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, } tmp_ptr = *ex_ptr; - *ex_ptr = g_new(struct ex_list, 1); + *ex_ptr = g_new0(struct ex_list, 1); (*ex_ptr)->ex_fport = port; (*ex_ptr)->ex_addr = addr; - (*ex_ptr)->ex_chardev = do_pty ==3 ; - (*ex_ptr)->ex_exec = (do_pty ==3 ) ? exec :g_strdup (exec); +if (chardev) { + (*ex_ptr)->ex_chardev = chardev; + }else { + (*ex_ptr)->ex_exec =g_strdup (cmdline); + } (*ex_ptr)->ex_next = tmp_ptr;return 0 ; }
slirp/misc.h +2 -2
@@ -9,7 +9,7 @@#define MISC_H struct ex_list { -int ex_chardev; +void *ex_chardev;struct in_addr ex_addr;/* Server address */ int ex_fport;/* Port to telnet to */ const char *ex_exec;/* Command line of what to exec */
@@ -52,7 +52,7 @@ struct slirp_quehead {void slirp_insque (void *,void *);void slirp_remque (void *); -int add_exec (struct ex_list **,int ,char *,struct in_addr ,int ); +int add_exec (struct ex_list **,void *,const char *,struct in_addr ,int );int fork_exec (struct socket *so,const char *ex);#endif
slirp/slirp.c +3 -2
@@ -1068,7 +1068,7 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,return 0 ; } -int slirp_add_exec (Slirp *slirp,int do_pty,const void *args, +int slirp_add_exec (Slirp *slirp,void *chardev,const char *cmdline,struct in_addr *guest_addr,int guest_port) {if (!guest_addr->s_addr) {
@@ -1081,7 +1081,8 @@ int slirp_add_exec(Slirp *slirp, int do_pty, const void *args, guest_addr->s_addr == slirp->vnameserver_addr.s_addr) {return -1 ; } -return add_exec (&slirp->exec_list, do_pty, (char *)args, *guest_addr, + +return add_exec (&slirp->exec_list, chardev, cmdline, *guest_addr,htons (guest_port)); }
slirp/tcp_subr.c +1 -1
@@ -962,7 +962,7 @@ int tcp_ctl(struct socket *so) so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) {if (ex_ptr->ex_chardev) { so->s =-1 ; - so->extra = (void *)ex_ptr->ex_exec; + so->extra = ex_ptr->ex_chardev;return 1 ; }DEBUG_MISC ((dfd," executing %s\n" , ex_ptr->ex_exec));
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 09/64] slirp: fix slirp_add_exec() leaks
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Free the list elements allocated in add_exec().
--- slirp/misc.h | 2 +- slirp/slirp.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
slirp/misc.h +1 -1
@@ -12,7 +12,7 @@ struct ex_list {void *ex_chardev;struct in_addr ex_addr;/* Server address */ int ex_fport;/* Port to telnet to */ -const char *ex_exec;/* Command line of what to exec */ +char *ex_exec;/* Command line of what to exec */ struct ex_list *ex_next; };
slirp/slirp.c +8 -0
@@ -342,6 +342,14 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,void slirp_cleanup (Slirp *slirp) { +struct ex_list *e, *next; + +for (e = slirp->exec_list; e; e = next) { + next = e->ex_next; +g_free (e->ex_exec); +g_free (e); + } +QTAILQ_REMOVE (&slirp_instances, slirp, entry);unregister_savevm (NULL ,"slirp" , slirp);
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 12/64] slirp: add tftp tracing
In reply to Samuel ThibaultFrom: Gerd Hoffmann <[email protected]>
Useful when debugging pxeboot, to see what the guest tries to do.
--- Makefile.objs | 1 + slirp/tftp.c | 3 +++ slirp/trace-events | 5 +++++ 3 files changed, 9 insertions(+) create mode 100644 slirp/trace-events
Makefile.objs +1 -0
@@ -190,6 +190,7 @@ 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/tftp.c +3 -0
@@ -26,6 +26,7 @@#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) {
@@ -204,6 +205,7 @@ static void tftp_send_error(struct tftp_session *spt,struct mbuf *m;struct tftp_t *tp; +trace_slirp_tftp_error (msg); m =m_get (spt->slirp);if (!m) {
@@ -323,6 +325,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,break ; } } +trace_slirp_tftp_rrq (req_fname);/* check mode */ if ((pktlen - k) <6 ) {
slirp/trace-events new file +5 -0
@@ -0,0 +1,5 @@ +# 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.2
[Qemu-devel] [PULL 11/64] slirp: remove dead declarations
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
An overdue cleanup. Remaining declarations could probably be moved in other headers, such as slirp.h.
--- slirp/main.h | 29 ----------------------------- 1 file changed, 29 deletions(-)
slirp/main.h +0 -29
@@ -12,38 +12,9 @@#include <sys/select.h> #endif -#define TOWRITEMAX 512 - -extern int slirp_socket; -extern int slirp_socket_unit; -extern int slirp_socket_port; -extern uint32_t slirp_socket_addr; -extern char *slirp_socket_passwd; -extern int ctty_closed; - -/* -* Get the difference in 2 times from updtim() -* Allow for wraparound times, "just in case" -* x is the greater of the 2 (current time) and y is -* what it's being compared against. -*/ -#define TIME_DIFF (x,y) (x)-(y) < 0 ? ~0-(y)+(x) : (x)-(y) - -extern char *slirp_tty; -extern char *exec_shell;extern u_int curtime;extern struct in_addr loopback_addr;extern unsigned long loopback_mask; -extern char *username; -extern char *socket_path; -extern int towrite_max; -extern int ppp_exit; -extern int tcp_keepintvl; - -#define PROTO_SLIP 0x1 -#ifdef USE_PPP -#define PROTO_PPP 0x2 -#endif int if_encap (Slirp *slirp,struct mbuf *ifm);ssize_t slirp_send (struct socket *so,const void *buf,size_t len,int flags);
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 14/64] slirp: remove unused M_TRAILINGSPACE
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 17/64] slirp: remove FULL_BOLT
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Looking at git history, this looks like something from the past, when there was a tty layer. Let's remove it.
--- slirp/if.c | 2 -- slirp/slirp_config.h | 7 ------- 2 files changed, 9 deletions(-)
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 }/*
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
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 19/64] slirp: remove HAVE_SYS_SIGNAL_H
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 24/64] slirp: remove unused HAVE_SYS_WAIT_H
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 07/64] slirp: move internal function declarations
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Clarify that those functions are internal to slirp.
--- slirp/libslirp.h | 3 --- slirp/slirp.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
slirp/libslirp.h +0 -3
@@ -7,9 +7,6 @@ typedef struct Slirp Slirp;typedef void (*slirp_output )(void *opaque,const uint8_t *pkt,int pkt_len); -int get_dns_addr (struct in_addr *pdns_addr); -int get_dns6_addr (struct in6_addr *pdns6_addr,uint32_t *scope_id); - Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vnetmask, struct in_addr vhost, bool in6_enabled,
slirp/slirp.h +3 -0
@@ -232,6 +232,9 @@ extern Slirp *slirp_instance;void if_start (Slirp *); +int get_dns_addr (struct in_addr *pdns_addr); +int get_dns6_addr (struct in6_addr *pdns6_addr,uint32_t *scope_id); +/* ncsi.c */ void ncsi_input (Slirp *slirp,const uint8_t *pkt,int pkt_len);
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 10/64] slirp: replace the poor-man string split with g_strsplit()
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Use the glib function for the work, fix a potential crash on >256 words.
--- slirp/misc.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
slirp/misc.c +3 -18
@@ -88,11 +88,8 @@ fork_exec(struct socket *so, const char *ex)socklen_t addrlen =sizeof (addr);socklen_t csaddrlen =sizeof (csaddr);int opt; -const char *argv[256 ]; -/* don't want to clobber the original */ -char *bptr; -const char *curarg; -int c, i, ret; +char **argv; +int ret;pid_t pid;DEBUG_CALL ("fork_exec" );
@@ -156,19 +153,7 @@ fork_exec(struct socket *so, const char *ex)for (s =getdtablesize () -1 ; s >=3 ; s--)close (s); - i =0 ; - bptr =g_strdup (ex);/* No need to free() this */ -do { -/* Change the string into argv[] */ - curarg = bptr; -while (*bptr !=' ' && *bptr != (char )0 ) - bptr++; - c = *bptr; - *bptr++ = (char )0 ; - argv[i++] =g_strdup (curarg); - }while (c); - - argv[i] =NULL ; + argv =g_strsplit (ex," " ,-1 );execvp (argv[0 ], (char **)argv);/* Ooops, failed, let's tell the user why */
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 13/64] slirp: move socket pair creation in helper function
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
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.2
[Qemu-devel] [PULL 20/64] slirp: remove unused HAVE_SYS_BITYPES_H
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 29/64] slirp: remove unused HAVE_INET_ATON
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 16/64] slirp: remove PROBE_CONN dead-code
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Nobody cares for over 14y. Somebody can revert or rewrite if interested by that.
--- slirp/slirp.c | 41 ----------------------------------------- slirp/slirp_config.h | 4 ---- 2 files changed, 45 deletions(-)
slirp/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 }/*
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
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 18/64] slirp: remove the disabled readv()/writev() code path
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
The 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.2
[Qemu-devel] [PULL 23/64] slirp: remove unused HAVE_ARPA_INET_H
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 06/64] slirp: rename /extra/chardev
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Now it's only used for the chardev pointer.
--- slirp/slirp.c | 4 ++-- slirp/socket.h | 2 +- slirp/tcp_subr.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
slirp/slirp.c +2 -2
@@ -1088,10 +1088,10 @@ int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline,ssize_t slirp_send (struct socket *so,const void *buf,size_t len,int flags) { -if (so->s ==-1 && so->extra) { +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->extra, buf, len); +qemu_chr_fe_write_all (so->chardev, buf, len);return len; }
slirp/socket.h +1 -1
@@ -67,7 +67,7 @@ struct socket {struct sbuf so_rcv;/* Receive buffer */ struct sbuf so_snd;/* Send buffer */ -void * extra;/* Extra pointer */ +void * chardev; };
slirp/tcp_subr.c +1 -1
@@ -961,7 +961,7 @@ int tcp_ctl(struct socket *so) so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) {if (ex_ptr->ex_chardev) { so->s =-1 ; - so->extra = ex_ptr->ex_chardev; + so->chardev = ex_ptr->ex_chardev;return 1 ; }DEBUG_MISC ((dfd," executing %s\n" , ex_ptr->ex_exec));
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 08/64] slirp: remove Monitor dependency, return a string for info
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
There is nothing performance-sensitive in returning an allocated string for info, and handling the monitor_printf() on the caller side.
--- net/slirp.c | 7 ++++--- slirp/libslirp.h | 2 +- slirp/misc.c | 23 +++++++++++++---------- 3 files changed, 18 insertions(+), 14 deletions(-)
net/slirp.c +4 -3
@@ -828,10 +828,11 @@ void hmp_info_usernet(Monitor *mon, const QDict *qdict) QTAILQ_FOREACH(s, &slirp_stacks, entry) {int id;bool got_hub_id =net_hub_id_for_client (&s->nc, &id) ==0 ; -monitor_printf (mon,"Hub %d (%s):\n" , +char *info =slirp_connection_info (s->slirp); +monitor_printf (mon,"Hub %d (%s):\n%s" , got_hub_id ? id :-1 , - s->nc.name); -slirp_connection_info (s->slirp, mon); + s->nc.name, info); +g_free (info); } }
slirp/libslirp.h +1 -1
@@ -35,7 +35,7 @@ int slirp_remove_hostfwd(Slirp *slirp, int is_udp,int slirp_add_exec (Slirp *slirp,void *chardev,const char *cmdline,struct in_addr *guest_addr,int guest_port); -void slirp_connection_info (Slirp *slirp,Monitor *mon); +char *slirp_connection_info (Slirp *slirp);void slirp_socket_recv (Slirp *slirp,struct in_addr guest_addr,int guest_port,const uint8_t *buf,int size);
slirp/misc.c +13 -10
@@ -8,7 +8,6 @@#include "qemu/osdep.h" #include "slirp.h" #include "libslirp.h" -#include "monitor/monitor.h" #include "qemu/error-report.h" #include "qemu/main-loop.h"
@@ -198,8 +197,9 @@ fork_exec(struct socket *so, const char *ex) }#endif -void slirp_connection_info (Slirp *slirp,Monitor *mon) +char *slirp_connection_info (Slirp *slirp) { +GString *str =g_string_new (NULL );const char *const tcpstates[] = { [TCPS_CLOSED ] ="CLOSED" , [TCPS_LISTEN ] ="LISTEN" ,
@@ -221,8 +221,9 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)const char *state;char buf[20 ]; -monitor_printf (mon," Protocol[State] FD Source Address Port " -"Dest. Address Port RecvQ SendQ\n" ); +g_string_append_printf (str, +" Protocol[State] FD Source Address Port " +"Dest. Address Port RecvQ SendQ\n" );for (so = slirp->tcb.so_next; so != &slirp->tcb; so = so->so_next) {if (so->so_state &SS_HOSTFWD ) {
@@ -244,10 +245,10 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) dst_port = so->so_fport; }snprintf (buf,sizeof (buf)," TCP[%s]" , state); -monitor_printf (mon,"%-19s %3d %15s %5d " , buf, so->s, +g_string_append_printf (str,"%-19s %3d %15s %5d " , buf, so->s, src.sin_addr.s_addr ?inet_ntoa (src.sin_addr) :"*" ,ntohs (src.sin_port)); -monitor_printf (mon,"%15s %5d %5d %5d\n" , +g_string_append_printf (str,"%15s %5d %5d %5d\n" ,inet_ntoa (dst_addr),ntohs (dst_port), so->so_rcv.sb_cc, so->so_snd.sb_cc); }
@@ -267,10 +268,10 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) dst_addr = so->so_faddr; dst_port = so->so_fport; } -monitor_printf (mon,"%-19s %3d %15s %5d " , buf, so->s, +g_string_append_printf (str,"%-19s %3d %15s %5d " , buf, so->s, src.sin_addr.s_addr ?inet_ntoa (src.sin_addr) :"*" ,ntohs (src.sin_port)); -monitor_printf (mon,"%15s %5d %5d %5d\n" , +g_string_append_printf (str,"%15s %5d %5d %5d\n" ,inet_ntoa (dst_addr),ntohs (dst_port), so->so_rcv.sb_cc, so->so_snd.sb_cc); }
@@ -280,9 +281,11 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) (so->so_expire - curtime) / 1000); src.sin_addr = so->so_laddr; dst_addr = so->so_faddr; -monitor_printf (mon,"%-19s %3d %15s - " , buf, so->s, +g_string_append_printf (str,"%-19s %3d %15s - " , buf, so->s, src.sin_addr.s_addr ?inet_ntoa (src.sin_addr) :"*" ); -monitor_printf (mon,"%15s - %5d %5d\n" ,inet_ntoa (dst_addr), +g_string_append_printf (str,"%15s - %5d %5d\n" ,inet_ntoa (dst_addr), so->so_rcv.sb_cc, so->so_snd.sb_cc); } + +return g_string_free (str, FALSE); }
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 21/64] slirp: remove NO_UNIX_SOCKETS
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 30/64] slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
One 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.2
[Qemu-devel] [PULL 36/64] slirp: add a callback to log guest errors
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- net/slirp.c | 7 +++++++ slirp/dhcpv6.c | 6 +++--- slirp/ip6_icmp.c | 7 +++---- slirp/libslirp.h | 2 ++ 4 files changed, 15 insertions(+), 7 deletions(-)
net/slirp.c +7 -0
@@ -23,6 +23,7 @@*/ #include "qemu/osdep.h" +#include "qemu/log.h" #include "net/slirp.h"
@@ -140,8 +141,14 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; +static void net_slirp_guest_error (const char *msg) +{ +qemu_log_mask (LOG_GUEST_ERROR ,"%s" , msg); +} +static const SlirpCb slirp_cb = { .output = net_slirp_output, + .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
@@ -342,8 +342,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 :
@@ -376,8 +375,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 ; } }
slirp/libslirp.h +2 -0
@@ -13,6 +13,8 @@ typedef struct Slirp Slirp;typedef struct SlirpCb {/* Send an ethernet frame to the guest network. */ void (*output)(void *opaque,const uint8_t *pkt,int pkt_len); +/* Print a message for an error due to guest misbehavior. */ +void (*guest_error)(const char *msg); }SlirpCb ;
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 26/64] slirp: remove HAVE_SYS_IOCTL_H
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 33/64] slirp: remove unused global slirp_instance
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 42/64] net: do not depend on slirp internals
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Only 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-compare.c | 11 +++++---- net/colo.c | 1 + net/colo.h | 7 +++--- net/filter-rewriter.c | 9 +++---- net/slirp.c | 2 +- net/util.h | 55 +++++++++++++++++++++++++++++++++++++++++++ stubs/slirp.c | 2 +- 7 files changed, 72 insertions(+), 15 deletions(-)
net/colo-compare.c +6 -5
@@ -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) \
@@ -129,19 +130,19 @@ static int compare_chr_send(CompareState *s,static gint seq_sorter (Packet *a,Packet *b,gpointer data) { -struct tcphdr *atcp, *btcp; +struct tcp_hdr *atcp, *btcp; - atcp = (struct tcphdr *)(a->transport_header); - btcp = (struct tcphdr *)(b->transport_header); + atcp = (struct tcp_hdr *)(a->transport_header); + btcp = (struct tcp_hdr *)(b->transport_header);return ntohl (atcp->th_seq) -ntohl (btcp->th_seq); }static void fill_pkt_tcp_info (void *data,uint32_t *max_ack) {Packet *pkt = data; -struct tcphdr *tcphd; +struct tcp_hdr *tcphd; - tcphd = (struct tcphdr *)pkt->transport_header; + tcphd = (struct tcp_hdr *)pkt->transport_header; pkt->tcp_seq =ntohl (tcphd->th_seq); pkt->tcp_ack =ntohl (tcphd->th_ack);
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/colo.h +3 -4
@@ -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
@@ -81,10 +80,10 @@ typedef struct Connection {/* the maximum of acknowledgement number in secondary_list queue */ uint32_t sack;/* offset = secondary_seq - primary_seq */ -tcp_seq offset; +uint32_t offset;int tcp_state;/* TCP FSM state */ -tcp_seq fin_ack_seq;/* the seq of 'fin=1,ack=1' */ +uint32_t fin_ack_seq;/* the seq of 'fin=1,ack=1' */ } Connection;uint32_t connection_key_hash (const void *opaque);
net/filter-rewriter.c +5 -4
@@ -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)
@@ -73,9 +74,9 @@ static int handle_primary_tcp_pkt(RewriterState *rf, Connection *conn, Packet *pkt, ConnectionKey *key) { -struct tcphdr *tcp_pkt; +struct tcp_hdr *tcp_pkt; - tcp_pkt = (struct tcphdr *)pkt->transport_header; + tcp_pkt = (struct tcp_hdr *)pkt->transport_header;if (trace_event_get_state_backends (TRACE_COLO_FILTER_REWRITER_DEBUG )) { trace_colo_filter_rewriter_pkt_info(__func__, inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst),
@@ -176,9 +177,9 @@ static int handle_secondary_tcp_pkt(RewriterState *rf, Connection *conn, Packet *pkt, ConnectionKey *key) { -struct tcphdr *tcp_pkt; +struct tcp_hdr *tcp_pkt; - tcp_pkt = (struct tcphdr *)pkt->transport_header; + tcp_pkt = (struct tcp_hdr *)pkt->transport_header;if (trace_event_get_state_backends (TRACE_COLO_FILTER_REWRITER_DEBUG )) { trace_colo_filter_rewriter_pkt_info(__func__,
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) {
net/util.h +55 -0
61 lines not on this page · raw message
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.2
[Qemu-devel] [PULL 34/64] slirp: replace error_report() with g_critical()
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Reduce 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 | 2 +- slirp/slirp.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
slirp/ip6_icmp.c +1 -1
@@ -417,7 +417,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 +1 -1
@@ -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); }
slirp/slirp.c +3 -3
@@ -1214,8 +1214,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 ; }
@@ -1323,7 +1323,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.2
[Qemu-devel] [PULL 27/64] slirp: remove HAVE_SYS_FILIO_H
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 25/64] slirp: remove unused HAVE_SYS_SELECT_H
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 31/64] slirp: replace SIZEOF_CHAR_P with glib equivalent
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 22/64] slirp: remove unused HAVE_SYS_STROPTS_H
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 28/64] slirp: remove unused DECLARE_IOVEC
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
It's actually qemu configure CONFIG_IOVEC that is being used.
slirp/ does not use it anyway
--- 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.2
[Qemu-devel] [PULL 43/64] glib-compat: add g_spawn_async_with_fds() fallback
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 38/64] slirp: remove unused sbflush()
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 39/64] slirp: NULL is defined by stddef.h
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 40/64] slirp: remove dead TCP_ACK_HACK code
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Untouched 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.2
[Qemu-devel] [PULL 41/64] slirp: replace ARRAY_SIZE with G_N_ELEMENTS
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Do 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
@@ -359,7 +359,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];
@@ -403,7 +403,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.2
[Qemu-devel] [PULL 15/64] slirp: use a callback structure to interface with qemu
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
This will bring slirp a bit forward to the state of an independent project.
--- net/slirp.c | 6 +++++- slirp/libslirp.h | 13 +++++++++++-- slirp/ncsi.c | 2 +- slirp/slirp.c | 10 +++++----- slirp/slirp.h | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-)
net/slirp.c +5 -1
@@ -140,6 +140,10 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; +static const 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/libslirp.h +11 -2
@@ -5,7 +5,16 @@typedef struct Slirp Slirp ; -typedef void (*slirp_output )(void *opaque,const uint8_t *pkt,int pkt_len); +/* +* Callbacks from slirp +* +* The opaque parameter comes from the opaque parameter given to slirp_init(). +*/ +typedef struct SlirpCb { +/* Send an ethernet frame to the guest network. */ +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 +26,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/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 ; }
slirp/slirp.h +1 -1
@@ -220,7 +220,7 @@ struct Slirp {GRand *grand;QEMUTimer *ra_timer; -slirp_output output; +const SlirpCb *cb;void *opaque; };
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 32/64] slirp: replace compile time DO_KEEPALIVE
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Use a global variable instead (similar to slirp_debug)
--- slirp/slirp.c | 3 +++ slirp/slirp.h | 6 +++--- slirp/slirp_config.h | 12 ------------ 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.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/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/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.2
[Qemu-devel] [PULL 35/64] slirp: improve a bit the debug macros
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Let them accept multiple arguments. Simplify the inner argument handling of DEBUG_ARGS/DEBUG_MISC_DEBUG_ERROR.
--- slirp/arp_table.c | 12 ++++++------ slirp/bootp.c | 3 +-- slirp/cksum.c | 4 ++-- slirp/debug.h | 47 ++++++++++++++++++++++++++++++++++++---------- 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/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/debug.h +37 -10
55 lines not on this page · raw message
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
@@ -76,7 +76,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
@@ -984,12 +984,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.2
[Qemu-devel] [PULL 37/64] slirp: remove #if notdef dead code
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- 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.2
[Qemu-devel] [PULL 44/64] slirp: simplify fork_exec()
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Use 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.2
[Qemu-devel] [PULL 45/64] slirp: replace error_report() with g_critical()
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Reduce dependency on QEMU. QEMU could use a custom log handler if it wants to redirect/filter it.
--- slirp/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
slirp/misc.c +1 -1
@@ -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 ]);
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 46/64] slirp: Enable fork_exec support on Windows
In reply to Samuel Thibaultg_spawn_async_with_fds is portable on Windows, so we can now enable fork_exec support there.
Thanks Daniel P. Berrangé for the notice!
--- slirp/misc.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
slirp/misc.c +2 -12
@@ -62,17 +62,6 @@ int add_exec(struct ex_list **ex_ptr, void *chardev, const char *cmdline, } -#ifdef _WIN32 - -int -fork_exec (struct socket *so,const char *ex) -{ -/* not implemented */ -return 0 ; -} - -#else -static int slirp_socketpair_with_oob (int sv[2 ]) {
@@ -132,7 +121,9 @@ err:static void fork_exec_child_setup (gpointer data) { +#ifndef _WIN32setsid (); +#endif }int
@@ -177,7 +168,6 @@ fork_exec(struct socket *so, const char *ex)qemu_set_nonblock (so->s);return 1 ; } -#endif char *slirp_connection_info (Slirp *slirp) {
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 48/64] slirp: rename exec_list
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
This list is not only used to handle command to execute on guest connection, it can also redirect to an arbitrary object, such as a chardev. Let's rename the struct and the field to "guestfwd".
--- slirp/misc.c | 6 +++--- slirp/misc.h | 6 +++--- slirp/slirp.c | 18 +++++++++--------- slirp/slirp.h | 2 +- slirp/tcp_input.c | 6 +++--- slirp/tcp_subr.c | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-)
slirp/misc.c +3 -3
@@ -36,10 +36,10 @@ remque(void *a) element->qh_rlink =NULL ; } -int add_exec (struct ex_list **ex_ptr,void *chardev,const char *cmdline, +int add_exec (struct gfwd_list **ex_ptr,void *chardev,const char *cmdline,struct in_addr addr,int port) { -struct ex_list *tmp_ptr; +struct gfwd_list *tmp_ptr;/* First, check if the port is "bound" */ for (tmp_ptr = *ex_ptr; tmp_ptr; tmp_ptr = tmp_ptr->ex_next) {
@@ -49,7 +49,7 @@ int add_exec(struct ex_list **ex_ptr, void *chardev, const char *cmdline, } tmp_ptr = *ex_ptr; - *ex_ptr = g_new0(struct ex_list, 1); + *ex_ptr = g_new0(struct gfwd_list, 1); (*ex_ptr)->ex_fport = port; (*ex_ptr)->ex_addr = addr;if (chardev) {
slirp/misc.h +3 -3
@@ -8,12 +8,12 @@#ifndef MISC_H #define MISC_H -struct ex_list { +struct gfwd_list {void *ex_chardev;struct in_addr ex_addr;/* Server address */ int ex_fport;/* Port to telnet to */ char *ex_exec;/* Command line of what to exec */ -struct ex_list *ex_next; +struct gfwd_list *ex_next; };#define EMU_NONE 0x0
@@ -51,7 +51,7 @@ struct slirp_quehead {void slirp_insque (void *,void *);void slirp_remque (void *); -int add_exec (struct ex_list **,void *,const char *,struct in_addr ,int ); +int add_exec (struct gfwd_list **,void *,const char *,struct in_addr ,int );int fork_exec (struct socket *so,const char *ex);#endif
slirp/slirp.c +9 -9
@@ -345,9 +345,9 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,void slirp_cleanup (Slirp *slirp) { -struct ex_list *e, *next; +struct gfwd_list *e, *next; -for (e = slirp->exec_list; e; e = next) { +for (e = slirp->guestfwd_list; e; e = next) { next = e->ex_next;g_free (e->ex_exec);g_free (e);
@@ -760,7 +760,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)struct ethhdr *reh = (struct ethhdr *)arp_reply;struct slirp_arphdr *rah = (struct slirp_arphdr *)(arp_reply +ETH_HLEN );int ar_op; -struct ex_list *ex_ptr; +struct gfwd_list *ex_ptr;if (!slirp->in_enabled) {return ;
@@ -780,7 +780,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)if (ah->ar_tip == slirp->vnameserver_addr.s_addr || ah->ar_tip == slirp->vhost_addr.s_addr) goto arp_ok; -for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { +for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {if (ex_ptr->ex_addr.s_addr == ah->ar_tip) goto arp_ok; }
@@ -1052,7 +1052,7 @@ int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline,return -1 ; } -return add_exec (&slirp->exec_list, chardev, cmdline, *guest_addr, +return add_exec (&slirp->guestfwd_list, chardev, cmdline, *guest_addr,htons (guest_port)); }
@@ -1423,9 +1423,9 @@ static const VMStateDescription vmstate_slirp = {static void slirp_state_save (QEMUFile *f,void *opaque) {Slirp *slirp = opaque; -struct ex_list *ex_ptr; +struct gfwd_list *ex_ptr; -for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) +for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next)if (ex_ptr->ex_chardev) {struct socket *so; so = slirp_find_ctl_socket(slirp, ex_ptr->ex_addr,
@@ -1445,7 +1445,7 @@ static void slirp_state_save(QEMUFile *f, void *opaque)static int slirp_state_load (QEMUFile *f,void *opaque,int version_id) {Slirp *slirp = opaque; -struct ex_list *ex_ptr; +struct gfwd_list *ex_ptr;while (qemu_get_byte (f)) {int ret;
@@ -1460,7 +1460,7 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) slirp->vnetwork_addr.s_addr) {return -EINVAL ; } -for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { +for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {if (ex_ptr->ex_chardev && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr && so->so_fport == ex_ptr->ex_fport) {
slirp/slirp.h +1 -1
@@ -147,7 +147,7 @@ struct Slirp {char client_hostname[33 ];int restricted; -struct ex_list *exec_list; +struct gfwd_list *guestfwd_list;/* mbuf states */ struct quehead m_freelist;
slirp/tcp_input.c +3 -3
@@ -211,7 +211,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af)struct sockaddr_storage lhost, fhost;struct sockaddr_in *lhost4, *fhost4;struct sockaddr_in6 *lhost6, *fhost6; -struct ex_list *ex_ptr; +struct gfwd_list *ex_ptr;Slirp *slirp;DEBUG_CALL ("tcp_input" );
@@ -394,7 +394,7 @@ findso:* for non-hostfwd connections. These should be dropped, unless it * happens to be a guestfwd. */ -for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { +for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {if (ex_ptr->ex_fport == ti->ti_dport && ti->ti_dst.s_addr == ex_ptr->ex_addr.s_addr) {break ;
@@ -616,7 +616,7 @@ findso:if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr && so->so_faddr.s_addr != slirp->vnameserver_addr.s_addr) {/* May be an add exec */ -for (ex_ptr = slirp->exec_list; ex_ptr; +for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {if (ex_ptr->ex_fport == so->so_fport && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) {
slirp/tcp_subr.c +2 -2
@@ -949,14 +949,14 @@ int tcp_ctl(struct socket *so) {Slirp *slirp = so->slirp;struct sbuf *sb = &so->so_snd; -struct ex_list *ex_ptr; +struct gfwd_list *ex_ptr;DEBUG_CALL ("tcp_ctl" );DEBUG_ARG ("so = %p" , so);if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr) {/* Check if it's pty_exec */ -for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { +for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {if (ex_ptr->ex_fport == so->so_fport && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) {if (ex_ptr->ex_chardev) {
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 51/64] slirp: replace some fprintf() with DEBUG_MISC
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Remove some clutter, and avoids direct call to fprintf().
--- slirp/slirp.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
slirp/slirp.c +6 -11
@@ -164,9 +164,7 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr,if (!f)return -1 ; -#ifdef DEBUG -fprintf (stderr,"IP address of your DNS(s): " ); -#endif +DEBUG_MISC ("IP address of your DNS(s): " );while (fgets (buff,512 , f) !=NULL ) {if (sscanf (buff,"nameserver%*[ \t]%256s" , buff2) ==1 ) {char *c =strchr (buff2,'%' );
@@ -188,15 +186,12 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr, *scope_id = if_index; } *cached_time = curtime; + }else { +DEBUG_MISC (", " ); } -#ifdef DEBUG - else - fprintf(stderr, ", "); -#endif +if (++found >3 ) { -#ifdef DEBUG -fprintf (stderr,"(more)" ); -#endif +DEBUG_MISC ("(more)" );break ; }#ifdef DEBUG
@@ -206,7 +201,7 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr,if (!res) { res ="(string conversion error)" ; } - fprintf(stderr, "%s", res); + DEBUG_MISC("%s", res); }#endif }
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 49/64] slirp: use virtual time for packet expiration
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Make all packets expiration time based on virtual clock.
--- slirp/if.c | 2 +- slirp/slirp.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
slirp/if.c +1 -1
@@ -148,7 +148,7 @@ diddit:*/ void if_start (Slirp *slirp) { -uint64_t now =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); +uint64_t now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL );bool from_batchq = false;struct mbuf *ifm, *ifm_next, *ifqt;
slirp/slirp.c +4 -3
@@ -582,7 +582,7 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error)return ; } - curtime =qemu_clock_get_ms (QEMU_CLOCK_REALTIME ); + curtime =qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL ); QTAILQ_FOREACH(slirp, &slirp_instances, entry) {/*
@@ -909,7 +909,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 = +qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) +1000000000ULL ; }return 0 ; }else {
@@ -936,7 +937,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 ; +qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) +1000000000ULL ; }return 0 ; }else {
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 52/64] slirp: replace a DEBUG block with WITH_ICMP_ERROR_MSG
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
icmp_send_error() doesnt actually log messages when DEBUG is enabled. Let's use a different define that describes better the tweaked behaviour of the function, and avoid uncompiled code.
--- slirp/ip_icmp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
slirp/ip_icmp.c +5 -3
@@ -34,6 +34,10 @@#include "slirp.h" #include "ip_icmp.h" +#ifndef WITH_ICMP_ERROR_MSG +#define WITH_ICMP_ERROR_MSG 0 +#endif +/* The message sent when emulating PING */ /* Be nice and tell them it's just a pseudo-ping packet */ static const char icmp_ping_msg[] ="This is a pseudo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n" ;
@@ -319,8 +323,7 @@ icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize,HTONS (icp->icmp_ip.ip_id);HTONS (icp->icmp_ip.ip_off); -#ifdef DEBUG -if (message) {/* DEBUG : append message to ICMP packet */ +if (message &&WITH_ICMP_ERROR_MSG ) {/* append message to ICMP packet */ int message_len;char *cpnt; message_len=strlen (message);
@@ -329,7 +332,6 @@ icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize,memcpy (cpnt, message, message_len); m->m_len+=message_len; } -#endif icp->icmp_cksum =0 ; icp->icmp_cksum =cksum (m, m->m_len);
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 54/64] slirp: always build with debug statements
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Make debug statements condiitonal only on slirp_debug flags, instead of the pre-processor DEBUG blocks, as it may introduce breakage easily, since the debug code isn't always compiled.
--- slirp/debug.h | 15 +++------------ slirp/misc.c | 6 +++++- 2 files changed, 8 insertions(+), 13 deletions(-)
slirp/debug.h +3 -12
@@ -5,9 +5,8 @@* terms and conditions of the copyright. */ -//#define DEBUG 1 - -#ifdef DEBUG +#ifndef DEBUG_H_ +#define DEBUG_H_ #define DBG_CALL 0x1#define DBG_MISC 0x2
@@ -50,12 +49,4 @@ extern int slirp_debug; } \ }while (0 ) -#else - -#define DEBUG_CALL (fmt, ...) -#define DEBUG_ARG (fmt, ...) -#define DEBUG_ARGS (fmt, ...) -#define DEBUG_MISC (fmt, ...) -#define DEBUG_ERROR (fmt, ...) - -#endif +#endif /* DEBUG_H_ */
slirp/misc.c +5 -1
@@ -12,9 +12,13 @@#include "qemu/main-loop.h" #ifdef DEBUG -int slirp_debug =DBG_CALL |DBG_MISC |DBG_ERROR ; +#define SLIRP_DEBUG (DBG_CALL | DBG_MISC | DBG_ERROR) +#else +#define SLIRP_DEBUG 0#endif +int slirp_debug =SLIRP_DEBUG ; +inline void insque (void *a,void *b) {
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 55/64] slirp: introduce SLIRP_DEBUG environment variable
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Learn to read SLIRP_DEBUG=call,misc,error (all or help also handled) to set the slirp_debug flags.
--- slirp/misc.c | 8 -------- slirp/slirp.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 8 deletions(-)
slirp/misc.c +0 -8
@@ -11,14 +11,6 @@#include "qemu/error-report.h" #include "qemu/main-loop.h" -#ifdef DEBUG -#define SLIRP_DEBUG (DBG_CALL | DBG_MISC | DBG_ERROR) -#else -#define SLIRP_DEBUG 0 -#endif - -int slirp_debug =SLIRP_DEBUG ; -inline void insque (void *a,void *b) {
slirp/slirp.c +15 -0
@@ -35,6 +35,8 @@#include <net/if.h> #endif +int slirp_debug; +/* Define to 1 if you want KEEPALIVE timers */ bool slirp_do_keepalive;
@@ -250,6 +252,7 @@ int get_dns6_addr(struct in6_addr *pdns6_addr, uint32_t *scope_id)static void slirp_init_once (void ) {static int initialized; +const char *debug;#ifdef _WIN32WSADATA Data;#endif
@@ -266,6 +269,18 @@ static void slirp_init_once(void) loopback_addr.s_addr =htonl (INADDR_LOOPBACK ); loopback_mask =htonl (IN_CLASSA_NET ); + + debug =g_getenv ("SLIRP_DEBUG" ); +if (debug) { +const GDebugKey keys[] = { + {"call" ,DBG_CALL }, + {"misc" ,DBG_MISC }, + {"error" ,DBG_ERROR }, + }; + slirp_debug =g_parse_debug_string (debug, keys,G_N_ELEMENTS (keys)); + } + + }static void slirp_state_save (QEMUFile *f,void *opaque);
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 47/64] slirp: drop <Vista compatibility
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Since commit 12f8def0e02232d7c6416ad9b66640f973c531d1 (v2.9), qemu requires Vista. Let's remove some conditional code.
Note that this introduces a missing declaration warning with mingw.
warning: implicit declaration of function 'inet_ntop'
See also: https://sourceforge.net/p/mingw-w64/mailman/message/36473782/
We could workaround it by declaring it ourself depending on __MINGW64_VERSION_*:WINSOCK_API_LINKAGE INT WSAAPI inet_pton(int Family, PCTSTR pszAddrString, PVOID pAddrBuf);
--- net/slirp.c | 22 ---------------------- slirp/ip6_icmp.c | 10 ++++------ slirp/ndp_table.c | 14 ++++++-------- 3 files changed, 10 insertions(+), 36 deletions(-)
net/slirp.c +0 -22
@@ -290,17 +290,6 @@ static int net_slirp_init(NetClientState *peer, const char *model, }#endif -#if defined(_WIN32) && (_WIN32_WINNT <0x0600 ) -/* No inet_pton helper before Vista... */ -if (vprefix6) { -/* Unsupported */ -error_setg (errp,"IPv6 prefix not supported" ); -return -1 ; - } -memset (&ip6_prefix,0 ,sizeof (ip6_prefix)); - ip6_prefix.s6_addr[0 ] =0xfe ; - ip6_prefix.s6_addr[1 ] =0xc0 ; -#else if (!vprefix6) { vprefix6 ="fec0::" ; }
@@ -308,7 +297,6 @@ static int net_slirp_init(NetClientState *peer, const char *model,error_setg (errp,"Failed to parse IPv6 prefix" );return -1 ; } -#endif if (!vprefix6_len) { vprefix6_len =64 ;
@@ -320,10 +308,6 @@ static int net_slirp_init(NetClientState *peer, const char *model, }if (vhost6) { -#if defined(_WIN32) && (_WIN32_WINNT <0x0600 ) -error_setg (errp,"IPv6 host not supported" ); -return -1 ; -#else if (!inet_pton (AF_INET6 , vhost6, &ip6_host)) {error_setg (errp,"Failed to parse IPv6 host" );return -1 ;
@@ -332,17 +316,12 @@ static int net_slirp_init(NetClientState *peer, const char *model,error_setg (errp,"IPv6 Host doesn't belong to network" );return -1 ; } -#endif }else { ip6_host = ip6_prefix; ip6_host.s6_addr[15 ] |=2 ; }if (vnameserver6) { -#if defined(_WIN32) && (_WIN32_WINNT <0x0600 ) -error_setg (errp,"IPv6 DNS not supported" ); -return -1 ; -#else if (!inet_pton (AF_INET6 , vnameserver6, &ip6_dns)) {error_setg (errp,"Failed to parse IPv6 DNS" );return -1 ;
@@ -351,7 +330,6 @@ static int net_slirp_init(NetClientState *peer, const char *model,error_setg (errp,"IPv6 DNS doesn't belong to network" );return -1 ; } -#endif }else { ip6_dns = ip6_prefix; ip6_dns.s6_addr[15 ] |=3 ;
slirp/ip6_icmp.c +4 -6
@@ -74,6 +74,7 @@ void icmp6_send_error(struct mbuf *m, uint8_t type, uint8_t code)Slirp *slirp = m->slirp;struct mbuf *t; struct ip6 *ip = mtod(m, struct ip6 *); +char addrstr[INET6_ADDRSTRLEN ];DEBUG_CALL ("icmp6_send_error" );DEBUG_ARGS (" type = %d, code = %d\n" , type, code);
@@ -90,11 +91,8 @@ void icmp6_send_error(struct mbuf *m, uint8_t type, uint8_t code) struct ip6 *rip = mtod(t, struct ip6 *); rip->ip_src = (struct in6_addr )LINKLOCAL_ADDR ; rip->ip_dst = ip->ip_src; -#if !defined(_WIN32) || (_WIN32_WINNT >=0x0600 ) -char addrstr[INET6_ADDRSTRLEN ];inet_ntop (AF_INET6 , &rip->ip_dst, addrstr,INET6_ADDRSTRLEN );DEBUG_ARG ("target = %s" , addrstr); -#endif rip->ip_nh =IPPROTO_ICMPV6 ; const int error_data_len = MIN(m->m_len,
@@ -222,12 +220,12 @@ void ndp_send_ra(Slirp *slirp)*/ void ndp_send_ns (Slirp *slirp,struct in6_addr addr) { -DEBUG_CALL ("ndp_send_ns" ); -#if !defined(_WIN32) || (_WIN32_WINNT >=0x0600 )char addrstr[INET6_ADDRSTRLEN ]; +inet_ntop (AF_INET6 , &addr, addrstr,INET6_ADDRSTRLEN ); + +DEBUG_CALL ("ndp_send_ns" );DEBUG_ARG ("target = %s" , addrstr); -#endif /* Build IPv6 packet */ struct mbuf *t =m_get (slirp);
slirp/ndp_table.c +6 -8
@@ -10,15 +10,14 @@void ndp_table_add (Slirp *slirp,struct in6_addr ip_addr,uint8_t ethaddr[ETH_ALEN ]) { +char addrstr[INET6_ADDRSTRLEN ];NdpTable *ndp_table = &slirp->ndp_table;int i; -DEBUG_CALL ("ndp_table_add" ); -#if !defined(_WIN32) || (_WIN32_WINNT >=0x0600 ) -char addrstr[INET6_ADDRSTRLEN ];inet_ntop (AF_INET6 , &(ip_addr), addrstr,INET6_ADDRSTRLEN ); + +DEBUG_CALL ("ndp_table_add" );DEBUG_ARG ("ip = %s" , addrstr); -#endif DEBUG_ARGS (" hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , ethaddr[0 ], ethaddr[1 ], ethaddr[2 ], ethaddr[3 ], ethaddr[4 ], ethaddr[5 ]);
@@ -50,15 +49,14 @@ void ndp_table_add(Slirp *slirp, struct in6_addr ip_addr,bool ndp_table_search (Slirp *slirp,struct in6_addr ip_addr,uint8_t out_ethaddr[ETH_ALEN ]) { +char addrstr[INET6_ADDRSTRLEN ];NdpTable *ndp_table = &slirp->ndp_table;int i; -DEBUG_CALL ("ndp_table_search" ); -#if !defined(_WIN32) || (_WIN32_WINNT >=0x0600 ) -char addrstr[INET6_ADDRSTRLEN ];inet_ntop (AF_INET6 , &(ip_addr), addrstr,INET6_ADDRSTRLEN ); + +DEBUG_CALL ("ndp_table_search" );DEBUG_ARG ("ip = %s" , addrstr); -#endif assert (!in6_zero (&ip_addr));
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 50/64] slirp: replace a fprintf with g_critical()
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Reduce dependency on QEMU. QEMU could use a custom glib log handler if it wants to redirect/filter it.
--- slirp/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
slirp/socket.c +1 -1
@@ -285,7 +285,7 @@ err:sofcantrcvmore (so);tcp_sockclosed (sototcpcb (so)); -fprintf (stderr,"soreadbuf buffer to small" ); +g_critical ("soreadbuf buffer too small" );return -1 ; }
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 53/64] slirp: no need to make DPRINTF conditional on DEBUG
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
DEBUG_CALL is already handled conditionally.
--- slirp/bootp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
slirp/bootp.c +2 -5
@@ -36,11 +36,7 @@static const uint8_t rfc1533_cookie[] = {RFC1533_COOKIE }; -#ifdef DEBUG #define DPRINTF (fmt, ...) DEBUG_CALL(fmt, ##__VA_ARGS__) -#else -#define DPRINTF (fmt, ...) do{}while(0) -#endif static BOOTPClient *get_new_addr (Slirp *slirp,struct in_addr *paddr,const uint8_t *macaddr)
@@ -166,8 +162,9 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)DPRINTF ("bootp packet op=%d msgtype=%d" , bp->bp_op, dhcp_msg_type);if (preq_addr.s_addr !=htonl (0L ))DPRINTF (" req_addr=%08" PRIx32"\n" ,ntohl (preq_addr.s_addr)); -else +else {DPRINTF ("\n" ); + }if (dhcp_msg_type ==0 ) dhcp_msg_type =DHCPREQUEST ;/* Force reply for old BOOTP clients */
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 56/64] slirp: use %p for pointers format
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
This fixes some compilation warnings on mingw64.
--- slirp/ip6_icmp.c | 2 +- slirp/ip6_input.c | 2 +- slirp/ip6_output.c | 4 ++-- slirp/udp6.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-)
slirp/ip6_icmp.c +1 -1
@@ -390,7 +390,7 @@ void icmp6_input(struct mbuf *m)int hlen =sizeof (struct ip6 );DEBUG_CALL ("icmp6_input" ); -DEBUG_ARG ("m = %lx" , (long ) m); +DEBUG_ARG ("m = %p" , m);DEBUG_ARG ("m_len = %d" , m->m_len);if (ntohs (ip->ip_pl) <ICMP6_MINLEN ) {
slirp/ip6_input.c +1 -1
@@ -31,7 +31,7 @@ void ip6_input(struct mbuf *m) }DEBUG_CALL ("ip6_input" ); -DEBUG_ARG ("m = %lx" , (long )m); +DEBUG_ARG ("m = %p" , m);DEBUG_ARG ("m_len = %d" , m->m_len);if (m->m_len <sizeof (struct ip6 )) {
slirp/ip6_output.c +2 -2
@@ -19,8 +19,8 @@ int ip6_output(struct socket *so, struct mbuf *m, int fast) struct ip6 *ip = mtod(m, struct ip6 *);DEBUG_CALL ("ip6_output" ); -DEBUG_ARG ("so = %lx" , (long )so); -DEBUG_ARG ("m = %lx" , (long )m); +DEBUG_ARG ("so = %p" , so); +DEBUG_ARG ("m = %p" , m);/* Fill IPv6 header */ ip->ip_v =IP6VERSION ;
slirp/udp6.c +3 -3
@@ -20,7 +20,7 @@ void udp6_input(struct mbuf *m)struct sockaddr_in6 lhost;DEBUG_CALL ("udp6_input" ); -DEBUG_ARG ("m = %lx" , (long )m); +DEBUG_ARG ("m = %p" , m);if (slirp->restricted) { goto bad;
@@ -144,8 +144,8 @@ int udp6_output(struct socket *so, struct mbuf *m,struct udphdr *uh;DEBUG_CALL ("udp6_output" ); -DEBUG_ARG ("so = %lx" , (long )so); -DEBUG_ARG ("m = %lx" , (long )m); +DEBUG_ARG ("so = %p" , so); +DEBUG_ARG ("m = %p" , m);/* adjust for header */ m->m_data -=sizeof (struct udphdr );
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 57/64] slirp: remove remaining DEBUG blocks
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Instead, rely on slirp_debug flags, or compile unconditionally (the substraction in cksum is unlikely to affect any benchmark result).
--- slirp/cksum.c | 4 ---- slirp/ip_icmp.c | 5 ++--- slirp/slirp.c | 5 +---- 3 files changed, 3 insertions(+), 11 deletions(-)
slirp/cksum.c +0 -4
@@ -70,9 +70,7 @@ int cksum(struct mbuf *m, int len)if (len < mlen) mlen = len; -#ifdef DEBUG len -= mlen; -#endif /* * Force to even boundary. */
@@ -122,12 +120,10 @@ int cksum(struct mbuf *m, int len) s_util.c[0 ] = *(uint8_t *)w; cont: -#ifdef DEBUG if (len) {DEBUG_ERROR ("cksum: out of data\n" );DEBUG_ERROR (" len = %d\n" , len); } -#endif if (mlen ==-1 ) {/* The last mbuf has odd # of bytes. Follow the standard (the odd byte may be shifted left by 8 bits
slirp/ip_icmp.c +2 -3
@@ -257,13 +257,12 @@ icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize,/* check msrc */ if (!msrc) goto end_error; ip = mtod(msrc, struct ip *); -#ifdef DEBUG - {char bufa[20 ], bufb[20 ]; +if (slirp_debug &DBG_MISC ) { +char bufa[20 ], bufb[20 ];strcpy (bufa,inet_ntoa (ip->ip_src));strcpy (bufb,inet_ntoa (ip->ip_dst));DEBUG_MISC (" %.16s to %.16s\n" , bufa, bufb); } -#endif if (ip->ip_off &IP_OFFMASK ) goto end_error;/* Only reply to fragment 0 */ /* Do not reply to source-only IPs */
slirp/slirp.c +1 -4
@@ -195,9 +195,7 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr,if (++found >3 ) {DEBUG_MISC ("(more)" );break ; - } -#ifdef DEBUG - else { + }else if (slirp_debug &DBG_MISC ) {char s[INET6_ADDRSTRLEN ];const char *res =inet_ntop (af, tmp_addr, s,sizeof (s));if (!res) {
@@ -205,7 +203,6 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr, }DEBUG_MISC ("%s" , res); } -#endif } }fclose (f);
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 58/64] slirp: replace DEBUG_ARGS with DEBUG_ARG
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
There is no clear benefit in calling an alias DEBUG_ARGS(). Replace calls with DEBUG_ARG(), and fix the white-spacing while at it.
--- slirp/arp_table.c | 12 ++++++------ slirp/debug.h | 2 -- slirp/ip6_icmp.c | 2 +- slirp/ndp_table.c | 18 +++++++++--------- slirp/slirp.c | 12 ++++++------ slirp/tcp_input.c | 6 +++--- 6 files changed, 25 insertions(+), 27 deletions(-)
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 (" hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , - ethaddr[0 ], ethaddr[1 ], ethaddr[2 ], - ethaddr[3 ], ethaddr[4 ], ethaddr[5 ]); +DEBUG_ARG ("hw addr = %02x:%02x:%02x:%02x:%02x:%02x" , + 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 (" 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_ARG ("found hw addr = %02x:%02x:%02x:%02x:%02x:%02x" , + out_ethaddr[0 ], out_ethaddr[1 ], out_ethaddr[2 ], + out_ethaddr[3 ], out_ethaddr[4 ], out_ethaddr[5 ]);return 1 ; } }
slirp/debug.h +0 -2
@@ -33,8 +33,6 @@ extern int slirp_debug; } \ } 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/ip6_icmp.c +1 -1
@@ -77,7 +77,7 @@ void icmp6_send_error(struct mbuf *m, uint8_t type, uint8_t code)char addrstr[INET6_ADDRSTRLEN ];DEBUG_CALL ("icmp6_send_error" ); -DEBUG_ARGS (" type = %d, code = %d\n" , type, code); +DEBUG_ARG ("type = %d, code = %d" , type, code);if (IN6_IS_ADDR_MULTICAST (&ip->ip_src) ||in6_zero (&ip->ip_src)) {
slirp/ndp_table.c +9 -9
@@ -18,9 +18,9 @@ void ndp_table_add(Slirp *slirp, struct in6_addr ip_addr,DEBUG_CALL ("ndp_table_add" );DEBUG_ARG ("ip = %s" , addrstr); -DEBUG_ARGS (" hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n" , - ethaddr[0 ], ethaddr[1 ], ethaddr[2 ], - ethaddr[3 ], ethaddr[4 ], ethaddr[5 ]); +DEBUG_ARG ("hw addr = %02x:%02x:%02x:%02x:%02x:%02x" , + 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 */
@@ -67,18 +67,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 (" 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_ARG ("multicast addr = %02x:%02x:%02x:%02x:%02x:%02x" , + 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 (" 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_ARG ("found hw addr = %02x:%02x:%02x:%02x:%02x:%02x" , + 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
@@ -992,12 +992,12 @@ int if_encap(Slirp *slirp, struct mbuf *ifm) }memcpy (eh->h_dest, ethaddr,ETH_ALEN ); -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 ]); +DEBUG_ARG ("src = %02x:%02x:%02x:%02x:%02x:%02x" , + 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_ARG ("dst = %02x:%02x:%02x:%02x:%02x:%02x" , + 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/tcp_input.c +3 -3
@@ -215,8 +215,8 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af)Slirp *slirp;DEBUG_CALL ("tcp_input" ); -DEBUG_ARGS (" m = %p iphlen = %2d inso = %p\n" , - m, iphlen, inso); +DEBUG_ARG ("m = %p iphlen = %2d inso = %p" , + m, iphlen, inso);/* * If called with m == 0, then we're continuing the connect
@@ -1389,7 +1389,7 @@ tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)int opt, optlen;DEBUG_CALL ("tcp_dooptions" ); -DEBUG_ARGS (" tp = %p cnt=%i\n" , tp, cnt); +DEBUG_ARG ("tp = %p cnt=%i" , tp, cnt);for (; cnt >0 ; cnt -= optlen, cp += optlen) { opt = cp[0 ];
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 59/64] slirp: factor out guestfwd addition checks
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
This will allow reusing the function in a following patch.
--- slirp/misc.c | 7 ------- slirp/slirp.c | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-)
slirp/misc.c +0 -7
@@ -37,13 +37,6 @@ int add_exec(struct gfwd_list **ex_ptr, void *chardev, const char *cmdline, {struct gfwd_list *tmp_ptr; -/* First, check if the port is "bound" */ -for (tmp_ptr = *ex_ptr; tmp_ptr; tmp_ptr = tmp_ptr->ex_next) { -if (port == tmp_ptr->ex_fport && - addr.s_addr == tmp_ptr->ex_addr.s_addr) -return -1 ; - } - tmp_ptr = *ex_ptr; *ex_ptr = g_new0(struct gfwd_list, 1); (*ex_ptr)->ex_fport = port;
slirp/slirp.c +21 -2
@@ -1046,9 +1046,11 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,return 0 ; } -int slirp_add_exec (Slirp *slirp,void *chardev,const char *cmdline, -struct in_addr *guest_addr,int guest_port) +static bool +check_guestfwd (Slirp *slirp,struct in_addr *guest_addr,int guest_port) { +struct gfwd_list *tmp_ptr; +if (!guest_addr->s_addr) { guest_addr->s_addr = slirp->vnetwork_addr.s_addr | (htonl (0x0204 ) & ~slirp->vnetwork_mask.s_addr);
@@ -1057,6 +1059,23 @@ int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline, slirp->vnetwork_addr.s_addr || guest_addr->s_addr == slirp->vhost_addr.s_addr || guest_addr->s_addr == slirp->vnameserver_addr.s_addr) { +return false; + } + +/* check if the port is "bound" */ +for (tmp_ptr = slirp->guestfwd_list; tmp_ptr; tmp_ptr = tmp_ptr->ex_next) { +if (guest_port == tmp_ptr->ex_fport && + guest_addr->s_addr == tmp_ptr->ex_addr.s_addr) +return false; + } + +return true; +} + +int slirp_add_exec (Slirp *slirp,void *chardev,const char *cmdline, +struct in_addr *guest_addr,int guest_port) +{ +if (!check_guestfwd (slirp, guest_addr, guest_port)) {return -1 ; }
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 60/64] slirp: add clock_get_ns() callback
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- net/slirp.c | 6 ++++++ slirp/if.c | 2 +- slirp/ip6_icmp.c | 4 ++-- slirp/libslirp.h | 2 ++ slirp/slirp.c | 12 +++++------- 5 files changed, 16 insertions(+), 10 deletions(-)
net/slirp.c +6 -0
@@ -146,9 +146,15 @@ static void net_slirp_guest_error(const char *msg)qemu_log_mask (LOG_GUEST_ERROR ,"%s" , msg); } +static int64_t net_slirp_clock_get_ns (void ) +{ +return qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); +} +static const SlirpCb slirp_cb = { .output = net_slirp_output, .guest_error = net_slirp_guest_error, + .clock_get_ns = net_slirp_clock_get_ns, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/if.c +1 -1
@@ -148,7 +148,7 @@ diddit:*/ void if_start (Slirp *slirp) { -uint64_t now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); +uint64_t now = slirp->cb->clock_get_ns ();bool from_batchq = false;struct mbuf *ifm, *ifm_next, *ifqt;
slirp/ip6_icmp.c +2 -2
@@ -17,7 +17,7 @@ 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 () /SCALE_MS + NDP_Interval);ndp_send_ra (slirp); }
@@ -31,7 +31,7 @@ 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 () /SCALE_MS + NDP_Interval); }void icmp6_cleanup (Slirp *slirp)
slirp/libslirp.h +2 -0
@@ -15,6 +15,8 @@ typedef struct SlirpCb {void (*output)(void *opaque,const uint8_t *pkt,int pkt_len);/* Print a message for an error due to guest misbehavior. */ void (*guest_error)(const char *msg); +/* Return the virtual clock value in nanoseconds */ +int64_t (*clock_get_ns)(void ); } SlirpCb;
slirp/slirp.c +5 -7
@@ -581,15 +581,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_VIRTUAL ); + curtime = slirp->cb->clock_get_ns () /SCALE_MS ; QTAILQ_FOREACH(slirp, &slirp_instances, entry) {/*
@@ -916,8 +916,7 @@ 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_VIRTUAL ) +1000000000ULL ; + ifm->expiration_date = slirp->cb->clock_get_ns () +1000000000ULL ; }return 0 ; }else {
@@ -943,8 +942,7 @@ static int if_encap6(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh,if (!ifm->resolution_requested) {ndp_send_ns (slirp, ip6h->ip_dst); ifm->resolution_requested = true; - ifm->expiration_date = -qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) +1000000000ULL ; + ifm->expiration_date = slirp->cb->clock_get_ns () +1000000000ULL ; }return 0 ; }else {
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 61/64] build-sys: use a seperate slirp-obj-y && slirp.mo
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
This will allow to have cflags for the whole slirp.mo -objs. It makes it possible to build tests that links only with slirp-obj-y (and not the whole common-obj).
It is also a step towards building slirp as a shared library, although this requires a bit more thoughts to build withnet/slirp.o (CONFIG_SLIRP would need to be 'm') and other build issues.
--- Makefile.objs | 3 +-- Makefile.target | 5 ++++- slirp/Makefile.objs | 35 ++++++++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 8 deletions(-)
Makefile.objs +1 -2
@@ -16,6 +16,7 @@ util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o) util-obj-y += qapi/qapi-introspect.o chardev-obj-y = chardev/ +slirp-obj-$(CONFIG_SLIRP) = slirp/ ####################################################################### # block-obj-y is code used by both qemu system emulation and qemu-img
@@ -78,8 +79,6 @@ common-obj-y += vl.o vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o -common-obj-$(CONFIG_SLIRP) += slirp/ - common-obj-y += backends/ common-obj-y += chardev/
Makefile.target +4 -1
@@ -165,6 +165,7 @@ target-obj-y := block-obj-y := common-obj-y := chardev-obj-y := +slirp-obj-y := include $(SRC_PATH)/Makefile.objs dummy := $(call unnest-vars,,target-obj-y) target-obj-y-save := $(target-obj-y)
@@ -177,9 +178,11 @@ dummy := $(call unnest-vars,.., \ qom-obj-y \ io-obj-y \ common-obj-y \ - common-obj-m) + common-obj-m \ + slirp-obj-y) target-obj-y := $(target-obj-y-save) all-obj-y += $(common-obj-y) +all-obj-y += $(slirp-obj-y) all-obj-y += $(target-obj-y) all-obj-y += $(qom-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(chardev-obj-y)
slirp/Makefile.objs +30 -5
@@ -1,5 +1,30 @@ -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 +slirp-obj-y = slirp.mo + +slirp.mo-objs = \ + arp_table.o \ + bootp.o \ + cksum.o \ + dhcpv6.o \ + dnssearch.o \ + if.o \ + ip6_icmp.o \ + ip6_input.o \ + ip6_output.o \ + ip_icmp.o \ + ip_input.o \ + ip_output.o \ + mbuf.o \ + misc.o \ + ncsi.o \ + ndp_table.o \ + sbuf.o \ + slirp.o \ + socket.o \ + tcp_input.o \ + tcp_output.o \ + tcp_subr.o \ + tcp_timer.o \ + tftp.o \ + udp.o \ + udp6.o \ + $(NULL)
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 62/64] slirp: set G_LOG_DOMAIN
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
We are moving to g_log() facilities to log errors and probably debug messages too. Let's have the "Slirp" prefix on messages slirp produces.
--- slirp/Makefile.objs | 2 ++ 1 file changed, 2 insertions(+)
slirp/Makefile.objs +2 -0
@@ -28,3 +28,5 @@ slirp.mo-objs = \ udp.o \ udp6.o \ $(NULL) + +slirp.mo-cflags = -DG_LOG_DOMAIN=\"Slirp\"
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 64/64] slirp: Mark debugging calls as unlikely
In reply to Samuel Thibaultto get them out of the hot path.
--- slirp/debug.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
slirp/debug.h +4 -4
@@ -15,25 +15,25 @@extern int slirp_debug;#define DEBUG_CALL (fmt, ...) do { \ - if (slirp_debug & DBG_CALL) { \ + if (G_UNLIKELY(slirp_debug & DBG_CALL)) { \ g_debug(fmt "...", ##__VA_ARGS__); \ } \ } while (0)#define DEBUG_ARG (fmt, ...) do { \ - if (slirp_debug & DBG_CALL) { \ + if (G_UNLIKELY(slirp_debug & DBG_CALL)) { \ g_debug(" " fmt, ##__VA_ARGS__); \ } \ } while (0)#define DEBUG_MISC (fmt, ...) do { \ - if (slirp_debug & DBG_MISC) { \ + if (G_UNLIKELY(slirp_debug & DBG_MISC)) { \ g_debug(fmt, ##__VA_ARGS__); \ } \ } while (0)#define DEBUG_ERROR (fmt, ...) do { \ - if (slirp_debug & DBG_ERROR) { \ + if (G_UNLIKELY(slirp_debug & DBG_ERROR)) { \ g_debug(fmt, ##__VA_ARGS__); \ } \ } while (0)
Signature · 1 line
2.19.2
[Qemu-devel] [PULL 63/64] slirp: call into g_debug() for DEBUG macros
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Make slirp use GLib logging, instead of fprintf(), so that applications can filter log, process it etc.
With recent versions of glib, G_MESSAGES_DEBUG must be set to "all" or "Slirp" to see slirp debug messages.
Reformat DEBUG_MISC & DEBUG_ERROR calls to not need \n ending.
--- slirp/cksum.c | 4 ++-- slirp/debug.h | 17 ++++------------- slirp/dhcpv6.c | 6 +++--- slirp/ip_icmp.c | 10 +++++----- slirp/slirp.c | 10 ++++------ slirp/socket.c | 24 ++++++++++++------------ slirp/tcp_input.c | 7 +++---- slirp/tcp_output.c | 2 +- slirp/tcp_subr.c | 2 +- slirp/udp.c | 5 ++--- slirp/udp6.c | 5 ++--- 11 files changed, 39 insertions(+), 53 deletions(-)
slirp/cksum.c +2 -2
@@ -121,8 +121,8 @@ int cksum(struct mbuf *m, int len) cont:if (len) { -DEBUG_ERROR ("cksum: out of data\n" ); -DEBUG_ERROR (" len = %d\n" , len); +DEBUG_ERROR ("cksum: out of data" ); +DEBUG_ERROR (" len = %d" , len); }if (mlen ==-1 ) {/* The last mbuf has odd # of bytes. Follow the
slirp/debug.h +4 -13
@@ -12,38 +12,29 @@#define DBG_MISC 0x2#define DBG_ERROR 0x4 -#define dfd stderr -extern int slirp_debug;#define DEBUG_CALL (fmt, ...) do { \ if (slirp_debug & DBG_CALL) { \ - fprintf(dfd, fmt, ##__VA_ARGS__); \ - fprintf(dfd, "...\n"); \ - fflush(dfd); \ + g_debug(fmt "...", ##__VA_ARGS__); \ } \ } while (0)#define DEBUG_ARG (fmt, ...) do { \ if (slirp_debug & DBG_CALL) { \ - fputc(' ', dfd); \ - fprintf(dfd, fmt, ##__VA_ARGS__); \ - fputc('\n', dfd); \ - fflush(dfd); \ + g_debug(" " fmt, ##__VA_ARGS__); \ } \ } while (0)#define DEBUG_MISC (fmt, ...) do { \ if (slirp_debug & DBG_MISC) { \ - fprintf(dfd, fmt, ##__VA_ARGS__); \ - fflush(dfd); \ + g_debug(fmt, ##__VA_ARGS__); \ } \ } while (0)#define DEBUG_ERROR (fmt, ...) do { \ if (slirp_debug & DBG_ERROR) { \ - fprintf(dfd, fmt, ##__VA_ARGS__); \ - fflush(dfd); \ + g_debug(fmt, ##__VA_ARGS__); \ } \ } while (0)
slirp/dhcpv6.c +3 -3
@@ -92,13 +92,13 @@ static int dhcpv6_parse_info_request(Slirp *slirp, uint8_t *odata, int olen, ri->want_boot_url = true;break ;default : -DEBUG_MISC ("dhcpv6: Unsupported option request %d\n" , +DEBUG_MISC ("dhcpv6: Unsupported option request %d" , req_opt); } }break ;default : -DEBUG_MISC ("dhcpv6 info req: Unsupported option %d, len=%d\n" , +DEBUG_MISC ("dhcpv6 info req: Unsupported option %d, len=%d" , option, len); }
@@ -203,6 +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 ("dhcpv6_input: Unsupported message type 0x%x\n" , data[0 ]); +DEBUG_MISC ("dhcpv6_input: Unsupported message type 0x%x" , data[0 ]); } }
slirp/ip_icmp.c +5 -5
@@ -103,7 +103,7 @@ 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 ("icmp_input icmp sendto tx errno = %d-%s\n" , +DEBUG_MISC ("icmp_input icmp sendto tx errno = %d-%s" , errno,strerror (errno));icmp_send_error (m,ICMP_UNREACH ,ICMP_UNREACH_NET ,0 ,strerror (errno));icmp_detach (so);
@@ -169,7 +169,7 @@ icmp_input(struct mbuf *m, int hlen)return ; }if (udp_attach (so,AF_INET ) ==-1 ) { -DEBUG_MISC ("icmp_input udp_attach errno = %d-%s\n" , +DEBUG_MISC ("icmp_input udp_attach errno = %d-%s" , errno,strerror (errno));sofree (so);m_free (m);
@@ -192,7 +192,7 @@ 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 ("icmp_input udp sendto tx errno = %d-%s\n" , +DEBUG_MISC ("icmp_input udp sendto tx errno = %d-%s" , errno,strerror (errno));icmp_send_error (m,ICMP_UNREACH ,ICMP_UNREACH_NET ,0 ,strerror (errno));udp_detach (so);
@@ -261,7 +261,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 (" %.16s to %.16s\n" , bufa, bufb); +DEBUG_MISC (" %.16s to %.16s" , bufa, bufb); }if (ip->ip_off &IP_OFFMASK ) goto end_error;/* Only reply to fragment 0 */
@@ -458,7 +458,7 @@ void icmp_receive(struct socket *so) }else { error_code =ICMP_UNREACH_HOST ; } -DEBUG_MISC (" udp icmp rx errno = %d-%s\n" , errno, +DEBUG_MISC (" udp icmp rx errno = %d-%s" , errno,strerror (errno));icmp_send_error (so->so_m,ICMP_UNREACH , error_code,0 ,strerror (errno)); }else {
slirp/slirp.c +4 -6
@@ -166,7 +166,7 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr,if (!f)return -1 ; -DEBUG_MISC ("IP address of your DNS(s): " ); +DEBUG_MISC ("IP address of your DNS(s):" );while (fgets (buff,512 , f) !=NULL ) {if (sscanf (buff,"nameserver%*[ \t]%256s" , buff2) ==1 ) {char *c =strchr (buff2,'%' );
@@ -188,20 +188,18 @@ static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr, *scope_id = if_index; } *cached_time = curtime; - }else { -DEBUG_MISC (", " ); }if (++found >3 ) { -DEBUG_MISC ("(more)" ); +DEBUG_MISC (" (more)" );break ; }else if (slirp_debug &DBG_MISC ) {char s[INET6_ADDRSTRLEN ];const char *res =inet_ntop (af, tmp_addr, s,sizeof (s));if (!res) { - res ="(string conversion error)" ; + res =" (string conversion error)" ; } -DEBUG_MISC ("%s" , res); +DEBUG_MISC (" %s" , res); } } }
slirp/socket.c +12 -12
@@ -208,7 +208,8 @@ soread(struct socket *so) } } -DEBUG_MISC (" --- soread() disconnected, nn = %d, errno = %d-%s\n" , nn, errno,strerror (errno)); +DEBUG_MISC (" --- soread() disconnected, nn = %d, errno = %d-%s" , + nn, errno,strerror (errno));sofcantrcvmore (so); if (err == ECONNRESET || err == ECONNREFUSED
@@ -237,7 +238,7 @@ soread(struct socket *so) nn += ret; } -DEBUG_MISC (" ... read nn = %d bytes\n" , nn); +DEBUG_MISC (" ... read nn = %d bytes" , nn);/* Update fields */ sb->sb_cc += nn;
@@ -370,7 +371,7 @@ sosendoob(struct socket *so) n =slirp_send (so, buff, len, (MSG_OOB ));/* |MSG_DONTWAIT)); */ #ifdef DEBUG if (n != len) { -DEBUG_ERROR ("Didn't send all data urgently XXXXX\n" ); +DEBUG_ERROR ("Didn't send all data urgently XXXXX" ); }#endif }
@@ -379,7 +380,7 @@ sosendoob(struct socket *so)return n; } so->so_urgc -= n; -DEBUG_MISC (" ---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, so->so_urgc); sb->sb_cc -= n; sb->sb_rptr += n;
@@ -460,7 +461,7 @@ sowrite(struct socket *so)if (ret >0 ) nn += ret; } -DEBUG_MISC (" ... wrote nn = %d bytes\n" , nn); +DEBUG_MISC (" ... wrote nn = %d bytes" , nn);/* Update sbuf */ sb->sb_cc -= nn;
@@ -478,7 +479,7 @@ sowrite(struct socket *so)return nn; err_disconnected: -DEBUG_MISC (" --- sowrite disconnected, so->so_state = %x, errno = %d\n" , +DEBUG_MISC (" --- sowrite disconnected, so->so_state = %x, errno = %d" , so->so_state, errno);sofcantsendmore (so);tcp_sockclosed (sototcpcb (so));
@@ -512,7 +513,7 @@ sorecvfrom(struct socket *so)if (errno ==EHOSTUNREACH ) code=ICMP_UNREACH_HOST ;else if (errno ==ENETUNREACH ) code=ICMP_UNREACH_NET ; -DEBUG_MISC (" udp icmp rx errno = %d-%s\n" , +DEBUG_MISC (" udp icmp rx errno = %d-%s" , errno,strerror (errno));icmp_send_error (so->so_m,ICMP_UNREACH , code,0 ,strerror (errno)); }else {
@@ -564,7 +565,7 @@ sorecvfrom(struct socket *so) m->m_len =recvfrom (so->s, m->m_data, len,0 , (struct sockaddr *)&addr, &addrlen); -DEBUG_MISC (" did recvfrom %d, errno = %d-%s\n" , +DEBUG_MISC (" did recvfrom %d, errno = %d-%s" , m->m_len, errno,strerror (errno));if (m->m_len<0 ) {/* Report error as ICMP */
@@ -579,7 +580,7 @@ sorecvfrom(struct socket *so) code =ICMP_UNREACH_NET ; } -DEBUG_MISC (" rx error, tx icmp ICMP_UNREACH:%i\n" , code); +DEBUG_MISC (" rx error, tx icmp ICMP_UNREACH:%i" , code);icmp_send_error (so->so_m,ICMP_UNREACH , code,0 ,strerror (errno));break ;case AF_INET6 :
@@ -591,7 +592,7 @@ sorecvfrom(struct socket *so) code =ICMP6_UNREACH_NO_ROUTE ; } -DEBUG_MISC (" rx error, tx icmp6 ICMP_UNREACH:%i\n" , code); +DEBUG_MISC (" rx error, tx icmp6 ICMP_UNREACH:%i" , code);icmp6_send_error (so->so_m,ICMP6_UNREACH , code);break ;default :
@@ -839,8 +840,7 @@ void sotranslate_out(struct socket *so, struct sockaddr_storage *addr) } } -DEBUG_MISC (" addr.sin_port=%d, " -"addr.sin_addr.s_addr=%.16s\n" , +DEBUG_MISC (" addr.sin_port=%d, addr.sin_addr.s_addr=%.16s" ,ntohs (sin->sin_port),inet_ntoa (sin->sin_addr));break ;
slirp/tcp_input.c +3 -4
@@ -641,8 +641,7 @@ findso: (errno != EINPROGRESS) && (errno != EWOULDBLOCK) ) {uint8_t code; -DEBUG_MISC (" tcp fconnect errno = %d-%s\n" , - errno,strerror (errno)); +DEBUG_MISC (" tcp fconnect errno = %d-%s" , 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,
@@ -1011,7 +1010,7 @@ trimthenstep6:if (SEQ_LEQ (ti->ti_ack, tp->snd_una)) {if (ti->ti_len ==0 && tiwin == tp->snd_wnd) { -DEBUG_MISC (" dup ack m = %p so = %p\n" , m, so); +DEBUG_MISC (" dup ack m = %p so = %p" , m, so);/* * If we have outstanding data (other than * a window probe), this is a completely
@@ -1550,7 +1549,7 @@ tcp_mss(struct tcpcb *tp, u_int offer) (mss - (TCP_RCVSPACE % mss)) : 0)); -DEBUG_MISC (" returning mss = %d\n" , mss); +DEBUG_MISC (" returning mss = %d" , mss);return mss; }
slirp/tcp_output.c +1 -1
@@ -92,7 +92,7 @@ again: flags = tcp_outflags[tp->t_state]; -DEBUG_MISC (" --- tcp_output flags = 0x%x\n" , flags); +DEBUG_MISC (" --- tcp_output flags = 0x%x" , flags);/* * If in persist timeout with window of 0, send 1 byte.
slirp/tcp_subr.c +1 -1
@@ -964,7 +964,7 @@ int tcp_ctl(struct socket *so) so->chardev = ex_ptr->ex_chardev;return 1 ; } -DEBUG_MISC (" executing %s\n" , ex_ptr->ex_exec); +DEBUG_MISC (" executing %s" , ex_ptr->ex_exec);return fork_exec (so, ex_ptr->ex_exec); } }
slirp/udp.c +2 -3
@@ -172,8 +172,7 @@ udp_input(register struct mbuf *m, int iphlen)*/ so =socreate (slirp);if (udp_attach (so,AF_INET ) ==-1 ) { -DEBUG_MISC (" udp_attach errno = %d-%s\n" , - errno,strerror (errno)); +DEBUG_MISC (" udp_attach errno = %d-%s" , errno,strerror (errno));sofree (so); goto bad; }
@@ -209,7 +208,7 @@ udp_input(register struct mbuf *m, int iphlen) m->m_len += iphlen; m->m_data -= iphlen; *ip=save_ip; -DEBUG_MISC ("udp tx errno = %d-%s\n" , errno,strerror (errno)); +DEBUG_MISC ("udp tx errno = %d-%s" , errno,strerror (errno));icmp_send_error (m,ICMP_UNREACH ,ICMP_UNREACH_NET ,0 ,strerror (errno)); goto bad;
slirp/udp6.c +2 -3
@@ -92,8 +92,7 @@ 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 (" udp6_attach errno = %d-%s\n" , - errno,strerror (errno)); +DEBUG_MISC (" udp6_attach errno = %d-%s" , errno,strerror (errno));sofree (so); goto bad; }
@@ -119,7 +118,7 @@ void udp6_input(struct mbuf *m) m->m_len += iphlen; m->m_data -= iphlen; *ip = save_ip; -DEBUG_MISC ("udp tx errno = %d-%s\n" , errno,strerror (errno)); +DEBUG_MISC ("udp tx errno = %d-%s" , errno,strerror (errno));icmp6_send_error (m,ICMP6_UNREACH ,ICMP6_UNREACH_NO_ROUTE ); goto bad; }
Signature · 1 line
2.19.2
Quoted 7 lines · Samuel Thibault
The following changes since commit
e85c577158a2e8e252414959da9ef15c12eec63d:Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2018-12-17' into staging (2018-12-18 14:31:06 +0000)
are available in the Git repository at:
Quoted 8 lines
https://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
for you to fetch changes up to
4c2b5ca1b5dd42bb96e954db7a46ebe39fd24620:slirp: Mark debugging calls as unlikely (2018-12-18 23:44:35 +0100)
----------------------------------------------------------------
Abstract away slirp toward a libslirp
This fails to compile (all platforms):
For the windows builds, a compile failure in slirp.c:/home/petmay01/qemu-for-merges/net/slirp.c: In function 'net_slirp_init':/home/petmay01/qemu-for-merges/net/slirp.c:302:10: error: implicit declaration of function 'inet_pton' [-Werror=implicit-function-declaration]
if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) {
^
/home/petmay01/qemu-for-merges/net/slirp.c:302:5: error: nested extern
declaration of 'inet_pton' [-Werror=nested-externs]
if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) {
^On Linux (x86-64 and other host archs) a link failure:
LINK arm-softmmu/qemu-system-arm../slirp/ncsi.o: In function `ncsi_input':/home/petmay01/linaro/qemu-for-merges/slirp/ncsi.c:166: undefined reference to `slirp_output'../slirp/slirp.o: In function `arp_input':/home/petmay01/linaro/qemu-for-merges/slirp/slirp.c:835: undefined reference to `slirp_output'../slirp/slirp.o: In function `if_encap4':/home/petmay01/linaro/qemu-for-merges/slirp/slirp.c:935: undefined reference to `slirp_output'../slirp/slirp.o: In function `if_encap':/home/petmay01/linaro/qemu-for-merges/slirp/slirp.c:1021: undefined reference to `slirp_output'
collect2: error: ld returned 1 exit status
Makefile:199: recipe for target 'qemu-system-arm' failed
It also manages to provoke an internal linker error on freebsd:
/usr/bin/ld: error in ../slirp/socket.o(.eh_frame); no .eh_frame_hdr
table will be created./usr/bin/ld: ../slirp/socket.o: invalid string offset 1416 >= 978 for section `.strtab'/usr/bin/ld: ../slirp/socket.o: invalid relocation type 38/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail /usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86- 64.c:276/usr/bin/ld: ../slirp/socket.o: invalid relocation type 51/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail /usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86-64.c:276 /usr/bin/ld: ../slirp/socket.o: invalid relocation type 57
[enormous long list of similar messages]/usr/bin/ld: ../slirp/socket.o: invalid relocation type 8248/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail /usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86- 64.c:276/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 internal error, aborting
at /usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/b fd/reloc.c line 5288 in bfd_byte *bfd_generic_get_relocated_section_contents(bfd *, structbfd_link_info *, struct bfd_link_order *, bfd_byte
*, bfd_boolean, asymbol **)
/usr/bin/ld: Please report this bug.
c++: error: linker command failed with exit code 1 (use -v to see invocation)
On NetBSD, a different slirp.c compiler error building the bsd-user target:
In file included from ../slirp/slirp.c:31:0:/var/tmp/qemu-test.nLOQbq/include/hw/hw.h:6:2: error: #error Cannot include hw/hw.h from user emulation
#error Cannot include hw/hw.h from user emulation
^
On OpenBSD, a rather uninformative linker error:/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
On OSX, the clang version of the same issue as Linux:
Undefined symbols for architecture x86_64:
"_slirp_output", referenced from:
_ncsi_input in ncsi.o
_slirp_input in slirp.o
_if_encap in slirp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
thanks
-- PMM
Hi
Quoted 26 lines · Peter Maydell
Quoted 7 lines · Samuel Thibault
The following changes since commit
e85c577158a2e8e252414959da9ef15c12eec63d:Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2018-12-17' into staging (2018-12-18 14:31:06 +0000)
are available in the Git repository at:
Quoted 8 lines
https://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
for you to fetch changes up to
4c2b5ca1b5dd42bb96e954db7a46ebe39fd24620:slirp: Mark debugging calls as unlikely (2018-12-18 23:44:35 +0100)
----------------------------------------------------------------
Abstract away slirp toward a libslirpThis fails to compile (all platforms):
For the windows builds, a compile failure in
slirp.c:/home/petmay01/qemu-for-merges/net/slirp.c: In function 'net_slirp_init':/home/petmay01/qemu-for-merges/net/slirp.c:302:10: error: implicit declaration of function 'inet_pton' [-Werror=implicit-function-declaration]
Quoted 7 lines
if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) {
^
/home/petmay01/qemu-for-merges/net/slirp.c:302:5: error: nested extern
declaration of 'inet_pton' [-Werror=nested-externs]
if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) {
^This one is easy, it needs "build-sys: require Vista API by default globally" series that Paolo has been sending in his last pullreqs.
Quoted 18 lines
On Linux (x86-64 and other host archs) a link failure:
LINK arm-softmmu/qemu-system-arm
../slirp/ncsi.o: In function `ncsi_input':/home/petmay01/linaro/qemu-for-merges/slirp/ncsi.c:166: undefined reference to `slirp_output'../slirp/slirp.o: In function `arp_input':/home/petmay01/linaro/qemu-for-merges/slirp/slirp.c:835: undefined reference to `slirp_output'../slirp/slirp.o: In function `if_encap4':/home/petmay01/linaro/qemu-for-merges/slirp/slirp.c:935: undefined reference to `slirp_output'../slirp/slirp.o: In function `if_encap':/home/petmay01/linaro/qemu-for-merges/slirp/slirp.c:1021: undefined reference to `slirp_output'
collect2: error: ld returned 1 exit status
Makefile:199: recipe for target 'qemu-system-arm' failed
Hmm, weird linker error. Could you give some details on your build environment?
Quoted 26 lines
It also manages to provoke an internal linker error on freebsd:
/usr/bin/ld: error in ../slirp/socket.o(.eh_frame); no .eh_frame_hdr
table will be created./usr/bin/ld:../slirp/socket.o: invalid string offset 1416 >= 978 for section `.strtab'/usr/bin/ld:../slirp/socket.o: invalid relocation type 38/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail/usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86-64.c:276/usr/bin/ld:../slirp/socket.o: invalid relocation type 51/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail/usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86-64.c:276/usr/bin/ld:../slirp/socket.o: invalid relocation type 57
[enormous long list of similar messages]/usr/bin/ld:../slirp/socket.o: invalid relocation type 8248/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail/usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86-64.c:276/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 internal error, aborting
at/usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/reloc.cline 5288 inbfd_byte*bfd_generic_get_relocated_section_contents(bfd *, structbfd_link_info*, structbfd_link_order*,bfd_byte
*,bfd_boolean, asymbol **)
Quoted 1 line
/usr/bin/ld: Please report this bug.
make vm-build-freebsd passes here... weirder
Quoted 11 lines
c++: error: linker command failed with exit code 1 (use -v to see invocation)
On NetBSD, a different
slirp.ccompiler error building the bsd-user target:
In file included from../slirp/slirp.c:31:0:/var/tmp/qemu-test.nLOQbq/include/hw/hw.h:6:2: error: #error Cannot includehw/hw.hfrom user emulation
#error Cannot includehw/hw.hfrom user emulation
^
make vm-build-netbsd passes here too...
Quoted 3 lines
On OpenBSD, a rather uninformative linker error:
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make vm-build-openbsd fails here however with the:
"Cannot include hw/hw.h from user emulation" (interesting, no? ;)
Eh, git blame:
062e552 Anthony Liguori 2009-01-08 19:27 +0000 31│ #include "hw/hw.h"
-#include "hw/hw.h"
+#include "migration/vmstate.h"
+#include "migration/qemu-file-types.h"
Seems to solve it. I will send a seperate patch.
Quoted 9 lines
On OSX, the clang version of the same issue as Linux:
Undefined symbols for architecturex86_64:
"_slirp_output", referenced from:
_ncsi_inputin ncsi.o
_slirp_inputin slirp.o
_if_encapin slirp.o
ld: symbol(s) not found for architecturex86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I don't have a mac, but all those linker errors look related.
I don't get why it sometime succeeds to link, but there is an obvious mistake in "build-sys: use a seperate slirp-obj-y && slirp.mo" (Sam, you should squash that fix)
Makefile.target +1 -2
@@ -182,13 +182,13 @@ dummy := $(call unnest-vars,.., \ slirp-obj-y) target-obj-y := $(target-obj-y-save) all-obj-y += $(common-obj-y) -all-obj-y += $(slirp-obj-y) all-obj-y += $(target-obj-y) all-obj-y += $(qom-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(chardev-obj-y) all-obj-$(CONFIG_USER_ONLY) += $(crypto-aes-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y) +all-obj-$(CONFIG_SOFTMMU) += $(slirp-obj-y) --
Marc-André Lureau
Hi
Quoted 120 lines · Marc-André Lureau
Hi
Quoted 26 lines · Peter Maydell
Quoted 7 lines · Samuel Thibault
The following changes since commit
e85c577158a2e8e252414959da9ef15c12eec63d:Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2018-12-17' into staging (2018-12-18 14:31:06 +0000)
are available in the Git repository at:
Quoted 8 lines
https://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
for you to fetch changes up to
4c2b5ca1b5dd42bb96e954db7a46ebe39fd24620:slirp: Mark debugging calls as unlikely (2018-12-18 23:44:35 +0100)
----------------------------------------------------------------
Abstract away slirp toward a libslirpThis fails to compile (all platforms):
For the windows builds, a compile failure in
slirp.c:/home/petmay01/qemu-for-merges/net/slirp.c: In function 'net_slirp_init':/home/petmay01/qemu-for-merges/net/slirp.c:302:10: error: implicit declaration of function 'inet_pton' [-Werror=implicit-function-declaration]Quoted 7 lines
if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) { ^ /home/petmay01/qemu-for-merges/net/slirp.c:302:5: error: nested extern declaration of 'inet_pton' [-Werror=nested-externs] if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) { ^This one is easy, it needs "build-sys: require Vista API by default globally" series that Paolo has been sending in his last pullreqs.
Quoted 18 lines
On Linux (x86-64 and other host archs) a link failure:
LINK arm-softmmu/qemu-system-arm
../slirp/ncsi.o: In function `ncsi_input':/home/petmay01/linaro/qemu-for-merges/slirp/ncsi.c:166: undefined reference to `slirp_output'../slirp/slirp.o: In function `arp_input':/home/petmay01/linaro/qemu-for-merges/slirp/slirp.c:835: undefined reference to `slirp_output'../slirp/slirp.o: In function `if_encap4':/home/petmay01/linaro/qemu-for-merges/slirp/slirp.c:935: undefined reference to `slirp_output'../slirp/slirp.o: In function `if_encap':/home/petmay01/linaro/qemu-for-merges/slirp/slirp.c:1021: undefined reference to `slirp_output'
collect2: error: ld returned 1 exit status
Makefile:199: recipe for target 'qemu-system-arm' failedHmm, weird linker error. Could you give some details on your build environment?
Quoted 26 lines
It also manages to provoke an internal linker error on freebsd:
/usr/bin/ld: error in ../slirp/socket.o(.eh_frame); no .eh_frame_hdr
table will be created./usr/bin/ld:../slirp/socket.o: invalid string offset 1416 >= 978 for section `.strtab'/usr/bin/ld:../slirp/socket.o: invalid relocation type 38/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail/usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86-64.c:276/usr/bin/ld:../slirp/socket.o: invalid relocation type 51/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail/usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86-64.c:276/usr/bin/ld:../slirp/socket.o: invalid relocation type 57
[enormous long list of similar messages]/usr/bin/ld:../slirp/socket.o: invalid relocation type 8248/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail/usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86-64.c:276/usr/bin/ld: BFD 2.17.50 [FreeBSD] 2007-07-03 internal error, aborting
at/usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/reloc.cline 5288 inbfd_byte*bfd_generic_get_relocated_section_contents(bfd *, structbfd_link_info*, structbfd_link_order*,bfd_byte
*,bfd_boolean, asymbol **)Quoted 1 line
/usr/bin/ld: Please report this bug.make vm-build-freebsd passes here... weirder
Quoted 11 lines
c++: error: linker command failed with exit code 1 (use -v to see invocation)
On NetBSD, a different
slirp.ccompiler error building the bsd-user target:
In file included from../slirp/slirp.c:31:0:/var/tmp/qemu-test.nLOQbq/include/hw/hw.h:6:2: error: #error Cannot includehw/hw.hfrom user emulation
#error Cannot includehw/hw.hfrom user emulation
^make vm-build-netbsd passes here too...
Quoted 3 lines
On OpenBSD, a rather uninformative linker error:
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit statusmake vm-build-openbsd fails here however with the:
"Cannot includehw/hw.hfrom user emulation" (interesting, no? ;)Eh, git blame:
062e552 Anthony Liguori 2009-01-08 19:27 +0000 31│ #include "hw/hw.h"(quoted diff) +2
-1-#include "hw/hw.h" +#include "migration/vmstate.h" +#include "migration/qemu-file-types.h"
Quoted 1 line
Seems to solve it. I will send a seperate patch.
Ok I figure that the error only happen when build for -user, however with the build fix below, it only builds for -softmmu. So that fix is not required.
All in all, I think we should give it another try once the "build-sys:
require Vista API" series is merged, and with the build-sys fix below squahed in "build-sys: use a seperate slirp-obj-y && slirp.mo".
Quoted 36 lines
Quoted 10 lines
On OSX, the clang version of the same issue as Linux:
Undefined symbols for architecturex86_64:
"_slirp_output", referenced from:
_ncsi_inputin ncsi.o
_slirp_inputin slirp.o
_if_encapin slirp.o
ld: symbol(s) not found for architecturex86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)I don't have a mac, but all those linker errors look related.
I don't get why it sometime succeeds to link, but there is an obvious mistake in "build-sys: use a seperate slirp-obj-y && slirp.mo" (Sam, you should squash that fix)
Makefile.target +1
-2@@ -182,13 +182,13 @@ dummy := $(call unnest-vars,.., \ slirp-obj-y) target-obj-y := $(target-obj-y-save) all-obj-y += $(common-obj-y) -all-obj-y += $(slirp-obj-y) all-obj-y += $(target-obj-y) all-obj-y += $(qom-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(chardev-obj-y) all-obj-$(CONFIG_USER_ONLY) += $(crypto-aes-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y) +all-obj-$(CONFIG_SOFTMMU) += $(slirp-obj-y) --Marc-André Lureau
Signature · 1 line
Marc-André Lureau
Marc-André Lureau, le jeu. 20 déc. 2018 16:01:44 +0400, a ecrit:
Quoted 7 lines
Quoted 4 lines
declaration of '
inet_pton' [-Werror=nested-externs]if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) { ^This one is easy, it needs "build-sys: require Vista API by default globally" series that Paolo has been sending in his last pullreqs.
Ok, let's wait for it for that part then.
Quoted 3 lines
there is an obvious
mistake in "build-sys: use a seperate slirp-obj-y && slirp.mo" (Sam, you should squash that fix)
Ok, squashed in my tree.
Samuel
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=8
=== TEST SCRIPT END ===
CC net/filter-rewriter.o
CC net/filter-replay.o/tmp/qemu-test/src/net/slirp.c: In function 'net_slirp_init':/tmp/qemu-test/src/net/slirp.c:302:10: error: implicit declaration of function 'inet_pton'; did you mean 'inet_aton'? [-Werror=implicit-function-declaration]
if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) {
^~~~~~~~~
inet_aton/tmp/qemu-test/src/net/slirp.c:302:10: error: nested extern declaration of 'inet_pton' [-Werror=nested-externs]
cc1: all warnings being treated as errors
make: *** [/tmp/qemu-test/src/rules.mak:69: net/slirp.o] Error 1
make: *** Waiting for unfinished jobs....
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Type: series
Subject: [Qemu-devel] [PULL 00/64] slirp updates
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
e31b3cf slirp: Mark debugging calls as unlikely
6b01bfd slirp: call into g_debug() for DEBUG macros a790e3d slirp: set G_LOG_DOMAIN
969e302 build-sys: use a seperate slirp-obj-y && slirp.mo 3332d62 slirp: add clock_get_ns() callback
f7af5a7 slirp: factor out guestfwd addition checks
b0b5168 slirp: replace DEBUG_ARGS with DEBUG_ARG
8493417 slirp: remove remaining DEBUG blocks
8fb3d34 slirp: use %p for pointers format
29b7c49 slirp: introduce SLIRP_DEBUG environment variable 454ba9c slirp: always build with debug statements
0b1c827 slirp: no need to make DPRINTF conditional on DEBUG 3659a07 slirp: replace a DEBUG block with WITH_ICMP_ERROR_MSG 4f8d093 slirp: replace some fprintf() with DEBUG_MISC 51a85a0 slirp: replace a fprintf with g_critical()
5120660 slirp: use virtual time for packet expiration 4193273 slirp: rename exec_list
69f9377 slirp: drop <Vista compatibility
342befa slirp: Enable fork_exec support on Windows
7b6909e slirp: replace error_report() with g_critical() 3fda8b1 slirp: simplify fork_exec()
ca3f1b9 glib-compat: add g_spawn_async_with_fds() fallback d375cff net: do not depend on slirp internals
b85cf93 slirp: replace ARRAY_SIZE with G_N_ELEMENTS 9fd32c7 slirp: remove dead TCP_ACK_HACK code
22962ef slirp: NULL is defined by stddef.h
c44961a slirp: remove unused sbflush()
d028770 slirp: remove #if notdef dead code
e83081a slirp: add a callback to log guest errors
a429733 slirp: improve a bit the debug macros
4048f90 slirp: replace error_report() with g_critical() ede154f slirp: remove unused global slirp_instance
42eb362 slirp: replace compile time DO_KEEPALIVE
f995a15 slirp: replace SIZEOF_CHAR_P with glib equivalent bebab19 slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent a2e2cd1 slirp: remove unused HAVE_INET_ATON
9741693 slirp: remove unused DECLARE_IOVEC
e641390 slirp: remove HAVE_SYS_FILIO_H
3d56770 slirp: remove HAVE_SYS_IOCTL_H
73eefd2 slirp: remove unused HAVE_SYS_SELECT_H
4b9df6b slirp: remove unused HAVE_SYS_WAIT_H
8b592af slirp: remove unused HAVE_ARPA_INET_H
e47d8ef slirp: remove unused HAVE_SYS_STROPTS_H
8a5755e slirp: remove NO_UNIX_SOCKETS
ff11bc4 slirp: remove unused HAVE_SYS_BITYPES_H
2678ee7 slirp: remove HAVE_SYS_SIGNAL_H
6c35ee2 slirp: remove the disabled readv()/writev() code path 5d26c2d slirp: remove FULL_BOLT
92c5bec slirp: remove PROBE_CONN dead-code
ae97899 slirp: use a callback structure to interface with qemu 90b64e9 slirp: remove unused M_TRAILINGSPACE
2d08aae slirp: move socket pair creation in helper function d21a220 slirp: add tftp tracing
111b170 slirp: remove dead declarations
329922b slirp: replace the poor-man string split with g_strsplit() 52b85bc slirp: fix slirp_add_exec() leaks
57540f4 slirp: remove Monitor dependency, return a string for info 948aa94 slirp: move internal function declarations
8bd8a0a slirp: rename /extra/chardev
358237e slirp: remove unused EMU_RSH
56ac752 slirp: use a dedicated field for chardev pointer eed1340 slirp: replace ex_pty with ex_chardev
1561e30 slirp: remove do_pty from fork_exec()
0a23de3 slirp: associate slirp_output callback with the Slirp context
=== OUTPUT BEGIN ===
Checking PATCH 1/64: slirp: associate slirp_output callback with the Slirp context... Checking PATCH 2/64: slirp: remove do_pty from fork_exec()...
Checking PATCH 3/64: slirp: replace ex_pty with ex_chardev...
ERROR: code indent should never use tabs
#24: FILE: slirp/misc.c:56:
+^I(*ex_ptr)->ex_chardev = do_pty == 3;$
ERROR: code indent should never use tabs
#37: FILE: slirp/misc.h:12:
+^Iint ex_chardev;$
total: 2 errors, 0 warnings, 40 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 4/64: slirp: use a dedicated field for chardev pointer...
ERROR: code indent should never use tabs
#79: FILE: slirp/misc.c:53:
+^I*ex_ptr = g_new0(struct ex_list, 1);$
ERROR: code indent should never use tabs
#84: FILE: slirp/misc.c:56:
+^Iif (chardev) {$
ERROR: code indent should never use tabs
#85: FILE: slirp/misc.c:57:
+^I^I(*ex_ptr)->ex_chardev = chardev;$
ERROR: code indent should never use tabs
#86: FILE: slirp/misc.c:58:
+^I} else {$
ERROR: code indent should never use tabs
#87: FILE: slirp/misc.c:59:
+^I^I(*ex_ptr)->ex_exec = g_strdup(cmdline);$
ERROR: code indent should never use tabs
#88: FILE: slirp/misc.c:60:
+^I}$
ERROR: code indent should never use tabs
#101: FILE: slirp/misc.h:12:
+^Ivoid *ex_chardev;$
total: 7 errors, 0 warnings, 100 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 5/64: slirp: remove unused EMU_RSH... Checking PATCH 6/64: slirp: rename /extra/chardev...
ERROR: "foo * bar" should be "foo *bar"
#41: FILE: slirp/socket.h:70:
+ void * chardev;
total: 1 errors, 0 warnings, 28 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 7/64: slirp: move internal function declarations... Checking PATCH 8/64: slirp: remove Monitor dependency, return a string for info... Checking PATCH 9/64: slirp: fix slirp_add_exec() leaks...
ERROR: code indent should never use tabs
#24: FILE: slirp/misc.h:15:
+^Ichar *ex_exec; /* Command line of what to exec */$
total: 1 errors, 0 warnings, 22 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 10/64: slirp: replace the poor-man string split with g_strsplit()...
ERROR: code indent should never use tabs
#28: FILE: slirp/misc.c:91:
+^Ichar **argv;$
ERROR: code indent should never use tabs
#29: FILE: slirp/misc.c:92:
+^Iint ret;$
total: 2 errors, 0 warnings, 33 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 11/64: slirp: remove dead declarations... Checking PATCH 12/64: slirp: add tftp tracing...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #59:
new file mode 100644
total: 0 errors, 1 warnings, 33 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 13/64: slirp: move socket pair creation in helper function...
ERROR: code indent should never use tabs
#104: FILE: slirp/misc.c:136:
+^Iint opt, c, sp[2];$
ERROR: code indent should never use tabs
#156: FILE: slirp/misc.c:151:
+^I^Iclosesocket(sp[0]);$
ERROR: code indent should never use tabs
#157: FILE: slirp/misc.c:152:
+^I^Iclosesocket(sp[1]);$
ERROR: code indent should never use tabs
#170: FILE: slirp/misc.c:156:
+^I^Isetsid();$
ERROR: code indent should never use tabs
#171: FILE: slirp/misc.c:157:
+^I^Idup2(sp[1], 0);$
ERROR: code indent should never use tabs
#172: FILE: slirp/misc.c:158:
+^I^Idup2(sp[1], 1);$
ERROR: code indent should never use tabs
#173: FILE: slirp/misc.c:159:
+^I^Idup2(sp[1], 2);$
ERROR: code indent should never use tabs
#174: FILE: slirp/misc.c:160:
+^I^Ifor (c = getdtablesize() - 1; c >= 3; c--)$
ERROR: suspect code indent for conditional statements (16, 19) #174: FILE: slirp/misc.c:160:
+ for (c = getdtablesize() - 1; c >= 3; c--)
+ close(c);
ERROR: braces {} are necessary for all arms of this statement #174: FILE: slirp/misc.c:160:
+ for (c = getdtablesize() - 1; c >= 3; c--)
[...]
ERROR: code indent should never use tabs
#175: FILE: slirp/misc.c:161:
+^I^I close(c);$
ERROR: code indent should never use tabs
#183: FILE: slirp/misc.c:173:
+^I^Iso->s = sp[0];$
ERROR: code indent should never use tabs
#184: FILE: slirp/misc.c:174:
+^I^Iclosesocket(sp[1]);$
ERROR: code indent should never use tabs
#198: FILE: slirp/misc.c:176:
+^I^Isocket_set_fast_reuse(so->s);$
ERROR: code indent should never use tabs
#199: FILE: slirp/misc.c:177:
+^I^Iopt = 1;$
WARNING: line over 80 characters
#200: FILE: slirp/misc.c:178:
+ qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
ERROR: code indent should never use tabs
#200: FILE: slirp/misc.c:178:
+^I^Iqemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));$
total: 16 errors, 1 warnings, 175 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 14/64: slirp: remove unused M_TRAILINGSPACE... Checking PATCH 15/64: slirp: use a callback structure to interface with qemu... Checking PATCH 16/64: slirp: remove PROBE_CONN dead-code... Checking PATCH 17/64: slirp: remove FULL_BOLT...
Checking PATCH 18/64: slirp: remove the disabled readv()/writev() code path... Checking PATCH 19/64: slirp: remove HAVE_SYS_SIGNAL_H...
Checking PATCH 20/64: slirp: remove unused HAVE_SYS_BITYPES_H... Checking PATCH 21/64: slirp: remove NO_UNIX_SOCKETS...
Checking PATCH 22/64: slirp: remove unused HAVE_SYS_STROPTS_H... Checking PATCH 23/64: slirp: remove unused HAVE_ARPA_INET_H... Checking PATCH 24/64: slirp: remove unused HAVE_SYS_WAIT_H... Checking PATCH 25/64: slirp: remove unused HAVE_SYS_SELECT_H... Checking PATCH 26/64: slirp: remove HAVE_SYS_IOCTL_H...
Checking PATCH 27/64: slirp: remove HAVE_SYS_FILIO_H...
WARNING: architecture specific defines should be avoided
#23: FILE: slirp/slirp.h:39:
+#ifdef __APPLE__
total: 0 errors, 1 warnings, 20 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 28/64: slirp: remove unused DECLARE_IOVEC...
Checking PATCH 29/64: slirp: remove unused HAVE_INET_ATON... Checking PATCH 30/64: slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent... Checking PATCH 31/64: slirp: replace SIZEOF_CHAR_P with glib equivalent... Checking PATCH 32/64: slirp: replace compile time DO_KEEPALIVE...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #54:
deleted file mode 100644
ERROR: code indent should never use tabs
#80: FILE: slirp/tcp_input.c:484:
+^Iif (slirp_do_keepalive)$
ERROR: suspect code indent for conditional statements (8, 11) #80: FILE: slirp/tcp_input.c:484:
+ if (slirp_do_keepalive)
tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL;
ERROR: braces {} are necessary for all arms of this statement #80: FILE: slirp/tcp_input.c:484:
+ if (slirp_do_keepalive)
[...]
else
[...]
ERROR: code indent should never use tabs
#93: FILE: slirp/tcp_timer.c:265:
+^I^Iif (slirp_do_keepalive && tp->t_state <= TCPS_CLOSE_WAIT) {$
total: 4 errors, 1 warnings, 43 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 33/64: slirp: remove unused global slirp_instance... Checking PATCH 34/64: slirp: replace error_report() with g_critical()... Checking PATCH 35/64: slirp: improve a bit the debug macros...
ERROR: code indent should never use tabs
#70: FILE: slirp/cksum.c:127:
+^I^IDEBUG_ERROR("cksum: out of data\n");$
ERROR: code indent should never use tabs
#71: FILE: slirp/cksum.c:128:
+^I^IDEBUG_ERROR(" len = %d\n", len);$
ERROR: code indent should never use tabs
#201: FILE: slirp/ip_icmp.c:168:
+^IDEBUG_MISC("icmp_input udp_attach errno = %d-%s\n",$
ERROR: space required after that ',' (ctx:VxV)
#202: FILE: slirp/ip_icmp.c:169:
+ errno,strerror(errno));
^ERROR: code indent should never use tabs
#212: FILE: slirp/ip_icmp.c:191:
+^IDEBUG_MISC("icmp_input udp sendto tx errno = %d-%s\n",$
ERROR: space required after that ',' (ctx:VxV)
#213: FILE: slirp/ip_icmp.c:192:
+ errno,strerror(errno));
^ERROR: code indent should never use tabs
#246: FILE: slirp/mbuf.c:235:
+^IDEBUG_ERROR("dtom failed");$
ERROR: line over 90 characters
#324: FILE: slirp/socket.c:211:
+ DEBUG_MISC(" --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno));
ERROR: code indent should never use tabs
#324: FILE: slirp/socket.c:211:
+^I^I^IDEBUG_MISC(" --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno));$
ERROR: space required after that ',' (ctx:VxV)
#324: FILE: slirp/socket.c:211:
+ DEBUG_MISC(" --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno));
^ERROR: code indent should never use tabs
#333: FILE: slirp/socket.c:240:
+^IDEBUG_MISC(" ... read nn = %d bytes\n", nn);$
ERROR: code indent should never use tabs
#342: FILE: slirp/socket.c:373:
+^I^I^IDEBUG_ERROR("Didn't send all data urgently XXXXX\n");$
ERROR: line over 90 characters
#351: FILE: slirp/socket.c:382:
+ DEBUG_MISC(" ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc);
ERROR: code indent should never use tabs
#351: FILE: slirp/socket.c:382:
+^IDEBUG_MISC(" ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc);$
ERROR: code indent should never use tabs
#370: FILE: slirp/socket.c:481:
+^IDEBUG_MISC(" --- sowrite disconnected, so->so_state = %x, errno = %d\n",$
ERROR: code indent should never use tabs
#381: FILE: slirp/socket.c:515:
+^I DEBUG_MISC(" udp icmp rx errno = %d-%s\n",$
ERROR: space required after that ',' (ctx:VxV)
#382: FILE: slirp/socket.c:516:
+ errno,strerror(errno));
^ERROR: code indent should never use tabs #392: FILE: slirp/socket.c:567:
+^I DEBUG_MISC(" did recvfrom %d, errno = %d-%s\n",$
ERROR: space required after that ',' (ctx:VxV)
#393: FILE: slirp/socket.c:568:
+ m->m_len, errno,strerror(errno));
^ERROR: code indent should never use tabs
#402: FILE: slirp/socket.c:582:
+^I DEBUG_MISC(" rx error, tx icmp ICMP_UNREACH:%i\n", code);$
ERROR: code indent should never use tabs
#411: FILE: slirp/socket.c:594:
+^I DEBUG_MISC(" rx error, tx icmp6 ICMP_UNREACH:%i\n", code);$
ERROR: code indent should never use tabs #438: FILE: slirp/tcp_input.c:239:
+^IDEBUG_ARGS(" m = %p iphlen = %2d inso = %p\n",$
ERROR: code indent should never use tabs
#449: FILE: slirp/tcp_input.c:665:
+^I DEBUG_MISC(" tcp fconnect errno = %d-%s\n",$
ERROR: space required after that ',' (ctx:VxV)
#450: FILE: slirp/tcp_input.c:666:
+ errno,strerror(errno));
^ERROR: suspect code indent for conditional statements (24, 26) #457: FILE: slirp/tcp_input.c:1034:
if (ti->ti_len == 0 && tiwin == tp->snd_wnd) {+ DEBUG_MISC(" dup ack m = %p so = %p\n", m, so);
ERROR: code indent should never use tabs
#460: FILE: slirp/tcp_input.c:1035:
+^I^I^I DEBUG_MISC(" dup ack m = %p so = %p\n", m, so);$
ERROR: code indent should never use tabs
#469: FILE: slirp/tcp_input.c:1413:
+^IDEBUG_ARGS(" tp = %p cnt=%i\n", tp, cnt);$
ERROR: code indent should never use tabs
#478: FILE: slirp/tcp_input.c:1613:
+^IDEBUG_MISC(" returning mss = %d\n", mss);$
ERROR: code indent should never use tabs
#491: FILE: slirp/tcp_output.c:95:
+^IDEBUG_MISC(" --- tcp_output flags = 0x%x\n", flags);$
ERROR: code indent should never use tabs
#527: FILE: slirp/udp.c:175:
+^I DEBUG_MISC(" udp_attach errno = %d-%s\n",$
ERROR: code indent should never use tabs
#537: FILE: slirp/udp.c:212:
+^I DEBUG_MISC("udp tx errno = %d-%s\n", errno, strerror(errno));$
total: 31 errors, 0 warnings, 445 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 36/64: slirp: add a callback to log guest errors... Checking PATCH 37/64: slirp: remove #if notdef dead code... Checking PATCH 38/64: slirp: remove unused sbflush()... Checking PATCH 39/64: slirp: NULL is defined by stddef.h... Checking PATCH 40/64: slirp: remove dead TCP_ACK_HACK code... Checking PATCH 41/64: slirp: replace ARRAY_SIZE with G_N_ELEMENTS...
ERROR: suspect code indent for conditional statements (2, 6) #39: FILE: slirp/tftp.c:362:
+ while (k < pktlen && nb_options < G_N_ELEMENTS(option_name)) {
const char *key, *value;ERROR: suspect code indent for conditional statements (2, 6) #46: FILE: slirp/tftp.c:405:
if (nb_options > 0) {
+ assert(nb_options <= G_N_ELEMENTS(option_name));
total: 2 errors, 0 warnings, 24 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 42/64: net: do not depend on slirp internals... Checking PATCH 43/64: glib-compat: add g_spawn_async_with_fds() fallback... Checking PATCH 44/64: slirp: simplify fork_exec()...
WARNING: Block comments use a leading /* on a separate line #60: FILE: slirp/misc.c:154:
+ g_spawn_async_with_fds(NULL /* cwd */,
WARNING: Block comments use a leading /* on a separate line #62: FILE: slirp/misc.c:156:
+ NULL /* env */,
WARNING: Block comments use a leading /* on a separate line #64: FILE: slirp/misc.c:158:
+ fork_exec_child_setup, NULL /* data */,
WARNING: Block comments use a leading /* on a separate line #65: FILE: slirp/misc.c:159:
+ NULL /* child_pid */,
total: 0 errors, 4 warnings, 92 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 45/64: slirp: replace error_report() with g_critical()... Checking PATCH 46/64: slirp: Enable fork_exec support on Windows... Checking PATCH 47/64: slirp: drop <Vista compatibility... Checking PATCH 48/64: slirp: rename exec_list...
ERROR: code indent should never use tabs
#30: FILE: slirp/misc.c:42:
+^Istruct gfwd_list *tmp_ptr;$
ERROR: code indent should never use tabs
#39: FILE: slirp/misc.c:52:
+^I*ex_ptr = g_new0(struct gfwd_list, 1);$
ERROR: code indent should never use tabs
#58: FILE: slirp/misc.h:16:
+^Istruct gfwd_list *ex_next;$
WARNING: line over 80 characters
#101: FILE: slirp/slirp.c:783:
+ for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
WARNING: line over 80 characters
#175: FILE: slirp/tcp_input.c:397:
+ for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
ERROR: code indent should never use tabs
#184: FILE: slirp/tcp_input.c:619:
+^I^Ifor (ex_ptr = slirp->guestfwd_list; ex_ptr;$
ERROR: suspect code indent for conditional statements (16, 18) #184: FILE: slirp/tcp_input.c:619:
+ for (ex_ptr = slirp->guestfwd_list; ex_ptr;
[...]
if(ex_ptr->ex_fport == so->so_fport &&
total: 5 errors, 2 warnings, 152 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 49/64: slirp: use virtual time for packet expiration... Checking PATCH 50/64: slirp: replace a fprintf with g_critical()... Checking PATCH 51/64: slirp: replace some fprintf() with DEBUG_MISC... Checking PATCH 52/64: slirp: replace a DEBUG block with WITH_ICMP_ERROR_MSG... Checking PATCH 53/64: slirp: no need to make DPRINTF conditional on DEBUG... Checking PATCH 54/64: slirp: always build with debug statements... Checking PATCH 55/64: slirp: introduce SLIRP_DEBUG environment variable... Checking PATCH 56/64: slirp: use %p for pointers format... Checking PATCH 57/64: slirp: remove remaining DEBUG blocks... Checking PATCH 58/64: slirp: replace DEBUG_ARGS with DEBUG_ARG...
ERROR: code indent should never use tabs
#147: FILE: slirp/tcp_input.c:218:
+^IDEBUG_ARG("m = %p iphlen = %2d inso = %p",$
ERROR: code indent should never use tabs
#157: FILE: slirp/tcp_input.c:1392:
+^IDEBUG_ARG("tp = %p cnt=%i", tp, cnt);$
total: 2 errors, 0 warnings, 112 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 59/64: slirp: factor out guestfwd addition checks... Checking PATCH 60/64: slirp: add clock_get_ns() callback... Checking PATCH 61/64: build-sys: use a seperate slirp-obj-y && slirp.mo... Checking PATCH 62/64: slirp: set G_LOG_DOMAIN...
Checking PATCH 63/64: slirp: call into g_debug() for DEBUG macros...
ERROR: code indent should never use tabs
#31: FILE: slirp/cksum.c:124:
+^I^IDEBUG_ERROR("cksum: out of data");$
ERROR: code indent should never use tabs
#32: FILE: slirp/cksum.c:125:
+^I^IDEBUG_ERROR(" len = %d", len);$
ERROR: code indent should never use tabs #129: FILE: slirp/ip_icmp.c:172:
+^IDEBUG_MISC("icmp_input udp_attach errno = %d-%s",$
ERROR: code indent should never use tabs
#138: FILE: slirp/ip_icmp.c:195:
+^IDEBUG_MISC("icmp_input udp sendto tx errno = %d-%s",$
WARNING: line over 80 characters
#206: FILE: slirp/socket.c:211:
+ DEBUG_MISC(" --- soread() disconnected, nn = %d, errno = %d-%s",
ERROR: code indent should never use tabs
#206: FILE: slirp/socket.c:211:
+^I^I^IDEBUG_MISC(" --- soread() disconnected, nn = %d, errno = %d-%s",$
ERROR: space required after that ',' (ctx:VxV)
#207: FILE: slirp/socket.c:212:
+ nn, errno,strerror(errno));
^ERROR: code indent should never use tabs
#216: FILE: slirp/socket.c:241:
+^IDEBUG_MISC(" ... read nn = %d bytes", nn);$
ERROR: code indent should never use tabs
#225: FILE: slirp/socket.c:374:
+^I^I^IDEBUG_ERROR("Didn't send all data urgently XXXXX");$
ERROR: line over 90 characters
#234: FILE: slirp/socket.c:383:
+ DEBUG_MISC(" ---2 sent %d bytes urgent data, %d urgent bytes left", n, so->so_urgc);
ERROR: code indent should never use tabs
#234: FILE: slirp/socket.c:383:
+^IDEBUG_MISC(" ---2 sent %d bytes urgent data, %d urgent bytes left", n, so->so_urgc);$
ERROR: code indent should never use tabs
#252: FILE: slirp/socket.c:482:
+^IDEBUG_MISC(" --- sowrite disconnected, so->so_state = %x, errno = %d",$
ERROR: code indent should never use tabs
#261: FILE: slirp/socket.c:516:
+^I DEBUG_MISC(" udp icmp rx errno = %d-%s",$
ERROR: code indent should never use tabs #270: FILE: slirp/socket.c:568:
+^I DEBUG_MISC(" did recvfrom %d, errno = %d-%s",$
ERROR: code indent should never use tabs
#279: FILE: slirp/socket.c:583:
+^I DEBUG_MISC(" rx error, tx icmp ICMP_UNREACH:%i", code);$
ERROR: code indent should never use tabs
#288: FILE: slirp/socket.c:595:
+^I DEBUG_MISC(" rx error, tx icmp6 ICMP_UNREACH:%i", code);$
ERROR: code indent should never use tabs
#312: FILE: slirp/tcp_input.c:644:
+^I DEBUG_MISC(" tcp fconnect errno = %d-%s", errno, strerror(errno));$
ERROR: suspect code indent for conditional statements (24, 26) #319: FILE: slirp/tcp_input.c:1012:
if (ti->ti_len == 0 && tiwin == tp->snd_wnd) {+ DEBUG_MISC(" dup ack m = %p so = %p", m, so);
ERROR: code indent should never use tabs
#321: FILE: slirp/tcp_input.c:1013:
+^I^I^I DEBUG_MISC(" dup ack m = %p so = %p", m, so);$
ERROR: code indent should never use tabs
#330: FILE: slirp/tcp_input.c:1552:
+^IDEBUG_MISC(" returning mss = %d", mss);$
ERROR: code indent should never use tabs #343: FILE: slirp/tcp_output.c:95:
+^IDEBUG_MISC(" --- tcp_output flags = 0x%x", flags);$
ERROR: code indent should never use tabs
#370: FILE: slirp/udp.c:175:
+^I DEBUG_MISC(" udp_attach errno = %d-%s", errno, strerror(errno));$
ERROR: code indent should never use tabs
#379: FILE: slirp/udp.c:211:
+^I DEBUG_MISC("udp tx errno = %d-%s", errno, strerror(errno));$
total: 22 errors, 1 warnings, 310 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 64/64: slirp: Mark debugging calls as unlikely... === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-quick@centos7 SHOW_ENV=1 J=8 === TEST SCRIPT END ===
libpmem support no
libudev no
WARNING: Use of SDL 1.2 is deprecated and will be removed in
WARNING: future releases. Please switch to using SDL 2.0
NOTE: cross-compilers enabled: 'cc'
GEN x86_64-softmmu/config-devices.mak.tmp
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]