Skip to content

Commit ca9fab8

Browse files
poetteringyuwata
authored andcommitted
Revert "resolvectl: Add show-multicast verb to show discovered LLMNR/mDNS hosts"
1 parent a24fb9b commit ca9fab8

File tree

8 files changed

+14
-246
lines changed

8 files changed

+14
-246
lines changed

man/org.freedesktop.resolve1.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ node /org/freedesktop/resolve1 {
115115
ResetStatistics();
116116
FlushCaches();
117117
ResetServerFeatures();
118-
GetMulticastHosts(out a(stiiay) UNNAMED);
119118
properties:
120119
readonly s LLMNRHostname = '...';
121120
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
@@ -165,8 +164,6 @@ node /org/freedesktop/resolve1 {
165164

166165
<!--method ResetServerFeatures is not documented!-->
167166

168-
<!--method GetMulticastHosts is not documented!-->
169-
170167
<!--property DNSSECNegativeTrustAnchors is not documented!-->
171168

172169
<!--Autogenerated cross-references for systemd.directives, do not edit-->
@@ -215,8 +212,6 @@ node /org/freedesktop/resolve1 {
215212

216213
<variablelist class="dbus-method" generated="True" extra-ref="ResetServerFeatures()"/>
217214

218-
<variablelist class="dbus-method" generated="True" extra-ref="GetMulticastHosts()"/>
219-
220215
<variablelist class="dbus-property" generated="True" extra-ref="LLMNRHostname"/>
221216

222217
<variablelist class="dbus-property" generated="True" extra-ref="LLMNR"/>

man/resolvectl.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,6 @@
180180
automatically, an explicit reverting is not necessary in that case.</para></listitem>
181181
</varlistentry>
182182

183-
<varlistentry>
184-
<term><command>show-multicast</command></term>
185-
186-
<listitem><para>Display the discovered LLMNR and mDNS hostnames along with their IPv4/IPv6 addresses.
187-
</para></listitem>
188-
</varlistentry>
189-
190183
<xi:include href="systemctl.xml" xpointer="log-level" />
191184
</variablelist>
192185
</refsect1>

mkosi.postinst

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/resolve/resolvectl.c

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,90 +2500,6 @@ static int verb_log_level(int argc, char *argv[], void *userdata) {
25002500
return 0;
25012501
}
25022502

2503-
static const char *resolve_flags_to_string(uint64_t flags) {
2504-
return flags & SD_RESOLVED_DNS ? "DNS" :
2505-
flags & SD_RESOLVED_LLMNR_IPV4 ? "LLMNR/IPv4" :
2506-
flags & SD_RESOLVED_LLMNR_IPV6 ? "LLMNR/IPv6" :
2507-
flags & SD_RESOLVED_MDNS_IPV4 ? "mDNS/IPv4" :
2508-
flags & SD_RESOLVED_MDNS_IPV6 ? "mDNS/IPv6" :
2509-
"";
2510-
}
2511-
2512-
static int verb_show_multicast(int argc, char *argv[], void *userdata) {
2513-
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
2514-
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
2515-
_cleanup_(table_unrefp) Table *table = NULL;
2516-
sd_bus *bus = userdata;
2517-
int r;
2518-
2519-
assert(bus);
2520-
2521-
table = table_new("Hostname", "Address", "Source");
2522-
if (!table)
2523-
return log_oom();
2524-
2525-
r = bus_call_method(bus, bus_resolve_mgr, "GetMulticastHosts", &error, &reply, NULL);
2526-
if (r < 0)
2527-
return log_error_errno(r, "Failed to query systemd-resolved: %s", bus_error_message(&error, r));
2528-
2529-
r = sd_bus_message_enter_container(reply, 'a', "(stiiay)");
2530-
if (r < 0)
2531-
return bus_log_parse_error(r);
2532-
2533-
while ((r = sd_bus_message_enter_container(reply, 'r', "stiiay")) > 0) {
2534-
char *canonical;
2535-
uint64_t flags;
2536-
_cleanup_free_ char *pretty = NULL;
2537-
int ifindex, family;
2538-
union in_addr_union a;
2539-
2540-
r = sd_bus_message_read(reply, "st", &canonical, &flags);
2541-
if (r < 0)
2542-
return bus_log_parse_error(r);
2543-
2544-
r = sd_bus_message_read(reply, "i", &ifindex);
2545-
if (r < 0)
2546-
return bus_log_parse_error(r);
2547-
2548-
sd_bus_error_free(&error);
2549-
r = bus_message_read_in_addr_auto(reply, &error, &family, &a);
2550-
if (r < 0)
2551-
return log_error_errno(
2552-
r,
2553-
"systemd-resolved returned invalid result: %s",
2554-
bus_error_message(&error, r));
2555-
2556-
r = sd_bus_message_exit_container(reply);
2557-
if (r < 0)
2558-
return bus_log_parse_error(r);
2559-
2560-
r = in_addr_ifindex_to_string(family, &a, ifindex, &pretty);
2561-
if (r < 0)
2562-
return log_error_errno(r, "Failed to print address: %m");
2563-
2564-
r = table_add_many(
2565-
table,
2566-
TABLE_STRING,
2567-
canonical,
2568-
TABLE_STRING,
2569-
pretty,
2570-
TABLE_STRING,
2571-
resolve_flags_to_string(flags));
2572-
if (r < 0)
2573-
return table_log_add_error(r);
2574-
}
2575-
2576-
r = sd_bus_message_exit_container(reply);
2577-
if (r < 0)
2578-
return bus_log_parse_error(r);
2579-
2580-
r = table_print(table, NULL);
2581-
if (r < 0)
2582-
return table_log_print_error(r);
2583-
2584-
return 0;
2585-
}
2586-
25872503
static void help_protocol_types(void) {
25882504
if (arg_legend)
25892505
puts("Known protocol types:");
@@ -2693,7 +2609,6 @@ static int native_help(void) {
26932609
" nta [LINK [DOMAIN...]] Get/set per-interface DNSSEC NTA\n"
26942610
" revert LINK Revert per-interface configuration\n"
26952611
" log-level [LEVEL] Get/set logging threshold for systemd-resolved\n"
2696-
" show-multicast Show domain names discovered via LLMNR/mDNS\n"
26972612
"\nOptions:\n"
26982613
" -h --help Show this help\n"
26992614
" --version Show package version\n"
@@ -3237,7 +3152,7 @@ static int native_parse_argv(int argc, char *argv[]) {
32373152
}
32383153

32393154
static int native_main(int argc, char *argv[], sd_bus *bus) {
3240-
/* clang-format off */
3155+
32413156
static const Verb verbs[] = {
32423157
{ "help", VERB_ANY, VERB_ANY, 0, verb_help },
32433158
{ "status", VERB_ANY, VERB_ANY, VERB_DEFAULT, verb_status },
@@ -3259,10 +3174,8 @@ static int native_main(int argc, char *argv[], sd_bus *bus) {
32593174
{ "nta", VERB_ANY, VERB_ANY, 0, verb_nta },
32603175
{ "revert", VERB_ANY, 2, 0, verb_revert_link },
32613176
{ "log-level", VERB_ANY, 2, 0, verb_log_level },
3262-
{ "show-multicast", VERB_ANY, VERB_ANY, 0, verb_show_multicast },
32633177
{}
32643178
};
3265-
/* clang-format on */
32663179

32673180
return dispatch_verb(argc, argv, verbs, bus);
32683181
}

src/resolve/resolved-bus.c

Lines changed: 10 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,15 @@ static int reply_query_state(DnsQuery *q) {
132132
}
133133
}
134134

135-
static int append_address(sd_bus_message *reply, DnsResourceRecord *rr, int ifindex, bool is_container) {
135+
static int append_address(sd_bus_message *reply, DnsResourceRecord *rr, int ifindex) {
136136
int r;
137137

138138
assert(reply);
139139
assert(rr);
140140

141-
if (is_container) {
142-
r = sd_bus_message_open_container(reply, 'r', "iiay");
143-
if (r < 0)
144-
return r;
145-
}
141+
r = sd_bus_message_open_container(reply, 'r', "iiay");
142+
if (r < 0)
143+
return r;
146144

147145
r = sd_bus_message_append(reply, "i", ifindex);
148146
if (r < 0)
@@ -167,11 +165,9 @@ static int append_address(sd_bus_message *reply, DnsResourceRecord *rr, int ifin
167165
if (r < 0)
168166
return r;
169167

170-
if (is_container) {
171-
r = sd_bus_message_close_container(reply);
172-
if (r < 0)
173-
return r;
174-
}
168+
r = sd_bus_message_close_container(reply);
169+
if (r < 0)
170+
return r;
175171

176172
return 0;
177173
}
@@ -220,7 +216,7 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
220216
if (r == 0)
221217
continue;
222218

223-
r = append_address(reply, rr, ifindex, true);
219+
r = append_address(reply, rr, ifindex);
224220
if (r < 0)
225221
goto finish;
226222

@@ -855,7 +851,7 @@ static int append_srv(DnsQuery *q, sd_bus_message *reply, DnsResourceRecord *rr)
855851
if (r == 0)
856852
continue;
857853

858-
r = append_address(reply, zz, ifindex, true);
854+
r = append_address(reply, zz, ifindex);
859855
if (r < 0)
860856
return r;
861857
}
@@ -2004,76 +2000,6 @@ static int bus_method_unregister_service(sd_bus_message *message, void *userdata
20042000
return call_dnssd_method(m, message, bus_dnssd_method_unregister, error);
20052001
}
20062002

2007-
static int bus_method_get_multicast_hosts(sd_bus_message *message, void *userdata, sd_bus_error *error) {
2008-
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
2009-
DnsScope *s;
2010-
Manager *m = userdata;
2011-
int r;
2012-
2013-
assert(message);
2014-
assert(m);
2015-
2016-
r = sd_bus_message_new_method_return(message, &reply);
2017-
if (r < 0)
2018-
return r;
2019-
2020-
r = sd_bus_message_open_container(reply, 'a', "(stiiay)");
2021-
if (r < 0)
2022-
return r;
2023-
2024-
LIST_FOREACH(scopes, s, m->dns_scopes) {
2025-
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL;
2026-
DnsResourceRecord *rr;
2027-
DnsAnswerFlags flags;
2028-
int ifindex;
2029-
2030-
if (s->protocol == DNS_PROTOCOL_DNS)
2031-
continue;
2032-
2033-
r = dns_cache_dump_to_answer(&s->cache, &answer);
2034-
if (r < 0)
2035-
return r;
2036-
if (r == 0)
2037-
continue;
2038-
2039-
DNS_ANSWER_FOREACH_FULL(rr, ifindex, flags, answer) {
2040-
_cleanup_free_ char *normalized = NULL;
2041-
bool authenticated = FLAGS_SET(flags, DNS_ANSWER_AUTHENTICATED);
2042-
2043-
r = dns_name_normalize(dns_resource_key_name(rr->key), 0, &normalized);
2044-
if (r < 0)
2045-
return r;
2046-
2047-
r = sd_bus_message_open_container(reply, 'r', "stiiay");
2048-
if (r < 0)
2049-
return r;
2050-
2051-
r = sd_bus_message_append(
2052-
reply,
2053-
"st",
2054-
normalized,
2055-
SD_RESOLVED_FLAGS_MAKE(s->protocol, s->family, authenticated));
2056-
if (r < 0)
2057-
return r;
2058-
2059-
r = append_address(reply, rr, ifindex, false);
2060-
if (r < 0)
2061-
return r;
2062-
2063-
r = sd_bus_message_close_container(reply);
2064-
if (r < 0)
2065-
return r;
2066-
}
2067-
}
2068-
2069-
r = sd_bus_message_close_container(reply);
2070-
if (r < 0)
2071-
return r;
2072-
2073-
return sd_bus_reply(message, reply);
2074-
}
2075-
2076-
/* clang-format off */
20772003
static const sd_bus_vtable resolve_vtable[] = {
20782004
SD_BUS_VTABLE_START(0),
20792005
SD_BUS_PROPERTY("LLMNRHostname", "s", NULL, offsetof(Manager, llmnr_hostname), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
@@ -2212,14 +2138,9 @@ static const sd_bus_vtable resolve_vtable[] = {
22122138
SD_BUS_NO_RESULT,
22132139
bus_method_reset_server_features,
22142140
SD_BUS_VTABLE_UNPRIVILEGED),
2215-
SD_BUS_METHOD_WITH_ARGS("GetMulticastHosts",
2216-
SD_BUS_NO_ARGS,
2217-
SD_BUS_RESULT("a(stiiay)", addresses),
2218-
bus_method_get_multicast_hosts,
2219-
SD_BUS_VTABLE_UNPRIVILEGED),
2141+
22202142
SD_BUS_VTABLE_END,
22212143
};
2222-
/* clang-format on */
22232144

22242145
const BusObjectImplementation manager_object = {
22252146
"/org/freedesktop/resolve1",

src/resolve/resolved-dns-cache.c

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,55 +1066,7 @@ int dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p) {
10661066
return 0;
10671067
}
10681068

1069-
int dns_cache_dump_to_answer(DnsCache *cache, DnsAnswer **ret) {
1070-
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL;
1071-
DnsCacheItem *i;
1072-
size_t n = 0;
1073-
int r;
1074-
1075-
assert(cache);
1076-
assert(ret);
1077-
1078-
HASHMAP_FOREACH(i, cache->by_key) {
1079-
DnsCacheItem *j;
1080-
1081-
LIST_FOREACH(by_key, j, i) {
1082-
if (!j->rr)
1083-
continue;
1084-
1085-
n++;
1086-
}
1087-
}
1088-
1089-
if (n == 0) {
1090-
*ret = NULL;
1091-
return 0;
1092-
}
1093-
1094-
answer = dns_answer_new(n);
1095-
if (!answer)
1096-
return -ENOMEM;
1097-
1098-
HASHMAP_FOREACH(i, cache->by_key) {
1099-
DnsCacheItem *j;
1100-
1101-
LIST_FOREACH(by_key, j, i) {
1102-
if (!j->rr)
1103-
continue;
1104-
1105-
r = dns_answer_add(
1106-
answer, j->rr, j->ifindex, j->authenticated ? DNS_ANSWER_AUTHENTICATED : 0);
1107-
if (r < 0)
1108-
return r;
1109-
}
1110-
}
1111-
1112-
*ret = TAKE_PTR(answer);
1113-
1114-
return n;
1115-
}
1116-
1117-
void dns_cache_dump_to_file(DnsCache *cache, FILE *f) {
1069+
void dns_cache_dump(DnsCache *cache, FILE *f) {
11181070
DnsCacheItem *i;
11191071

11201072
if (!cache)

src/resolve/resolved-dns-cache.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ int dns_cache_lookup(DnsCache *c, DnsResourceKey *key, bool clamp_ttl, int *rcod
2727

2828
int dns_cache_check_conflicts(DnsCache *cache, DnsResourceRecord *rr, int owner_family, const union in_addr_union *owner_address);
2929

30-
void dns_cache_dump_to_file(DnsCache *cache, FILE *f);
31-
int dns_cache_dump_to_answer(DnsCache *cache, DnsAnswer **answer);
30+
void dns_cache_dump(DnsCache *cache, FILE *f);
3231
bool dns_cache_is_empty(DnsCache *cache);
3332

3433
unsigned dns_cache_size(DnsCache *cache);

src/resolve/resolved-dns-scope.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ void dns_scope_dump(DnsScope *s, FILE *f) {
11591159

11601160
if (!dns_cache_is_empty(&s->cache)) {
11611161
fputs("CACHE:\n", f);
1162-
dns_cache_dump_to_file(&s->cache, f);
1162+
dns_cache_dump(&s->cache, f);
11631163
}
11641164
}
11651165

0 commit comments

Comments
 (0)