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

[Group] Add multicast listening on linux #12342

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ jobs:
strategy:
matrix:
build_variant: [no-ble-tsan]
group_variant: [no-ble-tsan-test-group]
chip_tool: ["", -same-event-loop]
env:
BUILD_VARIANT: ${{matrix.build_variant}}
GROUP_VARIANT: ${{matrix.group_variant}}
CHIP_TOOL_VARIANT: ${{matrix.chip_tool}}

if: github.actor != 'restyled-io[bot]'
Expand Down Expand Up @@ -72,7 +74,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-x64-chip-tool-${BUILD_VARIANT}${CHIP_TOOL_VARIANT} \
--target linux-x64-all-clusters-${BUILD_VARIANT} \
--target linux-x64-all-clusters-${GROUP_VARIANT} \
jepenven-silabs marked this conversation as resolved.
Show resolved Hide resolved
--target linux-x64-tv-app-${BUILD_VARIANT} \
build \
--copy-artifacts-to objdir-clone \
Expand All @@ -85,7 +87,7 @@ jobs:
--chip-tool ./out/linux-x64-chip-tool-${BUILD_VARIANT}${CHIP_TOOL_VARIANT}/chip-tool \
run \
--iterations 1 \
--all-clusters-app ./out/linux-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \
--all-clusters-app ./out/linux-x64-all-clusters-${GROUP_VARIANT}/chip-all-clusters-app \
--tv-app ./out/linux-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \
"
- name: Uploading core files
Expand Down Expand Up @@ -167,7 +169,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/tests/run_test_suite.py \
--chip-tool ./out/darwin-x64-chip-tool-${BUILD_VARIANT}${CHIP_TOOL_VARIANT}/chip-tool \
--target-skip-glob 'TV*' \
--target-skip-glob '{TestGroupMessaging,TV_*}' \
run \
--iterations 1 \
--all-clusters-app ./out/darwin-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \
Expand Down
1 change: 1 addition & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def HostTargets():
HostBuildVariant(name="no-ble", enable_ble=False),
HostBuildVariant(name="tsan", conflicts=['asan'], use_tsan=True),
HostBuildVariant(name="asan", conflicts=['tsan'], use_asan=True),
HostBuildVariant(name="test-group", test_group=True),
HostBuildVariant(name="same-event-loop",
validator=AcceptNameWithSubstring('-chip-tool'), separate_event_loop=False),
]
Expand Down
7 changes: 5 additions & 2 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def PlatformName(self):
class HostBuilder(GnBuilder):

def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ipv4=True,
enable_ble=True, use_tsan=False, use_asan=False, separate_event_loop=True
):
enable_ble=True, use_tsan=False, use_asan=False, separate_event_loop=True,
test_group=False):
super(HostBuilder, self).__init__(
root=os.path.join(root, 'examples', app.ExamplePath()),
runner=runner)
Expand All @@ -131,6 +131,9 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ip
if not separate_event_loop:
self.extra_gn_options.append('config_use_separate_eventloop=false')

if test_group:
self.extra_gn_options.append('chip_enable_test_group=true')

def GnBuildArgs(self):
if self.board == HostBoard.NATIVE:
return self.extra_gn_options
Expand Down
9 changes: 9 additions & 0 deletions src/app/server/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
import("//build_overrides/chip.gni")
import("${chip_root}/src/app/common_flags.gni")

# Move this inside the GroupDataProvider once implemented Issue #11075
declare_args() {
chip_enable_test_group = false
jepenven-silabs marked this conversation as resolved.
Show resolved Hide resolved
}

config("server_config") {
defines = []

if (chip_app_use_echo) {
defines += [ "CHIP_APP_USE_ECHO" ]
}

if (chip_enable_test_group) {
defines += [ "TEST_SUITE_GROUP" ]
}
}

