diff mbox series

[PULL,49/64] slirp: use virtual time for packet expiration

Message ID 20181218230442.27887-50-samuel.thibault@ens-lyon.org (mailing list archive)
State New, archived
Headers show
Series [PULL,01/64] slirp: associate slirp_output callback with the Slirp context | expand

Commit Message

Samuel Thibault Dec. 18, 2018, 11:04 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Make all packets expiration time based on virtual clock.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 slirp/if.c    | 2 +-
 slirp/slirp.c | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/slirp/if.c b/slirp/if.c
index aa88cc4e76..ce4f5fac53 100644
--- a/slirp/if.c
+++ b/slirp/if.c
@@ -148,7 +148,7 @@  diddit:
  */
 void if_start(Slirp *slirp)
 {
-    uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
+    uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
     bool from_batchq = false;
     struct mbuf *ifm, *ifm_next, *ifqt;
 
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 4949d17c73..91210dc00a 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -582,7 +582,7 @@  void slirp_pollfds_poll(GArray *pollfds, int select_error)
         return;
     }
 
-    curtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
+    curtime = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL);
 
     QTAILQ_FOREACH(slirp, &slirp_instances, entry) {
         /*
@@ -909,7 +909,8 @@  static int if_encap4(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh,
             ifm->resolution_requested = true;
 
             /* Expire request and drop outgoing packet after 1 second */
-            ifm->expiration_date = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + 1000000000ULL;
+            ifm->expiration_date =
+                qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1000000000ULL;
         }
         return 0;
     } else {
@@ -936,7 +937,7 @@  static int if_encap6(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh,
             ndp_send_ns(slirp, ip6h->ip_dst);
             ifm->resolution_requested = true;
             ifm->expiration_date =
-                qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + 1000000000ULL;
+                qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1000000000ULL;
         }
         return 0;
     } else {