]> git.ipfire.org Git - fireperf.git/commitdiff
client: Use a random port to connect to the server
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 1 Feb 2021 18:27:40 +0000 (18:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 1 Feb 2021 18:27:40 +0000 (18:27 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/client.c

index 82ae52820ce039ab778b714345378c348bd0b078..401a4f8708f69cdf8fba833841e5bc1f79877ab7 100644 (file)
@@ -109,13 +109,16 @@ static int open_connection(struct fireperf_config* conf) {
                goto ERROR;
        }
 
-       DEBUG(conf, "Opening socket %d...\n", fd);
+       // Chose a random port
+       int port = conf->port + (random() % conf->sockets);
+
+       DEBUG(conf, "Opening socket %d (port %d)...\n", fd, port);
 
        // Define the peer
        struct sockaddr_in6 peer = {
                .sin6_family = AF_INET6,
                .sin6_addr = conf->address,
-               .sin6_port = htons(conf->port),
+               .sin6_port = htons(port),
        };
 
        // Enable keepalive