static_library("server") {
Expand Down
10 changes: 10 additions & 0 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ CHIP_ERROR Server::Init(AppDelegate * delegate, uint16_t secureServicePort, uint
#endif
SuccessOrExit(err);

// Enable Group Listening
// TODO : Fix this once GroupDataProvider is implemented #Issue 11075
// for (iterate through all GroupDataProvider multicast Address)
// {
#ifdef TEST_SUITE_GROUP
err = mTransports.MulticastGroupJoinLeave(Transport::PeerAddress::Multicast(1, 1234), true);
SuccessOrExit(err);
#endif
//}

err = mSessions.Init(&DeviceLayer::SystemLayer(), &mTransports, &mMessageCounterManager);
SuccessOrExit(err);

Expand Down
3 changes: 1 addition & 2 deletions src/app/tests/TestWriteInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ void TestWriteInteraction::TestWriteClientGroup(nlTestSuite * apSuite, void * ap

err = writeClientHandle.SendWriteRequest(groupSession);

// Write will fail until issue #11078 is completed
NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_NOT_CONNECTED);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
// The internal WriteClient should be shutdown once we SendWriteRequest for group.
NL_TEST_ASSERT(apSuite, nullptr == writeClientHandle.mpWriteClient);
}
Expand Down
1 change: 0 additions & 1 deletion src/darwin/Framework/CHIP/templates/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ function getTests()
'TestIdentifyCluster',
'TestOperationalCredentialsCluster',
'TestModeSelectCluster',
'TestGroupMessaging',
];

