-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add separate knob for TCP server listen enabling. #36979
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
Conversation
133ccd7 to
7699ee4
Compare
|
PR #36979: Size comparison from e7f6d0e to 7699ee4 Full report (19 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, nrfconnect, qpg, stm32, tizen)
|
|
PR #36979: Size comparison from e7f6d0e to ec213db Full report (70 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
andy31415
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pidarped please add a #### Testing section to the PR summary.
Use a boolean indicator for TCP server enabling in the TCPListenParameters to signal Server enabling during initialization. By default, TCP Server is enabled on the Server side, and disabled on the client/controller side. Add API in TransportMgr to access this setting so that DNS-SD operational advertisements for TCP can be set accordingly.
366359b to
24df222
Compare
Co-authored-by: Andrei Litvin <[email protected]>
24df222 to
1ba654a
Compare
|
PR #36979: Size comparison from d3204f6 to 1ba654a Full report (70 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
|
|
||
| #if INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
| , | ||
| TcpListenParameters(DeviceLayer::TCPEndPointManager()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some documentation explaining that the ordering here is very important and pointing to the code that depends on that ordering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to add the documentation in a subsequent PR. Had intended to do so in this one but it auto-merged before that.
| #endif // CHIP_CONFIG_ENABLE_ICD_SERVER | ||
|
|
||
| #if INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
| app::DnssdServer::Instance().SetTCPServerEnabled(mTransports.GetTransport().GetImplAtIndex<1>().IsServerListenEnabled()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is weird. I would have expected the TcpListenParameters to tell the transport whether to enable server, not the transport deciding independently and then the Server having to get the info out somehow. And indeed the parameters have a flag for this. So what's going on here?
In particular, looks to me like Server always enables listen, so this whole IsServerListenEnabled complexity is not needed....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TcpListenParameters does carry the flag and it is set while initializing the TransportMgr. The way I have it in this PR is enabling the Server as a default setting in TcpListenParameters. The controller explicitly sets it to false.
For setting it in the DnssdServer, it is being retrieved from the Transport using the logic above because the setting in the TransportMgr is being assumed to be the source of truth.
| .SetAddressType(Inet::IPAddressType::kIPv6) | ||
| .SetListenPort(params.listenPort) | ||
| #if INET_CONFIG_ENABLE_IPV4 | ||
| #if INET_CONFIG_ENABLE_TCP_ENDPOINT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the ordering change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And note that the ordering here is public API certainly for Server, so you have no idea whom you might be breaking with these ordering changes. Like "introduces silent security bugs" breaking.
| Transport::TcpListenParameters(stateParams.tcpEndPointManager) | ||
| .SetAddressType(IPAddressType::kIPv6) | ||
| .SetListenPort(params.listenPort) | ||
| .SetServerListenEnabled(false) // Initialize as a TCP Client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, why would we force controllers to never be TCP servers? This isn't a "by default" like the PR description misleadingly says: it's just force-disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to keep the interaction simple, I was assuming controllers(like chip-tool and commissioning clients) to be TCP clients.
The TcpListenParameters probably need to be percolated further up in order to make it a truly configurable parameter. For now, I have set the controller to be a TCP Client.
| return TCPDisconnectImpl<0>(conn, shouldAbort); | ||
| } | ||
|
|
||
| bool IsServerListenEnabled() override { return IsServerListenEnabledImpl<0>(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used? It doesn't seem to be used. The one use in Server gets something explicitly by index...
And what does this function even mean? "We have some transport that's listening as a server"?
What does it even mean for a generic transport (e.g. UDP) to be "listening as a server"?
|
Here's what I propose concretely:
|
* Add separate knob for TCP server listen enabling. Use a boolean indicator for TCP server enabling in the TCPListenParameters to signal Server enabling during initialization. By default, TCP Server is enabled on the Server side, and disabled on the client/controller side. Add API in TransportMgr to access this setting so that DNS-SD operational advertisements for TCP can be set accordingly. * Add 2 unit tests * Apply suggestions from code review Co-authored-by: Andrei Litvin <[email protected]> --------- Co-authored-by: Andrei Litvin <[email protected]>
Address post-merge comments from PR project-chip#36979. Keep original order of raw transports in the TransportMgr tuple because it is part of the public API on the controller side. When setting the TCPServerListen flag in DnssdServer, use the same value as in TcpListenParams directly, instead of fetching from the TransportMgr.
* Restore original order of transports in TransportMgr. Address post-merge comments from PR #36979. Keep original order of raw transports in the TransportMgr tuple because it is part of the public API on the controller side. When setting the TCPServerListen flag in DnssdServer, use the same value as in TcpListenParams directly, instead of fetching from the TransportMgr. * Address review comments.
Use a boolean indicator for TCP server enabling in the TCPListenParameters to signal Server enabling during initialization. By default, TCP Server is enabled on the Server side, and disabled on the client/controller side.
Add API in TransportMgr to access this setting so that DNS-SD operational advertisements for TCP can be set accordingly.
Testing
Add 2 unit tests for checking TCP initialization as TCPClient, and both TCPClient and Server.