Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Esp32] mdns filter to handle MDNS traffic for esp32 #27961

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PSONALl
Copy link
Contributor

@PSONALl PSONALl commented Jul 14, 2023

  • This PR adds a filter to handle MDNS packets in queue and if queue gets full it drops the packets
  • The filter will also drop all IPV4 mdns packets
  • It helps to save heap during commissioning in crowded MDNS environment

Testing

  • Tested commissioning and control 30-40 times and verified heap changes
Comment on lines +27 to +28
namespace mdns {
namespace Minimal {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an odd namespace to put this in....

// Non-mDNS is not filtered
VerifyOrReturnValue(pktInfo.DestPort == kMdnsPort, FilterOutcome::kAllowPacket);

if (pktInfo.DestAddress.IsIPv4() && pktInfo.DestPort == kMdnsPort)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this bothering about checking pktInfo.DestPort again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added change which will drop all IPv4 Mdns packets and allow IPv6 Mdns packets

{
if (!mStopLogging)
{
ChipLogError(Discovery, "Started dropping mDNS from storm.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case has nothing to do with "storm", This is going to log as soon as we get an ipv4 packet, then stop logging usefully....


protected:
std::atomic_size_t mNumQueuedMdnsPackets = { 0 };
size_t mMaxQueuedPackets = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size_t mMaxQueuedPackets = 0;
const size_t mMaxQueuedPackets = 0;

so it's clear why a non-atomic thing is ok here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this change

{
if (mStopLogging)
{
mStopLogging = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are really worried about the before/after functions being called at the same time on different threads, this logic around mStopLogging is broken. By the time we get here we might have already gone back to a state where mNumQueuedMdnsPackets >= mMaxQueuedPackets, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a change which would not break

@bzbarsky-apple
Copy link
Contributor

@PSONALl Please ping me on Slack when you make the updates per above.

@stale
Copy link

stale bot commented Oct 15, 2023

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issue or PR label Oct 15, 2023
@bzbarsky-apple bzbarsky-apple removed the stale Stale issue or PR label Oct 16, 2023
@pullapprove pullapprove bot requested a review from pidarped November 8, 2023 16:27
@woody-apple woody-apple added this to the No Target Milestone milestone Nov 27, 2023
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


PSONALl seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

stale bot commented Mar 13, 2024

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issue or PR label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment