More work towards libslirp
Subsystems (2)
cover More work towards libslirp
The following changes since commit 01a9a51ffaf4699827ea6425cb2b834a356e159d:
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190205-pull-request' into staging (2019-02-05 14:01:29 +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 1e924479dce65a26a7432bf5920f89c1bf957d74:
slirp: API is extern C (2019-02-05 20:27:27 +0200)
----------------------------------------------------------------
More work towards libslirp
Marc-André Lureau (27):
slirp: generalize guestfwd with a callback based approach net/slirp: simplify checking for cmd: prefix
net/slirp: free forwarding rules on cleanup
net/slirp: fix leaks on forwarding rule registration error
slirp: add callbacks for timer
slirp: replace trace functions with DEBUG calls
slirp: replace QEMU_PACKED with SLIRP_PACKED
slirp: replace most qemu socket utilities with slirp own version
slirp: replace qemu_set_nonblock()
slirp: add unregister_poll_fd() callback
slirp: replace qemu_notify_event() with a callback
slirp: move QEMU state saving to a separate unit
slirp: do not include qemu headers in libslirp.h public API header
slirp: improve windows headers inclusion
slirp: add slirp own version of pstrcpy
slirp: remove qemu timer.h dependency
slirp: remove now useless QEMU headers inclusions
slirp: replace net/eth.h inclusion with own defines
slirp: replace qemu qtailq with slirp own copy
slirp: replace remaining qemu headers dependency
slirp: prefer c99 types over BSD kind
slirp: improve send_packet() callback
slirp: replace global polling with per-instance & notifier
slirp: remove slirp_instances list
slirp: use polling callbacks, drop glib requirement
slirp: pass opaque to all callbacks
slirp: API is extern C
Peter Maydell (2):
slirp: Avoid marking naturally packed structs as QEMU_PACKED
slirp: Don't mark struct ipq or struct ipasfrag as packed
Samuel Thibault (3):
slirp: Avoid unaligned 16bit memory access
slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT
slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/
----------------------------------------------------------------
Marc-André Lureau (27):
slirp: generalize guestfwd with a callback based approach net/slirp: simplify checking for cmd: prefix net/slirp: free forwarding rules on cleanup
net/slirp: fix leaks on forwarding rule registration error
slirp: add callbacks for timer
slirp: replace trace functions with DEBUG calls
slirp: replace QEMU_PACKED with SLIRP_PACKED
slirp: replace most qemu socket utilities with slirp own version
slirp: replace qemu_set_nonblock()
slirp: add unregister_poll_fd() callback
slirp: replace qemu_notify_event() with a callback
slirp: move QEMU state saving to a separate unit
slirp: do not include qemu headers in libslirp.h public API header
slirp: improve windows headers inclusion
slirp: add slirp own version of pstrcpy
slirp: remove qemu timer.h dependency
slirp: remove now useless QEMU headers inclusions
slirp: replace net/eth.h inclusion with own defines
slirp: replace qemu qtailq with slirp own copy
slirp: replace remaining qemu headers dependency
slirp: prefer c99 types over BSD kind
slirp: improve send_packet() callback
slirp: replace global polling with per-instance & notifier
slirp: remove slirp_instances list
slirp: use polling callbacks, drop glib requirement
slirp: pass opaque to all callbacks
slirp: API is extern C
Peter Maydell (2):
slirp: Avoid marking naturally packed structs as QEMU_PACKED
slirp: Don't mark struct ipq or struct ipasfrag as packed
Samuel Thibault (3):
slirp: Avoid unaligned 16bit memory access
slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT
slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/
Makefile.objs | 1 - include/glib-compat.h | 57 --- include/net/net.h | 2 +- include/qemu/main-loop.h | 15 + net/net.c | 4 +- net/slirp.c | 185 ++++++++- slirp/Makefile.objs | 4 +- slirp/arp_table.c | 3 +- slirp/bootp.c | 1 - slirp/cksum.c | 1 - slirp/debug.h | 13 +- slirp/dhcpv6.c | 4 +- slirp/dnssearch.c | 1 - slirp/if.c | 4 +- slirp/ip.h | 17 +- slirp/ip6.h | 14 +- slirp/ip6_icmp.c | 27 +- slirp/ip6_icmp.h | 26 +- slirp/ip6_input.c | 1 - slirp/ip6_output.c | 2 - slirp/ip_icmp.c | 14 +- slirp/ip_icmp.h | 18 +- slirp/ip_input.c | 5 +- slirp/ip_output.c | 1 - slirp/libslirp.h | 71 +++- slirp/main.h | 2 +- slirp/mbuf.c | 1 - slirp/mbuf.h | 2 +- slirp/misc.c | 126 ++++-- slirp/misc.h | 15 +- slirp/ncsi.c | 3 +- slirp/ndp_table.c | 2 - slirp/qtailq.h | 193 ++++++++++ slirp/sbuf.c | 8 +- slirp/sbuf.h | 2 +- slirp/slirp.c | 980 +++++++++++++++-------------------------------- slirp/slirp.h | 45 +-- slirp/socket.c | 33 +- slirp/socket.h | 9 +- slirp/state.c | 394 +++++++++++++++++++ slirp/state.h | 9 + slirp/tcp_input.c | 29 +- slirp/tcp_output.c | 13 +- slirp/tcp_subr.c | 49 +-- slirp/tcp_timer.c | 3 +- slirp/tcp_var.h | 14 +- slirp/tftp.c | 16 +- slirp/trace-events | 5 - slirp/udp.c | 16 +- slirp/udp.h | 2 +- slirp/udp6.c | 2 - slirp/util.c | 207 ++++++++++ slirp/util.h | 127 ++++++ stubs/Makefile.objs | 3 +- stubs/slirp.c | 13 - util/main-loop.c | 30 +- util/osdep.c | 2 +- 57 files changed, 1827 insertions(+), 1019 deletions(-) create mode 100644 slirp/qtailq.h create mode 100644 slirp/state.c create mode 100644 slirp/state.h delete mode 100644 slirp/trace-events create mode 100644 slirp/util.c create mode 100644 slirp/util.h delete mode 100644 stubs/slirp.c
PATCH 1/32 slirp: Avoid unaligned 16bit memory access
pkt parameter may be unaligned, so we must access it byte-wise.
This fixes sparc64 host SIGBUS during pxe boot.
--- slirp/slirp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
slirp/slirp.c +1 -1
@@ -829,7 +829,7 @@ void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)if (pkt_len <ETH_HLEN )return ; - proto =ntohs (*(uint16_t *)(pkt +12 )); + proto = (((uint16_t ) pkt[12 ]) <<8 ) + pkt[13 ];switch (proto) {case ETH_P_ARP :arp_input (slirp, pkt, pkt_len);
Signature · 1 line
2.20.1
PATCH 2/32 slirp: Avoid marking naturally packed structs as QEMU_PACKED
In reply to Samuel ThibaultFrom: Peter Maydell <[email protected]>
Various ipv6 structs in the slirp headers are marked QEMU_PACKED, but they are actually naturally aligned and will have no padding in them. Instead of marking them with the 'packed' attribute, assert at compile time that they are the size we expect. This allows us to take the address of fields within the structs without risking undefined behaviour, and suppresses clang -Waddress-of-packed-member warnings.
--- slirp/ip6.h | 12 ++++++++++-- slirp/ip6_icmp.h | 20 +++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-)
slirp/ip6.h +10 -2
@@ -133,7 +133,7 @@ struct ip6 {uint8_t ip_nh;/* next header */ uint8_t ip_hl;/* hop limit */ struct in6_addr ip_src, ip_dst;/* source and dest address */ -}QEMU_PACKED ; +};/* * IPv6 pseudo-header used by upper-layer protocols
@@ -145,7 +145,15 @@ struct ip6_pseudohdr {uint16_t ih_zero_hi;/* zero */ uint8_t ih_zero_lo;/* zero */ uint8_t ih_nh;/* next header */ -}QEMU_PACKED ; +}; +/* +* We don't want to mark these ip6 structs as packed as they are naturally +* correctly aligned; instead assert that there is no stray padding. +* If we marked the struct as packed then we would be unable to take +* the address of any of the fields in it. +*/ +QEMU_BUILD_BUG_ON (sizeof (struct ip6 ) !=40 ); +QEMU_BUILD_BUG_ON (sizeof (struct ip6_pseudohdr ) !=40 );#endif
slirp/ip6_icmp.h +15 -5
@@ -48,12 +48,16 @@ struct ndp_ra { /* Router Advertisement Message */uint16_t lifetime;/* Router Lifetime */ uint32_t reach_time;/* Reachable Time */ uint32_t retrans_time;/* Retrans Timer */ -}QEMU_PACKED ; +}; + +QEMU_BUILD_BUG_ON (sizeof (struct ndp_ra ) !=12 );struct ndp_ns {/* Neighbor Solicitation Message */ uint32_t reserved;struct in6_addr target;/* Target Address */ -}QEMU_PACKED ; +}; + +QEMU_BUILD_BUG_ON (sizeof (struct ndp_ns ) !=20 );struct ndp_na {/* Neighbor Advertisement Message */ #if G_BYTE_ORDER ==G_BIG_ENDIAN
@@ -72,13 +76,17 @@ struct ndp_na { /* Neighbor Advertisement Message */ reserved_lo:24 ;#endif struct in6_addr target;/* Target Address */ -}QEMU_PACKED ; +}; + +QEMU_BUILD_BUG_ON (sizeof (struct ndp_na ) !=20 );struct ndp_redirect {uint32_t reserved;struct in6_addr target;/* Target Address */ struct in6_addr dest;/* Destination Address */ -}QEMU_PACKED ; +}; + +QEMU_BUILD_BUG_ON (sizeof (struct ndp_redirect ) !=36 );/* * Structure of an icmpv6 header.
@@ -103,7 +111,9 @@ struct icmp6 {#define icmp6_nns icmp6_body.ndp_ns#define icmp6_nna icmp6_body.ndp_na#define icmp6_redirect icmp6_body.ndp_redirect -}QEMU_PACKED ; +}; + +QEMU_BUILD_BUG_ON (sizeof (struct icmp6 ) !=40 );#define ICMP6_MINLEN 4#define ICMP6_ERROR_MINLEN 8
Signature · 1 line
2.20.1
PATCH 3/32 slirp: Don't mark struct ipq or struct ipasfrag as packed
In reply to Samuel ThibaultFrom: Peter Maydell <[email protected]>
There is no reason to mark the struct ipq and struct ipasfrag as
packed: they are naturally aligned anyway, and are not representing any on-the-wire packet format. Indeed they vary in size depending on the size of pointers on the host system, because the 'struct qlink' members include 'void *' fields.
Dropping the 'packed' annotation fixes clang -Waddress-of-packed-member warnings and probably lets the compiler generate better code too.
The only thing we do care about in the layout of the struct is that the frag_link matches up with the ipf_link of the struct ipasfrag, as documented in the comment on that struct; assert at build time that this is the case.
--- slirp/ip.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
slirp/ip.h +5 -2
@@ -217,7 +217,7 @@ struct ipq {uint8_t ipq_p;/* protocol of this fragment */ uint16_t ipq_id;/* sequence id for reassembly */ struct in_addr ipq_src,ipq_dst; -}QEMU_PACKED ; +};/* * Ip header, when holding a fragment.
@@ -227,7 +227,10 @@ struct ipq {struct ipasfrag {struct qlink ipf_link;struct ip ipf_ip; -}QEMU_PACKED ; +}; + +QEMU_BUILD_BUG_ON (offsetof(struct ipq , frag_link) != + offsetof(struct ipasfrag , ipf_link));#define ipf_off ipf_ip.ip_off#define ipf_tos ipf_ip.ip_tos
Signature · 1 line
2.20.1
PATCH 4/32 slirp: generalize guestfwd with a callback based approach
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Instead of calling into QEMU chardev directly, and mixing it with slirp_add_exec() handling, add a new function slirp_add_guestfwd() which takes a write callback.
--- net/slirp.c | 14 ++++++++++---- slirp/libslirp.h | 6 +++++- slirp/misc.c | 37 +++++++++++++++++++++++-------------- slirp/misc.h | 15 +++++++++++++-- slirp/slirp.c | 27 +++++++++++++++++++-------- slirp/socket.h | 4 +++- slirp/tcp_subr.c | 4 ++-- 7 files changed, 75 insertions(+), 32 deletions(-)
net/slirp.c +10 -4
@@ -704,8 +704,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,NULL , smb_cmdline, &vserver_addr,139 ) <0 || -slirp_add_exec (s->slirp,NULL , smb_cmdline, &vserver_addr,445 ) <0 ) { +if (slirp_add_exec (s->slirp, smb_cmdline, &vserver_addr,139 ) <0 || +slirp_add_exec (s->slirp, smb_cmdline, &vserver_addr,445 ) <0 ) {slirp_smb_cleanup (s);g_free (smb_cmdline);error_setg (errp,"Conflicting/invalid smbserver address" );
@@ -736,6 +736,11 @@ static void guestfwd_read(void *opaque, const uint8_t *buf, int size)slirp_socket_recv (fwd->slirp, fwd->server, fwd->port, buf, size); } +static int guestfwd_write (const void *buf,size_t len,void *chr) +{ +return qemu_chr_fe_write_all (chr, buf, len); +} +static int slirp_guestfwd (SlirpState *s,const char *config_str,Error **errp) {struct in_addr server = { .s_addr =0 };
@@ -769,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,NULL , &p[4 ], &server, port) <0 ) { +if (slirp_add_exec (s->slirp, &p[4 ], &server, port) <0 ) {error_setg (errp,"Conflicting/invalid host:port in guest " "forwarding rule '%s'" , config_str);return -1 ;
@@ -796,7 +801,8 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)return -1 ; } -if (slirp_add_exec (s->slirp, &fwd->hd,NULL , &server, port) <0 ) { +if (slirp_add_guestfwd (s->slirp, guestfwd_write, &fwd->hd, + &server, port) <0 ) {error_setg (errp,"Conflicting/invalid host:port in guest " "forwarding rule '%s'" , config_str);g_free (fwd);
slirp/libslirp.h +5 -1
@@ -5,6 +5,8 @@typedef struct Slirp Slirp ; +typedef int (*SlirpWriteCb )(const void *buf,size_t len,void *opaque); +/* * Callbacks from slirp *
@@ -45,7 +47,9 @@ 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,void *chardev,const char *cmdline, +int slirp_add_exec (Slirp *slirp,const char *cmdline, +struct in_addr *guest_addr,int guest_port); +int slirp_add_guestfwd (Slirp *slirp,SlirpWriteCb write_cb,void *opaque,struct in_addr *guest_addr,int guest_port);char *slirp_connection_info (Slirp *slirp);
slirp/misc.c +23 -14
@@ -32,24 +32,33 @@ remque(void *a) element->qh_rlink =NULL ; } -int add_exec (struct gfwd_list **ex_ptr,void *chardev,const char *cmdline, +struct gfwd_list * +add_guestfwd (struct gfwd_list **ex_ptr, +SlirpWriteCb write_cb,void *opaque,struct in_addr addr,int port) { -struct gfwd_list *tmp_ptr; - - tmp_ptr = *ex_ptr; - *ex_ptr = g_new0(struct gfwd_list, 1); - (*ex_ptr)->ex_fport = port; - (*ex_ptr)->ex_addr = addr; -if (chardev) { - (*ex_ptr)->ex_chardev = chardev; - }else { - (*ex_ptr)->ex_exec =g_strdup (cmdline); - } - (*ex_ptr)->ex_next = tmp_ptr; -return 0 ; + struct gfwd_list *f = g_new0(struct gfwd_list, 1); + + f->write_cb = write_cb; + f->opaque = opaque; + f->ex_fport = port; + f->ex_addr = addr; + f->ex_next = *ex_ptr; + *ex_ptr = f; + +return f; } +struct gfwd_list * +add_exec (struct gfwd_list **ex_ptr,const char *cmdline, +struct in_addr addr,int port) +{ +struct gfwd_list *f =add_guestfwd (ex_ptr,NULL ,NULL , addr, port); + + f->ex_exec =g_strdup (cmdline); + +return f; +}static int slirp_socketpair_with_oob (int sv[2 ])
slirp/misc.h +13 -2
@@ -8,8 +8,11 @@ #ifndef MISC_H #define MISC_H +#include "libslirp.h" + struct gfwd_list { - void *ex_chardev; + SlirpWriteCb write_cb; + void *opaque; struct in_addr ex_addr; /* Server address */ int ex_fport; /* Port to telnet to */ char *ex_exec; /* Command line of what to exec */
@@ -51,7 +54,15 @@ struct slirp_quehead {void slirp_insque (void *,void *);void slirp_remque (void *); -int add_exec (struct gfwd_list **,void *,const char *,struct in_addr ,int );int fork_exec (struct socket *so,const char *ex); +struct gfwd_list * +add_guestfwd (struct gfwd_list **ex_ptr, +SlirpWriteCb write_cb,void *opaque, +struct in_addr addr,int port); + +struct gfwd_list * +add_exec (struct gfwd_list **ex_ptr,const char *cmdline, +struct in_addr addr,int port); +#endif
slirp/slirp.c +19 -8
@@ -25,7 +25,6 @@#include "qemu-common.h" #include "qemu/timer.h" #include "qemu/error-report.h" -#include "chardev/char-fe.h" #include "migration/register.h" #include "slirp.h" #include "hw/hw.h"
@@ -1068,23 +1067,35 @@ check_guestfwd(Slirp *slirp, struct in_addr *guest_addr, int guest_port)return true; } -int slirp_add_exec (Slirp *slirp,void *chardev,const char *cmdline, +int slirp_add_exec (Slirp *slirp,const char *cmdline,struct in_addr *guest_addr,int guest_port) {if (!check_guestfwd (slirp, guest_addr, guest_port)) {return -1 ; } -return add_exec (&slirp->guestfwd_list, chardev, cmdline, *guest_addr, -htons (guest_port)); +add_exec (&slirp->guestfwd_list, cmdline, *guest_addr,htons (guest_port)); +return 0 ; +} + +int slirp_add_guestfwd (Slirp *slirp,SlirpWriteCb write_cb,void *opaque, +struct in_addr *guest_addr,int guest_port) +{ +if (!check_guestfwd (slirp, guest_addr, guest_port)) { +return -1 ; + } + +add_guestfwd (&slirp->guestfwd_list, write_cb, opaque, + *guest_addr,htons (guest_port)); +return 0 ; }ssize_t slirp_send (struct socket *so,const void *buf,size_t len,int flags) { -if (so->s ==-1 && so->chardev) { +if (so->s ==-1 && so->guestfwd) {/* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ -qemu_chr_fe_write_all (so->chardev, buf, len); + so->guestfwd->write_cb (buf, len, so->guestfwd->opaque);return len; }
@@ -1449,7 +1460,7 @@ static void slirp_state_save(QEMUFile *f, void *opaque)struct gfwd_list *ex_ptr;for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) -if (ex_ptr->ex_chardev) { +if (ex_ptr->write_cb) {struct socket *so; so =slirp_find_ctl_socket (slirp, ex_ptr->ex_addr,ntohs (ex_ptr->ex_fport));
@@ -1484,7 +1495,7 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id)return -EINVAL ; }for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { -if (ex_ptr->ex_chardev && +if (ex_ptr->write_cb && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr && so->so_fport == ex_ptr->ex_fport) {break ;
slirp/socket.h +3 -1
@@ -8,6 +8,8 @@#ifndef SLIRP_SOCKET_H #define SLIRP_SOCKET_H +#include "misc.h" +#define SO_EXPIRE 240000#define SO_EXPIREFAST 10000
@@ -25,6 +27,7 @@ struct socket {struct socket *so_next,*so_prev;/* For a linked list of sockets */ int s;/* The actual socket */ +struct gfwd_list *guestfwd;int pollfds_idx;/* GPollFD GArray index */
@@ -67,7 +70,6 @@ struct socket {struct sbuf so_rcv;/* Receive buffer */ struct sbuf so_snd;/* Send buffer */ -void * chardev; };
slirp/tcp_subr.c +2 -2
@@ -964,9 +964,9 @@ int tcp_ctl(struct socket *so)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) { +if (ex_ptr->write_cb) { so->s =-1 ; - so->chardev = ex_ptr->ex_chardev; + so->guestfwd = ex_ptr;return 1 ; }DEBUG_MISC (" executing %s" , ex_ptr->ex_exec);
Signature · 1 line
2.20.1
PATCH 5/32 net/slirp: simplify checking for cmd: prefix
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- net/slirp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/slirp.c +1 -1
@@ -773,7 +773,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 (g_str_has_prefix (p,"cmd:" )) {if (slirp_add_exec (s->slirp, &p[4 ], &server, port) <0 ) {error_setg (errp,"Conflicting/invalid host:port in guest " "forwarding rule '%s'" , config_str);
Signature · 1 line
2.20.1
PATCH 6/32 net/slirp: free forwarding rules on cleanup
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- net/slirp.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
net/slirp.c +18 -7
@@ -75,6 +75,13 @@ struct slirp_config_str {char str[1024 ]; }; +struct GuestFwd { +CharBackend hd; +struct in_addr server; +int port; +Slirp *slirp; +}; + typedef struct SlirpState { NetClientState nc; QTAILQ_ENTRY(SlirpState) entry;
@@ -83,6 +90,7 @@ typedef struct SlirpState {#ifndef _WIN32gchar *smb_dir;#endif +GSList *fwd; } SlirpState;static struct slirp_config_str *slirp_configs;
@@ -122,10 +130,19 @@ static void slirp_smb_exit(Notifier *n, void *data)slirp_smb_cleanup (s); } +static void slirp_free_fwd (gpointer data) +{ +struct GuestFwd *fwd = data; + +qemu_chr_fe_deinit (&fwd->hd, true); +g_free (data); +} +static void net_slirp_cleanup (NetClientState *nc) {SlirpState *s =DO_UPCAST (SlirpState, nc, nc); +g_slist_free_full (s->fwd, slirp_free_fwd);slirp_cleanup (s->slirp);if (s->exit_notifier.notify) {qemu_remove_exit_notifier (&s->exit_notifier);
@@ -717,13 +734,6 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,#endif /* !defined(_WIN32) */ -struct GuestFwd { -CharBackend hd; -struct in_addr server; -int port; -Slirp *slirp; -}; -static int guestfwd_can_read (void *opaque) {struct GuestFwd *fwd = opaque;
@@ -814,6 +824,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)qemu_chr_fe_set_handlers (&fwd->hd, guestfwd_can_read, guestfwd_read,NULL ,NULL , fwd,NULL , true); + s->fwd =g_slist_append (s->fwd, fwd); }return 0 ;
Signature · 1 line
2.20.1
PATCH 7/32 net/slirp: fix leaks on forwarding rule registration error
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- net/slirp.c | 2 ++ 1 file changed, 2 insertions(+)
net/slirp.c +2 -0
@@ -807,6 +807,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)qemu_chr_fe_init (&fwd->hd, chr, &err);if (err) {error_propagate (errp, err); +object_unparent (OBJECT (chr));g_free (fwd);return -1 ; }
@@ -815,6 +816,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp) &server, port) < 0) {error_setg (errp,"Conflicting/invalid host:port in guest " "forwarding rule '%s'" , config_str); +qemu_chr_fe_deinit (&fwd->hd, true);g_free (fwd);return -1 ; }
Signature · 1 line
2.20.1
PATCH 8/32 slirp: add callbacks for timer
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- net/slirp.c | 21 +++++++++++++++++++++ slirp/ip6_icmp.c | 16 +++++++--------- slirp/libslirp.h | 14 +++++++++++--- slirp/slirp.h | 2 +- 4 files changed, 40 insertions(+), 13 deletions(-)
net/slirp.c +21 -0
@@ -168,10 +168,31 @@ static int64_t net_slirp_clock_get_ns(void)return qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); } +static void *net_slirp_timer_new (SlirpTimerCb cb,void *opaque) +{ +return timer_new_full (NULL ,QEMU_CLOCK_VIRTUAL , +SCALE_MS ,QEMU_TIMER_ATTR_EXTERNAL , + cb, opaque); +} + +static void net_slirp_timer_free (void *timer) +{ +timer_del (timer); +timer_free (timer); +} + +static void net_slirp_timer_mod (void *timer,int64_t expire_timer) +{ +timer_mod (timer, expire_timer); +} +static const SlirpCb slirp_cb = { .output = net_slirp_output, .guest_error = net_slirp_guest_error, .clock_get_ns = net_slirp_clock_get_ns, + .timer_new = net_slirp_timer_new, + .timer_free = net_slirp_timer_free, + .timer_mod = net_slirp_timer_mod, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/ip6_icmp.c +7 -9
@@ -16,8 +16,9 @@static void ra_timer_handler (void *opaque) {Slirp *slirp = opaque; -timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns () /SCALE_MS + NDP_Interval); + + slirp->cb->timer_mod (slirp->ra_timer, + slirp->cb->clock_get_ns () /SCALE_MS + NDP_Interval);ndp_send_ra (slirp); }
@@ -27,11 +28,9 @@ void icmp6_init(Slirp *slirp)return ; } - slirp->ra_timer =timer_new_full (NULL ,QEMU_CLOCK_VIRTUAL , -SCALE_MS ,QEMU_TIMER_ATTR_EXTERNAL , - ra_timer_handler, slirp); -timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns () /SCALE_MS + NDP_Interval); + slirp->ra_timer = slirp->cb->timer_new (ra_timer_handler, slirp); + slirp->cb->timer_mod (slirp->ra_timer, + slirp->cb->clock_get_ns () /SCALE_MS + NDP_Interval); }void icmp6_cleanup (Slirp *slirp)
@@ -40,8 +39,7 @@ void icmp6_cleanup(Slirp *slirp)return ; } -timer_del (slirp->ra_timer); -timer_free (slirp->ra_timer); + slirp->cb->timer_free (slirp->ra_timer); } static void icmp6_send_echoreply(struct mbuf *m, Slirp *slirp, struct ip6 *ip,
slirp/libslirp.h +11 -3
@@ -6,19 +6,27 @@typedef struct Slirp Slirp ;typedef int (*SlirpWriteCb )(const void *buf,size_t len,void *opaque); +typedef void (*SlirpTimerCb )(void *opaque);/* * 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. */ +/* +* Send an ethernet frame to the guest network. The opaque parameter +* is the one given to slirp_init(). +*/ 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 ); +/* Create a new timer with the given callback and opaque data */ +void *(*timer_new)(SlirpTimerCb cb,void *opaque); +/* Remove and free a timer */ +void (*timer_free)(void *timer); +/* Modify a timer to expire at @expire_time */ +void (*timer_mod)(void *timer,int64_t expire_time); }SlirpCb ;
slirp/slirp.h +1 -1
@@ -193,7 +193,7 @@ struct Slirp {NdpTable ndp_table;GRand *grand; -QEMUTimer *ra_timer; +void *ra_timer;const SlirpCb *cb;void *opaque;
Signature · 1 line
2.20.1
PATCH 9/32 slirp: replace trace functions with DEBUG calls
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Remove a dependency on QEMU. Use the existing logging facilities. Set SLIRP_DEBUG=tftp to get tftp log.
--- Makefile.objs | 1 - slirp/debug.h | 13 ++++++++++--- slirp/slirp.c | 1 + slirp/tftp.c | 7 ++++--- slirp/trace-events | 5 ----- 5 files changed, 15 insertions(+), 12 deletions(-) delete mode 100644 slirp/trace-events
Makefile.objs +0 -1
@@ -192,7 +192,6 @@ trace-events-subdirs += net trace-events-subdirs += qapi trace-events-subdirs += qom trace-events-subdirs += scsi -trace-events-subdirs += slirp trace-events-subdirs += target/arm trace-events-subdirs += target/i386 trace-events-subdirs += target/mips
slirp/debug.h +10 -3
@@ -8,9 +8,10 @@#ifndef DEBUG_H_ #define DEBUG_H_ -#define DBG_CALL 0x1 -#define DBG_MISC 0x2 -#define DBG_ERROR 0x4 +#define DBG_CALL (1 << 0) +#define DBG_MISC (1 << 1) +#define DBG_ERROR (1 << 2) +#define DBG_TFTP (1 << 3)extern int slirp_debug;
@@ -38,4 +39,10 @@ extern int slirp_debug; } \ } while (0) +#define DEBUG_TFTP (fmt, ...) do { \ + if (G_UNLIKELY(slirp_debug & DBG_TFTP)) { \ + g_debug(fmt, ##__VA_ARGS__); \ + } \ +} while (0) +#endif /* DEBUG_H_ */
slirp/slirp.c +1 -0
@@ -270,6 +270,7 @@ static void slirp_init_once(void) { "call", DBG_CALL }, { "misc", DBG_MISC }, { "error", DBG_ERROR }, + { "tftp", DBG_TFTP }, }; slirp_debug =g_parse_debug_string (debug, keys,G_N_ELEMENTS (keys)); }
slirp/tftp.c +4 -3
@@ -26,7 +26,6 @@#include "slirp.h" #include "qemu-common.h" #include "qemu/cutils.h" -#include "trace.h" static inline int tftp_session_in_use (struct tftp_session *spt) {
@@ -205,7 +204,8 @@ static void tftp_send_error(struct tftp_session *spt,struct mbuf *m;struct tftp_t *tp; -trace_slirp_tftp_error (msg); +DEBUG_TFTP ("tftp error msg: %s" , msg); + m =m_get (spt->slirp);if (!m) {
@@ -325,7 +325,8 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,break ; } } -trace_slirp_tftp_rrq (req_fname); + +DEBUG_TFTP ("tftp rrq file: %s" , req_fname);/* check mode */ if ((pktlen - k) <6 ) {
slirp/trace-events deleted +0 -5
@@ -1,5 +0,0 @@ -# See docs/devel/tracing.txt for syntax documentation. - -# slirp/tftp.c -slirp_tftp_rrq(const char *file) "file: %s" -slirp_tftp_error(const char *file) "msg: %s"
Signature · 1 line
2.20.1
PATCH 10/32 slirp: replace QEMU_PACKED with SLIRP_PACKED
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- slirp/ip.h | 10 +++++----- slirp/ip6_icmp.h | 6 +++--- slirp/slirp.h | 5 +++-- slirp/util.h | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 slirp/util.h
slirp/ip.h +5 -5
@@ -89,7 +89,7 @@ struct ip {uint8_t ip_p;/* protocol */ uint16_t ip_sum;/* checksum */ struct in_addr ip_src,ip_dst;/* source and dest address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;#define IP_MAXPACKET 65535/* maximum packet size */
@@ -151,7 +151,7 @@ struct ip_timestamp {n_long ipt_time; } ipt_ta[1 ]; } ipt_timestamp; -}QEMU_PACKED ; +}SLIRP_PACKED ;/* flag bits for ipt_flg */ #define IPOPT_TS_TSONLY 0/* timestamps only */
@@ -181,11 +181,11 @@ struct ip_timestamp {struct mbuf_ptr {struct mbuf *mptr;uint32_t dummy; -}QEMU_PACKED ; +}SLIRP_PACKED ;#else struct mbuf_ptr {struct mbuf *mptr; -}QEMU_PACKED ; +}SLIRP_PACKED ;#endif struct qlink {void *next, *prev;
@@ -201,7 +201,7 @@ struct ipovly {uint16_t ih_len;/* protocol length */ struct in_addr ih_src;/* source internet address */ struct in_addr ih_dst;/* destination internet address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;/* * Ip reassembly queue structure. Each fragment
slirp/ip6_icmp.h +3 -3
@@ -144,16 +144,16 @@ struct ndpopt {uint32_t pref_lt;/* Preferred Lifetime */ uint32_t reserved2;struct in6_addr prefix; - }QEMU_PACKED prefixinfo; + }SLIRP_PACKED prefixinfo;#define ndpopt_prefixinfo ndpopt_body.prefixinfostruct rdnss {uint16_t reserved;uint32_t lifetime;struct in6_addr addr; - } QEMU_PACKED rdnss; + } SLIRP_PACKED rdnss;#define ndpopt_rdnss ndpopt_body.rdnss } ndpopt_body; -}QEMU_PACKED ; +}SLIRP_PACKED ;/* NDP options type */ #define NDPOPT_LINKLAYER_SOURCE 1/* Source Link-Layer Address */
slirp/slirp.h +3 -2
@@ -45,6 +45,7 @@ typedef char *caddr_t;#define quehead slirp_quehead#include "debug.h" +#include "util.h" #include "qemu/queue.h" #include "qemu/sockets.h"
@@ -93,7 +94,7 @@ struct slirp_arphdr {uint32_t ar_sip;/* sender IP address */ unsigned char ar_tha[ETH_ALEN ];/* target hardware address */ uint32_t ar_tip;/* target IP address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;#define ARP_TABLE_SIZE 16
@@ -110,7 +111,7 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,struct ndpentry {unsigned char eth_addr[ETH_ALEN ];/* sender hardware address */ struct in6_addr ip_addr;/* sender IP address */ -}QEMU_PACKED ; +}SLIRP_PACKED ;#define NDP_TABLE_SIZE 16
slirp/util.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (c) 2003-2008 Fabrice Bellard +* Copyright (c) 2010-2019 Red Hat, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#ifndef UTIL_H_ +#define UTIL_H_ + +#if defined(_WIN32) +# define SLIRP_PACKED __attribute__((gcc_struct, packed)) +#else +# define SLIRP_PACKED __attribute__((packed)) +#endif + +#endif
Signature · 1 line
2.20.1
PATCH 11/32 slirp: replace most qemu socket utilities with slirp own version
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
qemu_set_nonblock() is slightly more problematic and will be dealt with in a separate patch.
--- slirp/Makefile.objs | 3 +- slirp/ip_icmp.c | 6 +- slirp/misc.c | 20 ++--- slirp/socket.c | 18 ++--- slirp/tcp_subr.c | 18 ++--- slirp/udp.c | 8 +- slirp/util.c | 176 ++++++++++++++++++++++++++++++++++++++++++++ slirp/util.h | 61 +++++++++++++++ 8 files changed, 274 insertions(+), 36 deletions(-) create mode 100644 slirp/util.c
slirp/Makefile.objs +2 -1
@@ -27,6 +27,7 @@ slirp.mo-objs = \ tftp.o \ udp.o \ udp6.o \ + util.o \ $(NULL) -slirp.mo-cflags = -DG_LOG_DOMAIN=\"Slirp\" +slirp.mo-cflags = -DG_LOG_DOMAIN=\"Slirp\" -DWITH_QEMU
slirp/ip_icmp.c +3 -3
@@ -83,7 +83,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen) struct ip *ip = mtod(m, struct ip *);struct sockaddr_in addr; - so->s =qemu_socket (AF_INET ,SOCK_DGRAM ,IPPROTO_ICMP ); + so->s =slirp_socket (AF_INET ,SOCK_DGRAM ,IPPROTO_ICMP );if (so->s ==-1 ) {return -1 ; }
@@ -114,7 +114,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen)void icmp_detach (struct socket *so) { -closesocket (so->s); +slirp_closesocket (so->s);sofree (so); }
@@ -421,7 +421,7 @@ void icmp_receive(struct socket *so) icp = mtod(m, struct icmp *); id = icp->icmp_id; - len =qemu_recv (so->s, icp,M_ROOM (m),0 ); + len =slirp_recv (so->s, icp,M_ROOM (m),0 );/* * The behavior of reading SOCK_DGRAM+IPPROTO_ICMP sockets is inconsistent * between host OSes. On Linux, only the ICMP header and payload is
slirp/misc.c +10 -10
@@ -72,14 +72,14 @@ slirp_socketpair_with_oob(int sv[2])int ret, s; sv[1 ] =-1 ; - s =qemu_socket (AF_INET ,SOCK_STREAM ,0 ); + s =slirp_socket (AF_INET ,SOCK_STREAM ,0 );if (s <0 ||bind (s, (struct sockaddr *)&addr, addrlen) <0 ||listen (s,1 ) <0 ||getsockname (s, (struct sockaddr *)&addr, &addrlen) <0 ) { goto err; } - sv[1 ] =qemu_socket (AF_INET ,SOCK_STREAM ,0 ); + sv[1 ] =slirp_socket (AF_INET ,SOCK_STREAM ,0 );if (sv[1 ] <0 ) { goto err; }
@@ -102,16 +102,16 @@ slirp_socketpair_with_oob(int sv[2]) goto err; } -closesocket (s); +slirp_closesocket (s);return 0 ; err:g_critical ("slirp_socketpair(): %s" ,strerror (errno));if (s >=0 ) { -closesocket (s); +slirp_closesocket (s); }if (sv[1 ] >=0 ) { -closesocket (sv[1 ]); +slirp_closesocket (sv[1 ]); }return -1 ; }
@@ -153,16 +153,16 @@ fork_exec(struct socket *so, const char *ex)if (err) {g_critical ("fork_exec: %s" , err->message);g_error_free (err); -closesocket (sp[0 ]); -closesocket (sp[1 ]); +slirp_closesocket (sp[0 ]); +slirp_closesocket (sp[1 ]);return 0 ; } so->s = sp[0 ]; -closesocket (sp[1 ]); -socket_set_fast_reuse (so->s); +slirp_closesocket (sp[1 ]); +slirp_socket_set_fast_reuse (so->s); opt =1 ; -qemu_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); +slirp_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));qemu_set_nonblock (so->s);return 1 ; }
slirp/socket.c +9 -9
@@ -187,7 +187,7 @@ soread(struct socket *so)*/ sopreprbuf (so, iov, &n); - nn =qemu_recv (so->s, iov[0 ].iov_base, iov[0 ].iov_len,0 ); + nn =slirp_recv (so->s, iov[0 ].iov_base, iov[0 ].iov_len,0 );if (nn <=0 ) {if (nn <0 && (errno ==EINTR || errno ==EAGAIN ))return 0 ;
@@ -203,7 +203,7 @@ soread(struct socket *so)if (getpeername (so->s, paddr, &alen) <0 ) { err = errno; }else { -getsockopt (so->s,SOL_SOCKET ,SO_ERROR , +slirp_getsockopt (so->s,SOL_SOCKET ,SO_ERROR , &err, &elen); } }
@@ -233,7 +233,7 @@ soread(struct socket *so)*/ if (n ==2 && nn == iov[0 ].iov_len) {int ret; - ret =qemu_recv (so->s, iov[1 ].iov_base, iov[1 ].iov_len,0 ); + ret =slirp_recv (so->s, iov[1 ].iov_base, iov[1 ].iov_len,0 );if (ret >0 ) nn += ret; }
@@ -554,7 +554,7 @@ sorecvfrom(struct socket *so)*/ len =M_FREEROOM (m);/* if (so->so_fport != htons(53)) { */ -ioctlsocket (so->s,FIONREAD , &n); +slirp_ioctlsocket (so->s,FIONREAD , &n);if (n > len) { n = (m->m_data - m->m_dat) + m->m_len + n +1 ;
@@ -719,14 +719,14 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, addr.sin_addr.s_addr = haddr; addr.sin_port = hport; -if (((s =qemu_socket (AF_INET ,SOCK_STREAM ,0 )) <0 ) || - (socket_set_fast_reuse (s) <0 ) || +if (((s =slirp_socket (AF_INET ,SOCK_STREAM ,0 )) <0 ) || + (slirp_socket_set_fast_reuse (s) <0 ) || (bind (s,(struct sockaddr *)&addr,sizeof (addr)) <0 ) || (listen (s,1 ) <0 )) {int tmperrno = errno;/* Don't clobber the real reason we failed */ if (s >=0 ) { -closesocket (s); +slirp_closesocket (s); }sofree (so);/* Restore the real errno */
@@ -737,9 +737,9 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,#endif return NULL ; } -qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); +slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); opt =1 ; -qemu_setsockopt (s,IPPROTO_TCP ,TCP_NODELAY , &opt,sizeof (int )); +slirp_setsockopt (s,IPPROTO_TCP ,TCP_NODELAY , &opt,sizeof (int ));getsockname (s,(struct sockaddr *)&addr,&addrlen); so->so_ffamily =AF_INET ;
slirp/tcp_subr.c +9 -9
@@ -337,7 +337,7 @@ tcp_close(struct tcpcb *tp)/* clobber input socket cache if we're closing the cached connection */ if (so == slirp->tcp_last_so) slirp->tcp_last_so = &slirp->tcb; -closesocket (so->s); +slirp_closesocket (so->s);sbfree (&so->so_rcv);sbfree (&so->so_snd);sofree (so);
@@ -407,17 +407,17 @@ int tcp_fconnect(struct socket *so, unsigned short af)DEBUG_CALL ("tcp_fconnect" );DEBUG_ARG ("so = %p" , so); - ret = so->s =qemu_socket (af,SOCK_STREAM ,0 ); + ret = so->s =slirp_socket (af,SOCK_STREAM ,0 );if (ret >=0 ) {int opt, s=so->s;struct sockaddr_storage addr;qemu_set_nonblock (s); -socket_set_fast_reuse (s); +slirp_socket_set_fast_reuse (s); opt =1 ; -qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt)); +slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt)); opt =1 ; -qemu_setsockopt (s,IPPROTO_TCP ,TCP_NODELAY , &opt,sizeof (opt)); +slirp_setsockopt (s,IPPROTO_TCP ,TCP_NODELAY , &opt,sizeof (opt)); addr = so->fhost.ss;DEBUG_CALL (" connect()ing" );
@@ -485,10 +485,10 @@ void tcp_connect(struct socket *inso)return ; }qemu_set_nonblock (s); -socket_set_fast_reuse (s); +slirp_socket_set_fast_reuse (s); opt =1 ; -qemu_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); -socket_set_nodelay (s); +slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); +slirp_socket_set_nodelay (s); so->fhost.ss = addr;sotranslate_accept (so);
@@ -496,7 +496,7 @@ void tcp_connect(struct socket *inso)/* Close the accept() socket, set right state */ if (inso->so_state &SS_FACCEPTONCE ) {/* If we only accept once, close the accept() socket */ -closesocket (so->s); +slirp_closesocket (so->s);/* Don't select it yet, even though we have an FD */ /* if it's not FACCEPTONCE, it's already NOFDREF */
slirp/udp.c +4 -4
@@ -281,7 +281,7 @@ int udp_output(struct socket *so, struct mbuf *m,int udp_attach (struct socket *so,unsigned short af) { - so->s =qemu_socket (af,SOCK_DGRAM ,0 ); + so->s =slirp_socket (af,SOCK_DGRAM ,0 );if (so->s !=-1 ) { so->so_expire = curtime +SO_EXPIRE ;insque (so, &so->slirp->udb);
@@ -292,7 +292,7 @@ udp_attach(struct socket *so, unsigned short af)void udp_detach (struct socket *so) { -closesocket (so->s); +slirp_closesocket (so->s);sofree (so); }
@@ -327,7 +327,7 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,socklen_t addrlen =sizeof (struct sockaddr_in ); so =socreate (slirp); - so->s =qemu_socket (AF_INET ,SOCK_DGRAM ,0 ); + so->s =slirp_socket (AF_INET ,SOCK_DGRAM ,0 );if (so->s <0 ) {sofree (so);return NULL ;
@@ -343,7 +343,7 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,udp_detach (so);return NULL ; } -socket_set_fast_reuse (so->s); +slirp_socket_set_fast_reuse (so->s);getsockname (so->s,(struct sockaddr *)&addr,&addrlen); so->fhost.sin = addr;
slirp/util.c new file +176 -0
176 lines not on this page · raw message
slirp/util.h +61 -0
71 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 12/32 slirp: replace qemu_set_nonblock()
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Replace qemu_set_nonblock() with slirp_set_nonblock()
qemu_set_nonblock() does some event registration with the main loop. Add a new callback register_poll_fd() for that reason.
Always build the fd-register stub, to avoid #if WIN32.
--- net/slirp.c | 6 ++++++ slirp/libslirp.h | 2 ++ slirp/misc.c | 3 ++- slirp/tcp_subr.c | 6 ++++-- slirp/util.c | 14 ++++++++++++++ slirp/util.h | 1 + stubs/Makefile.objs | 2 +- 7 files changed, 30 insertions(+), 4 deletions(-)
net/slirp.c +6 -0
@@ -186,6 +186,11 @@ static void net_slirp_timer_mod(void *timer, int64_t expire_timer)timer_mod (timer, expire_timer); } +static void net_slirp_register_poll_fd (int fd) +{ +qemu_fd_register (fd); +} +static const SlirpCb slirp_cb = { .output = net_slirp_output, .guest_error = net_slirp_guest_error,
@@ -193,6 +198,7 @@ static const SlirpCb slirp_cb = { .timer_new = net_slirp_timer_new, .timer_free = net_slirp_timer_free, .timer_mod = net_slirp_timer_mod, + .register_poll_fd = net_slirp_register_poll_fd, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/libslirp.h +2 -0
@@ -27,6 +27,8 @@ typedef struct SlirpCb {void (*timer_free)(void *timer);/* Modify a timer to expire at @expire_time */ void (*timer_mod)(void *timer,int64_t expire_time); +/* Register a fd for future polling */ +void (*register_poll_fd)(int fd); } SlirpCb;
slirp/misc.c +2 -1
@@ -163,7 +163,8 @@ fork_exec(struct socket *so, const char *ex)slirp_socket_set_fast_reuse (so->s); opt =1 ;slirp_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int )); -qemu_set_nonblock (so->s); +slirp_set_nonblock (so->s); + so->slirp->cb->register_poll_fd (so->s);return 1 ; }
slirp/tcp_subr.c +4 -2
@@ -412,7 +412,8 @@ int tcp_fconnect(struct socket *so, unsigned short af)int opt, s=so->s;struct sockaddr_storage addr; -qemu_set_nonblock (s); +slirp_set_nonblock (s); + so->slirp->cb->register_poll_fd (so->s);slirp_socket_set_fast_reuse (s); opt =1 ;slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt));
@@ -484,7 +485,8 @@ void tcp_connect(struct socket *inso)tcp_close (sototcpcb (so));/* This will sofree() as well */ return ; } -qemu_set_nonblock (s); +slirp_set_nonblock (s); + so->slirp->cb->register_poll_fd (so->s);slirp_socket_set_fast_reuse (s); opt =1 ;slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));
slirp/util.c +14 -0
@@ -43,6 +43,20 @@ int inet_aton(const char *cp, struct in_addr *ia) }#endif +void slirp_set_nonblock (int fd) +{ +#ifndef _WIN32 +int f; + f =fcntl (fd,F_GETFL ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 ); +#else +unsigned long opt =1 ; +ioctlsocket (fd,FIONBIO , &opt); +#endif +} +static void slirp_set_cloexec (int fd) {#ifndef _WIN32
slirp/util.h +1 -0
@@ -68,6 +68,7 @@ int inet_aton(const char *cp, struct in_addr *ia);#endif int slirp_socket (int domain,int type,int protocol); +void slirp_set_nonblock (int fd);static inline int slirp_socket_set_nodelay (int fd) {
stubs/Makefile.objs +1 -1
@@ -33,7 +33,7 @@ stub-obj-y += trace-control.o stub-obj-y += uuid.o stub-obj-y += vm-stop.o stub-obj-y += vmstate.o -stub-obj-$(CONFIG_WIN32) += fd-register.o +stub-obj-y += fd-register.o stub-obj-y += qmp_memory_device.o stub-obj-y += target-monitor-defs.o stub-obj-y += target-get-monitor-def.o
Signature · 1 line
2.20.1
PATCH 13/32 slirp: add unregister_poll_fd() callback
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Add a counter-part to register_poll_fd() for completeness.
(so far, register_poll_fd() is called only on struct socket fd)
--- net/slirp.c | 6 ++++++ slirp/ip_icmp.c | 1 + slirp/libslirp.h | 2 ++ slirp/slirp.c | 3 ++- slirp/tcp_subr.c | 2 ++ slirp/udp.c | 1 + 6 files changed, 14 insertions(+), 1 deletion(-)
net/slirp.c +6 -0
@@ -191,6 +191,11 @@ static void net_slirp_register_poll_fd(int fd)qemu_fd_register (fd); } +static void net_slirp_unregister_poll_fd (int fd) +{ +/* no qemu_fd_unregister */ +} +static const SlirpCb slirp_cb = { .output = net_slirp_output, .guest_error = net_slirp_guest_error,
@@ -199,6 +204,7 @@ static const SlirpCb slirp_cb = { .timer_free = net_slirp_timer_free, .timer_mod = net_slirp_timer_mod, .register_poll_fd = net_slirp_register_poll_fd, + .unregister_poll_fd = net_slirp_unregister_poll_fd, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/ip_icmp.c +1 -0
@@ -114,6 +114,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen)void icmp_detach (struct socket *so) { + so->slirp->cb->unregister_poll_fd (so->s);slirp_closesocket (so->s);sofree (so); }
slirp/libslirp.h +2 -0
@@ -29,6 +29,8 @@ typedef struct SlirpCb {void (*timer_mod)(void *timer,int64_t expire_time);/* Register a fd for future polling */ void (*register_poll_fd)(int fd); +/* Unregister a fd */ +void (*unregister_poll_fd)(int fd); } SlirpCb;
slirp/slirp.c +2 -1
@@ -1015,7 +1015,8 @@ int slirp_remove_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,getsockname (so->s, (struct sockaddr *)&addr, &addr_len) ==0 && addr.sin_addr.s_addr == host_addr.s_addr && addr.sin_port == port) { -close (so->s); + so->slirp->cb->unregister_poll_fd(so->s); +slirp_closesocket (so->s);sofree (so);return 0 ; }
slirp/tcp_subr.c +2 -0
@@ -337,6 +337,7 @@ tcp_close(struct tcpcb *tp)/* clobber input socket cache if we're closing the cached connection */ if (so == slirp->tcp_last_so) slirp->tcp_last_so = &slirp->tcb; + so->slirp->cb->unregister_poll_fd (so->s);slirp_closesocket (so->s);sbfree (&so->so_rcv);sbfree (&so->so_snd);
@@ -498,6 +499,7 @@ void tcp_connect(struct socket *inso)/* Close the accept() socket, set right state */ if (inso->so_state &SS_FACCEPTONCE ) {/* If we only accept once, close the accept() socket */ + so->slirp->cb->unregister_poll_fd (so->s);slirp_closesocket (so->s);/* Don't select it yet, even though we have an FD */
slirp/udp.c +1 -0
@@ -292,6 +292,7 @@ udp_attach(struct socket *so, unsigned short af)void udp_detach (struct socket *so) { + so->slirp->cb->unregister_poll_fd (so->s);slirp_closesocket (so->s);sofree (so); }
Signature · 1 line
2.20.1
PATCH 14/32 slirp: replace qemu_notify_event() with a callback
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Introduce a SlirpCb callback to kick the main io-thread.
Add an intermediary sodrop() function that will call SlirpCb.notify callback when sbdrop() returns true.
--- net/slirp.c | 1 + slirp/libslirp.h | 2 ++ slirp/sbuf.c | 6 ++++-- slirp/sbuf.h | 2 +- slirp/socket.c | 7 +++++++ slirp/socket.h | 1 + slirp/tcp_input.c | 6 +++--- 7 files changed, 19 insertions(+), 6 deletions(-)
net/slirp.c +1 -0
@@ -205,6 +205,7 @@ static const SlirpCb slirp_cb = { .timer_mod = net_slirp_timer_mod, .register_poll_fd = net_slirp_register_poll_fd, .unregister_poll_fd = net_slirp_unregister_poll_fd, + .notify = qemu_notify_event, }; static int net_slirp_init(NetClientState *peer, const char *model,
slirp/libslirp.h +2 -0
@@ -31,6 +31,8 @@ typedef struct SlirpCb {void (*register_poll_fd)(int fd);/* Unregister a fd */ void (*unregister_poll_fd)(int fd); +/* Kick the io-thread, to signal that new events may be processed */ +void (*notify)(void ); } SlirpCb;
slirp/sbuf.c +4 -2
@@ -17,7 +17,7 @@ sbfree(struct sbuf *sb)free (sb->sb_data); } -void +bool sbdrop (struct sbuf *sb,int num) {int limit = sb->sb_datalen /2 ;
@@ -34,8 +34,10 @@ sbdrop(struct sbuf *sb, int num) sb->sb_rptr -= sb->sb_datalen;if (sb->sb_cc < limit && sb->sb_cc + num >= limit) { -qemu_notify_event (); +return true; } + +return false; }void
slirp/sbuf.h +1 -1
@@ -21,7 +21,7 @@ struct sbuf { };void sbfree (struct sbuf *); -void sbdrop (struct sbuf *,int ); +bool sbdrop (struct sbuf *,int );void sbreserve (struct sbuf *,int );void sbappend (struct socket *,struct mbuf *);void sbcopy (struct sbuf *,int ,int ,char *);
slirp/socket.c +7 -0
@@ -928,3 +928,10 @@ void sotranslate_accept(struct socket *so)break ; } } + +void sodrop (struct socket *s,int num) +{ +if (sbdrop (&s->so_snd, num)) { + s->slirp->cb->notify (); + } +}
slirp/socket.h +1 -0
@@ -156,6 +156,7 @@ int soreadbuf(struct socket *so, const char *buf, int size);void sotranslate_out (struct socket *,struct sockaddr_storage *);void sotranslate_in (struct socket *,struct sockaddr_storage *);void sotranslate_accept (struct socket *); +void sodrop (struct socket *,int num);#endif /* SLIRP_SOCKET_H */
slirp/tcp_input.c +3 -3
@@ -506,7 +506,7 @@ findso: SEQ_GT(ti->ti_ack, tp->t_rtseq))tcp_xmit_timer (tp, tp->t_rtt); acked = ti->ti_ack - tp->snd_una; -sbdrop (&so->so_snd, acked); +sodrop (so, acked); tp->snd_una = ti->ti_ack;m_free (m);
@@ -1118,10 +1118,10 @@ trimthenstep6: }if (acked > so->so_snd.sb_cc) { tp->snd_wnd -= so->so_snd.sb_cc; -sbdrop (&so->so_snd, (int )so->so_snd.sb_cc); +sodrop (so, (int )so->so_snd.sb_cc); ourfinisacked =1 ; }else { -sbdrop (&so->so_snd, acked); +sodrop (so, acked); tp->snd_wnd -= acked; ourfinisacked =0 ; }
Signature · 1 line
2.20.1
PATCH 15/32 slirp: move QEMU state saving to a separate unit
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Make state saving optional: this will allow to build SLIRP without QEMU. (eventually, the vmstate helpers will be extracted, so an external project & process could save its state)
--- slirp/Makefile.objs | 1 + slirp/slirp.c | 372 ++--------------------------------------- slirp/slirp.h | 3 + slirp/state.c | 394 ++++++++++++++++++++++++++++++++++++++++++++ slirp/state.h | 9 + 5 files changed, 418 insertions(+), 361 deletions(-) create mode 100644 slirp/state.c create mode 100644 slirp/state.h
slirp/Makefile.objs +1 -0
@@ -20,6 +20,7 @@ slirp.mo-objs = \ sbuf.o \ slirp.o \ socket.o \ + state.o \ tcp_input.o \ tcp_output.o \ tcp_subr.o \
slirp/slirp.c +11 -361
405 lines not on this page · raw message
slirp/slirp.h +3 -0
@@ -271,4 +271,7 @@ int tcp_emu(struct socket *, struct mbuf *);int tcp_ctl (struct socket *);struct tcpcb *tcp_drop (struct tcpcb *tp,int err); +struct socket * +slirp_find_ctl_socket (Slirp *slirp,struct in_addr guest_addr,int guest_port); +#endif
slirp/state.c new file +394 -0
394 lines not on this page · raw message
slirp/state.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef SLIRP_STATE_H_ +#define SLIRP_STATE_H_ + +#include "libslirp.h" + +void slirp_state_register (Slirp *slirp); +void slirp_state_unregister (Slirp *slirp); + +#endif /* SLIRP_STATE_H_ */
Signature · 1 line
2.20.1
PATCH 16/32 slirp: do not include qemu headers in libslirp.h public API header
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- slirp/libslirp.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
slirp/libslirp.h +11 -1
@@ -1,7 +1,17 @@#ifndef LIBSLIRP_H #define LIBSLIRP_H -#include "qemu-common.h" +#include <glib.h> +#include <stdint.h> +#include <stdbool.h> + +#ifdef _WIN32 +#include <winsock2.h> +#include <in6addr.h> +#else +#include <netinet/in.h> +#include <arpa/inet.h> +#endif typedef struct Slirp Slirp ;
Signature · 1 line
2.20.1
PATCH 17/32 slirp: improve windows headers inclusion
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Our API usage requires Vista, set WIN32_LEAN_AND_MEAN to fix a number of issues (winsock2.h include order for ex, which is better to include first for legacy reasons).
While at it, group redundants #ifndef _WIN32 blocks.
--- slirp/slirp.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
slirp/slirp.h +11 -11
@@ -3,10 +3,19 @@#ifdef _WIN32 +/* as defined in sdkddkver.h */ +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0600/* Vista */ +#endif +/* reduces the number of implicitly included headers */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +typedef char *caddr_t ; -# include <windows.h> # include <winsock2.h> +# include <windows.h> # include <ws2tcpip.h> # include <sys/timeb.h> # include <iphlpapi.h>
@@ -19,19 +28,10 @@ typedef char *caddr_t;#ifndef _WIN32#include <sys/uio.h> -#endif - -#ifndef _WIN32#include <netinet/in.h> #include <arpa/inet.h> -#endif - -#ifndef _WIN32#include <sys/socket.h> -#endif - -#ifndef _WIN32 -# include <sys/ioctl.h> +#include <sys/ioctl.h> #endif #ifdef __APPLE__
Signature · 1 line
2.20.1
PATCH 18/32 slirp: add slirp own version of pstrcpy
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Remove a dependency on qemu util.
--- slirp/slirp.c | 4 ++-- slirp/tftp.c | 2 +- slirp/util.c | 17 +++++++++++++++++ slirp/util.h | 2 ++ 4 files changed, 22 insertions(+), 3 deletions(-)
slirp/slirp.c +2 -2
@@ -320,8 +320,8 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, slirp->vprefix_len = vprefix_len; slirp->vhost_addr6 = vhost6;if (vhostname) { -pstrcpy (slirp->client_hostname,sizeof (slirp->client_hostname), - vhostname); +slirp_pstrcpy (slirp->client_hostname,sizeof (slirp->client_hostname), + vhostname); } slirp->tftp_prefix =g_strdup (tftp_path); slirp->bootp_filename =g_strdup (bootfile);
slirp/tftp.c +1 -1
@@ -216,7 +216,7 @@ static void tftp_send_error(struct tftp_session *spt, tp->tp_op =htons (TFTP_ERROR ); tp->x.tp_error.tp_error_code =htons (errorcode); -pstrcpy ((char *)tp->x.tp_error.tp_msg,sizeof (tp->x.tp_error.tp_msg), msg); +slirp_pstrcpy ((char *)tp->x.tp_error.tp_msg,sizeof (tp->x.tp_error.tp_msg), msg); m->m_len =sizeof (struct tftp_t ) - (TFTP_BLOCKSIZE_MAX +2 ) +3 +strlen (msg) -sizeof (struct udphdr );
slirp/util.c +17 -0
@@ -188,3 +188,20 @@ int slirp_closesocket(int fd) return ret; }#endif /* WIN32 */ + +void slirp_pstrcpy (char *buf,int buf_size,const char *str) +{ +int c; +char *q = buf; + +if (buf_size <=0 ) +return ; + +for (;;) { + c = *str++; +if (c ==0 || q >= buf + buf_size -1 ) +break ; + *q++ = c; + } + *q ='\0' ; +}
slirp/util.h +2 -0
@@ -91,4 +91,6 @@ static inline int slirp_socket_set_fast_reuse(int fd) #endif } +void slirp_pstrcpy (char *buf,int buf_size,const char *str); +#endif
Signature · 1 line
2.20.1
PATCH 19/32 slirp: remove qemu timer.h dependency
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- slirp/if.c | 1 - slirp/ip6_icmp.c | 1 - slirp/slirp.c | 1 - slirp/util.h | 2 ++ 4 files changed, 2 insertions(+), 3 deletions(-)
slirp/if.c +0 -1
@@ -7,7 +7,6 @@#include "qemu/osdep.h" #include "slirp.h" -#include "qemu/timer.h" static void ifs_insque (struct mbuf *ifm,struct mbuf *ifmhead)
slirp/ip6_icmp.c +0 -1
@@ -6,7 +6,6 @@#include "qemu/osdep.h" #include "slirp.h" #include "ip6_icmp.h" -#include "qemu/timer.h" #include "qemu/error-report.h" #include "qemu/log.h"
slirp/slirp.c +0 -1
@@ -23,7 +23,6 @@*/ #include "qemu/osdep.h" #include "qemu-common.h" -#include "qemu/timer.h" #include "qemu/error-report.h" #include "migration/register.h" #include "slirp.h"
slirp/util.h +2 -0
@@ -48,6 +48,8 @@# define SLIRP_PACKED __attribute__((packed))#endif +#define SCALE_MS 1000000 +#ifdef _WIN32int slirp_closesocket (int fd);int slirp_ioctlsocket (int fd,int req,void *val);
Signature · 1 line
2.20.1
PATCH 20/32 slirp: remove now useless QEMU headers inclusions
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Some of those could have been squashed earlier, but it is easier to do it all here.
--- slirp/dhcpv6.c | 1 - slirp/ip6_icmp.c | 2 -- slirp/misc.c | 2 -- slirp/sbuf.c | 1 - slirp/slirp.c | 4 ---- slirp/slirp.h | 1 - slirp/tftp.c | 1 - slirp/util.h | 2 -- 8 files changed, 14 deletions(-)
slirp/dhcpv6.c +0 -1
@@ -21,7 +21,6 @@*/ #include "qemu/osdep.h" -#include "qemu/log.h" #include "slirp.h" #include "dhcpv6.h"
slirp/ip6_icmp.c +0 -2
@@ -6,8 +6,6 @@#include "qemu/osdep.h" #include "slirp.h" #include "ip6_icmp.h" -#include "qemu/error-report.h" -#include "qemu/log.h" #define NDP_Interval g_rand_int_range(slirp->grand, \ NDP_MinRtrAdvInterval, NDP_MaxRtrAdvInterval)
slirp/misc.c +0 -2
@@ -8,8 +8,6 @@#include "qemu/osdep.h" #include "slirp.h" #include "libslirp.h" -#include "qemu/error-report.h" -#include "qemu/main-loop.h" inline void insque (void *a,void *b)
slirp/sbuf.c +0 -1
@@ -7,7 +7,6 @@#include "qemu/osdep.h" #include "slirp.h" -#include "qemu/main-loop.h" static void sbappendsb (struct sbuf *sb,struct mbuf *m);
slirp/slirp.c +0 -4
@@ -23,11 +23,7 @@*/ #include "qemu/osdep.h" #include "qemu-common.h" -#include "qemu/error-report.h" -#include "migration/register.h" #include "slirp.h" -#include "hw/hw.h" -#include "qemu/cutils.h" #ifdef WITH_QEMU #include "state.h"
slirp/slirp.h +0 -1
@@ -48,7 +48,6 @@ typedef char *caddr_t;#include "util.h" #include "qemu/queue.h" -#include "qemu/sockets.h" #include "net/eth.h" #include "libslirp.h"
slirp/tftp.c +0 -1
@@ -25,7 +25,6 @@#include "qemu/osdep.h" #include "slirp.h" #include "qemu-common.h" -#include "qemu/cutils.h" static inline int tftp_session_in_use (struct tftp_session *spt) {
slirp/util.h +0 -2
@@ -53,9 +53,7 @@#ifdef _WIN32int slirp_closesocket (int fd);int slirp_ioctlsocket (int fd,int req,void *val); -#ifndef WITH_QEMU int inet_aton (const char *cp,struct in_addr *ia); -#endif #define slirp_getsockopt (sockfd, level, optname, optval, optlen) \ getsockopt(sockfd, level, optname, (void *)optval, optlen)#define slirp_setsockopt (sockfd, level, optname, optval, optlen) \
Signature · 1 line
2.20.1
PATCH 21/32 slirp: replace net/eth.h inclusion with own defines
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- slirp/ip6.h | 1 - slirp/slirp.h | 1 - slirp/util.h | 10 ++++++++++ 3 files changed, 10 insertions(+), 2 deletions(-)
slirp/ip6.h +0 -1
@@ -7,7 +7,6 @@#define SLIRP_IP6_H #include <glib.h> -#include "net/eth.h" #define ALLNODES_MULTICAST { .s6_addr = \ { 0xff, 0x02, 0x00, 0x00,\
slirp/slirp.h +0 -1
@@ -48,7 +48,6 @@ typedef char *caddr_t;#include "util.h" #include "qemu/queue.h" -#include "net/eth.h" #include "libslirp.h" #include "ip.h"
slirp/util.h +10 -0
@@ -50,6 +50,16 @@#define SCALE_MS 1000000 +#define ETH_ALEN 6 +#define ETH_HLEN 14 +#define ETH_P_IP (0x0800)/* Internet Protocol packet */ +#define ETH_P_ARP (0x0806)/* Address Resolution packet */ +#define ETH_P_IPV6 (0x86dd) +#define ETH_P_VLAN (0x8100) +#define ETH_P_DVLAN (0x88a8) +#define ETH_P_NCSI (0x88f8) +#define ETH_P_UNKNOWN (0xffff) +#ifdef _WIN32int slirp_closesocket (int fd);int slirp_ioctlsocket (int fd,int req,void *val);
Signature · 1 line
2.20.1
PATCH 22/32 slirp: replace qemu qtailq with slirp own copy
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
--- slirp/qtailq.h | 193 +++++++++++++++++++++++++++++++++++++++++++++++++ slirp/slirp.h | 3 +- 2 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 slirp/qtailq.h
slirp/qtailq.h new file +193 -0
@@ -0,0 +1,193 @@ +/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */ + +/* +* slirp version: Copy from QEMU, removed all but tail queues. +*/ + +/* +* Copyright (c) 1991, 1993 +* The Regents of the University of California. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* 3. Neither the name of the University nor the names of its contributors +* may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* +* @(#)queue.h 8.5 (Berkeley) 8/20/94 +*/ + +#ifndef QTAILQ_H +#define QTAILQ_H + +/* +* A tail queue is headed by a pair of pointers, one to the head of the +* list and the other to the tail of the list. The elements are doubly +* linked so that an arbitrary element can be removed without a need to +* traverse the list. New elements can be added to the list before or +* after an existing element, at the head of the list, or at the end of +* the list. A tail queue may be traversed in either direction. +*/ +typedef struct QTailQLink { +void *tql_next; +struct QTailQLink *tql_prev; +}QTailQLink ; + +/* +* Tail queue definitions. The union acts as a poor man template, as if +* it were QTailQLink<type>. +*/ +#define QTAILQ_HEAD (name, type) \ + union name { \ + struct type *tqh_first;/* first element */ \ +QTailQLink tqh_circ;/* link for circular backwards list */ \ + } + +#define QTAILQ_HEAD_INITIALIZER (head) \ + { .tqh_circ = { NULL, &(head).tqh_circ } } + +#define QTAILQ_ENTRY (type) \ + union { \ + struct type *tqe_next;/* next element */ \ +QTailQLink tqe_circ;/* link for circular backwards list */ \ + } + +#define QTAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_circ.tql_prev = &(head)->tqh_circ; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_circ.tql_prev = \ + &(elm)->field.tqe_circ; \ + else \ + (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_circ.tql_prev = &(head)->tqh_circ; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_circ.tql_prev = (head)->tqh_circ.tql_prev; \ + (head)->tqh_circ.tql_prev->tql_next = (elm); \ + (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_circ.tql_prev = \ + &(elm)->field.tqe_circ; \ + else \ + (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_circ.tql_prev = &(listelm)->field.tqe_circ; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_circ.tql_prev = (listelm)->field.tqe_circ.tql_prev; \ + (elm)->field.tqe_next = (listelm); \ + (listelm)->field.tqe_circ.tql_prev->tql_next = (elm); \ + (listelm)->field.tqe_circ.tql_prev = &(elm)->field.tqe_circ; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_REMOVE(head, elm, field) do { \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_circ.tql_prev = \ + (elm)->field.tqe_circ.tql_prev; \ + else \ + (head)->tqh_circ.tql_prev = (elm)->field.tqe_circ.tql_prev; \ + (elm)->field.tqe_circ.tql_prev->tql_next = (elm)->field.tqe_next; \ + (elm)->field.tqe_circ.tql_prev = NULL; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_FOREACH (var, head, field) \ + for ((var) = ((head)->tqh_first); \ + (var); \ + (var) = ((var)->field.tqe_next)) + +#define QTAILQ_FOREACH_SAFE (var, head, field, next_var) \ + for ((var) = ((head)->tqh_first); \ + (var) && ((next_var) = ((var)->field.tqe_next), 1); \ + (var) = (next_var)) + +#define QTAILQ_FOREACH_REVERSE (var, head, field) \ + for ((var) = QTAILQ_LAST(head); \ + (var); \ + (var) = QTAILQ_PREV(var, field)) + +#define QTAILQ_FOREACH_REVERSE_SAFE (var, head, field, prev_var) \ + for ((var) = QTAILQ_LAST(head); \ + (var) && ((prev_var) = QTAILQ_PREV(var, field)); \ + (var) = (prev_var)) + +/* +* Tail queue access methods. +*/ +#define QTAILQ_EMPTY (head) ((head)->tqh_first == NULL) +#define QTAILQ_FIRST (head) ((head)->tqh_first) +#define QTAILQ_NEXT (elm, field) ((elm)->field.tqe_next) +#define QTAILQ_IN_USE (elm, field) ((elm)->field.tqe_circ.tql_prev != NULL) + +#define QTAILQ_LINK_PREV (link) \ + ((link).tql_prev->tql_prev->tql_next) +#define QTAILQ_LAST (head) \ + ((typeof((head)->tqh_first)) QTAILQ_LINK_PREV((head)->tqh_circ)) +#define QTAILQ_PREV (elm, field) \ + ((typeof((elm)->field.tqe_next)) QTAILQ_LINK_PREV((elm)->field.tqe_circ)) + +#define field_at_offset (base, offset, type) \ + ((type *) (((char *) (base)) + (offset))) + +/* +* Raw access of elements of a tail queue head. Offsets are all zero +* because it's a union. +*/ +#define QTAILQ_RAW_FIRST (head) \ + field_at_offset(head, 0, void *) +#define QTAILQ_RAW_TQH_CIRC (head) \ + field_at_offset(head, 0, QTailQLink) + +/* +* Raw access of elements of a tail entry +*/ +#define QTAILQ_RAW_NEXT (elm, entry) \ + field_at_offset(elm, entry, void *) +#define QTAILQ_RAW_TQE_CIRC (elm, entry) \ + field_at_offset(elm, entry, QTailQLink) +/* +* Tail queue traversal using pointer arithmetic. +*/ +#define QTAILQ_RAW_FOREACH (elm, head, entry) \ + for ((elm) = *QTAILQ_RAW_FIRST(head); \ + (elm); \ + (elm) = *QTAILQ_RAW_NEXT(elm, entry)) +/* +* Tail queue insertion using pointer arithmetic. +*/ +#define QTAILQ_RAW_INSERT_TAIL(head, elm, entry) do { \ + *QTAILQ_RAW_NEXT(elm, entry) = NULL; \ + QTAILQ_RAW_TQE_CIRC(elm, entry)->tql_prev = QTAILQ_RAW_TQH_CIRC(head)->tql_prev; \ + QTAILQ_RAW_TQH_CIRC(head)->tql_prev->tql_next = (elm); \ + QTAILQ_RAW_TQH_CIRC(head)->tql_prev = QTAILQ_RAW_TQE_CIRC(elm, entry); \ +} while (/*CONSTCOND*/0) + +#endif /* QTAILQ_H */
slirp/slirp.h +1 -2
@@ -46,8 +46,7 @@ typedef char *caddr_t;#include "debug.h" #include "util.h" - -#include "qemu/queue.h" +#include "qtailq.h" #include "libslirp.h" #include "ip.h"
Signature · 1 line
2.20.1
PATCH 23/32 slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT
In reply to Samuel Thibaultto remove another dependency on qemu.
--- slirp/ip.h | 4 ++-- slirp/ip6.h | 4 ++-- slirp/ip6_icmp.h | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-)
slirp/ip.h +2 -2
@@ -229,8 +229,8 @@ struct ipasfrag {struct ip ipf_ip; }; -QEMU_BUILD_BUG_ON (offsetof(struct ipq , frag_link) != - offsetof(struct ipasfrag , ipf_link)); +G_STATIC_ASSERT (offsetof(struct ipq , frag_link) == + offsetof(struct ipasfrag , ipf_link));#define ipf_off ipf_ip.ip_off#define ipf_tos ipf_ip.ip_tos
slirp/ip6.h +2 -2
@@ -152,7 +152,7 @@ struct ip6_pseudohdr {* If we marked the struct as packed then we would be unable to take * the address of any of the fields in it. */ -QEMU_BUILD_BUG_ON (sizeof (struct ip6 ) !=40 ); -QEMU_BUILD_BUG_ON (sizeof (struct ip6_pseudohdr ) !=40 ); +G_STATIC_ASSERT (sizeof (struct ip6 ) ==40 ); +G_STATIC_ASSERT (sizeof (struct ip6_pseudohdr ) ==40 );#endif
slirp/ip6_icmp.h +5 -5
@@ -50,14 +50,14 @@ struct ndp_ra { /* Router Advertisement Message */uint32_t retrans_time;/* Retrans Timer */ }; -QEMU_BUILD_BUG_ON (sizeof (struct ndp_ra ) !=12 ); +G_STATIC_ASSERT (sizeof (struct ndp_ra ) ==12 );struct ndp_ns {/* Neighbor Solicitation Message */ uint32_t reserved;struct in6_addr target;/* Target Address */ }; -QEMU_BUILD_BUG_ON (sizeof (struct ndp_ns ) !=20 ); +G_STATIC_ASSERT (sizeof (struct ndp_ns ) ==20 );struct ndp_na {/* Neighbor Advertisement Message */ #if G_BYTE_ORDER ==G_BIG_ENDIAN
@@ -78,7 +78,7 @@ struct ndp_na { /* Neighbor Advertisement Message */struct in6_addr target;/* Target Address */ }; -QEMU_BUILD_BUG_ON (sizeof (struct ndp_na ) !=20 ); +G_STATIC_ASSERT (sizeof (struct ndp_na ) ==20 );struct ndp_redirect {uint32_t reserved;
@@ -86,7 +86,7 @@ struct ndp_redirect {struct in6_addr dest;/* Destination Address */ }; -QEMU_BUILD_BUG_ON (sizeof (struct ndp_redirect ) !=36 ); +G_STATIC_ASSERT (sizeof (struct ndp_redirect ) ==36 );/* * Structure of an icmpv6 header.
@@ -113,7 +113,7 @@ struct icmp6 {#define icmp6_redirect icmp6_body.ndp_redirect }; -QEMU_BUILD_BUG_ON (sizeof (struct icmp6 ) !=40 ); +G_STATIC_ASSERT (sizeof (struct icmp6 ) ==40 );#define ICMP6_MINLEN 4#define ICMP6_ERROR_MINLEN 8
Signature · 1 line
2.20.1
PATCH 24/32 slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/
In reply to Samuel ThibaultOnly slirp actually needs it, and will need it along in libslirp.
--- include/glib-compat.h | 57 --------------------------------------- slirp/misc.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 57 deletions(-)
include/glib-compat.h +0 -57
@@ -83,63 +83,6 @@ 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 )/* * g_poll has a problem on Windows when using
slirp/misc.c +62 -0
68 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 25/32 slirp: replace remaining qemu headers dependency
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Except for the migration code which is gated by WITH_QEMU, only include our own headers, so libslirp can be built standalone.
--- slirp/arp_table.c | 3 ++- slirp/bootp.c | 1 - slirp/cksum.c | 1 - slirp/dhcpv6.c | 1 - slirp/dnssearch.c | 1 - slirp/if.c | 1 - slirp/ip6.h | 1 + slirp/ip6_icmp.c | 1 - slirp/ip6_input.c | 1 - slirp/ip6_output.c | 2 -- slirp/ip_icmp.c | 1 - slirp/ip_input.c | 1 - slirp/ip_output.c | 1 - slirp/mbuf.c | 1 - slirp/misc.c | 2 -- slirp/ncsi.c | 1 - slirp/ndp_table.c | 2 -- slirp/sbuf.c | 1 - slirp/slirp.c | 2 -- slirp/socket.c | 2 -- slirp/tcp_input.c | 1 - slirp/tcp_output.c | 1 - slirp/tcp_subr.c | 1 - slirp/tcp_timer.c | 1 - slirp/tftp.c | 6 ++++-- slirp/udp.c | 1 - slirp/udp6.c | 2 -- slirp/util.h | 21 +++++++++++++++++++++ 28 files changed, 28 insertions(+), 33 deletions(-)
slirp/arp_table.c +2 -1
@@ -22,9 +22,10 @@* THE SOFTWARE. */ -#include "qemu/osdep.h" #include "slirp.h" +#include <string.h> +void arp_table_add (Slirp *slirp,uint32_t ip_addr,uint8_t ethaddr[ETH_ALEN ]) { const uint32_t broadcast_addr =
slirp/bootp.c +0 -1
@@ -21,7 +21,6 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu/osdep.h" #include "slirp.h" #if defined(_WIN32)
slirp/cksum.c +0 -1
@@ -30,7 +30,6 @@* in_cksum.c,v 1.2 1994/08/02 07:48:16 davidg Exp */ -#include "qemu/osdep.h" #include "slirp.h" /*
slirp/dhcpv6.c +0 -1
@@ -20,7 +20,6 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#include "qemu/osdep.h" #include "slirp.h" #include "dhcpv6.h"
slirp/dnssearch.c +0 -1
@@ -22,7 +22,6 @@* THE SOFTWARE. */ -#include "qemu/osdep.h" #include "slirp.h" static const uint8_t RFC3397_OPT_DOMAIN_SEARCH =119 ;
slirp/if.c +0 -1
@@ -5,7 +5,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" static void
slirp/ip6.h +1 -0
@@ -7,6 +7,7 @@#define SLIRP_IP6_H #include <glib.h> +#include <string.h> #define ALLNODES_MULTICAST { .s6_addr = \ { 0xff, 0x02, 0x00, 0x00,\
slirp/ip6_icmp.c +0 -1
@@ -3,7 +3,6 @@* Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip6_icmp.h"
slirp/ip6_input.c +0 -1
@@ -3,7 +3,6 @@* Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip6_icmp.h"
slirp/ip6_output.c +0 -2
@@ -3,8 +3,6 @@* Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne. */ -#include "qemu/osdep.h" -#include "qemu-common.h" #include "slirp.h" /* Number of packets queued before we start sending
slirp/ip_icmp.c +0 -1
@@ -30,7 +30,6 @@* ip_icmp.c,v 1.7 1995/05/30 08:09:42 rgrimes Exp */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip_icmp.h"
slirp/ip_input.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip_icmp.h"
slirp/ip_output.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" /* Number of packets queued before we start sending
slirp/mbuf.c +0 -1
@@ -15,7 +15,6 @@* the flags */ -#include "qemu/osdep.h" #include "slirp.h" #define MBUF_THRESH 30
slirp/misc.c +0 -2
@@ -5,9 +5,7 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" -#include "libslirp.h" inline void insque (void *a,void *b)
slirp/ncsi.c +0 -1
@@ -6,7 +6,6 @@* This code is licensed under the GPL version 2 or later. See the * COPYING file in the top-level directory. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ncsi-pkt.h"
slirp/ndp_table.c +0 -2
@@ -3,8 +3,6 @@* Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne. */ -#include "qemu/osdep.h" -#include "qemu-common.h" #include "slirp.h" void ndp_table_add(Slirp *slirp, struct in6_addr ip_addr,
slirp/sbuf.c +0 -1
@@ -5,7 +5,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" static void sbappendsb (struct sbuf *sb,struct mbuf *m);
slirp/slirp.c +0 -2
@@ -21,8 +21,6 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu/osdep.h" -#include "qemu-common.h" #include "slirp.h" #ifdef WITH_QEMU
slirp/socket.c +0 -2
@@ -5,8 +5,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" -#include "qemu-common.h" #include "slirp.h" #include "ip_icmp.h" #ifdef __sun__
slirp/tcp_input.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip_icmp.h"
slirp/tcp_output.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" static const u_char tcp_outflags[TCP_NSTATES ] = {
slirp/tcp_subr.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" /* patchable/settable parameters for tcp */
slirp/tcp_timer.c +0 -1
@@ -30,7 +30,6 @@* tcp_timer.c,v 1.2 1994/08/02 07:49:10 davidg Exp */ -#include "qemu/osdep.h" #include "slirp.h" static struct tcpcb *tcp_timers (registerstruct tcpcb *tp,int timer);
slirp/tftp.c +4 -2
@@ -22,9 +22,11 @@* THE SOFTWARE. */ -#include "qemu/osdep.h" #include "slirp.h" -#include "qemu-common.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> static inline int tftp_session_in_use (struct tftp_session *spt) {
slirp/udp.c +0 -1
@@ -38,7 +38,6 @@* terms and conditions of the copyright. */ -#include "qemu/osdep.h" #include "slirp.h" #include "ip_icmp.h"
slirp/udp6.c +0 -2
@@ -3,8 +3,6 @@* Guillaume Subiron */ -#include "qemu/osdep.h" -#include "qemu-common.h" #include "slirp.h" #include "udp.h" #include "dhcpv6.h"
slirp/util.h +21 -0
@@ -48,6 +48,27 @@# define SLIRP_PACKED __attribute__((packed))#endif +#ifndef DIV_ROUND_UP +#define DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#endif + +#ifndef container_of +#define container_of (ptr, type, member) __extension__ ({ \ + void *__mptr = (void *)(ptr); \ + ((type *)(__mptr - offsetof(type, member))); }) +#endif + +#if defined(_WIN32)/* CONFIG_IOVEC */ +# if !defined(IOV_MAX )/* XXX: to avoid duplicate with QEMU osdep.h */ +struct iovec { +void *iov_base; +size_t iov_len; +}; +# endif +#else +#include <sys/uio.h> +#endif +#define SCALE_MS 1000000#define ETH_ALEN 6
Signature · 1 line
2.20.1
PATCH 26/32 slirp: prefer c99 types over BSD kind
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Replace:
- u_char -> uint8_t
- u_short -> uint16_t
- u_long -> uint32_t
- u_int -> unsigned
- caddr_t -> char *
--- slirp/ip_icmp.c | 6 +++--- slirp/ip_icmp.h | 18 +++++++++--------- slirp/ip_input.c | 4 ++-- slirp/main.h | 2 +- slirp/mbuf.h | 2 +- slirp/slirp.c | 12 ++++++------ slirp/slirp.h | 8 +++----- slirp/socket.c | 6 +++--- slirp/socket.h | 4 ++-- slirp/tcp_input.c | 22 +++++++++++----------- slirp/tcp_output.c | 12 ++++++------ slirp/tcp_subr.c | 18 +++++++++--------- slirp/tcp_timer.c | 2 +- slirp/tcp_var.h | 14 +++++++------- slirp/udp.c | 6 +++--- slirp/udp.h | 2 +- util/osdep.c | 2 +- 17 files changed, 69 insertions(+), 71 deletions(-)
slirp/ip_icmp.c +3 -3
@@ -240,7 +240,7 @@ end_error:#define ICMP_MAXDATALEN (IP_MSS-28)void -icmp_send_error (struct mbuf *msrc,u_char type,u_char code,int minsize, +icmp_send_error (struct mbuf *msrc,uint8_t type,uint8_t code,int minsize,const char *message) {unsigned hlen, shlen, s_ip_len;
@@ -388,7 +388,7 @@ icmp_reflect(struct mbuf *m)* Strip out original options by copying rest of first * mbuf's data back, and adjust the IP length. */ -memmove ((caddr_t)(ip +1 ), (caddr_t )ip + hlen, +memmove ((char *)(ip +1 ), (char *)ip + hlen, (unsigned )(m->m_len - hlen)); hlen -= optlen; ip->ip_hl = hlen >>2 ;
@@ -412,7 +412,7 @@ void icmp_receive(struct socket *so)struct mbuf *m = so->so_m; struct ip *ip = mtod(m, struct ip *);int hlen = ip->ip_hl <<2 ; -u_char error_code; +uint8_t error_code;struct icmp *icp;int id, len;
slirp/ip_icmp.h +9 -9
@@ -44,22 +44,22 @@ typedef uint32_t n_time;* Structure of an icmp header. */ struct icmp { -u_char icmp_type;/* type of message, see below */ -u_char icmp_code;/* type sub code */ -u_short icmp_cksum;/* ones complement cksum of struct */ +uint8_t icmp_type;/* type of message, see below */ +uint8_t icmp_code;/* type sub code */ +uint16_t icmp_cksum;/* ones complement cksum of struct */ union { -u_char ih_pptr;/* ICMP_PARAMPROB */ +uint8_t ih_pptr;/* ICMP_PARAMPROB */ struct in_addr ih_gwaddr;/* ICMP_REDIRECT */ struct ih_idseq { -u_short icd_id; -u_short icd_seq; +uint16_t icd_id; +uint16_t icd_seq; } ih_idseq;int ih_void;/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ struct ih_pmtu { -u_short ipm_void; -u_short ipm_nextmtu; +uint16_t ipm_void; +uint16_t ipm_nextmtu; } ih_pmtu; } icmp_hun;#define icmp_pptr icmp_hun.ih_pptr
@@ -156,7 +156,7 @@ struct icmp {void icmp_init (Slirp *slirp);void icmp_cleanup (Slirp *slirp);void icmp_input (struct mbuf *,int ); -void icmp_send_error (struct mbuf *msrc,u_char type,u_char code,int minsize, +void icmp_send_error (struct mbuf *msrc,uint8_t type,uint8_t code,int minsize,const char *message);void icmp_reflect (struct mbuf *);void icmp_receive (struct socket *so);
slirp/ip_input.c +2 -2
@@ -458,11 +458,11 @@ ip_stripoptions(register struct mbuf *m, struct mbuf *mopt) { registerint i; struct ip *ip = mtod(m, struct ip *); - registercaddr_t opts; + registerchar *opts;int olen; olen = (ip->ip_hl<<2 ) -sizeof (struct ip ); - opts = (caddr_t)(ip +1 ); + opts = (char *)(ip +1 ); i = m->m_len - (sizeof (struct ip ) + olen);memcpy (opts, opts + olen, (unsigned )i); m->m_len -= olen;
slirp/main.h +1 -1
@@ -8,7 +8,7 @@#ifndef SLIRP_MAIN_H #define SLIRP_MAIN_H -extern u_int curtime; +extern unsigned curtime;extern struct in_addr loopback_addr;extern unsigned long loopback_mask;
slirp/mbuf.h +1 -1
@@ -85,7 +85,7 @@ struct mbuf {int m_size;/* Size of mbuf, from m_dat or m_ext */ struct socket *m_so; -caddr_t m_data;/* Current location of data */ +char *m_data;/* Current location of data */ int m_len;/* Amount of data in this mbuf, from m_data */ Slirp *slirp;
slirp/slirp.c +6 -6
@@ -46,7 +46,7 @@ static const uint8_t special_ethaddr[ETH_ALEN] = {0x52 ,0x55 ,0x00 ,0x00 ,0x00 ,0x00 }; -u_int curtime; +unsigned curtime; static QTAILQ_HEAD(, Slirp) slirp_instances =QTAILQ_HEAD_INITIALIZER (slirp_instances);
@@ -55,9 +55,9 @@ static struct in_addr dns_addr;#ifndef _WIN32static struct in6_addr dns6_addr;#endif -static u_int dns_addr_time; +static unsigned dns_addr_time;#ifndef _WIN32 -static u_int dns6_addr_time; +static unsigned dns6_addr_time;#endif #define TIMEOUT_FAST 2/* milliseconds */
@@ -92,7 +92,7 @@ int get_dns_addr(struct in_addr *pdns_addr) }if ((ret =GetNetworkParams (FixedInfo, &BufLen)) !=ERROR_SUCCESS ) { -printf ("GetNetworkParams failed. ret = %08x\n" , (u_int )ret ); +printf ("GetNetworkParams failed. ret = %08x\n" , (unsigned )ret );if (FixedInfo) {GlobalFree (FixedInfo); FixedInfo =NULL ;
@@ -126,7 +126,7 @@ static void winsock_cleanup(void)static int get_dns_addr_cached (void *pdns_addr,void *cached_addr,socklen_t addrlen, -struct stat *cached_stat,u_int *cached_time) +struct stat *cached_stat,unsigned *cached_time) {struct stat old_stat;if (curtime - *cached_time <TIMEOUT_DEFAULT ) {
@@ -149,7 +149,7 @@ static int get_dns_addr_cached(void *pdns_addr, void *cached_addr,static int get_dns_addr_resolv_conf (int af,void *pdns_addr,void *cached_addr,socklen_t addrlen,uint32_t *scope_id, -u_int *cached_time) +unsigned *cached_time) {char buff[512 ];char buff2[257 ];
slirp/slirp.h +3 -5
@@ -12,8 +12,6 @@#define WIN32_LEAN_AND_MEAN #endif -typedef char *caddr_t ; -# include <winsock2.h> # include <windows.h> # include <ws2tcpip.h>
@@ -124,8 +122,8 @@ bool ndp_table_search(Slirp *slirp, struct in6_addr ip_addr,struct Slirp {QTAILQ_ENTRY (Slirp) entry; -u_int time_fasttimo; -u_int last_slowtimo; +unsigned time_fasttimo; +unsigned last_slowtimo;bool do_slowtimo;bool in_enabled, in6_enabled;
@@ -245,7 +243,7 @@ int ip6_output(struct socket *, struct mbuf *, int fast);/* tcp_input.c */ void tcp_input (registerstruct mbuf *,int ,struct socket *,unsigned short af); -int tcp_mss (registerstruct tcpcb *,u_int ); +int tcp_mss (registerstruct tcpcb *,unsigned );/* tcp_output.c */ int tcp_output (registerstruct tcpcb *);
slirp/socket.c +3 -3
@@ -506,7 +506,7 @@ sorecvfrom(struct socket *so)/* XXX Check if reply is "correct"? */ if (len ==-1 || len ==0 ) { -u_char code=ICMP_UNREACH_PORT ; +uint8_t code=ICMP_UNREACH_PORT ;if (errno ==EHOSTUNREACH ) code=ICMP_UNREACH_HOST ;else if (errno ==ENETUNREACH ) code=ICMP_UNREACH_NET ;
@@ -676,8 +676,8 @@ sosendto(struct socket *so, struct mbuf *m)* Listen for incoming TCP connections */ struct socket * -tcp_listen (Slirp *slirp,uint32_t haddr,u_int hport,uint32_t laddr, -u_int lport,int flags) +tcp_listen (Slirp *slirp,uint32_t haddr,unsigned hport,uint32_t laddr, +unsigned lport,int flags) {struct sockaddr_in addr;struct socket *so;
slirp/socket.h +2 -2
@@ -61,7 +61,7 @@ struct socket {int32_t so_state;/* internal state flags SS_*, below */ struct tcpcb *so_tcpcb;/* pointer to TCP protocol control block */ -u_int so_expire;/* When the socket will expire */ +unsigned so_expire;/* When the socket will expire */ int so_queued;/* Number of packets queued from this socket */ int so_nqueued;/* Number of packets queued in a row
@@ -144,7 +144,7 @@ int sosendoob(struct socket *);int sowrite (struct socket *);void sorecvfrom (struct socket *);int sosendto (struct socket *,struct mbuf *); -struct socket *tcp_listen (Slirp *,uint32_t ,u_int ,uint32_t ,u_int , +struct socket *tcp_listen (Slirp *,uint32_t ,unsigned ,uint32_t ,unsigned ,int );void soisfconnecting (registerstruct socket *);void soisfconnected (registerstruct socket *);
slirp/tcp_input.c +11 -11
@@ -76,7 +76,7 @@ } \ } -static void tcp_dooptions (struct tcpcb *tp,u_char *cp,int cnt, +static void tcp_dooptions (struct tcpcb *tp,uint8_t *cp,int cnt,struct tcpiphdr *ti);static void tcp_xmit_timer (registerstruct tcpcb *tp,int rtt);
@@ -197,7 +197,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af)struct ip save_ip, *ip;struct ip6 save_ip6, *ip6; registerstruct tcpiphdr *ti; -caddr_t optp =NULL ; +char *optp =NULL ;int optlen =0 ;int len, tlen, off; registerstruct tcpcb *tp =NULL ;
@@ -205,7 +205,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af)struct socket *so =NULL ;int todrop, acked, ourfinisacked, needoutput =0 ;int iss =0 ; -u_long tiwin; +uint32_t tiwin;int ret;struct sockaddr_storage lhost, fhost;struct sockaddr_in *lhost4, *fhost4;
@@ -327,7 +327,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af) ti->ti_len = tlen;if (off >sizeof (struct tcphdr )) { optlen = off -sizeof (struct tcphdr ); - optp =mtod (m, caddr_t) +sizeof (struct tcpiphdr ); + optp = mtod(m, char *) + sizeof (struct tcpiphdr); } tiflags = ti->ti_flags;
@@ -469,7 +469,7 @@ findso:* else do it below (after getting remote address). */ if (optp && tp->t_state !=TCPS_LISTEN ) -tcp_dooptions (tp, (u_char *)optp, optlen, ti); +tcp_dooptions (tp, (uint8_t *)optp, optlen, ti);/* * Header prediction: check for the two common cases
@@ -724,7 +724,7 @@ findso:tcp_template (tp);if (optp) -tcp_dooptions (tp, (u_char *)optp, optlen, ti); +tcp_dooptions (tp, (uint8_t *)optp, optlen, ti);if (iss) tp->iss = iss;
@@ -1039,7 +1039,7 @@ trimthenstep6: tp->t_dupacks =0 ; else if (++tp->t_dupacks == TCPREXMTTHRESH) {tcp_seq onxt = tp->snd_nxt; -u_int win = +unsigned win =MIN (tp->snd_wnd, tp->snd_cwnd) /2 / tp->t_maxseg;
@@ -1108,8 +1108,8 @@ trimthenstep6:* (maxseg^2 / cwnd per packet). */ { - registeru_int cw = tp->snd_cwnd; - registeru_int incr = tp->t_maxseg; + registerunsigned cw = tp->snd_cwnd; + registerunsigned incr = tp->t_maxseg;if (cw > tp->snd_ssthresh) incr = incr * incr / cw;
@@ -1381,7 +1381,7 @@ drop: }static void -tcp_dooptions (struct tcpcb *tp,u_char *cp,int cnt,struct tcpiphdr *ti) +tcp_dooptions (struct tcpcb *tp,uint8_t *cp,int cnt,struct tcpiphdr *ti) {uint16_t mss;int opt, optlen;
@@ -1511,7 +1511,7 @@ tcp_xmit_timer(register struct tcpcb *tp, int rtt)*/ int -tcp_mss (struct tcpcb *tp,u_int offer) +tcp_mss (struct tcpcb *tp,unsigned offer) {struct socket *so = tp->t_socket;int mss;
slirp/tcp_output.c +6 -6
@@ -40,7 +40,7 @@#include "slirp.h" -static const u_char tcp_outflags[TCP_NSTATES ] = { +static const uint8_t tcp_outflags[TCP_NSTATES ] = {TH_RST |TH_ACK ,0 ,TH_SYN ,TH_SYN |TH_ACK ,TH_ACK ,TH_ACK ,TH_FIN |TH_ACK ,TH_FIN |TH_ACK ,TH_FIN |TH_ACK ,TH_ACK ,TH_ACK ,
@@ -63,7 +63,7 @@ tcp_output(struct tcpcb *tp) registerstruct tcpiphdr *ti, tcpiph_save;struct ip *ip;struct ip6 *ip6; -u_char opt[MAX_TCPOPTLEN ]; +uint8_t opt[MAX_TCPOPTLEN ];unsigned optlen, hdrlen;int idle, sendalot;
@@ -271,7 +271,7 @@ send: opt[0 ] =TCPOPT_MAXSEG ; opt[1 ] =4 ; mss =htons ((uint16_t )tcp_mss (tp,0 )); -memcpy ((caddr_t)(opt +2 ), (caddr_t)&mss,sizeof (mss)); +memcpy ((char *)(opt +2 ), (char *)&mss,sizeof (mss)); optlen =4 ; } }
@@ -301,7 +301,7 @@ send: m->m_data +=IF_MAXLINKHDR ; m->m_len = hdrlen; -sbcopy (&so->so_snd, off, (int ) len,mtod (m, caddr_t) + hdrlen); + sbcopy(&so->so_snd, off, (int) len, mtod(m, char *) + hdrlen); m->m_len += len;/*
@@ -324,7 +324,7 @@ send: ti = mtod(m, struct tcpiphdr *); -memcpy ((caddr_t )ti, &tp->t_template,sizeof (struct tcpiphdr )); +memcpy ((char *)ti, &tp->t_template,sizeof (struct tcpiphdr ));/* * Fill in fields, remembering maximum advertised
@@ -353,7 +353,7 @@ send: ti->ti_seq =htonl (tp->snd_max); ti->ti_ack =htonl (tp->rcv_nxt);if (optlen) { -memcpy ((caddr_t)(ti +1 ), (caddr_t )opt, optlen); +memcpy ((char *)(ti +1 ), (char *)opt, optlen); ti->ti_off = (sizeof (struct tcphdr ) + optlen) >>2 ; } ti->ti_flags = flags;
slirp/tcp_subr.c +9 -9
@@ -163,7 +163,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,* ti points into m so the next line is just making * the mbuf point to ti */ - m->m_data = (caddr_t )ti; + m->m_data = (char *)ti; m->m_len =sizeof (struct tcpiphdr ); tlen =0 ;
@@ -182,7 +182,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m, }#undef xchg } - ti->ti_len =htons ((u_short)(sizeof (struct tcphdr ) + tlen)); + ti->ti_len =htons ((uint16_t )(sizeof (struct tcphdr ) + tlen)); tlen +=sizeof (struct tcpiphdr ); m->m_len = tlen;
@@ -613,10 +613,10 @@ int tcp_emu(struct socket *so, struct mbuf *m) { Slirp *slirp = so->slirp; -u_int n1, n2, n3, n4, n5, n6; +unsigned n1, n2, n3, n4, n5, n6;char buff[257 ];uint32_t laddr; -u_int lport; +unsigned lport;char *bptr;DEBUG_CALL ("tcp_emu" );
@@ -853,7 +853,7 @@ tcp_emu(struct socket *so, struct mbuf *m) bptr = m->m_data;while (bptr < m->m_data + m->m_len) { -u_short p; +uint16_t p;static int ra =0 ;char ra_tbl[4 ];
@@ -909,8 +909,8 @@ tcp_emu(struct socket *so, struct mbuf *m)/* This is the field containing the port * number that RA-player is listening to. */ - lport = (((u_char *)bptr)[0 ] <<8 ) - + ((u_char *)bptr)[1 ]; + lport = (((uint8_t *)bptr)[0 ] <<8 ) + + ((uint8_t *)bptr)[1 ];if (lport <6970 ) lport +=256 ;/* don't know why */ if (lport <6970 || lport >7170 )
@@ -928,8 +928,8 @@ tcp_emu(struct socket *so, struct mbuf *m) }if (p ==7071 ) p =0 ; - *(u_char *)bptr++ = (p >>8 ) &0xff ; - *(u_char *)bptr = p &0xff ; + *(uint8_t *)bptr++ = (p >>8 ) &0xff ; + *(uint8_t *)bptr = p &0xff ; ra =0 ;return 1 ;/* port redirected, we're done */ break ;
slirp/tcp_timer.c +1 -1
@@ -232,7 +232,7 @@ tcp_timers(register struct tcpcb *tp, int timer)* to go below this.) */ { -u_int win =MIN (tp->snd_wnd, tp->snd_cwnd) /2 / tp->t_maxseg; +unsigned win =MIN (tp->snd_wnd, tp->snd_cwnd) /2 / tp->t_maxseg;if (win <2 ) win =2 ; tp->snd_cwnd = tp->t_maxseg;
slirp/tcp_var.h +7 -7
@@ -47,9 +47,9 @@ struct tcpcb {short t_rxtshift;/* log(2) of rexmt exp. backoff */ short t_rxtcur;/* current retransmit value */ short t_dupacks;/* consecutive dup acks recd */ -u_short t_maxseg;/* maximum segment size */ +uint16_t t_maxseg;/* maximum segment size */ uint8_t t_force;/* 1 if forcing out a byte */ -u_short t_flags; +uint16_t t_flags;#define TF_ACKNOW 0x0001/* ack peer immediately */ #define TF_DELACK 0x0002/* ack, but try to delay it */ #define TF_NODELAY 0x0004/* don't delay packets to coalesce */
@@ -105,7 +105,7 @@ struct tcpcb {tcp_seq t_rtseq;/* sequence number being timed */ short t_srtt;/* smoothed round-trip time */ short t_rttvar;/* variance in round-trip time */ -u_short t_rttmin;/* minimum rtt allowed */ +uint16_t t_rttmin;/* minimum rtt allowed */ uint32_t max_sndwnd;/* largest window peer has offered */ /* out-of-band data */
@@ -116,10 +116,10 @@ struct tcpcb {short t_softerror;/* possible error not yet reported */ /* RFC 1323 variables */ -u_char snd_scale;/* window scaling for send window */ -u_char rcv_scale;/* window scaling for recv window */ -u_char request_r_scale;/* pending window scaling */ -u_char requested_s_scale; +uint8_t snd_scale;/* window scaling for send window */ +uint8_t rcv_scale;/* window scaling for recv window */ +uint8_t request_r_scale;/* pending window scaling */ +uint8_t requested_s_scale;uint32_t ts_recent;/* timestamp echo data */ uint32_t ts_recent_age;/* when last updated */ tcp_seq last_ack_sent;
slirp/udp.c +3 -3
@@ -92,7 +92,7 @@ udp_input(register struct mbuf *m, int iphlen)* Get IP and UDP header together in first mbuf. */ ip = mtod(m, struct ip *); - uh = (struct udphdr *)((caddr_t )ip + iphlen); + uh = (struct udphdr *)((char *)ip + iphlen);/* * Make mbuf data length reflect UDP length.
@@ -319,8 +319,8 @@ udp_tos(struct socket *so) }struct socket * -udp_listen (Slirp *slirp,uint32_t haddr,u_int hport,uint32_t laddr, -u_int lport,int flags) +udp_listen (Slirp *slirp,uint32_t haddr,unsigned hport,uint32_t laddr, +unsigned lport,int flags) {struct sockaddr_in addr;struct socket *so;
slirp/udp.h +1 -1
@@ -78,7 +78,7 @@ void udp_cleanup(Slirp *);void udp_input (registerstruct mbuf *,int );int udp_attach (struct socket *,unsigned short af);void udp_detach (struct socket *); -struct socket *udp_listen (Slirp *,uint32_t ,u_int ,uint32_t ,u_int , +struct socket *udp_listen (Slirp *,uint32_t ,unsigned ,uint32_t ,unsigned ,int ); int udp_output(struct socket *so, struct mbuf *m, struct sockaddr_in *saddr, struct sockaddr_in *daddr,
util/osdep.c +1 -1
@@ -29,7 +29,7 @@#include <sys/statvfs.h> /* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for discussion about Solaris header problems */ -extern int madvise (caddr_t ,size_t ,int ); +extern int madvise (char *,size_t ,int );#endif #include "qemu-common.h"
Signature · 1 line
2.20.1
PATCH 27/32 slirp: improve send_packet() callback
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Use a more descriptive name for the callback.
Reuse the SlirpWriteCb type. Wrap it to check that all data has been written.
Return a ssize_t for potential error handling and data-loss reporting.
--- include/net/net.h | 2 +- net/net.c | 4 ++-- net/slirp.c | 9 +++++---- slirp/libslirp.h | 11 +++++++---- slirp/ncsi.c | 2 +- slirp/slirp.c | 17 ++++++++++++++--- slirp/slirp.h | 2 ++ 7 files changed, 32 insertions(+), 15 deletions(-)
include/net/net.h +1 -1
@@ -146,7 +146,7 @@ ssize_t qemu_sendv_packet(NetClientState *nc, const struct iovec *iov, int iovcnt);ssize_t qemu_sendv_packet_async (NetClientState *nc,const struct iovec *iov,int iovcnt,NetPacketSent *sent_cb); -void qemu_send_packet (NetClientState *nc,const uint8_t *buf,int size); +ssize_t qemu_send_packet (NetClientState *nc,const uint8_t *buf,int size);ssize_t qemu_send_packet_raw (NetClientState *nc,const uint8_t *buf,int size);ssize_t qemu_send_packet_async (NetClientState *nc,const uint8_t *buf,int size,NetPacketSent *sent_cb);
net/net.c +2 -2
@@ -668,9 +668,9 @@ ssize_t qemu_send_packet_async(NetClientState *sender, buf, size, sent_cb); } -void qemu_send_packet (NetClientState *nc,const uint8_t *buf,int size) +ssize_t qemu_send_packet (NetClientState *nc,const uint8_t *buf,int size) { -qemu_send_packet_async (nc, buf, size,NULL ); +return qemu_send_packet_async (nc, buf, size,NULL ); }ssize_t qemu_send_packet_raw (NetClientState *nc,const uint8_t *buf,int size)
net/slirp.c +5 -4
@@ -108,11 +108,12 @@ static void slirp_smb_cleanup(SlirpState *s);static inline void slirp_smb_cleanup (SlirpState *s) { }#endif -static void net_slirp_output (void *opaque,const uint8_t *pkt,int pkt_len) +static ssize_t net_slirp_send_packet (const void *pkt,size_t pkt_len, +void *opaque) {SlirpState *s = opaque; -qemu_send_packet (&s->nc, pkt, pkt_len); +return qemu_send_packet (&s->nc, pkt, pkt_len); }static ssize_t net_slirp_receive (NetClientState *nc,const uint8_t *buf,size_t size)
@@ -197,7 +198,7 @@ static void net_slirp_unregister_poll_fd(int fd) }static const SlirpCb slirp_cb = { - .output = net_slirp_output, + .send_packet = net_slirp_send_packet, .guest_error = net_slirp_guest_error, .clock_get_ns = net_slirp_clock_get_ns, .timer_new = net_slirp_timer_new,
@@ -780,7 +781,7 @@ static void guestfwd_read(void *opaque, const uint8_t *buf, int size)slirp_socket_recv (fwd->slirp, fwd->server, fwd->port, buf, size); } -static int guestfwd_write (const void *buf,size_t len,void *chr) +static ssize_t guestfwd_write (const void *buf,size_t len,void *chr) {return qemu_chr_fe_write_all (chr, buf, len); }
slirp/libslirp.h +7 -4
@@ -15,7 +15,7 @@typedef struct Slirp Slirp ; -typedef int (*SlirpWriteCb )(const void *buf,size_t len,void *opaque); +typedef ssize_t (*SlirpWriteCb )(const void *buf,size_t len,void *opaque);typedef void (*SlirpTimerCb )(void *opaque);/*
@@ -23,10 +23,13 @@ typedef void (*SlirpTimerCb)(void *opaque);*/ typedef struct SlirpCb { /* - * Send an ethernet frame to the guest network. The opaque parameter - * is the one given to slirp_init(). + * Send an ethernet frame to the guest network. The opaque + * parameter is the one given to slirp_init(). The function + * doesn't need to send all the data and may return <len (no + * buffering is done on libslirp side, so the data will be dropped + * in this case). <0 reports an IO error. */ - void (*output)(void *opaque, const uint8_t *pkt, int pkt_len); + SlirpWriteCb send_packet; /* Print a message for an error due to guest misbehavior. */ void (*guest_error)(const char *msg); /* Return the virtual clock value in nanoseconds */
slirp/ncsi.c +1 -1
@@ -162,5 +162,5 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) *pchecksum =htonl (checksum); ncsi_rsp_len +=4 ; - slirp->cb->output (slirp->opaque, ncsi_reply,ETH_HLEN + ncsi_rsp_len); +slirp_send_packet_all (slirp, ncsi_reply,ETH_HLEN + ncsi_rsp_len); }
slirp/slirp.c +14 -3
@@ -800,7 +800,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->cb->output (slirp->opaque, arp_reply,sizeof (arp_reply)); +slirp_send_packet_all (slirp, arp_reply,sizeof (arp_reply)); }break ;case ARPOP_REPLY :
@@ -900,7 +900,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->cb->output (slirp->opaque, arp_req,sizeof (arp_req)); +slirp_send_packet_all (slirp, arp_req,sizeof (arp_req)); ifm->resolution_requested = true;/* Expire request and drop outgoing packet after 1 second */
@@ -985,7 +985,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->cb->output (slirp->opaque, buf, ifm->m_len +ETH_HLEN ); +slirp_send_packet_all (slirp, buf, ifm->m_len +ETH_HLEN );return 1 ; }
@@ -1152,3 +1152,14 @@ void slirp_socket_recv(Slirp *slirp, struct in_addr guest_addr, int guest_port,if (ret >0 )tcp_output (sototcpcb (so)); } + +void slirp_send_packet_all (Slirp *slirp,const void *buf,size_t len) +{ +ssize_t ret = slirp->cb->send_packet (buf, len, slirp->opaque); + +if (ret <0 ) { +g_critical ("Failed to send packet, ret: %zd" , ret); + }else if (ret < len) { +DEBUG_ERROR ("send_packet() didn't send all data: %zd < %zu" , ret, len); + } +}
slirp/slirp.h +2 -0
@@ -269,4 +269,6 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err);struct socket *slirp_find_ctl_socket (Slirp *slirp,struct in_addr guest_addr,int guest_port); +void slirp_send_packet_all (Slirp *slirp,const void *buf,size_t len); +#endif
Signature · 1 line
2.20.1
PATCH 28/32 slirp: replace global polling with per-instance & notifier
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Remove hard-coded dependency on slirp in main-loop, and use a "poll" notifier instead. The notifier is registered per slirp instance.
--- include/qemu/main-loop.h | 15 ++ net/slirp.c | 24 ++ slirp/libslirp.h | 4 +- slirp/slirp.c | 555 +++++++++++++++++++-------------------- stubs/Makefile.objs | 1 - stubs/slirp.c | 13 - util/main-loop.c | 30 ++- 7 files changed, 333 insertions(+), 309 deletions(-) delete mode 100644 stubs/slirp.c
include/qemu/main-loop.h +15 -0
@@ -302,4 +302,19 @@ void qemu_fd_register(int fd);QEMUBH *qemu_bh_new (QEMUBHFunc *cb,void *opaque);void qemu_bh_schedule_idle (QEMUBH *bh); +enum { +MAIN_LOOP_POLL_FILL , +MAIN_LOOP_POLL_ERR , +MAIN_LOOP_POLL_OK , +}; + +typedef struct MainLoopPoll { +int state; +uint32_t timeout; +GArray *pollfds; +}MainLoopPoll ; + +void main_loop_poll_add_notifier (Notifier *notify); +void main_loop_poll_remove_notifier (Notifier *notify); +#endif
net/slirp.c +24 -0
@@ -86,6 +86,7 @@ typedef struct SlirpState {NetClientState nc;QTAILQ_ENTRY (SlirpState) entry;Slirp *slirp; +Notifier poll_notifier;Notifier exit_notifier;#ifndef _WIN32gchar *smb_dir;
@@ -144,6 +145,7 @@ static void net_slirp_cleanup(NetClientState *nc)SlirpState *s =DO_UPCAST (SlirpState, nc, nc);g_slist_free_full (s->fwd, slirp_free_fwd); +main_loop_poll_remove_notifier (&s->poll_notifier);slirp_cleanup (s->slirp);if (s->exit_notifier.notify) {qemu_remove_exit_notifier (&s->exit_notifier);
@@ -209,6 +211,25 @@ static const SlirpCb slirp_cb = { .notify = qemu_notify_event, }; +static void net_slirp_poll_notify (Notifier *notifier,void *data) +{ +MainLoopPoll *poll = data; +SlirpState *s =container_of (notifier, SlirpState, poll_notifier); + +switch (poll->state) { +case MAIN_LOOP_POLL_FILL : +slirp_pollfds_fill (s->slirp, poll->pollfds, &poll->timeout); +break ; +case MAIN_LOOP_POLL_OK : +case MAIN_LOOP_POLL_ERR : +slirp_pollfds_poll (s->slirp, poll->pollfds, + poll->state ==MAIN_LOOP_POLL_ERR ); +break ; +default : +g_assert_not_reached (); + } +} + static int net_slirp_init(NetClientState *peer, const char *model, const char *name, int restricted, bool ipv4, const char *vnetwork, const char *vhost,
@@ -429,6 +450,9 @@ static int net_slirp_init(NetClientState *peer, const char *model, &slirp_cb, s);QTAILQ_INSERT_TAIL (&slirp_stacks, s, entry); + s->poll_notifier.notify = net_slirp_poll_notify; +main_loop_poll_add_notifier (&s->poll_notifier); +for (config = slirp_configs; config; config = config->next) {if (config->flags &SLIRP_CFG_HOSTFWD ) {if (slirp_hostfwd (s, config->str, errp) <0 ) {
slirp/libslirp.h +2 -2
@@ -63,9 +63,9 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, void *opaque);void slirp_cleanup (Slirp *slirp); -void slirp_pollfds_fill (GArray *pollfds,uint32_t *timeout); +void slirp_pollfds_fill (Slirp *slirp,GArray *pollfds,uint32_t *timeout); -void slirp_pollfds_poll (GArray *pollfds,int select_error); +void slirp_pollfds_poll (Slirp *slirp,GArray *pollfds,int select_error);void slirp_input (Slirp *slirp,const uint8_t *pkt,int pkt_len);
slirp/slirp.c +268 -287
647 lines not on this page · raw message
stubs/Makefile.objs +0 -1
@@ -26,7 +26,6 @@ stub-obj-y += qtest.o stub-obj-y += replay.o stub-obj-y += runstate-check.o stub-obj-y += set-fd-handler.o -stub-obj-y += slirp.o stub-obj-y += sysbus.o stub-obj-y += tpm.o stub-obj-y += trace-control.o
stubs/slirp.c deleted +0 -13
@@ -1,13 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "qemu/host-utils.h" -#include "slirp/libslirp.h" - -void slirp_pollfds_fill (GArray *pollfds,uint32_t *timeout) -{ -} - -void slirp_pollfds_poll (GArray *pollfds,int select_error) -{ -} -
util/main-loop.c +24 -6
@@ -469,25 +469,42 @@ static int os_host_main_loop_wait(int64_t timeout) }#endif +static NotifierList main_loop_poll_notifiers = +NOTIFIER_LIST_INITIALIZER (main_loop_poll_notifiers); + +void main_loop_poll_add_notifier (Notifier *notify) +{ +notifier_list_add (&main_loop_poll_notifiers, notify); +} + +void main_loop_poll_remove_notifier (Notifier *notify) +{ +notifier_remove (notify); +} +void main_loop_wait (int nonblocking) { +MainLoopPoll mlpoll = { + .state =MAIN_LOOP_POLL_FILL , + .timeout =UINT32_MAX , + .pollfds = gpollfds, + };int ret; -uint32_t timeout =UINT32_MAX ;int64_t timeout_ns;if (nonblocking) { - timeout =0 ; + mlpoll.timeout =0 ; }/* poll any events */ g_array_set_size (gpollfds,0 );/* reset for new iteration */ /* XXX: separate device handlers from system ones */ -slirp_pollfds_fill (gpollfds, &timeout); +notifier_list_notify (&main_loop_poll_notifiers, &mlpoll); -if (timeout ==UINT32_MAX ) { +if (mlpoll.timeout ==UINT32_MAX ) { timeout_ns =-1 ; }else { - timeout_ns = (uint64_t )timeout * (int64_t )(SCALE_MS ); + timeout_ns = (uint64_t )mlpoll.timeout * (int64_t )(SCALE_MS ); } timeout_ns = qemu_soonest_timeout(timeout_ns,
@@ -495,7 +512,8 @@ void main_loop_wait(int nonblocking) &main_loop_tlg)); ret =os_host_main_loop_wait (timeout_ns); -slirp_pollfds_poll (gpollfds, (ret <0 )); + mlpoll.state = ret <0 ?MAIN_LOOP_POLL_ERR :MAIN_LOOP_POLL_OK ; +notifier_list_notify (&main_loop_poll_notifiers, &mlpoll);/* CPU thread can infinitely wait for event after missing the warp */
Signature · 1 line
2.20.1
PATCH 29/32 slirp: remove slirp_instances list
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Now that polling is done per-instance, we don't need a global list of slirp instances.
--- slirp/slirp.c | 5 ----- 1 file changed, 5 deletions(-)
slirp/slirp.c +0 -5
@@ -48,9 +48,6 @@ static const uint8_t special_ethaddr[ETH_ALEN] = {unsigned curtime; -static QTAILQ_HEAD(, Slirp) slirp_instances = -QTAILQ_HEAD_INITIALIZER (slirp_instances); -static struct in_addr dns_addr;#ifndef _WIN32static struct in6_addr dns6_addr;
@@ -333,7 +330,6 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,#ifdef WITH_QEMU slirp_state_register (slirp);#endif -QTAILQ_INSERT_TAIL (&slirp_instances, slirp, entry);return slirp; }
@@ -348,7 +344,6 @@ void slirp_cleanup(Slirp *slirp)g_free (e); } -QTAILQ_REMOVE (&slirp_instances, slirp, entry);#ifdef WITH_QEMU slirp_state_unregister (slirp);#endif
Signature · 1 line
2.20.1
PATCH 30/32 slirp: use polling callbacks, drop glib requirement
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
It would be legitimate to use libslirp without glib. Let's add_poll/get_revents pair of callbacks to provide the same functionality.
--- net/slirp.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++-- slirp/libslirp.h | 17 ++++++++++-- slirp/slirp.c | 72 +++++++++++++++++------------------------------- 3 files changed, 109 insertions(+), 52 deletions(-)
net/slirp.c +69 -3
@@ -211,6 +211,71 @@ static const SlirpCb slirp_cb = { .notify = qemu_notify_event, }; +static int slirp_poll_to_gio (int events) +{ +int ret =0 ; + +if (events &SLIRP_POLL_IN ) { + ret |=G_IO_IN ; + } +if (events &SLIRP_POLL_OUT ) { + ret |=G_IO_OUT ; + } +if (events &SLIRP_POLL_PRI ) { + ret |=G_IO_PRI ; + } +if (events &SLIRP_POLL_ERR ) { + ret |=G_IO_ERR ; + } +if (events &SLIRP_POLL_HUP ) { + ret |=G_IO_HUP ; + } + +return ret; +} + +static int net_slirp_add_poll (int fd,int events,void *opaque) +{ +GArray *pollfds = opaque; +GPollFD pfd = { + .fd = fd, + .events =slirp_poll_to_gio (events), + }; +int idx = pollfds->len; +g_array_append_val (pollfds, pfd); +return idx; +} + +static int slirp_gio_to_poll (int events) +{ +int ret =0 ; + +if (events &G_IO_IN ) { + ret |=SLIRP_POLL_IN ; + } +if (events &G_IO_OUT ) { + ret |=SLIRP_POLL_OUT ; + } +if (events &G_IO_PRI ) { + ret |=SLIRP_POLL_PRI ; + } +if (events &G_IO_ERR ) { + ret |=SLIRP_POLL_ERR ; + } +if (events &G_IO_HUP ) { + ret |=SLIRP_POLL_HUP ; + } + +return ret; +} + +static int net_slirp_get_revents (int idx,void *opaque) +{ +GArray *pollfds = opaque; + +return slirp_gio_to_poll (g_array_index (pollfds, GPollFD, idx).revents); +} +static void net_slirp_poll_notify (Notifier *notifier,void *data) {MainLoopPoll *poll = data;
@@ -218,12 +283,13 @@ static void net_slirp_poll_notify(Notifier *notifier, void *data)switch (poll->state) {case MAIN_LOOP_POLL_FILL : -slirp_pollfds_fill (s->slirp, poll->pollfds, &poll->timeout); +slirp_pollfds_fill (s->slirp, &poll->timeout, + net_slirp_add_poll, poll->pollfds);break ;case MAIN_LOOP_POLL_OK :case MAIN_LOOP_POLL_ERR : -slirp_pollfds_poll (s->slirp, poll->pollfds, - poll->state ==MAIN_LOOP_POLL_ERR ); +slirp_pollfds_poll (s->slirp, poll->state ==MAIN_LOOP_POLL_ERR , + net_slirp_get_revents, poll->pollfds);break ;default :g_assert_not_reached ();
slirp/libslirp.h +14 -3
@@ -1,7 +1,6 @@#ifndef LIBSLIRP_H #define LIBSLIRP_H -#include <glib.h> #include <stdint.h> #include <stdbool.h>
@@ -15,8 +14,18 @@typedef struct Slirp Slirp ; +enum { +SLIRP_POLL_IN =1 <<0 , +SLIRP_POLL_OUT =1 <<1 , +SLIRP_POLL_PRI =1 <<2 , +SLIRP_POLL_ERR =1 <<3 , +SLIRP_POLL_HUP =1 <<4 , +}; +typedef ssize_t (*SlirpWriteCb )(const void *buf,size_t len,void *opaque);typedef void (*SlirpTimerCb )(void *opaque); +typedef int (*SlirpAddPollCb )(int fd,int events,void *opaque); +typedef int (*SlirpGetREventsCb )(int idx,void *opaque);/* * Callbacks from slirp
@@ -63,9 +72,11 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, void *opaque);void slirp_cleanup (Slirp *slirp); -void slirp_pollfds_fill (Slirp *slirp,GArray *pollfds,uint32_t *timeout); +void slirp_pollfds_fill (Slirp *slirp,uint32_t *timeout, +SlirpAddPollCb add_poll,void *opaque); -void slirp_pollfds_poll (Slirp *slirp,GArray *pollfds,int select_error); +void slirp_pollfds_poll (Slirp *slirp,int select_error, +SlirpGetREventsCb get_revents,void *opaque);void slirp_input (Slirp *slirp,const uint8_t *pkt,int pkt_len);
slirp/slirp.c +26 -46
166 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 31/32 slirp: pass opaque to all callbacks
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
This is friendlier for FFI bindings.
--- net/slirp.c | 25 ++++++++++++++++--------- slirp/dhcpv6.c | 2 +- slirp/if.c | 2 +- slirp/ip6_icmp.c | 15 +++++++++------ slirp/ip_icmp.c | 2 +- slirp/libslirp.h | 16 ++++++++-------- slirp/misc.c | 2 +- slirp/slirp.c | 13 ++++++------- slirp/socket.c | 2 +- slirp/tcp_subr.c | 8 ++++---- slirp/udp.c | 2 +- 11 files changed, 49 insertions(+), 40 deletions(-)
net/slirp.c +16 -9
@@ -161,44 +161,51 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; -static void net_slirp_guest_error (const char *msg) +static void net_slirp_guest_error (const char *msg,void *opaque) {qemu_log_mask (LOG_GUEST_ERROR ,"%s" , msg); } -static int64_t net_slirp_clock_get_ns (void ) +static int64_t net_slirp_clock_get_ns (void *opaque) {return qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); } -static void *net_slirp_timer_new (SlirpTimerCb cb,void *opaque) +static void *net_slirp_timer_new (SlirpTimerCb cb, +void *cb_opaque,void *opaque) {return timer_new_full (NULL ,QEMU_CLOCK_VIRTUAL ,SCALE_MS ,QEMU_TIMER_ATTR_EXTERNAL , - cb, opaque); + cb, cb_opaque); } -static void net_slirp_timer_free (void *timer) +static void net_slirp_timer_free (void *timer,void *opaque) {timer_del (timer);timer_free (timer); } -static void net_slirp_timer_mod (void *timer,int64_t expire_timer) +static void net_slirp_timer_mod (void *timer,int64_t expire_timer, +void *opaque) {timer_mod (timer, expire_timer); } -static void net_slirp_register_poll_fd (int fd) +static void net_slirp_register_poll_fd (int fd,void *opaque) {qemu_fd_register (fd); } -static void net_slirp_unregister_poll_fd (int fd) +static void net_slirp_unregister_poll_fd (int fd,void *opaque) {/* no qemu_fd_unregister */ } +static void net_slirp_notify (void *opaque) +{ +qemu_notify_event (); +} +static const SlirpCb slirp_cb = { .send_packet = net_slirp_send_packet, .guest_error = net_slirp_guest_error,
@@ -208,7 +215,7 @@ static const SlirpCb slirp_cb = { .timer_mod = net_slirp_timer_mod, .register_poll_fd = net_slirp_register_poll_fd, .unregister_poll_fd = net_slirp_unregister_poll_fd, - .notify = qemu_notify_event, + .notify = net_slirp_notify, };static int slirp_poll_to_gio (int events)
slirp/dhcpv6.c +1 -1
@@ -59,7 +59,7 @@ static int dhcpv6_parse_info_request(Slirp *slirp, uint8_t *odata, int olen,int len = odata[2 ] <<8 | odata[3 ];if (len +4 > olen) { - slirp->cb->guest_error ("Guest sent bad DHCPv6 packet!" ); + slirp->cb->guest_error ("Guest sent bad DHCPv6 packet!" , slirp->opaque);return -E2BIG ; }
slirp/if.c +1 -1
@@ -146,7 +146,7 @@ diddit:*/ void if_start (Slirp *slirp) { -uint64_t now = slirp->cb->clock_get_ns (); +uint64_t now = slirp->cb->clock_get_ns (slirp->opaque);bool from_batchq = false;struct mbuf *ifm, *ifm_next, *ifqt;
slirp/ip6_icmp.c +9 -6
@@ -14,7 +14,8 @@ static void ra_timer_handler(void *opaque)Slirp *slirp = opaque; slirp->cb->timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns () /SCALE_MS + NDP_Interval); + slirp->cb->clock_get_ns (slirp->opaque) /SCALE_MS + NDP_Interval, + slirp->opaque);ndp_send_ra (slirp); }
@@ -24,9 +25,10 @@ void icmp6_init(Slirp *slirp)return ; } - slirp->ra_timer = slirp->cb->timer_new (ra_timer_handler, slirp); + slirp->ra_timer = slirp->cb->timer_new (ra_timer_handler, slirp, slirp->opaque); slirp->cb->timer_mod (slirp->ra_timer, - slirp->cb->clock_get_ns () /SCALE_MS + NDP_Interval); + slirp->cb->clock_get_ns (slirp->opaque) /SCALE_MS + NDP_Interval, + slirp->opaque); }void icmp6_cleanup (Slirp *slirp)
@@ -35,7 +37,7 @@ void icmp6_cleanup(Slirp *slirp)return ; } - slirp->cb->timer_free (slirp->ra_timer); + slirp->cb->timer_free (slirp->ra_timer, slirp->opaque); } static void icmp6_send_echoreply(struct mbuf *m, Slirp *slirp, struct ip6 *ip,
@@ -334,7 +336,8 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, struct ip6 *ip,case ICMP6_NDP_RA :DEBUG_CALL (" type = Router Advertisement" ); - slirp->cb->guest_error ("Warning: guest sent NDP RA, but shouldn't" ); + slirp->cb->guest_error ("Warning: guest sent NDP RA, but shouldn't" , + slirp->opaque);break ;case ICMP6_NDP_NS :
@@ -368,7 +371,7 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, struct ip6 *ip,case ICMP6_NDP_REDIRECT :DEBUG_CALL (" type = Redirect" ); slirp->cb->guest_error ( -"Warning: guest sent NDP REDIRECT, but shouldn't" ); +"Warning: guest sent NDP REDIRECT, but shouldn't" , slirp->opaque);break ; } }
slirp/ip_icmp.c +1 -1
@@ -113,7 +113,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen)void icmp_detach (struct socket *so) { - so->slirp->cb->unregister_poll_fd (so->s); + so->slirp->cb->unregister_poll_fd (so->s, so->slirp->opaque);slirp_closesocket (so->s);sofree (so); }
slirp/libslirp.h +8 -8
@@ -40,21 +40,21 @@ typedef struct SlirpCb {*/ SlirpWriteCb send_packet;/* Print a message for an error due to guest misbehavior. */ -void (*guest_error)(const char *msg); +void (*guest_error)(const char *msg,void *opaque);/* Return the virtual clock value in nanoseconds */ -int64_t (*clock_get_ns)(void ); +int64_t (*clock_get_ns)(void *opaque);/* Create a new timer with the given callback and opaque data */ -void *(*timer_new)(SlirpTimerCb cb,void *opaque); +void *(*timer_new)(SlirpTimerCb cb,void *cb_opaque,void *opaque);/* Remove and free a timer */ -void (*timer_free)(void *timer); +void (*timer_free)(void *timer,void *opaque);/* Modify a timer to expire at @expire_time */ -void (*timer_mod)(void *timer,int64_t expire_time); +void (*timer_mod)(void *timer,int64_t expire_time,void *opaque);/* Register a fd for future polling */ -void (*register_poll_fd)(int fd); +void (*register_poll_fd)(int fd,void *opaque);/* Unregister a fd */ -void (*unregister_poll_fd)(int fd); +void (*unregister_poll_fd)(int fd,void *opaque);/* Kick the io-thread, to signal that new events may be processed */ -void (*notify)(void ); +void (*notify)(void *opaque); } SlirpCb;
slirp/misc.c +1 -1
@@ -222,7 +222,7 @@ fork_exec(struct socket *so, const char *ex) opt =1 ;slirp_setsockopt (so->s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));slirp_set_nonblock (so->s); - so->slirp->cb->register_poll_fd (so->s); + so->slirp->cb->register_poll_fd (so->s, so->slirp->opaque);return 1 ; }
slirp/slirp.c +6 -7
@@ -289,6 +289,7 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,slirp_init_once (); + slirp->opaque = opaque; slirp->cb = callbacks; slirp->grand =g_rand_new (); slirp->restricted = restricted;
@@ -325,12 +326,9 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,translate_dnssearch (slirp, vdnssearch); } - slirp->opaque = opaque; -#ifdef WITH_QEMU slirp_state_register (slirp);#endif -return slirp; }
@@ -537,7 +535,7 @@ void slirp_pollfds_poll(Slirp *slirp, int select_error,struct socket *so, *so_next;int ret; - curtime = slirp->cb->clock_get_ns () /SCALE_MS ; + curtime = slirp->cb->clock_get_ns (slirp->opaque) /SCALE_MS ;/* * See if anything has timed out
@@ -860,7 +858,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 = slirp->cb->clock_get_ns () +1000000000ULL ; + ifm->expiration_date = + slirp->cb->clock_get_ns (slirp->opaque) +1000000000ULL ; }return 0 ; }else {
@@ -886,7 +885,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 = slirp->cb->clock_get_ns () +1000000000ULL ; + ifm->expiration_date = slirp->cb->clock_get_ns (slirp->opaque) +1000000000ULL ; }return 0 ; }else {
@@ -961,7 +960,7 @@ int slirp_remove_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,getsockname (so->s, (struct sockaddr *)&addr, &addr_len) ==0 && addr.sin_addr.s_addr == host_addr.s_addr && addr.sin_port == port) { - so->slirp->cb->unregister_poll_fd(so->s); + so->slirp->cb->unregister_poll_fd(so->s, so->slirp->opaque);slirp_closesocket (so->s);sofree (so);return 0 ;
slirp/socket.c +1 -1
@@ -930,6 +930,6 @@ void sotranslate_accept(struct socket *so)void sodrop (struct socket *s,int num) {if (sbdrop (&s->so_snd, num)) { - s->slirp->cb->notify (); + s->slirp->cb->notify (s->slirp->opaque); } }
slirp/tcp_subr.c +4 -4
@@ -336,7 +336,7 @@ tcp_close(struct tcpcb *tp)/* clobber input socket cache if we're closing the cached connection */ if (so == slirp->tcp_last_so) slirp->tcp_last_so = &slirp->tcb; - so->slirp->cb->unregister_poll_fd (so->s); + so->slirp->cb->unregister_poll_fd (so->s, so->slirp->opaque);slirp_closesocket (so->s);sbfree (&so->so_rcv);sbfree (&so->so_snd);
@@ -413,7 +413,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)struct sockaddr_storage addr;slirp_set_nonblock (s); - so->slirp->cb->register_poll_fd (so->s); + so->slirp->cb->register_poll_fd (so->s, so->slirp->opaque);slirp_socket_set_fast_reuse (s); opt =1 ;slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (opt));
@@ -486,7 +486,7 @@ void tcp_connect(struct socket *inso)return ; }slirp_set_nonblock (s); - so->slirp->cb->register_poll_fd (so->s); + so->slirp->cb->register_poll_fd (so->s, so->slirp->opaque);slirp_socket_set_fast_reuse (s); opt =1 ;slirp_setsockopt (s,SOL_SOCKET ,SO_OOBINLINE , &opt,sizeof (int ));
@@ -498,7 +498,7 @@ void tcp_connect(struct socket *inso)/* Close the accept() socket, set right state */ if (inso->so_state &SS_FACCEPTONCE ) {/* If we only accept once, close the accept() socket */ - so->slirp->cb->unregister_poll_fd (so->s); + so->slirp->cb->unregister_poll_fd (so->s, so->slirp->opaque);slirp_closesocket (so->s);/* Don't select it yet, even though we have an FD */
slirp/udp.c +1 -1
@@ -291,7 +291,7 @@ udp_attach(struct socket *so, unsigned short af)void udp_detach (struct socket *so) { - so->slirp->cb->unregister_poll_fd (so->s); + so->slirp->cb->unregister_poll_fd (so->s, so->slirp->opaque);slirp_closesocket (so->s);sofree (so); }
Signature · 1 line
2.20.1
PATCH 32/32 slirp: API is extern C
In reply to Samuel ThibaultFrom: Marc-André Lureau <[email protected]>
Make it possible to use headers easily with C++ projects.
--- slirp/libslirp.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
slirp/libslirp.h +8 -1
@@ -12,6 +12,10 @@#include <arpa/inet.h> #endif +#ifdef __cplusplus +extern "C" { +#endif +typedef struct Slirp Slirp ;enum {
@@ -96,5 +100,8 @@ void slirp_socket_recv(Slirp *slirp, struct in_addr guest_addr, int guest_port, const uint8_t *buf, int size);size_t slirp_socket_can_recv (Slirp *slirp,struct in_addr guest_addr,int guest_port); - +#ifdef __cplusplus +} /* extern "C" */#endif + +#endif /* LIBSLIRP_H */
Signature · 1 line
2.20.1
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:
Subject: [Qemu-devel] [PULLv3 00/32] More work towards libslirp
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
9669c97562..47994e16b1 master -> master t [tag update] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'48788f32b8 slirp: API is extern C3d1cdcf3da slirp: pass opaque to all callbacks0d81dddc82 slirp: use polling callbacks, drop glib requirement d01c351f90 slirp: remove slirp_instances list1270fcc441 slirp: replace global polling with per-instance & notifier b8897fc434 slirp: improve send_packet() callbackb664c28b37 slirp: prefer c99 types over BSD kind09e965067c slirp: replace remaining qemu headers dependency 3724a91777 slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/ 53b357d14c slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT 3ea01d196d slirp: replace qemu qtailq with slirp own copy a481fdc029 slirp: replace net/eth.h inclusion with own defines fa670ffa71 slirp: remove now useless QEMU headers inclusions a30ea55480 slirp: remove qemu timer.h dependency8d9af67bc6 slirp: add slirp own version of pstrcpy8c230c3803 slirp: improve windows headers inclusionef56e8d421 slirp: do not include qemu headers in libslirp.h public API header 5ac5a10014 slirp: move QEMU state saving to a separate unit 0abf445228 slirp: replace qemu_notify_event() with a callback 12c6d0ef34 slirp: add unregister_poll_fd() callback1985ed9e0c slirp: replace qemu_set_nonblock()c6403fae65 slirp: replace most qemu socket utilities with slirp own version bae9e17858 slirp: replace QEMU_PACKED with SLIRP_PACKED cb52c8a00b slirp: replace trace functions with DEBUG calls cc0a0b1889 slirp: add callbacks for timer51a1cf007b net/slirp: fix leaks on forwarding rule registration error 9e775ae01f net/slirp: free forwarding rules on cleanup2a3e11c41e net/slirp: simplify checking for cmd: prefix 18e1d03b03 slirp: generalize guestfwd with a callback based approach 60aeb1455e slirp: Don't mark struct ipq or struct ipasfrag as packed 81efc1aad8 slirp: Avoid marking naturally packed structs as QEMU_PACKED 9de8154ed7 slirp: Avoid unaligned 16bit memory access
=== OUTPUT BEGIN ===
1/32 Checking commit 9de8154ed708 (slirp: Avoid unaligned 16bit memory access) 2/32 Checking commit 81efc1aad888 (slirp: Avoid marking naturally packed structs as QEMU_PACKED) 3/32 Checking commit 60aeb1455ea7 (slirp: Don't mark struct ipq or struct ipasfrag as packed) 4/32 Checking commit 18e1d03b0387 (slirp: generalize guestfwd with a callback based approach)
ERROR: code indent should never use tabs
#148: FILE: slirp/misc.h:14:
+^ISlirpWriteCb write_cb;$
ERROR: code indent should never use tabs
#149: FILE: slirp/misc.h:15:
+^Ivoid *opaque;$
total: 2 errors, 0 warnings, 226 lines checked
Patch 4/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/32 Checking commit 2a3e11c41e31 (net/slirp: simplify checking for cmd: prefix) 6/32 Checking commit 9e775ae01fc4 (net/slirp: free forwarding rules on cleanup) 7/32 Checking commit 51a1cf007bb8 (net/slirp: fix leaks on forwarding rule registration error) 8/32 Checking commit cc0a0b1889f8 (slirp: add callbacks for timer)
9/32 Checking commit cb52c8a00b9f (slirp: replace trace functions with DEBUG calls)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#100:
deleted file mode 100644
total: 0 errors, 1 warnings, 62 lines checked
Patch 9/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
10/32 Checking commit bae9e1785826 (slirp: replace QEMU_PACKED with SLIRP_PACKED)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #111:
new file mode 100644
total: 0 errors, 1 warnings, 111 lines checked
Patch 10/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/32 Checking commit c6403fae651b (slirp: replace most qemu socket utilities with slirp own version)
ERROR: code indent should never use tabs
#130: FILE: slirp/socket.c:190:
+^Inn = slirp_recv(so->s, iov[0].iov_base, iov[0].iov_len,0);$
ERROR: space required after that ',' (ctx:VxV)
#130: FILE: slirp/socket.c:190:
+ nn = slirp_recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
^WARNING: line over 80 characters
#139: FILE: slirp/socket.c:206:
+ slirp_getsockopt(so->s, SOL_SOCKET, SO_ERROR,
ERROR: code indent should never use tabs
#139: FILE: slirp/socket.c:206:
+^I^I^I^I^Islirp_getsockopt(so->s, SOL_SOCKET, SO_ERROR,$
ERROR: space required after that ',' (ctx:VxV)
#148: FILE: slirp/socket.c:236:
+ ret = slirp_recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
^ERROR: code indent should never use tabs
#157: FILE: slirp/socket.c:557:
+^I slirp_ioctlsocket(so->s, FIONREAD, &n);$
ERROR: code indent should never use tabs
#167: FILE: slirp/socket.c:722:
+^Iif (((s = slirp_socket(AF_INET,SOCK_STREAM,0)) < 0) ||$
ERROR: space required after that ',' (ctx:VxV)
#167: FILE: slirp/socket.c:722:
+ if (((s = slirp_socket(AF_INET,SOCK_STREAM,0)) < 0) ||
^
ERROR: space required after that ',' (ctx:VxV)
#167: FILE: slirp/socket.c:722:
+ if (((s = slirp_socket(AF_INET,SOCK_STREAM,0)) < 0) ||
^
ERROR: do not use assignment in if condition
#167: FILE: slirp/socket.c:722:
+ if (((s = slirp_socket(AF_INET,SOCK_STREAM,0)) < 0) ||
ERROR: code indent should never use tabs
#168: FILE: slirp/socket.c:723:
+^I (slirp_socket_set_fast_reuse(s) < 0) ||$
ERROR: code indent should never use tabs
#184: FILE: slirp/socket.c:740:
+^Islirp_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));$
ERROR: code indent should never use tabs
#187: FILE: slirp/socket.c:742:
+^Islirp_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(int));$
ERROR: code indent should never use tabs
#200: FILE: slirp/tcp_subr.c:340:
+^Islirp_closesocket(so->s);$
ERROR: code indent should never use tabs
#267: FILE: slirp/udp.c:295:
+^Islirp_closesocket(so->s);$
ERROR: code indent should never use tabs
#276: FILE: slirp/udp.c:330:
+^Iso->s = slirp_socket(AF_INET,SOCK_DGRAM,0);$
ERROR: space required after that ',' (ctx:VxV)
#276: FILE: slirp/udp.c:330:
+ so->s = slirp_socket(AF_INET,SOCK_DGRAM,0);
^ERROR: space required after that ',' (ctx:VxV)
#276: FILE: slirp/udp.c:330:
+ so->s = slirp_socket(AF_INET,SOCK_DGRAM,0);
^ERROR: code indent should never use tabs
#285: FILE: slirp/udp.c:346:
+^Islirp_socket_set_fast_reuse(so->s);$
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #290:
new file mode 100644
ERROR: return of an errno should typically be -ve (return -EINTR) #379: FILE: slirp/util.c:85:
+ return EINTR;
ERROR: return of an errno should typically be -ve (return -EINVAL) #381: FILE: slirp/util.c:87:
+ return EINVAL;
ERROR: return of an errno should typically be -ve (return -EBADF) #383: FILE: slirp/util.c:89:
+ return EBADF;
ERROR: return of an errno should typically be -ve (return -ENOMEM) #385: FILE: slirp/util.c:91:
+ return ENOMEM;
ERROR: return of an errno should typically be -ve (return -EINVAL) #387: FILE: slirp/util.c:93:
+ return EINVAL;
ERROR: return of an errno should typically be -ve (return -ENAMETOOLONG) #389: FILE: slirp/util.c:95:
+ return ENAMETOOLONG;
ERROR: return of an errno should typically be -ve (return -ENOTEMPTY) #391: FILE: slirp/util.c:97:
+ return ENOTEMPTY;
WARNING: Block comments use a leading /* on a separate line #393: FILE: slirp/util.c:99:
+ /* not using EWOULDBLOCK as we don't want code to have
WARNING: Block comments use a trailing */ on a separate line #394: FILE: slirp/util.c:100:
+ * to check both EWOULDBLOCK and EAGAIN */
ERROR: return of an errno should typically be -ve (return -EAGAIN) #395: FILE: slirp/util.c:101:
+ return EAGAIN;
ERROR: return of an errno should typically be -ve (return -EINPROGRESS) #397: FILE: slirp/util.c:103:
+ return EINPROGRESS;
ERROR: return of an errno should typically be -ve (return -EALREADY) #399: FILE: slirp/util.c:105:
+ return EALREADY;
ERROR: return of an errno should typically be -ve (return -ENOTSOCK) #401: FILE: slirp/util.c:107:
+ return ENOTSOCK;
ERROR: return of an errno should typically be -ve (return -EDESTADDRREQ) #403: FILE: slirp/util.c:109:
+ return EDESTADDRREQ;
ERROR: return of an errno should typically be -ve (return -EMSGSIZE) #405: FILE: slirp/util.c:111:
+ return EMSGSIZE;
ERROR: return of an errno should typically be -ve (return -EPROTOTYPE) #407: FILE: slirp/util.c:113:
+ return EPROTOTYPE;
ERROR: return of an errno should typically be -ve (return -ENOPROTOOPT) #409: FILE: slirp/util.c:115:
+ return ENOPROTOOPT;
ERROR: return of an errno should typically be -ve (return -EPROTONOSUPPORT) #411: FILE: slirp/util.c:117:
+ return EPROTONOSUPPORT;
ERROR: return of an errno should typically be -ve (return -EOPNOTSUPP) #413: FILE: slirp/util.c:119:
+ return EOPNOTSUPP;
ERROR: return of an errno should typically be -ve (return -EAFNOSUPPORT) #415: FILE: slirp/util.c:121:
+ return EAFNOSUPPORT;
ERROR: return of an errno should typically be -ve (return -EADDRINUSE) #417: FILE: slirp/util.c:123:
+ return EADDRINUSE;
ERROR: return of an errno should typically be -ve (return -EADDRNOTAVAIL) #419: FILE: slirp/util.c:125:
+ return EADDRNOTAVAIL;
ERROR: return of an errno should typically be -ve (return -ENETDOWN) #421: FILE: slirp/util.c:127:
+ return ENETDOWN;
ERROR: return of an errno should typically be -ve (return -ENETUNREACH) #423: FILE: slirp/util.c:129:
+ return ENETUNREACH;
ERROR: return of an errno should typically be -ve (return -ENETRESET) #425: FILE: slirp/util.c:131:
+ return ENETRESET;
ERROR: return of an errno should typically be -ve (return -ECONNABORTED) #427: FILE: slirp/util.c:133:
+ return ECONNABORTED;
ERROR: return of an errno should typically be -ve (return -ECONNRESET) #429: FILE: slirp/util.c:135:
+ return ECONNRESET;
ERROR: return of an errno should typically be -ve (return -ENOBUFS) #431: FILE: slirp/util.c:137:
+ return ENOBUFS;
ERROR: return of an errno should typically be -ve (return -EISCONN) #433: FILE: slirp/util.c:139:
+ return EISCONN;
ERROR: return of an errno should typically be -ve (return -ENOTCONN) #435: FILE: slirp/util.c:141:
+ return ENOTCONN;
ERROR: return of an errno should typically be -ve (return -ETIMEDOUT) #437: FILE: slirp/util.c:143:
+ return ETIMEDOUT;
ERROR: return of an errno should typically be -ve (return -ECONNREFUSED) #439: FILE: slirp/util.c:145:
+ return ECONNREFUSED;
ERROR: return of an errno should typically be -ve (return -ELOOP) #441: FILE: slirp/util.c:147:
+ return ELOOP;
ERROR: return of an errno should typically be -ve (return -EHOSTUNREACH) #443: FILE: slirp/util.c:149:
+ return EHOSTUNREACH;
ERROR: return of an errno should typically be -ve (return -EIO) #445: FILE: slirp/util.c:151:
+ return EIO;
WARNING: line over 80 characters
#514: FILE: slirp/util.h:61:
+#define slirp_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
WARNING: Block comments use a leading /* on a separate line #537: FILE: slirp/util.h:84:
+ /* Enabling the reuse of an endpoint that was used by a socket still in
WARNING: Block comments use a trailing */ on a separate line #541: FILE: slirp/util.h:88:
+ * http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspx */
total: 51 errors, 7 warnings, 477 lines checked
Patch 11/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
12/32 Checking commit 1985ed9e0c68 (slirp: replace qemu_set_nonblock()) 13/32 Checking commit 12c6d0ef34b7 (slirp: add unregister_poll_fd() callback)
ERROR: code indent should never use tabs
#87: FILE: slirp/tcp_subr.c:340:
+^Iso->slirp->cb->unregister_poll_fd(so->s);$
ERROR: code indent should never use tabs
#107: FILE: slirp/udp.c:295:
+^Iso->slirp->cb->unregister_poll_fd(so->s);$
total: 2 errors, 0 warnings, 63 lines checked
Patch 13/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
14/32 Checking commit 0abf4452285c (slirp: replace qemu_notify_event() with a callback)
ERROR: code indent should never use tabs
#115: FILE: slirp/tcp_input.c:509:
+^I^I^I^Isodrop(so, acked);$
ERROR: code indent should never use tabs
#124: FILE: slirp/tcp_input.c:1121:
+^I^I^Isodrop(so, (int)so->so_snd.sb_cc);$
ERROR: code indent should never use tabs
#128: FILE: slirp/tcp_input.c:1124:
+^I^I^Isodrop(so, acked);$
total: 3 errors, 0 warnings, 79 lines checked
Patch 14/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
15/32 Checking commit 5ac5a1001413 (slirp: move QEMU state saving to a separate unit)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #455:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #547: FILE: slirp/state.c:88:
+/* The sbuf has a pair of pointers that are migrated as offsets;
WARNING: Block comments use a leading /* on a separate line #645: FILE: slirp/state.c:186:
+/* The OS provided ss_family field isn't that portable; it's size
ERROR: if this code is redundant consider removing it #715: FILE: slirp/state.c:256:
+#if 0
total: 1 errors, 3 warnings, 475 lines checked
Patch 15/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
16/32 Checking commit ef56e8d421c6 (slirp: do not include qemu headers in libslirp.h public API header) 17/32 Checking commit 8c230c38036a (slirp: improve windows headers inclusion)
18/32 Checking commit 8d9af67bc67d (slirp: add slirp own version of pstrcpy)
WARNING: line over 80 characters
#37: FILE: slirp/tftp.c:219:
+ slirp_pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_msg), msg);
ERROR: braces {} are necessary for all arms of this statement #55: FILE: slirp/util.c:197:
+ if (buf_size <= 0)
[...]
ERROR: space required before the open parenthesis '(' #58: FILE: slirp/util.c:200:
+ for(;;) {
ERROR: braces {} are necessary for all arms of this statement #60: FILE: slirp/util.c:202:
+ if (c == 0 || q >= buf + buf_size - 1)
[...]
total: 3 errors, 1 warnings, 44 lines checked
Patch 18/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
19/32 Checking commit a30ea5548007 (slirp: remove qemu timer.h dependency) 20/32 Checking commit fa670ffa7129 (slirp: remove now useless QEMU headers inclusions) 21/32 Checking commit a481fdc02925 (slirp: replace net/eth.h inclusion with own defines) 22/32 Checking commit 3ea01d196d45 (slirp: replace qemu qtailq with slirp own copy)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #12:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #76: FILE: slirp/qtailq.h:60:
+ struct type *tqh_first; /* first element */ \
WARNING: Block comments use a leading /* on a separate line #77: FILE: slirp/qtailq.h:61:
+ QTailQLink tqh_circ; /* link for circular backwards list */ \
WARNING: Block comments use a leading /* on a separate line #85: FILE: slirp/qtailq.h:69:
+ struct type *tqe_next; /* next element */ \
WARNING: Block comments use a leading /* on a separate line #86: FILE: slirp/qtailq.h:70:
+ QTailQLink tqe_circ; /* link for circular backwards list */ \
WARNING: Block comments use a leading /* on a separate line #92: FILE: slirp/qtailq.h:76:
+} while (/*CONSTCOND*/0)
ERROR: do not use assignment in if condition
#95: FILE: slirp/qtailq.h:79:
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
WARNING: Block comments use a leading /* on a separate line #102: FILE: slirp/qtailq.h:86:
+} while (/*CONSTCOND*/0)
WARNING: Block comments use a leading /* on a separate line #109: FILE: slirp/qtailq.h:93:
+} while (/*CONSTCOND*/0)
ERROR: do not use assignment in if condition
#112: FILE: slirp/qtailq.h:96:
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
WARNING: Block comments use a leading /* on a separate line #119: FILE: slirp/qtailq.h:103:
+} while (/*CONSTCOND*/0)
WARNING: Block comments use a leading /* on a separate line #126: FILE: slirp/qtailq.h:110:
+} while (/*CONSTCOND*/0)
WARNING: Block comments use a leading /* on a separate line #136: FILE: slirp/qtailq.h:120:
+} while (/*CONSTCOND*/0)
WARNING: line over 80 characters
#164: FILE: slirp/qtailq.h:148:
+#define QTAILQ_IN_USE(elm, field) ((elm)->field.tqe_circ.tql_prev != NULL)
WARNING: line over 80 characters
#171: FILE: slirp/qtailq.h:155:
+ ((typeof((elm)->field.tqe_next)) QTAILQ_LINK_PREV((elm)->field.tqe_circ))
WARNING: line over 80 characters
#202: FILE: slirp/qtailq.h:186:
+#define QTAILQ_RAW_INSERT_TAIL(head, elm, entry) do { \
WARNING: line over 80 characters
#203: FILE: slirp/qtailq.h:187:
+ *QTAILQ_RAW_NEXT(elm, entry) = NULL; \
WARNING: line over 80 characters
#204: FILE: slirp/qtailq.h:188:
+ QTAILQ_RAW_TQE_CIRC(elm, entry)->tql_prev = QTAILQ_RAW_TQH_CIRC(head)->tql_prev; \
WARNING: line over 80 characters
#205: FILE: slirp/qtailq.h:189:
+ QTAILQ_RAW_TQH_CIRC(head)->tql_prev->tql_next = (elm); \
WARNING: line over 80 characters
#206: FILE: slirp/qtailq.h:190:
+ QTAILQ_RAW_TQH_CIRC(head)->tql_prev = QTAILQ_RAW_TQE_CIRC(elm, entry); \
WARNING: Block comments use a leading /* on a separate line #207: FILE: slirp/qtailq.h:191:
+} while (/*CONSTCOND*/0)
total: 2 errors, 19 warnings, 202 lines checked
Patch 22/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
23/32 Checking commit 53b357d14c7a (slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT) 24/32 Checking commit 3724a9177731 (slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/) 25/32 Checking commit 09e965067cbb (slirp: replace remaining qemu headers dependency) 26/32 Checking commit b664c28b37ad (slirp: prefer c99 types over BSD kind)
ERROR: code indent should never use tabs
#60: FILE: slirp/ip_icmp.h:47:
+^Iuint8_t^Iicmp_type;^I^I/* type of message, see below */$
ERROR: code indent should never use tabs
#61: FILE: slirp/ip_icmp.h:48:
+^Iuint8_t^Iicmp_code;^I^I/* type sub code */$
WARNING: line over 80 characters
#62: FILE: slirp/ip_icmp.h:49:
+ uint16_t icmp_cksum; /* ones complement cksum of struct */
ERROR: code indent should never use tabs
#62: FILE: slirp/ip_icmp.h:49:
+^Iuint16_t^Iicmp_cksum;^I^I/* ones complement cksum of struct */$
ERROR: code indent should never use tabs
#65: FILE: slirp/ip_icmp.h:51:
+^I^Iuint8_t ih_pptr;^I^I^I/* ICMP_PARAMPROB */$
ERROR: code indent should never use tabs
#70: FILE: slirp/ip_icmp.h:54:
+^I^I^Iuint16_t^Iicd_id;$
ERROR: code indent should never use tabs
#71: FILE: slirp/ip_icmp.h:55:
+^I^I^Iuint16_t^Iicd_seq;$
ERROR: code indent should never use tabs
#79: FILE: slirp/ip_icmp.h:61:
+^I^I^Iuint16_t ipm_void;$
ERROR: code indent should never use tabs
#80: FILE: slirp/ip_icmp.h:62:
+^I^I^Iuint16_t ipm_nextmtu;$
ERROR: code indent should never use tabs
#102: FILE: slirp/ip_input.c:461:
+^Iregister char *opts;$
ERROR: code indent should never use tabs
#107: FILE: slirp/ip_input.c:465:
+^Iopts = (char *)(ip + 1);$
ERROR: code indent should never use tabs #133: FILE: slirp/mbuf.h:88:
+^Ichar *m_data;^I^I^I/* Current location of data */$
ERROR: space prohibited before that close parenthesis ')' #167: FILE: slirp/slirp.c:95:
+ printf("GetNetworkParams failed. ret = %08x\n", (unsigned)ret );
ERROR: code indent should never use tabs
#231: FILE: slirp/socket.c:509:
+^I uint8_t code=ICMP_UNREACH_PORT;$
ERROR: spaces required around that '=' (ctx:VxV)
#231: FILE: slirp/socket.c:509:
+ uint8_t code=ICMP_UNREACH_PORT;
^ERROR: code indent should never use tabs
#255: FILE: slirp/socket.h:64:
+ unsigned^Iso_expire;^I^I/* When the socket will expire */$
ERROR: "foo * bar" should be "foo *bar"
#264: FILE: slirp/socket.h:147:
+struct socket * tcp_listen(Slirp *, uint32_t, unsigned, uint32_t, unsigned,
ERROR: code indent should never use tabs
#286: FILE: slirp/tcp_input.c:200:
+^Ichar *optp = NULL;$
ERROR: code indent should never use tabs
#295: FILE: slirp/tcp_input.c:208:
+^Iuint32_t tiwin;$
ERROR: code indent should never use tabs
#304: FILE: slirp/tcp_input.c:330:
+^I optp = mtod(m, char *) + sizeof (struct tcpiphdr);$
ERROR: space prohibited between function name and open parenthesis '(' #304: FILE: slirp/tcp_input.c:330:
+ optp = mtod(m, char *) + sizeof (struct tcpiphdr);
ERROR: code indent should never use tabs #313: FILE: slirp/tcp_input.c:472:
+^I^Itcp_dooptions(tp, (uint8_t *)optp, optlen, ti);$
ERROR: code indent should never use tabs
#322: FILE: slirp/tcp_input.c:727:
+^I tcp_dooptions(tp, (uint8_t *)optp, optlen, ti);$
ERROR: code indent should never use tabs
#331: FILE: slirp/tcp_input.c:1042:
+^I^I^I^I^Iunsigned win =$
ERROR: code indent should never use tabs
#341: FILE: slirp/tcp_input.c:1111:
+^I^I register unsigned cw = tp->snd_cwnd;$
ERROR: code indent should never use tabs
#342: FILE: slirp/tcp_input.c:1112:
+^I^I register unsigned incr = tp->t_maxseg;$
ERROR: code indent should never use tabs
#382: FILE: slirp/tcp_output.c:66:
+^Iuint8_t opt[MAX_TCPOPTLEN];$
ERROR: code indent should never use tabs
#391: FILE: slirp/tcp_output.c:274:
+^I^I^Imemcpy((char *)(opt + 2), (char *)&mss, sizeof(mss));$
ERROR: code indent should never use tabs
#400: FILE: slirp/tcp_output.c:304:
+^I^Isbcopy(&so->so_snd, off, (int) len, mtod(m, char *) + hdrlen);$
ERROR: code indent should never use tabs
#409: FILE: slirp/tcp_output.c:327:
+^Imemcpy((char *)ti, &tp->t_template, sizeof (struct tcpiphdr));$
ERROR: space prohibited between function name and open parenthesis '(' #409: FILE: slirp/tcp_output.c:327:
+ memcpy((char *)ti, &tp->t_template, sizeof (struct tcpiphdr));
ERROR: code indent should never use tabs #418: FILE: slirp/tcp_output.c:356:
+^I^Imemcpy((char *)(ti + 1), (char *)opt, optlen);$
ERROR: code indent should never use tabs
#431: FILE: slirp/tcp_subr.c:166:
+^I^Im->m_data = (char *)ti;$
ERROR: code indent should never use tabs
#440: FILE: slirp/tcp_subr.c:185:
+^Iti->ti_len = htons((uint16_t)(sizeof (struct tcphdr) + tlen));$
ERROR: space prohibited between function name and open parenthesis '(' #440: FILE: slirp/tcp_subr.c:185:
+ ti->ti_len = htons((uint16_t)(sizeof (struct tcphdr) + tlen));
ERROR: code indent should never use tabs
#449: FILE: slirp/tcp_subr.c:616:
+^Iunsigned n1, n2, n3, n4, n5, n6;$
ERROR: code indent should never use tabs
#453: FILE: slirp/tcp_subr.c:619:
+^Iunsigned lport;$
ERROR: code indent should never use tabs
#462: FILE: slirp/tcp_subr.c:856:
+^I^I^Iuint16_t p;$
ERROR: code indent should never use tabs
#472: FILE: slirp/tcp_subr.c:912:
+^I^I^I^Ilport = (((uint8_t*)bptr)[0] << 8)$
ERROR: "(foo*)" should be "(foo *)"
#472: FILE: slirp/tcp_subr.c:912:
+ lport = (((uint8_t*)bptr)[0] << 8)
ERROR: code indent should never use tabs
#473: FILE: slirp/tcp_subr.c:913:
+^I^I^I^I+ ((uint8_t *)bptr)[1];$
ERROR: code indent should never use tabs
#483: FILE: slirp/tcp_subr.c:931:
+^I^I^I^I*(uint8_t *)bptr++ = (p >> 8) & 0xff;$
WARNING: line over 80 characters
#497: FILE: slirp/tcp_timer.c:235:
+ unsigned win = MIN(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;
ERROR: code indent should never use tabs #510: FILE: slirp/tcp_var.h:50:
+^Iuint16_t^It_maxseg;^I^I/* maximum segment size */$
ERROR: code indent should never use tabs
#513: FILE: slirp/tcp_var.h:52:
+^Iuint16_t^It_flags;$
ERROR: code indent should never use tabs #522: FILE: slirp/tcp_var.h:108:
+^Iuint16_t^It_rttmin;^I^I/* minimum rtt allowed */$
ERROR: code indent should never use tabs
#534: FILE: slirp/tcp_var.h:119:
+^Iuint8_t^Isnd_scale;^I^I/* window scaling for send window */$
ERROR: code indent should never use tabs
#535: FILE: slirp/tcp_var.h:120:
+^Iuint8_t^Ircv_scale;^I^I/* window scaling for recv window */$
ERROR: code indent should never use tabs
#536: FILE: slirp/tcp_var.h:121:
+^Iuint8_t^Irequest_r_scale;^I/* pending window scaling */$
ERROR: code indent should never use tabs
#537: FILE: slirp/tcp_var.h:122:
+^Iuint8_t^Irequested_s_scale;$
ERROR: code indent should never use tabs
#550: FILE: slirp/udp.c:95:
+^Iuh = (struct udphdr *)((char *)ip + iphlen);$
ERROR: "foo * bar" should be "foo *bar"
#574: FILE: slirp/udp.h:81:
+struct socket * udp_listen(Slirp *, uint32_t, unsigned, uint32_t, unsigned,
ERROR: externs should be avoided in .c files
#587: FILE: util/osdep.c:32:
+extern int madvise(char *, size_t, int);
total: 51 errors, 2 warnings, 455 lines checked
Patch 26/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
27/32 Checking commit b8897fc434b7 (slirp: improve send_packet() callback)
28/32 Checking commit 1270fcc4411f (slirp: replace global polling with per-instance & notifier)
ERROR: spaces required around that '/' (ctx:VxV)
#237: FILE: slirp/slirp.c:471:
+ (so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) {
^WARNING: Block comments use a leading /* on a separate line #565: FILE: slirp/slirp.c:611:
+ /* Socket error might have resulted in the socket being
WARNING: Block comments use a trailing */ on a separate line #566: FILE: slirp/slirp.c:612:
+ * removed, do not try to do anything more with it. */
WARNING: Block comments use a leading /* on a separate line #594: FILE: slirp/slirp.c:634:
+ /* Socket error might have resulted in the socket being
WARNING: Block comments use a trailing */ on a separate line #595: FILE: slirp/slirp.c:635:
+ * removed, do not try to do anything more with it. */
WARNING: Block comments use a leading /* on a separate line #653: FILE: slirp/slirp.c:675:
+ /* Call tcp_output in case we need to send a window
WARNING: Block comments use a trailing */ on a separate line #655: FILE: slirp/slirp.c:677:
+ * until it sends a window probe. */
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #817:
deleted file mode 100644
total: 1 errors, 7 warnings, 829 lines checked
Patch 28/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
29/32 Checking commit d01c351f9047 (slirp: remove slirp_instances list) 30/32 Checking commit 0d81dddc821d (slirp: use polling callbacks, drop glib requirement) 31/32 Checking commit 3d1cdcf3da5b (slirp: pass opaque to all callbacks)
WARNING: line over 80 characters
#95: FILE: slirp/dhcpv6.c:62:
+ slirp->cb->guest_error("Guest sent bad DHCPv6 packet!", slirp->opaque);
WARNING: line over 80 characters
#131: FILE: slirp/ip6_icmp.c:28:
+ slirp->ra_timer = slirp->cb->timer_new(ra_timer_handler, slirp, slirp->opaque);
WARNING: line over 80 characters
#276: FILE: slirp/slirp.c:888:
+ ifm->expiration_date = slirp->cb->clock_get_ns(slirp->opaque) + 1000000000ULL;
ERROR: code indent should never use tabs
#310: FILE: slirp/tcp_subr.c:339:
+^Iso->slirp->cb->unregister_poll_fd(so->s, so->slirp->opaque);$
ERROR: code indent should never use tabs
#350: FILE: slirp/udp.c:294:
+^Iso->slirp->cb->unregister_poll_fd(so->s, so->slirp->opaque);$
total: 2 errors, 3 warnings, 273 lines checked
Patch 31/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
32/32 Checking commit 48788f32b83b (slirp: API is extern C)
WARNING: architecture specific defines should be avoided #21: FILE: slirp/libslirp.h:15:
+#ifdef __cplusplus
WARNING: architecture specific defines should be avoided #33: FILE: slirp/libslirp.h:103:
+#ifdef __cplusplus
total: 0 errors, 2 warnings, 19 lines checked
Patch 32/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== 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 seems to have some coding style problems. See output below for more information:
Subject: [Qemu-devel] [PULLv3 00/32] More work towards libslirp
Message-id: [email protected]
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
9669c97..47994e1 master -> master - [tag update] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected]
Submodule 'capstone' (https://git.qemu.org/git/capstone.git) registered for path 'capstone'
Submodule 'dtc' (https://git.qemu.org/git/dtc.git) registered for path 'dtc'
Submodule 'roms/QemuMacDrivers' (https://git.qemu.org/git/QemuMacDrivers.git) registered for path 'roms/QemuMacDrivers' Submodule 'roms/SLOF' (https://git.qemu.org/git/SLOF.git) registered for path 'roms/SLOF'
Submodule 'roms/ipxe' (https://git.qemu.org/git/ipxe.git) registered for path 'roms/ipxe'
Submodule 'roms/openbios' (https://git.qemu.org/git/openbios.git) registered for path 'roms/openbios'
Submodule 'roms/openhackware' (https://git.qemu.org/git/openhackware.git) registered for path 'roms/openhackware' Submodule 'roms/qemu-palcode' (https://git.qemu.org/git/qemu-palcode.git) registered for path 'roms/qemu-palcode' Submodule 'roms/seabios' (https://git.qemu.org/git/seabios.git/) registered for path 'roms/seabios'
Submodule 'roms/seabios-hppa' (https://github.com/hdeller/seabios-hppa.git) registered for path 'roms/seabios-hppa' Submodule 'roms/sgabios' (https://git.qemu.org/git/sgabios.git) registered for path 'roms/sgabios'
Submodule 'roms/skiboot' (https://git.qemu.org/git/skiboot.git) registered for path 'roms/skiboot'
Submodule 'roms/u-boot' (https://git.qemu.org/git/u-boot.git) registered for path 'roms/u-boot'
Submodule 'roms/u-boot-sam460ex' (https://git.qemu.org/git/u-boot-sam460ex.git) registered for path 'roms/u-boot-sam460ex' Submodule 'tests/fp/berkeley-softfloat-3' (https://github.com/cota/berkeley-softfloat-3) registered for path 'tests/fp/berkeley-softfloat-3' Submodule 'tests/fp/berkeley-testfloat-3' (https://github.com/cota/berkeley-testfloat-3) registered for path 'tests/fp/berkeley-testfloat-3' Submodule 'ui/keycodemapdb' (https://git.qemu.org/git/keycodemapdb.git) registered for path 'ui/keycodemapdb'
Cloning into 'capstone'...
Submodule path 'capstone': checked out '22ead3e0bfdb87516656453336160e0a37b066bf'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '88f18909db731a627456f26d779445f84e449536'
Cloning into 'roms/QemuMacDrivers'...
Submodule path 'roms/QemuMacDrivers': checked out '90c488d5f4a407342247b9ea869df1c2d9c8e266'
Cloning into 'roms/SLOF'...
Submodule path 'roms/SLOF': checked out 'a5b428e1c1eae703bdd62a3f527223c291ee3fdc'
Cloning into 'roms/ipxe'...
Submodule path 'roms/ipxe': checked out 'de4565cbe76ea9f7913a01f331be3ee901bb6e17'
Cloning into 'roms/openbios'...
Submodule path 'roms/openbios': checked out '441a84d3a642a10b948369c63f32367e8ff6395b'
Cloning into 'roms/openhackware'...
Submodule path 'roms/openhackware': checked out 'c559da7c8eec5e45ef1f67978827af6f0b9546f5'
Cloning into 'roms/qemu-palcode'...
Submodule path 'roms/qemu-palcode': checked out '51c237d7e20d05100eacadee2f61abc17e6bc097'
Cloning into 'roms/seabios'...
Submodule path 'roms/seabios': checked out 'a698c8995ffb2838296ec284fe3c4ad33dfca307'
Cloning into 'roms/seabios-hppa'...
Submodule path 'roms/seabios-hppa': checked out '1ef99a01572c2581c30e16e6fe69e9ea2ef92ce0'
Cloning into 'roms/sgabios'...
Submodule path 'roms/sgabios': checked out 'cbaee52287e5f32373181cff50a00b6c4ac9015a'
Cloning into 'roms/skiboot'...
Submodule path 'roms/skiboot': checked out 'e0ee24c27a172bcf482f6f2bc905e6211c134bcc'
Cloning into 'roms/u-boot'...
Submodule path 'roms/u-boot': checked out 'd85ca029f257b53a96da6c2fb421e78a003a9943'
Cloning into 'roms/u-boot-sam460ex'...
Submodule path 'roms/u-boot-sam460ex': checked out '60b3916f33e617a815973c5a6df77055b2e3a588'
Cloning into 'tests/fp/berkeley-softfloat-3'...
Submodule path 'tests/fp/berkeley-softfloat-3': checked out 'b64af41c3276f97f0e181920400ee056b9c88037'
Cloning into 'tests/fp/berkeley-testfloat-3'...
Submodule path 'tests/fp/berkeley-testfloat-3': checked out '5a59dcec19327396a011a17fd924aed4fec416b3'
Cloning into 'ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out '6b3d716e2b6472eb7189d3220552280ef3d832ce'
Switched to a new branch 'test'
48788f3 slirp: API is extern C
3d1cdcf slirp: pass opaque to all callbacks
0d81ddd slirp: use polling callbacks, drop glib requirement
d01c351 slirp: remove slirp_instances list
1270fcc slirp: replace global polling with per-instance & notifier
b8897fc slirp: improve send_packet() callback
b664c28 slirp: prefer c99 types over BSD kind
09e9650 slirp: replace remaining qemu headers dependency
3724a91 slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/
53b357d slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT
3ea01d1 slirp: replace qemu qtailq with slirp own copy
a481fdc slirp: replace net/eth.h inclusion with own defines
fa670ff slirp: remove now useless QEMU headers inclusions
a30ea55 slirp: remove qemu timer.h dependency
8d9af67 slirp: add slirp own version of pstrcpy
8c230c3 slirp: improve windows headers inclusion
ef56e8d slirp: do not include qemu headers in libslirp.h public API header
5ac5a10 slirp: move QEMU state saving to a separate unit
0abf445 slirp: replace qemu_notify_event() with a callback
12c6d0e slirp: add unregister_poll_fd() callback
1985ed9 slirp: replace qemu_set_nonblock()
c6403fa slirp: replace most qemu socket utilities with slirp own version
bae9e17 slirp: replace QEMU_PACKED with SLIRP_PACKED
cb52c8a slirp: replace trace functions with DEBUG calls
cc0a0b1 slirp: add callbacks for timer
51a1cf0 net/slirp: fix leaks on forwarding rule registration error
9e775ae net/slirp: free forwarding rules on cleanup
2a3e11c net/slirp: simplify checking for cmd: prefix
18e1d03 slirp: generalize guestfwd with a callback based approach
60aeb14 slirp: Don't mark struct ipq or struct ipasfrag as packed
81efc1a slirp: Avoid marking naturally packed structs as QEMU_PACKED
9de8154 slirp: Avoid unaligned 16bit memory access
=== OUTPUT BEGIN ===
1/32 Checking commit 9de8154ed708 (slirp: Avoid unaligned 16bit memory access) 2/32 Checking commit 81efc1aad888 (slirp: Avoid marking naturally packed structs as QEMU_PACKED) 3/32 Checking commit 60aeb1455ea7 (slirp: Don't mark struct ipq or struct ipasfrag as packed) 4/32 Checking commit 18e1d03b0387 (slirp: generalize guestfwd with a callback based approach)
ERROR: code indent should never use tabs
#148: FILE: slirp/misc.h:14:
+^ISlirpWriteCb write_cb;$
ERROR: code indent should never use tabs
#149: FILE: slirp/misc.h:15:
+^Ivoid *opaque;$
total: 2 errors, 0 warnings, 226 lines checked
Patch 4/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/32 Checking commit 2a3e11c41e31 (net/slirp: simplify checking for cmd: prefix) 6/32 Checking commit 9e775ae01fc4 (net/slirp: free forwarding rules on cleanup) 7/32 Checking commit 51a1cf007bb8 (net/slirp: fix leaks on forwarding rule registration error) 8/32 Checking commit cc0a0b1889f8 (slirp: add callbacks for timer)
9/32 Checking commit cb52c8a00b9f (slirp: replace trace functions with DEBUG calls)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#100:
deleted file mode 100644
total: 0 errors, 1 warnings, 62 lines checked
Patch 9/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
10/32 Checking commit bae9e1785826 (slirp: replace QEMU_PACKED with SLIRP_PACKED)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #111:
new file mode 100644
total: 0 errors, 1 warnings, 111 lines checked
Patch 10/32 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/32 Checking commit c6403fae651b (slirp: replace most qemu socket utilities with slirp own version)
ERROR: code indent should never use tabs
#130: FILE: slirp/socket.c:190:
+^Inn = slirp_recv(so->s, iov[0].iov_base, iov[0].iov_len,0);$
ERROR: space required after that ',' (ctx:VxV)
#130: FILE: slirp/socket.c:190:
+ nn = slirp_recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
^WARNING: line over 80 characters
#139: FILE: slirp/socket.c:206:
+ slirp_getsockopt(so->s, SOL_SOCKET, SO_ERROR,
ERROR: code indent should never use tabs
#139: FILE: slirp/socket.c:206:
+^I^I^I^I^Islirp_getsockopt(so->s, SOL_SOCKET, SO_ERROR,$
ERROR: space required after that ',' (ctx:VxV)
#148: FILE: slirp/socket.c:236:
+ ret = slirp_recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
^ERROR: code indent should never use tabs
#157: FILE: slirp/socket.c:557:
+^I slirp_ioctlsocket(so->s, FIONREAD, &n);$
ERROR: code indent should never use tabs
#167: FILE: slirp/socket.c:722:
+^Iif (((s = slirp_socket(AF_INET,SOCK_STREAM,0)) < 0) ||$
ERROR: space required after that ',' (ctx:VxV)
#167: FILE: slirp/socket.c:722:
+ if (((s = slirp_socket(AF_INET,SOCK_STREAM,0)) < 0) ||
^
ERROR: space required after that ',' (ctx:VxV)
#167: FILE: slirp/socket.c:722:
+ if (((s = slirp_socket(AF_INET,SOCK_STREAM,0)) < 0) ||
^
ERROR: do not use assignment in if condition
#167: FILE: slirp/socket.c:722:
+ if (((s = slirp_socket(AF_INET,SOCK_STREAM,0)) < 0) ||
ERROR: code indent should never use tabs
#168: FILE: slirp/socket.c:723:
+^I (slirp_socket_set_fast_reuse(s) < 0) ||$
ERROR: code indent should never use tabs
#184: FILE: slirp/socket.c:740:
+^Islirp_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));$
ERROR: code indent should never use tabs
#187: FILE: slirp/socket.c:742:
+^Islirp_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(int));$
ERROR: code indent should never use tabs
#200: FILE: slirp/tcp_subr.c:340:
+^Islirp_closesocket(so->s);$
ERROR: code indent should never use tabs
#267: FILE: slirp/udp.c:295:
+^Islirp_closesocket(so->s);$
ERROR: code indent should never use tabs
#276: FILE: slirp/udp.c:330:
+^Iso->s = slirp_socket(AF_INET,SOCK_DGRAM,0);$
ERROR: space required after that ',' (ctx:VxV)
#276: FILE: slirp/udp.c:330:
+ so->s = slirp_socket(AF_INET,SOCK_DGRAM,0);
^ERROR: space required after that ',' (ctx:VxV)
#276: FILE: slirp/udp.c:330:
+ so->s = slirp_socket(AF_INET,SOCK_DGRAM,0);
^ERROR: code indent should never use tabs
#285: FILE: slirp/udp.c:346:
+^Islirp_socket_set_fast_reuse(so->s);$
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #290:
new file mode 100644
ERROR: return of an errno should typically be -ve (return -EINTR) #379: FILE: slirp/util.c:85:
+ return EINTR;
ERROR: return of an errno should typically be -ve (return -EINVAL) #381: FILE: slirp/util.c:87:
+ return EINVAL;
ERROR: return of an errno should typically be -ve (return -EBADF) #383: FILE: slirp/util.c:89:
+ return EBADF;
ERROR: return of an errno should typically be -ve (return -ENOMEM) #385: FILE: slirp/util.c:91:
+ return ENOMEM;
ERROR: return of an errno should typically be -ve (return -EINVAL) #387: FILE: slirp/util.c:93:
+ return EINVAL;
ERROR: return of an errno should typically be -ve (return -ENAMETOOLONG) #389: FILE: slirp/util.c:95:
+ return ENAMETOOLONG;
ERROR: return of an errno should typically be -ve (return -ENOTEMPTY) #391: FILE: slirp/util.c:97:
+ return ENOTEMPTY;
WARNING: Block comments use a leading /* on a separate line #393: FILE: slirp/util.c:99:
+ /* not using EWOULDBLOCK as we don't want code to have
WARNING: Block comments use a trailing */ on a separate line #394: FILE: slirp/util.c:100:
+ * to check both EWOULDBLOCK and EAGAIN */
ERROR: return of an errno should typically be -ve (return -EAGAIN) #395: FILE: slirp/util.c:101:
+ return EAGAIN;
ERROR: return of an errno should typically be -ve (return -EINPROGRESS) #397: FILE: slirp/util.c:103:
+ return EINPROGRESS;
ERROR: return of an errno should typically be -ve (return -EALREADY) #399: FILE: slirp/util.c:105:
+ return EALREADY;
ERROR: return of an errno should typically be -ve (return -ENOTSOCK) #401: FILE: slirp/util.c:107:
+ return ENOTSOCK;
ERROR: return of an errno should typically be -ve (return -EDESTADDRREQ) #403: FILE: slirp/util.c:109:
+ return EDESTADDRREQ;
ERROR: return of an errno should typically be -ve (return -EMSGSIZE) #405: FILE: slirp/util.c:111:
+ return EMSGSIZE;
ERROR: return of an errno should typically be -ve (return -EPROTOTYPE) #407: FILE: slirp/util.c:113:
+ return EPROTOTYPE;
ERROR: return of an errno should typically be -ve (return -ENOPROTOOPT) #409: FILE: slirp/util.c:115:
+ return ENOPROTOOPT;
ERROR: return of an errno should typically be -ve (return -EPROTONOSUPPORT) #411: FILE: slirp/util.c:117:
+ return EPROTONOSUPPORT;
ERROR: return of an errno should typically be -ve (return -EOPNOTSUPP) #413: FILE: slirp/util.c:119:
+ return EOPNOTSUPP;
ERROR: return of an errno should typically be -ve (return -EAFNOSUPPORT) #415: FILE: slirp/util.c:121:
+ return EAFNOSUPPORT;
ERROR: return of an errno should typically be -ve (return -EADDRINUSE) #417: FILE: slirp/util.c:123:
+ return EADDRINUSE;
ERROR: return of an errno should typically be -ve (return -EADDRNOTAVAIL) #419: FILE: slirp/util.c:125:
+ return EADDRNOTAVAIL;
ERROR: return of an errno should typically be -ve (return -ENETDOWN) #421: FILE: slirp/util.c:127:
+ return ENETDOWN;
ERROR: return of an errno should typically be -ve (return -ENETUNREACH) #423: FILE: slirp/util.c:129:
+ return ENETUNREACH;
ERROR: return of an errno should typically be -ve (return -ENETRESET) #425: FILE: slirp/util.c:131:
+ return ENETRESET;
ERROR: return of an errno should typically be -ve (return -ECONNABORTED) #427: FILE: slirp/util.c:133:
+ return ECONNABORTED;
ERROR: return of an errno should typically be -ve (return -ECONNRESET) #429: FILE: slirp/util.c:135:
+ return ECONNRESET;
ERROR: return of an errno should typically be -ve (return -ENOBUFS) #431: FILE: slirp/util.c:137:
+ return ENOBUFS;
ERROR: return of an errno should typically be -ve (return -EISCONN) #433: FILE: slirp/util.c:139:
+ return EISCONN;
ERROR: return of an errno should typically be -ve (return -ENOTCONN) #435: FILE: slirp/util.c:141:
+ return ENOTCONN;
ERROR: return of an errno should typically be -ve (return -ETIMEDOUT) #437: FILE: slirp/util.c:143:
+ return ETIMEDOUT;
ERROR: return of an errno should typically be -ve (return -ECONNREFUSED) #439: FILE: slirp/util.c:145:
+ return ECONNREFUSED;
ERROR: return of an errno should typically be -ve (return -ELOOP) #441: FILE: slirp/util.c:147:
+ return ELOOP;
ERROR: return of an errno should typically be -ve (return -EHOSTUNREACH) #443: FILE: slirp/util.c:149:
+ return EHOSTUNREACH;
ERROR: return of an errno should typically be -ve (return -EIO) #445: FILE: slirp/util.c:151:
+ return EIO;
WARNING: line over 80 characters
#514: FILE: slirp/util.h:61:
+#define slirp_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
WARNING: Block comments use a leading /* on a separate line #537: FILE: slirp/util.h:84:
+ /* Enabling the reuse of an endpoint that was used by a socket still in
WARNING: Block comments use a trailing */ on a separate line #541: FILE: slirp/util.h:88:
+ * http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspx */
total: 51 errors, 7 warnings, 477 lines checked
Patch 11/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
12/32 Checking commit 1985ed9e0c68 (slirp: replace qemu_set_nonblock()) 13/32 Checking commit 12c6d0ef34b7 (slirp: add unregister_poll_fd() callback)
ERROR: code indent should never use tabs
#87: FILE: slirp/tcp_subr.c:340:
+^Iso->slirp->cb->unregister_poll_fd(so->s);$
ERROR: code indent should never use tabs
#107: FILE: slirp/udp.c:295:
+^Iso->slirp->cb->unregister_poll_fd(so->s);$
total: 2 errors, 0 warnings, 63 lines checked
Patch 13/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
14/32 Checking commit 0abf4452285c (slirp: replace qemu_notify_event() with a callback)
ERROR: code indent should never use tabs
#115: FILE: slirp/tcp_input.c:509:
+^I^I^I^Isodrop(so, acked);$
ERROR: code indent should never use tabs
#124: FILE: slirp/tcp_input.c:1121:
+^I^I^Isodrop(so, (int)so->so_snd.sb_cc);$
ERROR: code indent should never use tabs
#128: FILE: slirp/tcp_input.c:1124:
+^I^I^Isodrop(so, acked);$
total: 3 errors, 0 warnings, 79 lines checked
Patch 14/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
15/32 Checking commit 5ac5a1001413 (slirp: move QEMU state saving to a separate unit)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #455:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #547: FILE: slirp/state.c:88:
+/* The sbuf has a pair of pointers that are migrated as offsets;
WARNING: Block comments use a leading /* on a separate line #645: FILE: slirp/state.c:186:
+/* The OS provided ss_family field isn't that portable; it's size
ERROR: if this code is redundant consider removing it #715: FILE: slirp/state.c:256:
+#if 0
total: 1 errors, 3 warnings, 475 lines checked
Patch 15/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
16/32 Checking commit ef56e8d421c6 (slirp: do not include qemu headers in libslirp.h public API header) 17/32 Checking commit 8c230c38036a (slirp: improve windows headers inclusion)
18/32 Checking commit 8d9af67bc67d (slirp: add slirp own version of pstrcpy)
WARNING: line over 80 characters
#37: FILE: slirp/tftp.c:219:
+ slirp_pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_msg), msg);
ERROR: braces {} are necessary for all arms of this statement #55: FILE: slirp/util.c:197:
+ if (buf_size <= 0)
[...]
ERROR: space required before the open parenthesis '(' #58: FILE: slirp/util.c:200:
+ for(;;) {
ERROR: braces {} are necessary for all arms of this statement #60: FILE: slirp/util.c:202:
+ if (c == 0 || q >= buf + buf_size - 1)
[...]
total: 3 errors, 1 warnings, 44 lines checked
Patch 18/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
19/32 Checking commit a30ea5548007 (slirp: remove qemu timer.h dependency) 20/32 Checking commit fa670ffa7129 (slirp: remove now useless QEMU headers inclusions) 21/32 Checking commit a481fdc02925 (slirp: replace net/eth.h inclusion with own defines) 22/32 Checking commit 3ea01d196d45 (slirp: replace qemu qtailq with slirp own copy)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #12:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #76: FILE: slirp/qtailq.h:60:
+ struct type *tqh_first; /* first element */ \
WARNING: Block comments use a leading /* on a separate line #77: FILE: slirp/qtailq.h:61:
+ QTailQLink tqh_circ; /* link for circular backwards list */ \
WARNING: Block comments use a leading /* on a separate line #85: FILE: slirp/qtailq.h:69:
+ struct type *tqe_next; /* next element */ \
WARNING: Block comments use a leading /* on a separate line #86: FILE: slirp/qtailq.h:70:
+ QTailQLink tqe_circ; /* link for circular backwards list */ \
WARNING: Block comments use a leading /* on a separate line #92: FILE: slirp/qtailq.h:76:
+} while (/*CONSTCOND*/0)
ERROR: do not use assignment in if condition
#95: FILE: slirp/qtailq.h:79:
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
WARNING: Block comments use a leading /* on a separate line #102: FILE: slirp/qtailq.h:86:
+} while (/*CONSTCOND*/0)
WARNING: Block comments use a leading /* on a separate line #109: FILE: slirp/qtailq.h:93:
+} while (/*CONSTCOND*/0)
ERROR: do not use assignment in if condition
#112: FILE: slirp/qtailq.h:96:
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
WARNING: Block comments use a leading /* on a separate line #119: FILE: slirp/qtailq.h:103:
+} while (/*CONSTCOND*/0)
WARNING: Block comments use a leading /* on a separate line #126: FILE: slirp/qtailq.h:110:
+} while (/*CONSTCOND*/0)
WARNING: Block comments use a leading /* on a separate line #136: FILE: slirp/qtailq.h:120:
+} while (/*CONSTCOND*/0)
WARNING: line over 80 characters
#164: FILE: slirp/qtailq.h:148:
+#define QTAILQ_IN_USE(elm, field) ((elm)->field.tqe_circ.tql_prev != NULL)
WARNING: line over 80 characters
#171: FILE: slirp/qtailq.h:155:
+ ((typeof((elm)->field.tqe_next)) QTAILQ_LINK_PREV((elm)->field.tqe_circ))
WARNING: line over 80 characters
#202: FILE: slirp/qtailq.h:186:
+#define QTAILQ_RAW_INSERT_TAIL(head, elm, entry) do { \
WARNING: line over 80 characters
#203: FILE: slirp/qtailq.h:187:
+ *QTAILQ_RAW_NEXT(elm, entry) = NULL; \
WARNING: line over 80 characters
#204: FILE: slirp/qtailq.h:188:
+ QTAILQ_RAW_TQE_CIRC(elm, entry)->tql_prev = QTAILQ_RAW_TQH_CIRC(head)->tql_prev; \
WARNING: line over 80 characters
#205: FILE: slirp/qtailq.h:189:
+ QTAILQ_RAW_TQH_CIRC(head)->tql_prev->tql_next = (elm); \
WARNING: line over 80 characters
#206: FILE: slirp/qtailq.h:190:
+ QTAILQ_RAW_TQH_CIRC(head)->tql_prev = QTAILQ_RAW_TQE_CIRC(elm, entry); \
WARNING: Block comments use a leading /* on a separate line #207: FILE: slirp/qtailq.h:191:
+} while (/*CONSTCOND*/0)
total: 2 errors, 19 warnings, 202 lines checked
Patch 22/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
23/32 Checking commit 53b357d14c7a (slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT) 24/32 Checking commit 3724a9177731 (slirp: Move g_spawn_async_with_fds_qemu compatibility to slirp/) 25/32 Checking commit 09e965067cbb (slirp: replace remaining qemu headers dependency) 26/32 Checking commit b664c28b37ad (slirp: prefer c99 types over BSD kind)
ERROR: code indent should never use tabs
#60: FILE: slirp/ip_icmp.h:47:
+^Iuint8_t^Iicmp_type;^I^I/* type of message, see below */$
ERROR: code indent should never use tabs
#61: FILE: slirp/ip_icmp.h:48:
+^Iuint8_t^Iicmp_code;^I^I/* type sub code */$
WARNING: line over 80 characters
#62: FILE: slirp/ip_icmp.h:49:
+ uint16_t icmp_cksum; /* ones complement cksum of struct */
ERROR: code indent should never use tabs
#62: FILE: slirp/ip_icmp.h:49:
+^Iuint16_t^Iicmp_cksum;^I^I/* ones complement cksum of struct */$
ERROR: code indent should never use tabs
#65: FILE: slirp/ip_icmp.h:51:
+^I^Iuint8_t ih_pptr;^I^I^I/* ICMP_PARAMPROB */$
ERROR: code indent should never use tabs
#70: FILE: slirp/ip_icmp.h:54:
+^I^I^Iuint16_t^Iicd_id;$
ERROR: code indent should never use tabs
#71: FILE: slirp/ip_icmp.h:55:
+^I^I^Iuint16_t^Iicd_seq;$
ERROR: code indent should never use tabs
#79: FILE: slirp/ip_icmp.h:61:
+^I^I^Iuint16_t ipm_void;$
ERROR: code indent should never use tabs
#80: FILE: slirp/ip_icmp.h:62:
+^I^I^Iuint16_t ipm_nextmtu;$
ERROR: code indent should never use tabs
#102: FILE: slirp/ip_input.c:461:
+^Iregister char *opts;$
ERROR: code indent should never use tabs
#107: FILE: slirp/ip_input.c:465:
+^Iopts = (char *)(ip + 1);$
ERROR: code indent should never use tabs #133: FILE: slirp/mbuf.h:88:
+^Ichar *m_data;^I^I^I/* Current location of data */$
ERROR: space prohibited before that close parenthesis ')' #167: FILE: slirp/slirp.c:95:
+ printf("GetNetworkParams failed. ret = %08x\n", (unsigned)ret );
ERROR: code indent should never use tabs
#231: FILE: slirp/socket.c:509:
+^I uint8_t code=ICMP_UNREACH_PORT;$
ERROR: spaces required around that '=' (ctx:VxV)
#231: FILE: slirp/socket.c:509:
+ uint8_t code=ICMP_UNREACH_PORT;
^ERROR: code indent should never use tabs
#255: FILE: slirp/socket.h:64:
+ unsigned^Iso_expire;^I^I/* When the socket will expire */$
ERROR: "foo * bar" should be "foo *bar"
#264: FILE: slirp/socket.h:147:
+struct socket * tcp_listen(Slirp *, uint32_t, unsigned, uint32_t, unsigned,
ERROR: code indent should never use tabs
#286: FILE: slirp/tcp_input.c:200:
+^Ichar *optp = NULL;$
ERROR: code indent should never use tabs
#295: FILE: slirp/tcp_input.c:208:
+^Iuint32_t tiwin;$
ERROR: code indent should never use tabs
#304: FILE: slirp/tcp_input.c:330:
+^I optp = mtod(m, char *) + sizeof (struct tcpiphdr);$
ERROR: space prohibited between function name and open parenthesis '(' #304: FILE: slirp/tcp_input.c:330:
+ optp = mtod(m, char *) + sizeof (struct tcpiphdr);
ERROR: code indent should never use tabs #313: FILE: slirp/tcp_input.c:472:
+^I^Itcp_dooptions(tp, (uint8_t *)optp, optlen, ti);$
ERROR: code indent should never use tabs
#322: FILE: slirp/tcp_input.c:727:
+^I tcp_dooptions(tp, (uint8_t *)optp, optlen, ti);$
ERROR: code indent should never use tabs
#331: FILE: slirp/tcp_input.c:1042:
+^I^I^I^I^Iunsigned win =$
ERROR: code indent should never use tabs
#341: FILE: slirp/tcp_input.c:1111:
+^I^I register unsigned cw = tp->snd_cwnd;$
ERROR: code indent should never use tabs
#342: FILE: slirp/tcp_input.c:1112:
+^I^I register unsigned incr = tp->t_maxseg;$
ERROR: code indent should never use tabs
#382: FILE: slirp/tcp_output.c:66:
+^Iuint8_t opt[MAX_TCPOPTLEN];$
ERROR: code indent should never use tabs
#391: FILE: slirp/tcp_output.c:274:
+^I^I^Imemcpy((char *)(opt + 2), (char *)&mss, sizeof(mss));$
ERROR: code indent should never use tabs
#400: FILE: slirp/tcp_output.c:304:
+^I^Isbcopy(&so->so_snd, off, (int) len, mtod(m, char *) + hdrlen);$
ERROR: code indent should never use tabs
#409: FILE: slirp/tcp_output.c:327:
+^Imemcpy((char *)ti, &tp->t_template, sizeof (struct tcpiphdr));$
ERROR: space prohibited between function name and open parenthesis '(' #409: FILE: slirp/tcp_output.c:327:
+ memcpy((char *)ti, &tp->t_template, sizeof (struct tcpiphdr));
ERROR: code indent should never use tabs #418: FILE: slirp/tcp_output.c:356:
+^I^Imemcpy((char *)(ti + 1), (char *)opt, optlen);$
ERROR: code indent should never use tabs
#431: FILE: slirp/tcp_subr.c:166:
+^I^Im->m_data = (char *)ti;$
ERROR: code indent should never use tabs
#440: FILE: slirp/tcp_subr.c:185:
+^Iti->ti_len = htons((uint16_t)(sizeof (struct tcphdr) + tlen));$
ERROR: space prohibited between function name and open parenthesis '(' #440: FILE: slirp/tcp_subr.c:185:
+ ti->ti_len = htons((uint16_t)(sizeof (struct tcphdr) + tlen));
ERROR: code indent should never use tabs
#449: FILE: slirp/tcp_subr.c:616:
+^Iunsigned n1, n2, n3, n4, n5, n6;$
ERROR: code indent should never use tabs
#453: FILE: slirp/tcp_subr.c:619:
+^Iunsigned lport;$
ERROR: code indent should never use tabs
#462: FILE: slirp/tcp_subr.c:856:
+^I^I^Iuint16_t p;$
ERROR: code indent should never use tabs
#472: FILE: slirp/tcp_subr.c:912:
+^I^I^I^Ilport = (((uint8_t*)bptr)[0] << 8)$
ERROR: "(foo*)" should be "(foo *)"
#472: FILE: slirp/tcp_subr.c:912:
+ lport = (((uint8_t*)bptr)[0] << 8)
ERROR: code indent should never use tabs
#473: FILE: slirp/tcp_subr.c:913:
+^I^I^I^I+ ((uint8_t *)bptr)[1];$
ERROR: code indent should never use tabs
#483: FILE: slirp/tcp_subr.c:931:
+^I^I^I^I*(uint8_t *)bptr++ = (p >> 8) & 0xff;$
WARNING: line over 80 characters
#497: FILE: slirp/tcp_timer.c:235:
+ unsigned win = MIN(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;
ERROR: code indent should never use tabs #510: FILE: slirp/tcp_var.h:50:
+^Iuint16_t^It_maxseg;^I^I/* maximum segment size */$
ERROR: code indent should never use tabs
#513: FILE: slirp/tcp_var.h:52:
+^Iuint16_t^It_flags;$
ERROR: code indent should never use tabs #522: FILE: slirp/tcp_var.h:108:
+^Iuint16_t^It_rttmin;^I^I/* minimum rtt allowed */$
ERROR: code indent should never use tabs
#534: FILE: slirp/tcp_var.h:119:
+^Iuint8_t^Isnd_scale;^I^I/* window scaling for send window */$
ERROR: code indent should never use tabs
#535: FILE: slirp/tcp_var.h:120:
+^Iuint8_t^Ircv_scale;^I^I/* window scaling for recv window */$
ERROR: code indent should never use tabs
#536: FILE: slirp/tcp_var.h:121:
+^Iuint8_t^Irequest_r_scale;^I/* pending window scaling */$
ERROR: code indent should never use tabs
#537: FILE: slirp/tcp_var.h:122:
+^Iuint8_t^Irequested_s_scale;$
ERROR: code indent should never use tabs
#550: FILE: slirp/udp.c:95:
+^Iuh = (struct udphdr *)((char *)ip + iphlen);$
ERROR: "foo * bar" should be "foo *bar"
#574: FILE: slirp/udp.h:81:
+struct socket * udp_listen(Slirp *, uint32_t, unsigned, uint32_t, unsigned,
ERROR: externs should be avoided in .c files
#587: FILE: util/osdep.c:32:
+extern int madvise(char *, size_t, int);
total: 51 errors, 2 warnings, 455 lines checked
Patch 26/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
27/32 Checking commit b8897fc434b7 (slirp: improve send_packet() callback)
28/32 Checking commit 1270fcc4411f (slirp: replace global polling with per-instance & notifier)
ERROR: spaces required around that '/' (ctx:VxV)
#237: FILE: slirp/slirp.c:471:
+ (so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) {
^WARNING: Block comments use a leading /* on a separate line #565: FILE: slirp/slirp.c:611:
+ /* Socket error might have resulted in the socket being
WARNING: Block comments use a trailing */ on a separate line #566: FILE: slirp/slirp.c:612:
+ * removed, do not try to do anything more with it. */
WARNING: Block comments use a leading /* on a separate line #594: FILE: slirp/slirp.c:634:
+ /* Socket error might have resulted in the socket being
WARNING: Block comments use a trailing */ on a separate line #595: FILE: slirp/slirp.c:635:
+ * removed, do not try to do anything more with it. */
WARNING: Block comments use a leading /* on a separate line #653: FILE: slirp/slirp.c:675:
+ /* Call tcp_output in case we need to send a window
WARNING: Block comments use a trailing */ on a separate line #655: FILE: slirp/slirp.c:677:
+ * until it sends a window probe. */
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #817:
deleted file mode 100644
total: 1 errors, 7 warnings, 829 lines checked
Patch 28/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
29/32 Checking commit d01c351f9047 (slirp: remove slirp_instances list) 30/32 Checking commit 0d81dddc821d (slirp: use polling callbacks, drop glib requirement) 31/32 Checking commit 3d1cdcf3da5b (slirp: pass opaque to all callbacks)
WARNING: line over 80 characters
#95: FILE: slirp/dhcpv6.c:62:
+ slirp->cb->guest_error("Guest sent bad DHCPv6 packet!", slirp->opaque);
WARNING: line over 80 characters
#131: FILE: slirp/ip6_icmp.c:28:
+ slirp->ra_timer = slirp->cb->timer_new(ra_timer_handler, slirp, slirp->opaque);
WARNING: line over 80 characters
#276: FILE: slirp/slirp.c:888:
+ ifm->expiration_date = slirp->cb->clock_get_ns(slirp->opaque) + 1000000000ULL;
ERROR: code indent should never use tabs
#310: FILE: slirp/tcp_subr.c:339:
+^Iso->slirp->cb->unregister_poll_fd(so->s, so->slirp->opaque);$
ERROR: code indent should never use tabs
#350: FILE: slirp/udp.c:294:
+^Iso->slirp->cb->unregister_poll_fd(so->s, so->slirp->opaque);$
total: 2 errors, 3 warnings, 273 lines checked
Patch 31/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
32/32 Checking commit 48788f32b83b (slirp: API is extern C)
WARNING: architecture specific defines should be avoided #21: FILE: slirp/libslirp.h:15:
+#ifdef __cplusplus
WARNING: architecture specific defines should be avoided #33: FILE: slirp/libslirp.h:103:
+#ifdef __cplusplus
total: 0 errors, 2 warnings, 19 lines checked
Patch 32/32 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== 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]
Quoted 7 lines · Samuel Thibault
The following changes since commit
01a9a51ffaf4699827ea6425cb2b834a356e159d:Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190205-pull-request' into staging (2019-02-05 14:01:29 +0000)
are available in the Git repository at:
Quoted 9 lines
https://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
for you to fetch changes up to
1e924479dce65a26a7432bf5920f89c1bf957d74:slirp: API is extern C (2019-02-05 20:27:27 +0200)
----------------------------------------------------------------
More work towards libslirp
Format string issues for the Windows build:
/home/petmay01/qemu-for-merges/slirp/slirp.c: In function 'slirp_send_packet_all':/home/petmay01/qemu-for-merges/slirp/slirp.c:1116:20: error: unknown conversion type character 'z' in format [-Werror=format=]
g_critical("Failed to send packet, ret: %zd", ret);
^
/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include/glib-2.0/glib/gmessages.h:333:32:
note: in definition of macro 'g_critical'
__VA_ARGS__)
^
/home/petmay01/qemu-for-merges/slirp/slirp.c:1116:20: error: too many
arguments for format [-Werror=format-extra-args]
g_critical("Failed to send packet, ret: %zd", ret);
^
/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include/glib-2.0/glib/gmessages.h:333:32:
note: in definition of macro 'g_critical'
__VA_ARGS__)
^
/home/petmay01/qemu-for-merges/slirp/slirp.c:1118:21: error: unknown
conversion type character 'z' in format [-Werror=format=]
DEBUG_ERROR("send_packet() didn't send all data: %zd < %zu", ret, len);
^
/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include/glib-2.0/glib/gmessages.h:342:32:
note: in definition of macro 'g_debug'
__VA_ARGS__)
^
/home/petmay01/qemu-for-merges/slirp/slirp.c:1118:9: note: in
expansion of macro 'DEBUG_ERROR'
DEBUG_ERROR("send_packet() didn't send all data: %zd < %zu", ret, len);
^
/home/petmay01/qemu-for-merges/slirp/slirp.c:1118:21: error: unknown
conversion type character 'z' in format [-Werror=format=]
DEBUG_ERROR("send_packet() didn't send all data: %zd < %zu", ret, len);
^
/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include/glib-2.0/glib/gmessages.h:342:32:
note: in definition of macro 'g_debug'
__VA_ARGS__)
^
/home/petmay01/qemu-for-merges/slirp/slirp.c:1118:9: note: in
expansion of macro 'DEBUG_ERROR'
DEBUG_ERROR("send_packet() didn't send all data: %zd < %zu", ret, len);
^
/home/petmay01/qemu-for-merges/slirp/slirp.c:1118:21: error: too many
arguments for format [-Werror=format-extra-args]
DEBUG_ERROR("send_packet() didn't send all data: %zd < %zu", ret, len);
^
/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include/glib-2.0/glib/gmessages.h:342:32:
note: in definition of macro 'g_debug'
__VA_ARGS__)
^
/home/petmay01/qemu-for-merges/slirp/slirp.c:1118:9: note: in
expansion of macro 'DEBUG_ERROR'
DEBUG_ERROR("send_packet() didn't send all data: %zd < %zu", ret, len);
^cc1: all warnings being treated as errors
All the other builds went OK.
thanks
-- PMM
Quoted 19 lines · Peter Maydell
Quoted 7 lines · Samuel Thibault
The following changes since commit
01a9a51ffaf4699827ea6425cb2b834a356e159d:Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190205-pull-request' into staging (2019-02-05 14:01:29 +0000)
are available in the Git repository at:
Quoted 9 lines
https://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
for you to fetch changes up to
1e924479dce65a26a7432bf5920f89c1bf957d74:slirp: API is extern C (2019-02-05 20:27:27 +0200)
----------------------------------------------------------------
More work towards libslirp
Quoted 8 lines
Format string issues for the Windows build:
/home/petmay01/qemu-for-merges/slirp/slirp.c: In function 'slirp_send_packet_all':/home/petmay01/qemu-for-merges/slirp/slirp.c:1116:20: error: unknown conversion type character 'z' in format [-Werror=format=]g_critical("Failed to send packet, ret: %zd", ret); ^
Note that with any of the glib functions that take a format string, you *must* use the glib format macros, not the system provided format macros. ie G_*_FORMAT, not any of the PRI* macros
from stdint.h. This is because you can't assume that the glib
functions call through to the platform's own printf impl. See:
https://developer.gnome.org/glib/stable/glib-Basic-Types.html
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Peter Maydell, le jeu. 07 févr. 2019 11:46:23 +0000, a ecrit:
Quoted 13 lines
Quoted 11 lines · Samuel Thibault
The following changes since commit
01a9a51ffaf4699827ea6425cb2b834a356e159d:Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190205-pull-request' into staging (2019-02-05 14:01:29 +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
1e924479dce65a26a7432bf5920f89c1bf957d74:
Quoted 7 lines
Quoted 5 lines
slirp: API is extern C (2019-02-05 20:27:27 +0200)
----------------------------------------------------------------
More work towards libslirpFormat string issues for the Windows build:
Oh, I am not getting these errors with make docker-test-mingw@fedora, perhaps something would need to be fixed there to test as much as you do?
Quoted 1 line
All the other builds went OK.
Good :) I'll have a look at these formatting issues.
Samuel
Hi
Quoted 21 lines · Samuel Thibault
Peter Maydell, le jeu. 07 févr. 2019 11:46:23 +0000, a ecrit:
Quoted 19 lines
Quoted 16 lines · Samuel Thibault
The following changes since commit
01a9a51ffaf4699827ea6425cb2b834a356e159d:Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190205-pull-request' into staging (2019-02-05 14:01:29 +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
1e924479dce65a26a7432bf5920f89c1bf957d74:slirp: API is extern C (2019-02-05 20:27:27 +0200)
----------------------------------------------------------------
More work towards libslirp
Quoted 9 lines
Quoted 1 line
Format string issues for the Windows build:
Oh, I am not getting these errors with make docker-test-mingw@fedora, perhaps something would need to be fixed there to test as much as you do?
Quoted 1 line
All the other builds went OK.
Good :) I'll have a look at these formatting issues.
I am also unable to reproduce yet. Any hint on how to reproduce?
I wonder if this is related to __USE_MINGW_ANSI_STDIO somehow (could be, although glib doesn't use the same functions, the compiler might not know the difference)
In any case, we should replace %PRI & %z with glib equivalents under slirp/.
--
Marc-André Lureau
Quoted 5 lines · Marc-André Lureau
I am also unable to reproduce yet. Any hint on how to reproduce?
I wonder if this is related to
__USE_MINGW_ANSI_STDIOsomehow (could be, although glib doesn't use the same functions, the compiler might not know the difference)
I do the windows builds using the https://mxe.cc/ cross tools and libs.
thanks
-- PMM
Quoted 16 lines · Samuel Thibault
Peter Maydell, le jeu. 07 févr. 2019 11:46:23 +0000, a ecrit:
Quoted 15 lines
Quoted 13 lines · Samuel Thibault
The following changes since commit
01a9a51ffaf4699827ea6425cb2b834a356e159d:Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190205-pull-request' into staging (2019-02-05 14:01:29 +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
1e924479dce65a26a7432bf5920f89c1bf957d74:slirp: API is extern C (2019-02-05 20:27:27 +0200)
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
----------------------------------------------------------------
More work towards libslirpFormat string issues for the Windows build:
Oh, I am not getting these errors with make docker-test-mingw@fedora, perhaps something would need to be fixed there to test as much as you do?
You're seeing a difference due to the version of glib2 that's built.
Previously the GLIB_*_FORMAT macros would contain the win32 platform specific formats, and the g_critical function would be annotated with 'printf'.
Now GLib2's GLIB_*_FORMAT macros will contain the GNU compatible formats, and the g_critical function would be annotated 'gnu_printf'.
So your Fedora build test used the gnu_printf based glib2 and so didn't trigger the warnings.
Peter's build probably uses an older glib.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|