-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,7 +214,12 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) | |
| .SetAddressType(IPAddressType::kIPv6) | ||
| .SetListenPort(mOperationalServicePort) | ||
| .SetNativeParams(initParams.endpointNativeParams) | ||
|
|
||
| #if INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
| , | ||
| TcpListenParameters(DeviceLayer::TCPEndPointManager()) | ||
| .SetAddressType(IPAddressType::kIPv6) | ||
| .SetListenPort(mOperationalServicePort) | ||
| #endif | ||
| #if INET_CONFIG_ENABLE_IPV4 | ||
| , | ||
| UdpListenParameters(DeviceLayer::UDPEndPointManager()) | ||
|
|
@@ -225,12 +230,6 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) | |
| , | ||
| BleListenParameters(DeviceLayer::ConnectivityMgr().GetBleLayer()) | ||
| #endif | ||
| #if INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
| , | ||
| TcpListenParameters(DeviceLayer::TCPEndPointManager()) | ||
| .SetAddressType(IPAddressType::kIPv6) | ||
| .SetListenPort(mOperationalServicePort) | ||
| #endif | ||
| #if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF | ||
| , | ||
| Transport::WiFiPAFListenParameters(DeviceLayer::ConnectivityMgr().GetWiFiPAF()) | ||
|
|
@@ -330,6 +329,10 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) | |
| app::DnssdServer::Instance().SetICDManager(&mICDManager); | ||
| #endif // CHIP_CONFIG_ENABLE_ICD_SERVER | ||
|
|
||
| #if INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
| app::DnssdServer::Instance().SetTCPServerEnabled(mTransports.GetTransport().GetImplAtIndex<1>().IsServerListenEnabled()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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....
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
|
|
||
| if (GetFabricTable().FabricCount() != 0) | ||
| { | ||
| #if CONFIG_NETWORK_LAYER_BLE | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,8 +167,15 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params) | |
| ReturnErrorOnFailure(stateParams.transportMgr->Init(Transport::UdpListenParameters(stateParams.udpEndPointManager) | ||
| .SetAddressType(Inet::IPAddressType::kIPv6) | ||
| .SetListenPort(params.listenPort) | ||
| #if INET_CONFIG_ENABLE_IPV4 | ||
| #if INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the ordering change here?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| #endif | ||
| #if INET_CONFIG_ENABLE_IPV4 | ||
| , | ||
| Transport::UdpListenParameters(stateParams.udpEndPointManager) | ||
| .SetAddressType(Inet::IPAddressType::kIPv4) | ||
| .SetListenPort(params.listenPort) | ||
|
|
@@ -177,12 +184,6 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params) | |
| , | ||
| Transport::BleListenParameters(stateParams.bleLayer) | ||
| #endif | ||
| #if INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
| , | ||
| Transport::TcpListenParameters(stateParams.tcpEndPointManager) | ||
| .SetAddressType(IPAddressType::kIPv6) | ||
| .SetListenPort(params.listenPort) | ||
| #endif | ||
| #if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF | ||
| , | ||
| Transport::WiFiPAFListenParameters() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,6 +106,8 @@ class Tuple : public Base | |
| { | ||
| return TCPDisconnectImpl<0>(conn, shouldAbort); | ||
| } | ||
|
|
||
| bool IsServerListenEnabled() override { return IsServerListenEnabledImpl<0>(); } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"? |
||
| #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT | ||
|
|
||
| void Close() override { return CloseImpl<0>(); } | ||
|
|
@@ -222,6 +224,18 @@ class Tuple : public Base | |
| template <size_t N, typename std::enable_if<(N >= sizeof...(TransportTypes))>::type * = nullptr> | ||
| void TCPDisconnectImpl(Transport::ActiveTCPConnectionState * conn, bool shouldAbort = 0) | ||
| {} | ||
|
|
||
| template <size_t N, typename std::enable_if<(N < sizeof...(TransportTypes))>::type * = nullptr> | ||
| bool IsServerListenEnabledImpl() | ||
| { | ||
| return std::get<N>(mTransports).IsServerListenEnabled() || IsServerListenEnabledImpl<N + 1>(); | ||
| } | ||
|
|
||
| template <size_t N, typename std::enable_if<(N >= sizeof...(TransportTypes))>::type * = nullptr> | ||
| bool IsServerListenEnabledImpl() | ||
| { | ||
| return false; | ||
| } | ||
| #endif // 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.
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.