-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ip6] filter host originated multicast packets
- Loading branch information
Showing
6 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
tests/scripts/thread-cert/backbone/test_mlr_multicast_routing_self_originated_packet.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright (c) 2023, The OpenThread Authors. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the | ||
# names of its contributors may be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
# This test verifies that the multicast packet originated from BBR is only | ||
# forwarded to thread network when the destination group address is in the | ||
# multicast listener table. | ||
# | ||
import unittest | ||
import sys | ||
|
||
import thread_cert | ||
import config | ||
from pktverify.consts import ICMPV6_TYPE_DESTINATION_UNREACHABLE | ||
from pktverify.packet_verifier import PacketVerifier | ||
|
||
PBBR = 1 | ||
ROUTER = 2 | ||
|
||
MA1 = 'ff04::10' | ||
MA2 = 'ff05::20' | ||
|
||
|
||
class TestMlrMulticastRoutingSelfOriginatedPacket(thread_cert.TestCase): | ||
USE_MESSAGE_FACTORY = False | ||
|
||
# Topology: | ||
# | ||
# ------(eth)---------- | ||
# | | ||
# PBBR---ROUTER | ||
# | ||
TOPOLOGY = { | ||
PBBR: { | ||
'name': 'PBBR', | ||
'allowlist': [ROUTER], | ||
'is_otbr': True, | ||
'version': '1.2', | ||
}, | ||
ROUTER: { | ||
'name': 'ROUTER', | ||
'allowlist': [PBBR], | ||
'version': '1.2', | ||
}, | ||
} | ||
|
||
def test(self): | ||
self.nodes[PBBR].start() | ||
self.simulator.go(config.LEADER_STARTUP_DELAY) | ||
self.assertEqual('leader', self.nodes[PBBR].get_state()) | ||
self.nodes[PBBR].enable_backbone_router() | ||
self.simulator.go(3) | ||
self.assertTrue(self.nodes[PBBR].is_primary_backbone_router) | ||
|
||
self.nodes[ROUTER].start() | ||
self.simulator.go(5) | ||
self.assertEqual('router', self.nodes[ROUTER].get_state()) | ||
|
||
self.simulator.go(5) | ||
|
||
self.collect_ipaddrs() | ||
|
||
# Verify PBBR can send packets to mlr registered multicast address on Thread network | ||
self.nodes[ROUTER].add_ipmaddr(MA1) | ||
self.simulator.go(3) | ||
self.assertTrue(self.nodes[PBBR].ping(MA1, backbone=True, ttl=10, interface=config.THREAD_IFNAME)) | ||
|
||
# Verify PBBR can't send packets to not registered multicast address on Thread network | ||
self.assertFalse(self.nodes[PBBR].ping(MA2, backbone=True, ttl=10, interface=config.THREAD_IFNAME)) | ||
|
||
def verify(self, pv: PacketVerifier): | ||
pkts = pv.pkts | ||
pv.add_common_vars() | ||
pv.summary.show() | ||
|
||
with pkts.save_index(): | ||
pv.verify_attached('ROUTER') | ||
|
||
PBBR = pv.vars['PBBR'] | ||
#PBBR_OMR = pv.vars['PBBR_OMR'] | ||
|
||
# PBBR should send ping request to MA1 to Thread network | ||
pkts.filter_wpan_src64(PBBR).filter_AMPLFMA().filter( | ||
lambda p: p.ipv6inner.dst == MA1).filter_ping_request().must_next() | ||
|
||
# PBBR should not send ping request to MA2 to Thread network | ||
pkts.filter_wpan_src64(PBBR).filter_AMPLFMA().filter( | ||
lambda p: p.ipv6inner.dst == MA2).filter_ping_request().must_not_next() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |