From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.insanity.kuhnchris.eu (insanity.kuhnchris.eu [37.59.36.123]) by passt.top (Postfix) with ESMTPS id 53EBB5A024D for ; Fri, 3 Mar 2023 23:49:36 +0100 (CET) From: KuhnChris DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kuhnchris.eu; s=mail; t=1677883777; bh=5AmDpd4QQPSaC12p1zvL4phONazf8mN3R55vtROdiIw=; h=From:To:Cc:Subject; b=moWtMgcScyQ+pGEjUbebMJguviPZDRrFMjgW/lEJUsPtyR21g47zksMdD+vAswCSu 0fOaNetodLnoj9pAgVVH+XdsEUkPR9VBih9YnwDPOjD2PQG/fnxNcFkYFlMB8/aW4T 592KoV1FrWNDMkzZd9/pFuxFIpNO6wGvNI+IBOREK7jpLnPyt+MJeDAqcaXHgWg4pm ALqLCR4El0g+VEHB5VVJZon5IjKF2fxCy3eQzZ9NumIqUn3sFx3cO7fz4DdE/OQ6lV /YVVd08eRIKhZ8U5cV5J4MDn0EMOJP22OXbytca6WlwHUdctigGwYIcVteilNRIO27 M0OtlpwoU2VaA== To: passt-dev@passt.top Subject: [PATCH 1/3] musl adaptations Date: Fri, 3 Mar 2023 22:49:29 +0000 Message-Id: <20230303224931.11791-1-kuhnchris+github@kuhnchris.eu> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-MailFrom: kuhnchris+github@kuhnchris.eu X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation Message-ID-Hash: D6RQ5224K3URMV3AINMY2A6JFTSZVX65 X-Message-ID-Hash: D6RQ5224K3URMV3AINMY2A6JFTSZVX65 X-Mailman-Approved-At: Sat, 04 Mar 2023 09:52:28 +0100 CC: KuhnChris X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --- conf.c | 6 +++--- passt.c | 2 +- passt.h | 4 ++-- util.h | 14 ++++++++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/conf.c b/conf.c index 0e512f4..c1dd9ba 100644 --- a/conf.c +++ b/conf.c @@ -1305,13 +1305,13 @@ void conf(struct ctx *c, int argc, char **argv) if (logfile) die("Can't log to both file and stderr"); - if (c->stderr) + if (c->force_stderr) die("Multiple --stderr options given"); - c->stderr = 1; + c->force_stderr = 1; break; case 'l': - if (c->stderr) + if (c->force_stderr) die("Can't log to both stderr and file"); if (logfile) diff --git a/passt.c b/passt.c index 5b8146e..f67213a 100644 --- a/passt.c +++ b/passt.c @@ -241,7 +241,7 @@ int main(int argc, char **argv) conf(&c, argc, argv); trace_init(c.trace); - if (c.stderr || isatty(fileno(stdout))) + if (c.force_stderr || isatty(fileno(stdout))) __openlog(log_name, LOG_PERROR, LOG_DAEMON); quit_fd = pasta_netns_quit_init(&c); diff --git a/passt.h b/passt.h index e0383eb..71d3602 100644 --- a/passt.h +++ b/passt.h @@ -32,7 +32,7 @@ struct tap_l4_msg { union epoll_ref; #include - +#include #include "packet.h" #include "icmp.h" #include "port_fwd.h" @@ -197,7 +197,7 @@ struct ctx { int trace; int quiet; int foreground; - int stderr; + int force_stderr; int nofile; char sock_path[UNIX_PATH_MAX]; char pcap[PATH_MAX]; diff --git a/util.h b/util.h index 570094c..7315ce2 100644 --- a/util.h +++ b/util.h @@ -7,7 +7,10 @@ #define UTIL_H #include +#include #include +#include +#include #include "log.h" @@ -88,6 +91,8 @@ #define MAC_ZERO ((uint8_t [ETH_ALEN]){ 0 }) #define MAC_IS_ZERO(addr) (!memcmp((addr), MAC_ZERO, ETH_ALEN)) +#if defined(__GLIBC__) || defined(__UCLIBC__) + #if __BYTE_ORDER == __BIG_ENDIAN #define htons_constant(x) (x) #define htonl_constant(x) (x) @@ -96,6 +101,15 @@ #define htonl_constant(x) (__bswap_constant_32(x)) #endif +#else + +/* mainly musl fallback */ + +#define htons_constant(x) (x) +#define htonl_constant(x) (x) + +#endif + #define IN4_IS_ADDR_UNSPECIFIED(a) \ ((a)->s_addr == htonl(INADDR_ANY)) #define IN4_IS_ADDR_BROADCAST(a) \ -- 2.38.4