Don't compile the installIPv6RABlocker if unused - #5825
Conversation
Signed-off-by: Red Vyper <dev@redvyper.org>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughChangesIPv6 RA blocker compatibility
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to The PR only prevents an unused IPv6 router-advertisement blocker from being built on ESP-IDF 5+ while preserving existing ESP-IDF 4 behavior, so no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Title checkExplanation The title clearly identifies the main change: preventing compilation of Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Warning |
|
Isn't it ironic that the AI that checks the code says that a commit contains AI slop just because I have the same comment repeated for clarity next to the same pre-processor if clause? |
|
I strongly disagree, and IMO this is the worst kind of slop: pointless extra code that adds only noise and clutter but makes no difference to the final output. These unnecessary |
Fair enough.
Not that great going that direct on someone contributing. To answer on the merit, I don't think your objection holds up for the following reasons. How can a person know that some of those ifdefs were deliberately omitted if there is no comment and no commit message saying so? You know it because you wrote the original piece of code but sometimes you need to take into account other people's fresh point of view and let them know in advance the rationale behind a piece of code. On the linker doing it for us: Moreover, I'd like you consider the bigger picture, which is the final goal of getting rid completely at this piece of code entirely. After all, this is just a workaround needed because the project doesn't support IPv6 yet but the underlying LwIP does it. Implementing IPv6 properly will make this piece of code not necessary anymore. |
|
I think @willmmiles is right, both |
|
@softhack007 I am sure that's the case, still I think that being sure that something happens because the pre-processor gets the right and clear hint is better than hoping for the best. I personally think that's better but since that function is supposed to be removed at some point in time, at least when I'm finished with the IPv6 implementation for ESP32, I won't insist on the matter as much as my believes push me. |
|
@RedVyper I am sure - if it would not be the case, our firmware binaries would be much larger. |
You're right, and I'm sorry. I posted in anger, and that's not fair to you or any other contributors. It doesn't help you learn or improve our code. I'll make sure to cool off before posting in the future.
Best practices in C/C++ code are to avoid using the preprocessor unless it's absolutely necessary. It's always a loaded footgun; while there are plenty of tricks that can't be achieved any other way, it should treated as a method of last resort. We already have enough such noise making it difficult to follow code - in a case like this, less is more. Regarding documentation, as a general rule, I don't think it's necessary to comment every time a best practice is followed.
Respectfully,
Sadly, I fear we are stuck with it until we remove IDF v4 support. The IPv6 "support" in the IDF v4 platform is essentially unworkable due to bugs like this one -- the two stacks poorly share a number of global variables resulting in much confusion if either protocol is broken or misconfigured in the local network environment. This workaround is a case in point: we need it because, even when "disabled", IPv6 packets are still overwriting global variables used by the IPv4 stack. I wish I could say that was an isolated bug, but to my read of the code, that sort of issue was typical of the quality of the integration in that release. I believe that enabling IPv6 in IDF v4 will result in more issues caused by platform bugs than successful use cases. I've no objections to enabling IPv6 with the newer IDF platform releases, though -- hopefully we won't find any other showstopping bugs. As you're pursuing that end, I'd encourage you to review the factoring of the various network management functions to avoid that feature also turning into an |
Thanks for having noticed that. My goal is to give my contribute to the project and make it better. Nothing else.
I can understand the idea that "if it's not there you cannot have it break something" but I'm still convinced that keeping control over how the code is pre-processed and compiled is essential. Relying to other software that one doesn't control is kinda weird to me. I understand that you can say that you kinda have control over that by passing it the various parameters but still it feels wrong to me.
Yet you noticed that without proper comments I didn't know what your intentions were when you wrote that part of the code. This is why I am a big fan of "keep the code as concise as possible while being allowed to be very detailed on the comments". They don't waste space in the build, after all.
As I said before I hope that something works the way it's intended but if I can check myself that it cannot go wrong, then I prefer to do so. Please note that some of my comments up to here are strong opinions but yet opinions. It's totally normal that you have your own. If I have to insist on something I'd go with proper comments to improve legibility to people that are reading the code for the first time and need context.
My goal for now is IPv6 support only for IDF v5.
I'm trying to work by little steps, so that my PRs are small and easily reviewable. At a certain point there will be the chance to refactor the network section, perhaps. But for now I want to be as surgical as possible. |
I don't really think that's a meaningful thing to do in this context. If I added a comment every time I omitted an unnecessary line of code, at the limit that's an infinite amount of comments. How am I to know what line you're thinking of that I didn't write? I appreciate that you've got a different opinion on
I gathered that, and that's why I brought it up -- I'm concerned the "surgical" approach will result in messy code and a larger maintenance burden ( |
|
Back on-topic: what makes this PR a bit more questionable is that the function to install the blocker is removed, however the blocker itself As the PR is basically a no-op from firmware binary perspective, and compilation guards are already in place to prevent compilation when the core does not define |
While I keep disagreeing with your opinion, I value it and your role so I will adapt to what you think it's best for the project.
There's a reason why the other PR is a draft and I won't remove the draft state until I get the web UI on par with IPv4. But I need your opinion on the state of the PR as it is now because it's easier for me to adapt the base of that PR if you give me your opinion on the small bits that I submitted until now. I already have two new features ready that I'd like to adapt to your vision.
I basically have the same comment that I gave @willmmiles about this. And I also have the same answer. I accept your vision on this and we can move no problem. After all, this function will become obsolete when the other PR will be in a mergeable state. But to get there I need his opinion on the code that's there right now. |
The function
installIPv6RABlocker()installs a raw-ICMPv6 callback that blackholes unsolicited IPv6 router advertisements, working around the LwIP bug where an RA overwrites the IPv4 DNS servers. That workaround is only needed on ESP-IDF v4 and older: the call site inwled.cpphas been gated onESP_IDF_VERSION_MAJOR < 5for a while, but the function's definition (network.cpp) and declaration (fcn_declare.h) were not.So on ESP-IDF v5 targets the function was still compiled and emitted into the binary despite having no callers. This adds the matching guards so the three sites agree.
No behavioural change on any target: on IDF v4 the blocker is compiled and installed exactly as before; on IDF v5 it was never called, and now simply isn't built.
Summary by CodeRabbit