aboutgitcodebugslistschat
path: root/passt.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-09-27 00:16:51 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-09-27 01:28:02 +0200
commit3943f20ef99d4146f0fa1a4025e2a62a3ad961f2 (patch)
treefdb76bae8253f4ac58b69735bb3a5626ece6aac4 /passt.c
parent4b0ccb83237cad3dc22334c55cf7a63f3be3f4b3 (diff)
downloadpasst-3943f20ef99d4146f0fa1a4025e2a62a3ad961f2.tar
passt-3943f20ef99d4146f0fa1a4025e2a62a3ad961f2.tar.gz
passt-3943f20ef99d4146f0fa1a4025e2a62a3ad961f2.tar.bz2
passt-3943f20ef99d4146f0fa1a4025e2a62a3ad961f2.tar.lz
passt-3943f20ef99d4146f0fa1a4025e2a62a3ad961f2.tar.xz
passt-3943f20ef99d4146f0fa1a4025e2a62a3ad961f2.tar.zst
passt-3943f20ef99d4146f0fa1a4025e2a62a3ad961f2.zip
passt: Actually initialise timers for protocol handlers
The initial timestamp was not initialised, so timers for protocol handlers wouldn't run at all sometimes. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'passt.c')
-rw-r--r--passt.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/passt.c b/passt.c
index 6645e45..fa3d80a 100644
--- a/passt.c
+++ b/passt.c
@@ -127,6 +127,16 @@ static void timer_handler(struct ctx *c, struct timespec *now)
}
/**
+ * timer_init() - Set initial timestamp for timer runs to current time
+ * @c: Execution context
+ * @now: Current timestamp
+ */
+static void timer_init(struct ctx *c, struct timespec *now)
+{
+ c->tcp.timer_run = c->udp.timer_run = c->icmp.timer_run = *now;
+}
+
+/**
* proto_update_l2_buf() - Update scatter-gather L2 buffers in protocol handlers
* @eth_d: Ethernet destination address, NULL if unchanged
* @eth_s: Ethernet source address, NULL if unchanged
@@ -363,8 +373,10 @@ int main(int argc, char **argv)
tap_sock_init(&c);
- if ((!c.no_udp && udp_sock_init(&c)) ||
- (!c.no_tcp && tcp_sock_init(&c)))
+ clock_gettime(CLOCK_MONOTONIC, &now);
+
+ if ((!c.no_udp && udp_sock_init(&c, &now)) ||
+ (!c.no_tcp && tcp_sock_init(&c, &now)))
exit(EXIT_FAILURE);
if (c.v6 && !c.no_dhcpv6)
@@ -379,6 +391,8 @@ int main(int argc, char **argv)
if (isatty(fileno(stdout)) && !c.foreground)
daemon(0, 0);
+
+ timer_init(&c, &now);
loop:
nfds = epoll_wait(c.epollfd, events, EPOLL_EVENTS, TIMER_INTERVAL);
if (nfds == -1 && errno != EINTR) {