connectedhomeip: [Group] UDP endpoint bound to wrong interface when sending group messages

Problem

When testing group messages in SVE, we found that chip-tool fails to send group multicast messages.

Test steps:

./chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null },{"fabricIndex": 1, "privilege": 4, "authMode": 3, "subjects": [1], "targets": null }]' 1 0

./chip-tool groupkeymanagement key-set-write '{"groupKeySetID": 42, "groupKeySecurityPolicy": 0, "epochKey0": "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf", "epochStartTime0": 2220000,"epochKey1": "d1d1d2d3d4d5d6d7d8d9dadbdcdddedf", "epochStartTime1": 2220001,"epochKey2": "d2d1d2d3d4d5d6d7d8d9dadbdcdddedf", "epochStartTime2": 2220002 }' 1 0

./chip-tool groups add-group 0x0001 grp1 1 1

./chip-tool groupkeymanagement write group-key-map '[{"groupId": 1, "groupKeySetID": 42, "fabricIndex": 1}]' 1 0

./chip-tool groupsettings add-group grp1 0x0001

./chip-tool groupsettings add-keysets 0x0042 0 0x000000000021dfe0 hex:d0d1d2d3d4d5d6d7d8d9dadbdcdddedf

./chip-tool groupsettings bind-keyset 0x0001 0x0042

./chip-tool onoff toggle 0xffffffffffff0001 1

The multicast message was not sent after executing the chip-tool onoff toggle command.

The bug is caused by the UDP endpoint bound to an incorrect interface. The IPv6Bind function is called with a null interface during initialization and it turned out that multicast messages won’t be sent under this scenario.

I tried to force the interface with the following patch:

diff --git a/src/inet/UDPEndPointImplSockets.cpp b/src/inet/UDPEndPointImplSockets.cpp
index 93b0828f5..59b91e762 100644
--- a/src/inet/UDPEndPointImplSockets.cpp
+++ b/src/inet/UDPEndPointImplSockets.cpp
@@ -102,6 +102,11 @@ CHIP_ERROR IPv6Bind(int socket, const IPAddress & address, uint16_t port, Interf
     else
     {
 #ifdef IPV6_MULTICAST_IF
+        ChipLogProgress(Inet, "IPV6_MULTICAST_IF interface %d", interfaceId);
+        if (interfaceId == 0)
+        {
+            interfaceId = 2;
+        }

The patch will enable group commands on my ethernet link.

Proposed Solution

Explicitly bind to an interface when sending multicast packets.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (13 by maintainers)

Most upvoted comments

@jadhavrohit924 On Mac, group communication does not work properly at the moment.