|
|
2aacef |
From 4b911f2d385feb8153dacaf923108fc6d00fa149 Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
2aacef |
Date: Fri, 4 Nov 2022 13:11:55 +0900
|
|
|
2aacef |
Subject: [PATCH] resolvectl: warn if the global mDNS or LLMNR support level is
|
|
|
2aacef |
lower than the requested one
|
|
|
2aacef |
|
|
|
2aacef |
(cherry picked from commit c38a03df4af78721f45947ffa2013554d81954a4)
|
|
|
2aacef |
|
|
|
2aacef |
Related: #2138081
|
|
|
2aacef |
---
|
|
|
2aacef |
src/resolve/resolvectl.c | 37 +++++++++++++++++++++++++++++++++++++
|
|
|
2aacef |
1 file changed, 37 insertions(+)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c
|
|
|
2aacef |
index 2a7347ca27..c52773508f 100644
|
|
|
2aacef |
--- a/src/resolve/resolvectl.c
|
|
|
2aacef |
+++ b/src/resolve/resolvectl.c
|
|
|
2aacef |
@@ -32,6 +32,7 @@
|
|
|
2aacef |
#include "pretty-print.h"
|
|
|
2aacef |
#include "process-util.h"
|
|
|
2aacef |
#include "resolvconf-compat.h"
|
|
|
2aacef |
+#include "resolve-util.h"
|
|
|
2aacef |
#include "resolvectl.h"
|
|
|
2aacef |
#include "resolved-def.h"
|
|
|
2aacef |
#include "resolved-dns-packet.h"
|
|
|
2aacef |
@@ -2280,6 +2281,8 @@ static int verb_default_route(int argc, char **argv, void *userdata) {
|
|
|
2aacef |
|
|
|
2aacef |
static int verb_llmnr(int argc, char **argv, void *userdata) {
|
|
|
2aacef |
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
|
|
2aacef |
+ _cleanup_free_ char *global_llmnr_support_str = NULL;
|
|
|
2aacef |
+ ResolveSupport global_llmnr_support, llmnr_support;
|
|
|
2aacef |
sd_bus *bus = ASSERT_PTR(userdata);
|
|
|
2aacef |
int r;
|
|
|
2aacef |
|
|
|
2aacef |
@@ -2295,6 +2298,22 @@ static int verb_llmnr(int argc, char **argv, void *userdata) {
|
|
|
2aacef |
if (argc < 3)
|
|
|
2aacef |
return status_ifindex(bus, arg_ifindex, NULL, STATUS_LLMNR, NULL);
|
|
|
2aacef |
|
|
|
2aacef |
+ llmnr_support = resolve_support_from_string(argv[2]);
|
|
|
2aacef |
+ if (llmnr_support < 0)
|
|
|
2aacef |
+ return log_error_errno(llmnr_support, "Invalid LLMNR setting: %s", argv[2]);
|
|
|
2aacef |
+
|
|
|
2aacef |
+ r = bus_get_property_string(bus, bus_resolve_mgr, "LLMNR", &error, &global_llmnr_support_str);
|
|
|
2aacef |
+ if (r < 0)
|
|
|
2aacef |
+ return log_error_errno(r, "Failed to get the global LLMNR support state: %s", bus_error_message(&error, r));
|
|
|
2aacef |
+
|
|
|
2aacef |
+ global_llmnr_support = resolve_support_from_string(global_llmnr_support_str);
|
|
|
2aacef |
+ if (global_llmnr_support < 0)
|
|
|
2aacef |
+ return log_error_errno(global_llmnr_support, "Received invalid global LLMNR setting: %s", global_llmnr_support_str);
|
|
|
2aacef |
+
|
|
|
2aacef |
+ if (global_llmnr_support < llmnr_support)
|
|
|
2aacef |
+ log_warning("Setting LLMNR support level \"%s\" for \"%s\", but the global support level is \"%s\".",
|
|
|
2aacef |
+ argv[2], arg_ifname, global_llmnr_support_str);
|
|
|
2aacef |
+
|
|
|
2aacef |
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkLLMNR", &error, NULL, "is", arg_ifindex, argv[2]);
|
|
|
2aacef |
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
|
|
|
2aacef |
sd_bus_error_free(&error);
|
|
|
2aacef |
@@ -2314,6 +2333,8 @@ static int verb_llmnr(int argc, char **argv, void *userdata) {
|
|
|
2aacef |
|
|
|
2aacef |
static int verb_mdns(int argc, char **argv, void *userdata) {
|
|
|
2aacef |
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
|
|
2aacef |
+ _cleanup_free_ char *global_mdns_support_str = NULL;
|
|
|
2aacef |
+ ResolveSupport global_mdns_support, mdns_support;
|
|
|
2aacef |
sd_bus *bus = ASSERT_PTR(userdata);
|
|
|
2aacef |
int r;
|
|
|
2aacef |
|
|
|
2aacef |
@@ -2329,6 +2350,22 @@ static int verb_mdns(int argc, char **argv, void *userdata) {
|
|
|
2aacef |
if (argc < 3)
|
|
|
2aacef |
return status_ifindex(bus, arg_ifindex, NULL, STATUS_MDNS, NULL);
|
|
|
2aacef |
|
|
|
2aacef |
+ mdns_support = resolve_support_from_string(argv[2]);
|
|
|
2aacef |
+ if (mdns_support < 0)
|
|
|
2aacef |
+ return log_error_errno(mdns_support, "Invalid mDNS setting: %s", argv[2]);
|
|
|
2aacef |
+
|
|
|
2aacef |
+ r = bus_get_property_string(bus, bus_resolve_mgr, "MulticastDNS", &error, &global_mdns_support_str);
|
|
|
2aacef |
+ if (r < 0)
|
|
|
2aacef |
+ return log_error_errno(r, "Failed to get the global mDNS support state: %s", bus_error_message(&error, r));
|
|
|
2aacef |
+
|
|
|
2aacef |
+ global_mdns_support = resolve_support_from_string(global_mdns_support_str);
|
|
|
2aacef |
+ if (global_mdns_support < 0)
|
|
|
2aacef |
+ return log_error_errno(global_mdns_support, "Received invalid global mDNS setting: %s", global_mdns_support_str);
|
|
|
2aacef |
+
|
|
|
2aacef |
+ if (global_mdns_support < mdns_support)
|
|
|
2aacef |
+ log_warning("Setting mDNS support level \"%s\" for \"%s\", but the global support level is \"%s\".",
|
|
|
2aacef |
+ argv[2], arg_ifname, global_mdns_support_str);
|
|
|
2aacef |
+
|
|
|
2aacef |
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkMulticastDNS", &error, NULL, "is", arg_ifindex, argv[2]);
|
|
|
2aacef |
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
|
|
|
2aacef |
sd_bus_error_free(&error);
|