From 07bfefe40b8b0c9d72576b075bb01aac6c84c5ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= <vladimir.cunat@nic.cz>
Date: Wed, 24 Aug 2022 10:58:26 +0200
Subject: [PATCH] daemon/io: log another message if `freebind` isn't supported

So far the message wasn't pointing to freebind at all:
[net   ] bind to '::1@53' (UDP): Operation not supported

I used preprocessor to avoid duplication and unused warnings.

Another way would be to ignore the freebind option if not supported,
but I think it's better to convince users not to specify it.
---
 daemon/io.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/daemon/io.c b/daemon/io.c
index 824a4b9f5..4d8579241 100644
--- a/daemon/io.c
+++ b/daemon/io.c
@@ -148,6 +148,8 @@ void udp_recv(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf,
 
 static int family_to_freebind_option(sa_family_t sa_family, int *level, int *name)
 {
+#define LOG_NO_FB kr_log_error(NETWORK, "your system does not support 'freebind', " \
+				"please remove it from your configuration\n")
 	switch (sa_family) {
 	case AF_INET:
 		*level = IPPROTO_IP;
@@ -156,6 +158,7 @@ static int family_to_freebind_option(sa_family_t sa_family, int *level, int *nam
 #elif defined(IP_BINDANY)
 		*name = IP_BINDANY;
 #else
+		LOG_NO_FB;
 		return kr_error(ENOTSUP);
 #endif
 		break;
@@ -167,6 +170,7 @@ static int family_to_freebind_option(sa_family_t sa_family, int *level, int *nam
 		*level = IPPROTO_IPV6;
 		*name = IPV6_BINDANY;
 #else
+		LOG_NO_FB;
 		return kr_error(ENOTSUP);
 #endif
 		break;
-- 
GitLab