From c0d02f799562e4c34a6c785f1a336a3f3497b1b0 Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Thu, 7 Oct 2021 12:07:04 -0400 Subject: [PATCH 1/2] 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 --- src/lib/mdns/Advertiser_ImplMinimalMdns.cpp | 4 +++- src/lib/mdns/minimal/ResponseSender.cpp | 6 ++++-- src/lib/mdns/minimal/responders/QueryResponder.cpp | 2 -- 3 files changed, 7 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..3629370393ac91 100644 --- a/src/lib/mdns/minimal/ResponseSender.cpp +++ b/src/lib/mdns/minimal/ResponseSender.cpp @@ -161,16 +161,18 @@ 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++) { From 1487b4533ec49a5f22215bdc890a74cf774bb699 Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Thu, 7 Oct 2021 14:08:02 -0400 Subject: [PATCH 2/2] Restyled --- src/lib/mdns/minimal/ResponseSender.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/mdns/minimal/ResponseSender.cpp b/src/lib/mdns/minimal/ResponseSender.cpp index 3629370393ac91..975269d8c89120 100644 --- a/src/lib/mdns/minimal/ResponseSender.cpp +++ b/src/lib/mdns/minimal/ResponseSender.cpp @@ -166,7 +166,8 @@ CHIP_ERROR ResponseSender::FlushReply() if (mSendState.SendUnicast()) { - ChipLogProgress(Discovery, "Directly sending mDns reply to peer %s on port %d", srcAddressString, 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())); }