From 1075803075eae82c0fc05bd1f962fafba302a1cd Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Thu, 7 Oct 2021 22:04:50 -0400 Subject: [PATCH] Improve logging for minMdns (#10319) * Improve logging for minMdns - Remove duplicate log lines that falsely indicated sending when it was just building responses - When responding, clarify the identity of the querier that caused the response to be generated and sent Testing done: - Ran unit tests and all-clusters-app commissioning on Linux * Restyled --- src/lib/mdns/Advertiser_ImplMinimalMdns.cpp | 4 +++- src/lib/mdns/minimal/ResponseSender.cpp | 7 +++++-- src/lib/mdns/minimal/responders/QueryResponder.cpp | 2 -- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/mdns/Advertiser_ImplMinimalMdns.cpp b/src/lib/mdns/Advertiser_ImplMinimalMdns.cpp index 65b8f55aff7fe7..12a155825390ad 100644 --- a/src/lib/mdns/Advertiser_ImplMinimalMdns.cpp +++ b/src/lib/mdns/Advertiser_ImplMinimalMdns.cpp @@ -246,7 +246,9 @@ class AdvertiserMinMdns : public ServiceAdvertiser, void AdvertiserMinMdns::OnMdnsPacketData(const BytesRange & data, const chip::Inet::IPPacketInfo * info) { #ifdef DETAIL_LOGGING - ChipLogDetail(Discovery, "MinMdns received a query."); + char srcAddressString[chip::Inet::kMaxIPAddressStringLength]; + VerifyOrDie(info->SrcAddress.ToString(srcAddressString) != nullptr); + ChipLogDetail(Discovery, "Received an mDNS query from %s", srcAddressString); #endif mCurrentSource = info; diff --git a/src/lib/mdns/minimal/ResponseSender.cpp b/src/lib/mdns/minimal/ResponseSender.cpp index b8f412146a7b87..975269d8c89120 100644 --- a/src/lib/mdns/minimal/ResponseSender.cpp +++ b/src/lib/mdns/minimal/ResponseSender.cpp @@ -161,16 +161,19 @@ CHIP_ERROR ResponseSender::FlushReply() if (mResponseBuilder.HasResponseRecords()) { + char srcAddressString[chip::Inet::kMaxIPAddressStringLength]; + VerifyOrDie(mSendState.GetSourceAddress().ToString(srcAddressString) != nullptr); if (mSendState.SendUnicast()) { - ChipLogProgress(Discovery, "Directly sending mDns reply to peer on port %d", mSendState.GetSourcePort()); + ChipLogProgress(Discovery, "Directly sending mDns reply to peer %s on port %d", srcAddressString, + mSendState.GetSourcePort()); ReturnErrorOnFailure(mServer->DirectSend(mResponseBuilder.ReleasePacket(), mSendState.GetSourceAddress(), mSendState.GetSourcePort(), mSendState.GetSourceInterfaceId())); } else { - ChipLogProgress(Discovery, "Broadcasting mDns reply"); + ChipLogProgress(Discovery, "Broadcasting mDns reply for query from %s", srcAddressString); ReturnErrorOnFailure( mServer->BroadcastSend(mResponseBuilder.ReleasePacket(), kMdnsStandardPort, mSendState.GetSourceInterfaceId())); } diff --git a/src/lib/mdns/minimal/responders/QueryResponder.cpp b/src/lib/mdns/minimal/responders/QueryResponder.cpp index 6966908656df92..0b94abe746740e 100644 --- a/src/lib/mdns/minimal/responders/QueryResponder.cpp +++ b/src/lib/mdns/minimal/responders/QueryResponder.cpp @@ -139,8 +139,6 @@ void QueryResponderBase::MarkAdditionalRepliesFor(QueryResponderIterator it) void QueryResponderBase::AddAllResponses(const chip::Inet::IPPacketInfo * source, ResponderDelegate * delegate) { - ChipLogProgress(Discovery, "Replying to DNS-SD service listing request"); - // reply to dns-sd service list request for (size_t i = 0; i < mResponderInfoSize; i++) {