const SoftwareDiagnostics = [
Expand Down
101 changes: 0 additions & 101 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions src/inet/UDPEndPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ namespace {

CHIP_ERROR CheckMulticastGroupArgs(InterfaceId aInterfaceId, const IPAddress & aAddress)
{
VerifyOrReturnError(aInterfaceId.IsPresent(), INET_ERROR_UNKNOWN_INTERFACE);
VerifyOrReturnError(aAddress.IsMulticast(), INET_ERROR_WRONG_ADDRESS_TYPE);
return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -1419,7 +1418,7 @@ CHIP_ERROR UDPEndPointImplSockets::IPv6JoinLeaveMulticastGroupImpl(InterfaceId a
}
#endif // CHIP_SYSTEM_CONFIG_USE_PLATFORM_MULTICAST_API

#if defined(INET_IPV6_ADD_MEMBERSHIP) && defined(INET_IPV6_DROP_MEMBERSHIP)
#ifdef IPV6_MULTICAST_IMPLEMENTED
jepenven-silabs marked this conversation as resolved.
Show resolved Hide resolved
const InterfaceId::PlatformType lIfIndex = aInterfaceId.GetPlatformInterface();

struct ipv6_mreq lMulticastRequest;
Expand All @@ -1435,9 +1434,9 @@ CHIP_ERROR UDPEndPointImplSockets::IPv6JoinLeaveMulticastGroupImpl(InterfaceId a
return CHIP_ERROR_POSIX(errno);
}
return CHIP_NO_ERROR;
#else // defined(INET_IPV6_ADD_MEMBERSHIP) && defined(INET_IPV6_DROP_MEMBERSHIP)
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
#endif // defined(INET_IPV6_ADD_MEMBERSHIP) && defined(INET_IPV6_DROP_MEMBERSHIP)
#else
return CHIP_ERROR_NOT_IMPLEMENTED;
#endif
}

#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS
Expand Down Expand Up @@ -2023,7 +2022,7 @@ void UDPEndPoint::Close()

CHIP_ERROR UDPEndPoint::JoinMulticastGroup(InterfaceId aInterfaceId, const IPAddress & aAddress)
{
CHIP_ERROR lRetval = CHIP_ERROR_NOT_IMPLEMENTED;
CHIP_ERROR lRetval = CHIP_NO_ERROR;

const IPAddressType lAddrType = aAddress.Type();
lRetval = CheckMulticastGroupArgs(aInterfaceId, aAddress);
Expand Down
5 changes: 5 additions & 0 deletions src/messaging/ExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const
return;
}
}
else
{
ChipLogProgress(ExchangeManager, "Received Groupcast Message with GroupId of %d",
packetHeader.GetDestinationGroupId().Value());
}

// If it's not a duplicate message, search for an unsolicited message handler if it is marked as being sent by an initiator.
// Since we didn't find an existing exchange that matches the message, it must be an unsolicited message. However all
Expand Down
4 changes: 4 additions & 0 deletions src/platform/Darwin/InetPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#define INET_CONFIG_NUM_TCP_ENDPOINTS 32
#endif // INET_CONFIG_NUM_TCP_ENDPOINTS

#ifndef IPV6_MULTICAST_IMPLEMENTED
#define IPV6_MULTICAST_IMPLEMENTED
#endif

#ifndef INET_CONFIG_NUM_UDP_ENDPOINTS
#define INET_CONFIG_NUM_UDP_ENDPOINTS 32
#endif // INET_CONFIG_NUM_UDP_ENDPOINTS
4 changes: 4 additions & 0 deletions src/platform/Linux/InetPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#define INET_CONFIG_NUM_TCP_ENDPOINTS 32
#endif // INET_CONFIG_NUM_TCP_ENDPOINTS

#ifndef IPV6_MULTICAST_IMPLEMENTED
#define IPV6_MULTICAST_IMPLEMENTED
#endif

#ifndef INET_CONFIG_NUM_UDP_ENDPOINTS
#define INET_CONFIG_NUM_UDP_ENDPOINTS 32
#endif // INET_CONFIG_NUM_UDP_ENDPOINTS
Expand Down
47 changes: 33 additions & 14 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,25 +195,44 @@ CHIP_ERROR SessionManager::SendPreparedMessage(SessionHandle sessionHandle, cons

if (sessionHandle.IsSecure())
{
// Find an active connection to the specified peer node
SecureSession * session = GetSecureSession(sessionHandle);
if (session == nullptr)
if (sessionHandle.IsGroupSession())
{
ChipLogError(Inet, "Secure transport could not find a valid PeerConnection");
return CHIP_ERROR_NOT_CONNECTED;
chip::Transport::PeerAddress multicastAddress =
Transport::PeerAddress::Multicast(sessionHandle.GetFabricIndex(), sessionHandle.GetGroupId().Value());
destination = static_cast<Transport::PeerAddress *>(&multicastAddress);
char addressStr[Transport::PeerAddress::kMaxToStringSize];
multicastAddress.ToString(addressStr, Transport::PeerAddress::kMaxToStringSize);

ChipLogProgress(Inet,
"Sending %s msg %p with MessageCounter:" ChipLogFormatMessageCounter " to %d"
" at monotonic time: %" PRId64
" msec to Multicast IPV6 address : %s with GroupID of %d and fabric Id of %d",
"encrypted", &preparedMessage, preparedMessage.GetMessageCounter(), sessionHandle.GetGroupId().Value(),
System::SystemClock().GetMonotonicMilliseconds64().count(), addressStr,
sessionHandle.GetGroupId().Value(), sessionHandle.GetFabricIndex());
}
else
{
// Find an active connection to the specified peer node
SecureSession * session = GetSecureSession(sessionHandle);
if (session == nullptr)
{
ChipLogError(Inet, "Secure transport could not find a valid PeerConnection");
return CHIP_ERROR_NOT_CONNECTED;
}

// This marks any connection where we send data to as 'active'
mSecureSessions.MarkSessionActive(session);
// This marks any connection where we send data to as 'active'
mSecureSessions.MarkSessionActive(session);

destination = &session->GetPeerAddress();
destination = &session->GetPeerAddress();

ChipLogProgress(Inet,
"Sending %s msg %p with MessageCounter:" ChipLogFormatMessageCounter " to 0x" ChipLogFormatX64
" (%u) at monotonic time: %" PRId64 " msec",
"encrypted", &preparedMessage, preparedMessage.GetMessageCounter(),
ChipLogValueX64(session->GetPeerNodeId()), session->GetFabricIndex(),
System::SystemClock().GetMonotonicMilliseconds64().count());
ChipLogProgress(Inet,
"Sending %s msg %p with MessageCounter:" ChipLogFormatMessageCounter " to 0x" ChipLogFormatX64
" (%u) at monotonic time: %" PRId64 " msec",
"encrypted", &preparedMessage, preparedMessage.GetMessageCounter(),
ChipLogValueX64(session->GetPeerNodeId()), session->GetFabricIndex(),
System::SystemClock().GetMonotonicMilliseconds64().count());
}
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions src/transport/TransportMgrBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ void TransportMgrBase::Close()
mTransport = nullptr;
}

CHIP_ERROR TransportMgrBase::MulticastGroupJoinLeave(const Transport::PeerAddress & address, bool join)
{
return mTransport->MulticastGroupJoinLeave(address, join);
}

void TransportMgrBase::HandleMessageReceived(const Transport::PeerAddress & peerAddress, System::PacketBufferHandle && msg)
{
if (msg->HasChainedBuffer())
Expand Down
2 changes: 2 additions & 0 deletions src/transport/TransportMgrBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class TransportMgrBase : public Transport::RawTransportDelegate

void SetSessionManager(TransportMgrDelegate * sessionManager) { mSessionManager = sessionManager; }

CHIP_ERROR MulticastGroupJoinLeave(const Transport::PeerAddress & address, bool join);

void HandleMessageReceived(const Transport::PeerAddress & peerAddress, System::PacketBufferHandle && msg) override;

private:
Expand Down
Loading