slirp: Prevent recursion of if_start
if_start can be called recursively via if_encap. Avoid this as our
scheme of dequeuing packets is not compatible with this.
CC: Fabien Chouteau <chouteau@adacore.com>
CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
CC: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
diff --git a/slirp/if.c b/slirp/if.c
index 14fdef1..f7aebe9 100644
--- a/slirp/if.c
+++ b/slirp/if.c
@@ -163,10 +163,17 @@
DEBUG_CALL("if_start");
+ if (slirp->if_start_busy) {
+ return;
+ }
+ slirp->if_start_busy = true;
+
while (slirp->if_queued) {
/* check if we can really output */
- if (!slirp_can_output(slirp->opaque))
+ if (!slirp_can_output(slirp->opaque)) {
+ slirp->if_start_busy = false;
return;
+ }
/*
* See which queue to get next packet from
@@ -221,4 +228,6 @@
}
slirp->if_queued = requeued;
+
+ slirp->if_start_busy = false;
}