From a54eb16853eef419905bffef047c9267d9ae9ab7 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 17 Mar 2021 20:20:32 +0100 Subject: [PATCH] Check if SO_REUSEPORT is defined before using it. --- src/discovery.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/discovery.c b/src/discovery.c index 18919745..5cc1d412 100644 --- a/src/discovery.c +++ b/src/discovery.c @@ -906,7 +906,9 @@ bool discovery_start(meshlink_handle_t *mesh) { .in.sin_port = ntohs(5353), }; setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); +#ifdef SO_REUSEPORT setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)); +#endif setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &one8, sizeof(one8)); setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl8, sizeof(ttl8)); @@ -927,7 +929,9 @@ bool discovery_start(meshlink_handle_t *mesh) { } setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); +#ifdef SO_REUSEPORT setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)); +#endif setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)); setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &one, sizeof(one)); setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl, sizeof(ttl)); -- 2.39.5