slirp updates
warning: redirection vers https://people.debian.org/~sthibault/qemu.git/
The following changes since commit 460b6c8e581aa06b86f59eebd9e52edfe7adf417:
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2017-09-23 12:55:40 +0100)
are available in the git repository at:
http://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
for you to fetch changes up to 13146a83951e045c810c37c5c11c2a016ebc0663:
slirp: Add a special case for the NULL socket (2017-09-24 20:04:09 +0200)
----------------------------------------------------------------
slirp updates
----------------------------------------------------------------
Dr. David Alan Gilbert (1):
slirp: Add explanation for hostfwd parsing failure
Kevin Cernekee (2):
slirp: Fix intermittent send queue hangs on a socket
slirp: Add a special case for the NULL socket
net/slirp.c | 13 ++++++++++- slirp/if.c | 69 +++++++++++++++++++++++------------------------------------ slirp/slirp.h | 1 - 3 files changed, 39 insertions(+), 44 deletions(-)
[Qemu-devel] [PULL 1/3] slirp: Add explanation for hostfwd parsing failure
From: "Dr. David Alan Gilbert" <[email protected]>
e.g.
./x86_64-softmmu/qemu-system-x86_64 -nographic -netdev 'user,id=vnet,hostfwd=:555.0.0.0:0-:22'
qemu-system-x86_64: -netdev user,id=vnet,hostfwd=:555.0.0.0:0-:22: Invalid host forwarding rule ':555.0.0.0:0-:22' (Bad host address)
--- net/slirp.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
net/slirp.c +12 -1
@@ -496,9 +496,11 @@ static int slirp_hostfwd(SlirpState *s, const char *redir_str,char buf[256 ];int is_udp;char *end; +const char *fail_reason ="Unknown reason" ; p = redir_str;if (!p ||get_str_sep (buf,sizeof (buf), &p,':' ) <0 ) { + fail_reason ="No : separators" ; goto fail_syntax; }if (!strcmp (buf,"tcp" ) || buf[0 ] =='\0' ) {
@@ -506,35 +508,43 @@ static int slirp_hostfwd(SlirpState *s, const char *redir_str, }else if (!strcmp (buf,"udp" )) { is_udp =1 ; }else { + fail_reason ="Bad protocol name" ; goto fail_syntax; }if (!legacy_format) {if (get_str_sep (buf,sizeof (buf), &p,':' ) <0 ) { + fail_reason ="Missing : separator" ; goto fail_syntax; }if (buf[0 ] !='\0' && !inet_aton (buf, &host_addr)) { + fail_reason ="Bad host address" ; goto fail_syntax; } }if (get_str_sep (buf,sizeof (buf), &p, legacy_format ?':' :'-' ) <0 ) { + fail_reason ="Bad host port separator" ; goto fail_syntax; } host_port =strtol (buf, &end,0 );if (*end !='\0' || host_port <0 || host_port >65535 ) { + fail_reason ="Bad host port" ; goto fail_syntax; }if (get_str_sep (buf,sizeof (buf), &p,':' ) <0 ) { + fail_reason ="Missing guest address" ; goto fail_syntax; }if (buf[0 ] !='\0' && !inet_aton (buf, &guest_addr)) { + fail_reason ="Bad guest address" ; goto fail_syntax; } guest_port =strtol (p, &end,0 );if (*end !='\0' || guest_port <1 || guest_port >65535 ) { + fail_reason ="Bad guest port" ; goto fail_syntax; }
@@ -547,7 +557,8 @@ static int slirp_hostfwd(SlirpState *s, const char *redir_str,return 0 ; fail_syntax: -error_setg (errp,"Invalid host forwarding rule '%s'" , redir_str); +error_setg (errp,"Invalid host forwarding rule '%s' (%s)" , redir_str, + fail_reason);return -1 ; }
Signature · 1 line
2.14.1
[Qemu-devel] [PULL 2/3] slirp: Fix intermittent send queue hangs on a socket
In reply to Samuel ThibaultFrom: Kevin Cernekee <[email protected]>
if_output() originally sent one mbuf per call and used the slirp->next_m variable to keep track of where it left off. But nowadays it tries to send all of the mbufs from the fastq, and one mbuf from each session on the batchq. The next_m variable is both redundant and harmful: there is a case[0] involving delayed packets in which next_m ends up pointing to &slirp->if_batchq when an active session still exists, and this blocks all traffic for that session until qemu is restarted.
The test case was created to reproduce a problem that was seen on long-running Chromium OS VM tests[1] which rapidly create and destroy ssh connections through hostfwd.
[0] https://pastebin.com/NNy6LreF
[1] https://bugs.chromium.org/p/chromium/issues/detail?id=766323
--- slirp/if.c | 51 +++++++++++++++++---------------------------------- slirp/slirp.h | 1 - 2 files changed, 17 insertions(+), 35 deletions(-)
slirp/if.c +17 -34
@@ -30,7 +30,6 @@ if_init(Slirp *slirp) { slirp->if_fastq.qh_link = slirp->if_fastq.qh_rlink = &slirp->if_fastq; slirp->if_batchq.qh_link = slirp->if_batchq.qh_rlink = &slirp->if_batchq; - slirp->next_m = (struct mbuf *) &slirp->if_batchq; }/*
@@ -100,10 +99,6 @@ if_output(struct socket *so, struct mbuf *ifm) } }else { ifq = (struct mbuf *) slirp->if_batchq.qh_rlink; -/* Set next_m if the queue was empty so far */ -if ((struct quehead *) slirp->next_m == &slirp->if_batchq) { - slirp->next_m = ifm; - } }/* Create a new doubly linked list for this session */
@@ -143,21 +138,18 @@ diddit: }/* -* Send a packet -* We choose a packet based on its position in the output queues; +* Send one packet from each session. * If there are packets on the fastq, they are sent FIFO, before -* everything else. Otherwise we choose the first packet from the -* batchq and send it. the next packet chosen will be from the session -* after this one, then the session after that one, and so on.. So, -* for example, if there are 3 ftp session's fighting for bandwidth, +* everything else. Then we choose the first packet from each +* batchq session (socket) and send it. +* For example, if there are 3 ftp sessions fighting for bandwidth, * one packet will be sent from the first session, then one packet -* from the second session, then one packet from the third, then back -* to the first, etc. etc. +* from the second session, then one packet from the third. */ void if_start (Slirp *slirp) {uint64_t now =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); -bool from_batchq, next_from_batchq; +bool from_batchq = false;struct mbuf *ifm, *ifm_next, *ifqt;DEBUG_CALL ("if_start" );
@@ -167,26 +159,29 @@ void if_start(Slirp *slirp) } slirp->if_start_busy = true; +struct mbuf *batch_head =NULL ; +if (slirp->if_batchq.qh_link != &slirp->if_batchq) { + batch_head = (struct mbuf *) slirp->if_batchq.qh_link; + } +if (slirp->if_fastq.qh_link != &slirp->if_fastq) { ifm_next = (struct mbuf *) slirp->if_fastq.qh_link; - next_from_batchq = false; - }else if ((struct quehead *) slirp->next_m != &slirp->if_batchq) { -/* Nothing on fastq, pick up from batchq via next_m */ - ifm_next = slirp->next_m; - next_from_batchq = true; + }else if (batch_head) { +/* Nothing on fastq, pick up from batchq */ + ifm_next = batch_head; + from_batchq = true; }else { ifm_next =NULL ; }while (ifm_next) { ifm = ifm_next; - from_batchq = next_from_batchq; ifm_next = ifm->ifq_next;if ((struct quehead *) ifm_next == &slirp->if_fastq) {/* No more packets in fastq, switch to batchq */ - ifm_next = slirp->next_m; - next_from_batchq = true; + ifm_next = batch_head; + from_batchq = true; }if ((struct quehead *) ifm_next == &slirp->if_batchq) {/* end of batchq */
@@ -199,11 +194,6 @@ void if_start(Slirp *slirp)continue ; } -if (ifm == slirp->next_m) { -/* Set which packet to send on next iteration */ - slirp->next_m = ifm->ifq_next; - } -/* Remove it from the queue */ ifqt = ifm->ifq_prev;remque (ifm);
@@ -214,15 +204,8 @@ void if_start(Slirp *slirp)insque (next, ifqt);ifs_remque (ifm); -if (!from_batchq) { -/* Next packet in fastq is from the same session */ ifm_next = next; - next_from_batchq = false; - }else if ((struct quehead *) slirp->next_m == &slirp->if_batchq) { -/* Set next_m and ifm_next if the session packet is now the -* only one on batchq */ - slirp->next_m = ifm_next = next; } }
slirp/slirp.h +0 -1
@@ -183,7 +183,6 @@ struct Slirp {/* if states */ struct quehead if_fastq;/* fast queue (for interactive data) */ struct quehead if_batchq;/* queue for non-interactive data */ -struct mbuf *next_m;/* pointer to next mbuf to output */ bool if_start_busy;/* avoid if_start recursion */ /* ip states */
Signature · 1 line
2.14.1
[Qemu-devel] [PULL 3/3] slirp: Add a special case for the NULL socket
In reply to Samuel ThibaultFrom: Kevin Cernekee <[email protected]>
NULL sockets are used for NDP, BOOTP, and other critical operations. If the topmost mbuf in a NULL session is blocked pending resolution, it may cause problems if it blocks other packets with a NULL socket. So do not add mbufs with a NULL socket field to the same session.
--- slirp/if.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
slirp/if.c +10 -8
@@ -73,14 +73,16 @@ if_output(struct socket *so, struct mbuf *ifm)* We mustn't put this packet back on the fastq (or we'll send it out of order) * XXX add cache here? */ -for (ifq = (struct mbuf *) slirp->if_batchq.qh_rlink; - (struct quehead *) ifq != &slirp->if_batchq; - ifq = ifq->ifq_prev) { -if (so == ifq->ifq_so) { -/* A match! */ - ifm->ifq_so = so; -ifs_insque (ifm, ifq->ifs_prev); - goto diddit; +if (so) { +for (ifq = (struct mbuf *) slirp->if_batchq.qh_rlink; + (struct quehead *) ifq != &slirp->if_batchq; + ifq = ifq->ifq_prev) { +if (so == ifq->ifq_so) { +/* A match! */ + ifm->ifq_so = so; +ifs_insque (ifm, ifq->ifs_prev); + goto diddit; + } } }
Signature · 1 line
2.14.1
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PULL 0/3] slirp updates
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'3b8560cf71 slirp: Add a special case for the NULL socket 91a5c1c7c4 slirp: Fix intermittent send queue hangs on a socket 16d5416215 slirp: Add explanation for hostfwd parsing failure
=== OUTPUT BEGIN ===
Checking PATCH 1/3: slirp: Add explanation for hostfwd parsing failure... Checking PATCH 2/3: slirp: Fix intermittent send queue hangs on a socket... Checking PATCH 3/3: slirp: Add a special case for the NULL socket...
ERROR: code indent should never use tabs
#31: FILE: slirp/if.c:76:
+^Iif (so) {$
ERROR: code indent should never use tabs
#32: FILE: slirp/if.c:77:
+^I^Ifor (ifq = (struct mbuf *) slirp->if_batchq.qh_rlink;$
ERROR: code indent should never use tabs
#33: FILE: slirp/if.c:78:
+^I^I (struct quehead *) ifq != &slirp->if_batchq;$
ERROR: code indent should never use tabs
#34: FILE: slirp/if.c:79:
+^I^I ifq = ifq->ifq_prev) {$
ERROR: code indent should never use tabs
#35: FILE: slirp/if.c:80:
+^I^I^Iif (so == ifq->ifq_so) {$
ERROR: code indent should never use tabs
#36: FILE: slirp/if.c:81:
+^I^I^I^I/* A match! */$
ERROR: code indent should never use tabs
#37: FILE: slirp/if.c:82:
+^I^I^I^Iifm->ifq_so = so;$
ERROR: code indent should never use tabs
#38: FILE: slirp/if.c:83:
+^I^I^I^Iifs_insque(ifm, ifq->ifs_prev);$
ERROR: code indent should never use tabs
#39: FILE: slirp/if.c:84:
+^I^I^I^Igoto diddit;$
ERROR: code indent should never use tabs
#40: FILE: slirp/if.c:85:
+^I^I^I}$
total: 10 errors, 0 warnings, 24 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Peter Maydell
AppliedQuoted 16 lines · Samuel Thibault
warning: redirection vers https://people.debian.org/~sthibault/qemu.git/
The following changes since commit460b6c8e581aa06b86f59eebd9e52edfe7adf417:Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2017-09-23 12:55:40 +0100)
are available in the git repository at:
http://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
for you to fetch changes up to
13146a83951e045c810c37c5c11c2a016ebc0663:slirp: Add a special case for the NULL socket (2017-09-24 20:04:09 +0200)
----------------------------------------------------------------
slirp updates
Quoted 7 lines
----------------------------------------------------------------
Dr. David Alan Gilbert (1):
slirp: Add explanation for hostfwd parsing failureKevin Cernekee (2):
slirp: Fix intermittent send queue hangs on a socket
slirp: Add a special case for the NULL socket
Applied, thanks.
-- PMM