diff options
-rw-r--r-- | man/coredumpctl.xml | 8 | ||||
-rw-r--r-- | man/systemd-detect-virt.xml | 4 | ||||
-rw-r--r-- | shell-completion/bash/coredumpctl | 3 | ||||
-rw-r--r-- | shell-completion/zsh/_coredumpctl | 1 | ||||
-rw-r--r-- | src/basic/virt.c | 20 | ||||
-rw-r--r-- | src/resolve/resolved-dns-scope.c | 58 | ||||
-rw-r--r-- | src/resolve/resolved-dns-scope.h | 2 | ||||
-rw-r--r-- | src/resolve/resolved-dns-transaction.c | 2 | ||||
-rw-r--r-- | src/resolve/resolved-link.c | 4 | ||||
-rw-r--r-- | src/resolve/resolved-link.h | 1 | ||||
-rw-r--r-- | src/resolve/resolved-mdns.c | 21 |
11 files changed, 75 insertions, 49 deletions
diff --git a/man/coredumpctl.xml b/man/coredumpctl.xml index abc245be5e..72a244d2eb 100644 --- a/man/coredumpctl.xml +++ b/man/coredumpctl.xml @@ -92,6 +92,14 @@ </varlistentry> <varlistentry> + <term><option>-r</option></term> + <term><option>--reverse</option></term> + + <listitem><para>Reverse output so that the newest entries are displayed first. + </para></listitem> + </varlistentry> + + <varlistentry> <term><option>-F</option> <replaceable>FIELD</replaceable></term> <term><option>--field=</option><replaceable>FIELD</replaceable></term> diff --git a/man/systemd-detect-virt.xml b/man/systemd-detect-virt.xml index 996c2fa256..dc10b4dd43 100644 --- a/man/systemd-detect-virt.xml +++ b/man/systemd-detect-virt.xml @@ -91,12 +91,12 @@ <row> <entry valign="top" morerows="10">VM</entry> <entry><varname>qemu</varname></entry> - <entry>QEMU software virtualization</entry> + <entry>QEMU software virtualization, without KVM</entry> </row> <row> <entry><varname>kvm</varname></entry> - <entry>Linux KVM kernel virtual machine</entry> + <entry>Linux KVM kernel virtual machine, from within QEMU</entry> </row> <row> diff --git a/shell-completion/bash/coredumpctl b/shell-completion/bash/coredumpctl index 6091677506..d34f89e2bb 100644 --- a/shell-completion/bash/coredumpctl +++ b/shell-completion/bash/coredumpctl @@ -37,7 +37,8 @@ __journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC} _coredumpctl() { local i verb comps local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} - local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field -1' + local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field -1 + -r --reverse' local -A VERBS=( [LIST]='list' diff --git a/shell-completion/zsh/_coredumpctl b/shell-completion/zsh/_coredumpctl index e4c04a697f..64b44c1214 100644 --- a/shell-completion/zsh/_coredumpctl +++ b/shell-completion/zsh/_coredumpctl @@ -32,6 +32,7 @@ _arguments \ {-o+,--output=}'[Write output to FILE]:output file:_files' \ {-F+,--field=}'[Show field in list output]:field' \ '-1[Show information about most recent entry only]' \ + {-r,--reverse}'[Show the newest entries first]' \ '--no-pager[Do not pipe output into a pager]' \ '--no-legend[Do not print the column headers]' \ {-h,--help}'[Show this help]' \ diff --git a/src/basic/virt.c b/src/basic/virt.c index 03ce71a728..0fbbdea602 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -316,25 +316,31 @@ static int detect_vm_zvm(void) { /* Returns a short identifier for the various VM implementations */ int detect_vm(void) { static thread_local int cached_found = _VIRTUALIZATION_INVALID; - int r; + int r, cpuid; if (cached_found >= 0) return cached_found; /* We have to use the correct order here: - * Some virtualization technologies do use KVM hypervisor but are - * expected to be detected as something else. So detect DMI first. * - * An example is Virtualbox since version 5.0, which uses KVM backend. - * Detection via DMI works corretly, the CPU ID would find KVM - * only. */ + * -> First try to detect qemu/kvm and return 'kvm'. + * -> Some virtualization technologies do use KVM hypervisor but are + * expected to be detected as something else. Virtualbox since + * version 5.0 is an example. So detect DMI next. + * -> Get infos from CPUID third. */ + + cpuid = detect_vm_cpuid(); r = detect_vm_dmi(); + + if (r == VIRTUALIZATION_QEMU && cpuid == VIRTUALIZATION_KVM) + return cpuid; + if (r < 0) return r; if (r != VIRTUALIZATION_NONE) goto finish; - r = detect_vm_cpuid(); + r = cpuid; if (r < 0) return r; if (r != VIRTUALIZATION_NONE) diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c index 750409eebf..ffaefbe3f2 100644 --- a/src/resolve/resolved-dns-scope.c +++ b/src/resolve/resolved-dns-scope.c @@ -793,15 +793,8 @@ DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, /* Try to find an ongoing transaction that is a equal to the * specified question */ t = hashmap_get(scope->transactions_by_key, key); - if (!t) { - DnsResourceKey *key_any; - - key_any = dns_resource_key_new(DNS_CLASS_IN, DNS_TYPE_ANY, dns_resource_key_name(key)); - t = hashmap_get(scope->transactions_by_key, key_any); - key_any = dns_resource_key_unref(key_any); - if (!t) - return NULL; - } + if (!t) + return NULL; /* Refuse reusing transactions that completed based on cached * data instead of a real packet, if that's requested. */ @@ -1068,49 +1061,46 @@ static int on_announcement_timeout(sd_event_source *s, usec_t usec, void *userda scope->announce_event_source = sd_event_source_unref(scope->announce_event_source); - dns_scope_announce(scope, false); + (void) dns_scope_announce(scope, false); return 0; } -void dns_scope_announce(DnsScope *scope, bool goodbye) { +int dns_scope_announce(DnsScope *scope, bool goodbye) { _cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL; _cleanup_(dns_packet_unrefp) DnsPacket *p = NULL; LinkAddress *a; int r; if (!scope) - return; + return 0; if (scope->protocol != DNS_PROTOCOL_MDNS) - return; + return 0; + + answer = dns_answer_new(scope->link->n_addresses * 2); + if (!answer) + return log_oom(); - answer = dns_answer_new(4); LIST_FOREACH(addresses, a, scope->link->addresses) { r = dns_answer_add(answer, a->mdns_address_rr, 0, goodbye ? DNS_ANSWER_GOODBYE : DNS_ANSWER_CACHE_FLUSH); - if (r < 0) { - log_debug_errno(r, "Failed to add address RR to answer: %m"); - return; - } + if (r < 0) + return log_debug_errno(r, "Failed to add address RR to answer: %m"); + r = dns_answer_add(answer, a->mdns_ptr_rr, 0, goodbye ? DNS_ANSWER_GOODBYE : DNS_ANSWER_CACHE_FLUSH); - if (r < 0) { - log_debug_errno(r, "Failed to add PTR RR to answer: %m"); - return; - } + if (r < 0) + return log_debug_errno(r, "Failed to add PTR RR to answer: %m"); } if (dns_answer_isempty(answer)) - return; + return 0; r = dns_scope_make_reply_packet(scope, 0, DNS_RCODE_SUCCESS, NULL, answer, NULL, false, &p); - if (r < 0) { - log_debug_errno(r, "Failed to build reply packet: %m"); - return; - } + if (r < 0) + return log_debug_errno(r, "Failed to build reply packet: %m"); + r = dns_scope_emit_udp(scope, -1, p); - if (r < 0) { - log_debug_errno(r, "Failed to send reply packet: %m"); - return; - } + if (r < 0) + return log_debug_errno(r, "Failed to send reply packet: %m"); /* In section 8.3 of RFC6762: "The Multicast DNS responder MUST send at least two unsolicited * responses, one second apart." */ @@ -1130,6 +1120,10 @@ void dns_scope_announce(DnsScope *scope, bool goodbye) { MDNS_JITTER_RANGE_USEC, on_announcement_timeout, scope); if (r < 0) - log_debug_errno(r, "Failed to schedule second announcement: %m"); + return log_debug_errno(r, "Failed to schedule second announcement: %m"); + + (void) sd_event_source_set_description(scope->announce_event_source, "mdns-announce"); } + + return 0; } diff --git a/src/resolve/resolved-dns-scope.h b/src/resolve/resolved-dns-scope.h index 360d86bc25..6f94b1fdcd 100644 --- a/src/resolve/resolved-dns-scope.h +++ b/src/resolve/resolved-dns-scope.h @@ -117,4 +117,4 @@ bool dns_scope_network_good(DnsScope *s); int dns_scope_ifindex(DnsScope *s); -void dns_scope_announce(DnsScope *scope, bool goodbye); +int dns_scope_announce(DnsScope *scope, bool goodbye); diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index 0c7a8867fb..69e1d58ccf 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -364,7 +364,7 @@ void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state) { dns_zone_item_notify(z); SWAP_TWO(t->notify_zone_items, t->notify_zone_items_done); if (t->probing) - dns_scope_announce(t->scope, false); + (void) dns_scope_announce(t->scope, false); SET_FOREACH_MOVE(d, t->notify_transactions_done, t->notify_transactions) dns_transaction_notify(d, t); diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c index 7b6e4f8398..44c0cd654f 100644 --- a/src/resolve/resolved-link.c +++ b/src/resolve/resolved-link.c @@ -669,6 +669,7 @@ int link_address_new(Link *l, LinkAddress **ret, int family, const union in_addr a->link = l; LIST_PREPEND(addresses, l->addresses, a); + l->n_addresses++; if (ret) *ret = a; @@ -683,6 +684,9 @@ LinkAddress *link_address_free(LinkAddress *a) { if (a->link) { LIST_REMOVE(addresses, a->link->addresses, a); + assert(a->link->n_addresses > 0); + a->link->n_addresses--; + if (a->llmnr_address_rr) { if (a->family == AF_INET && a->link->llmnr_ipv4_scope) dns_zone_remove_rr(&a->link->llmnr_ipv4_scope->zone, a->llmnr_address_rr); diff --git a/src/resolve/resolved-link.h b/src/resolve/resolved-link.h index 1e9be8ae84..55a56b7906 100644 --- a/src/resolve/resolved-link.h +++ b/src/resolve/resolved-link.h @@ -60,6 +60,7 @@ struct Link { unsigned flags; LIST_HEAD(LinkAddress, addresses); + unsigned n_addresses; LIST_HEAD(DnsServer, dns_servers); DnsServer *current_dns_server; diff --git a/src/resolve/resolved-mdns.c b/src/resolve/resolved-mdns.c index f5cae6f682..c40e8f75f0 100644 --- a/src/resolve/resolved-mdns.c +++ b/src/resolve/resolved-mdns.c @@ -78,10 +78,8 @@ static int mdns_scope_process_query(DnsScope *s, DnsPacket *p) { assert(p); r = dns_packet_extract(p); - if (r < 0) { - log_debug_errno(r, "Failed to extract resource records from incoming packet: %m"); - return r; - } + if (r < 0) + return log_debug_errno(r, "Failed to extract resource records from incoming packet: %m"); /* TODO: there might be more than one question in mDNS queries. */ assert_return((dns_question_size(p->question) > 0), -EINVAL); @@ -173,6 +171,19 @@ static int on_mdns_packet(sd_event_source *s, int fd, uint32_t revents, void *us t = dns_scope_find_transaction(scope, rr->key, false); if (t) dns_transaction_process_reply(t, p); + + /* Also look for the various types of ANY transactions */ + t = dns_scope_find_transaction(scope, &DNS_RESOURCE_KEY_CONST(rr->key->class, DNS_TYPE_ANY, dns_resource_key_name(rr->key)), false); + if (t) + dns_transaction_process_reply(t, p); + + t = dns_scope_find_transaction(scope, &DNS_RESOURCE_KEY_CONST(DNS_CLASS_ANY, rr->key->type, dns_resource_key_name(rr->key)), false); + if (t) + dns_transaction_process_reply(t, p); + + t = dns_scope_find_transaction(scope, &DNS_RESOURCE_KEY_CONST(DNS_CLASS_ANY, DNS_TYPE_ANY, dns_resource_key_name(rr->key)), false); + if (t) + dns_transaction_process_reply(t, p); } dns_cache_put(&scope->cache, NULL, DNS_PACKET_RCODE(p), p->answer, false, (uint32_t) -1, 0, p->family, &p->sender); @@ -182,7 +193,7 @@ static int on_mdns_packet(sd_event_source *s, int fd, uint32_t revents, void *us r = mdns_scope_process_query(scope, p); if (r < 0) { - log_debug("mDNS query processing failed."); + log_debug_errno(r, "mDNS query processing failed: %m"); return 0; } } else |