@@ -232,7 +232,7 @@ control Filter(
232
232
// that follow the format 33:33:xxxx:xxxx where the last 32 bits
233
233
// are taken directly from the last 32 bits of the IPv6 address.
234
234
//
235
- // Sadly, the first two conditions cannot e checked properly by
235
+ // Sadly, the first two conditions cannot be checked properly by
236
236
// the parser, as we reach the total available parser match
237
237
// registers on the device.
238
238
if (hdr .ethernet .dst_mac [47 :40 ] != 8 w0x33 ||
@@ -689,7 +689,7 @@ control NatIngress (
689
689
if (hdr .ipv4 .isValid () && meta .is_valid ) {
690
690
if (meta .is_mcast ) {
691
691
ingress_ipv4_mcast .apply ();
692
- } else {
692
+ } else {
693
693
ingress_ipv4 .apply ();
694
694
}
695
695
} else if (hdr .ipv6 .isValid () && meta .is_valid ) {
@@ -1468,27 +1468,36 @@ control MulticastIngress (
1468
1468
in ingress_intrinsic_metadata_t ig_intr_md ,
1469
1469
inout ingress_intrinsic_metadata_for_tm_t ig_tm_md )
1470
1470
{
1471
- DirectCounter <bit <32 >>(CounterType_t .PACKETS_AND_BYTES ) mcast_ipv4_ctr ;
1472
1471
DirectCounter <bit <32 >>(CounterType_t .PACKETS_AND_BYTES ) mcast_ipv6_ctr ;
1473
1472
DirectCounter <bit <32 >>(CounterType_t .PACKETS_AND_BYTES ) mcast_ipv4_ssm_ctr ;
1474
1473
DirectCounter <bit <32 >>(CounterType_t .PACKETS_AND_BYTES ) mcast_ipv6_ssm_ctr ;
1475
1474
1476
- Hash <bit <13 >>(HashAlgorithm_t .CRC16 ) mcast_hashv4_level1 ;
1477
- Hash <bit <13 >>(HashAlgorithm_t .CRC16 ) mcast_hashv4_level2 ;
1478
1475
Hash <bit <13 >>(HashAlgorithm_t .CRC16 ) mcast_hashv6_level1 ;
1479
1476
Hash <bit <13 >>(HashAlgorithm_t .CRC16 ) mcast_hashv6_level2 ;
1480
1477
1481
1478
// Drop action for IPv4 multicast packets with no group.
1479
+ //
1480
+ // At this point, We should only allow replication for IPv6 packets that
1481
+ // are admin-scoped before possible decapping.
1482
1482
action drop_mcastv4_no_group () {
1483
1483
ig_dprsr_md .drop_ctl = 1 ;
1484
1484
meta .drop_reason = DROP_MULTICAST_NO_GROUP ;
1485
- mcast_ipv4_ctr .count ();
1486
1485
}
1487
1486
1488
1487
// Drop action for IPv6 multicast packets with no group.
1488
+ //
1489
+ // At this point, we should only allow replication for IPv6 packets that
1490
+ // are admin-scoped before possible decapping.
1489
1491
action drop_mcastv6_no_group () {
1490
1492
ig_dprsr_md .drop_ctl = 1 ;
1491
1493
meta .drop_reason = DROP_MULTICAST_NO_GROUP ;
1494
+ }
1495
+
1496
+ // Drop action for IPv6 multicast packets with no group
1497
+ // that is a valid admin-scoped multicast group.
1498
+ action drop_mcastv6_admin_scoped_no_group () {
1499
+ ig_dprsr_md .drop_ctl = 1 ;
1500
+ meta .drop_reason = DROP_MULTICAST_NO_GROUP ;
1492
1501
mcast_ipv6_ctr .count ();
1493
1502
}
1494
1503
@@ -1520,35 +1529,9 @@ control MulticastIngress (
1520
1529
mcast_ipv6_ssm_ctr .count ();
1521
1530
}
1522
1531
1523
- action configure_mcastv4 (
1524
- MulticastGroupId_t mcast_grp_a ,
1525
- bit <16 > rid ,
1526
- bit <16 > level1_excl_id ,
1527
- bit <9 > level2_excl_id
1528
- ) {
1529
- ig_tm_md .mcast_grp_a = mcast_grp_a ;
1530
- ig_tm_md .rid = rid ;
1531
- ig_tm_md .level1_exclusion_id = level1_excl_id ;
1532
- ig_tm_md .level2_exclusion_id = level2_excl_id ;
1533
-
1534
- // Set multicast hash based on IPv4 packet fields
1535
- ig_tm_md .level1_mcast_hash = (bit <13 >)mcast_hashv4_level1 .get ({
1536
- hdr .ipv4 .src_addr ,
1537
- hdr .ipv4 .dst_addr ,
1538
- hdr .ipv4 .protocol ,
1539
- meta .l4_src_port ,
1540
- meta .l4_dst_port
1541
- });
1542
-
1543
- // Set secondary multicast hash based on IPv4 packet fields
1544
- ig_tm_md .level2_mcast_hash = (bit <13 >)mcast_hashv4_level2 .get ({
1545
- (bit <16 >)hdr .ipv4 .identification ,
1546
- ig_intr_md .ingress_port
1547
- });
1548
-
1549
- mcast_ipv4_ctr .count ();
1550
- }
1551
-
1532
+ // Configure IPv6 multicast replication with bifurcated design:
1533
+ // mcast_grp_a: external/customer replication group
1534
+ // mcast_grp_b: underlay/infrastructure replication group
1552
1535
action configure_mcastv6 (
1553
1536
MulticastGroupId_t mcast_grp_a ,
1554
1537
MulticastGroupId_t mcast_grp_b ,
@@ -1580,21 +1563,10 @@ control MulticastIngress (
1580
1563
mcast_ipv6_ctr .count ();
1581
1564
}
1582
1565
1583
- table mcast_replication_ipv4 {
1584
- key = { hdr .ipv4 .dst_addr : exact ; }
1585
- actions = {
1586
- configure_mcastv4 ;
1587
- drop_mcastv4_no_group ;
1588
- }
1589
- default_action = drop_mcastv4_no_group ;
1590
- const size = IPV4_MULTICAST_TABLE_SIZE ;
1591
- counters = mcast_ipv4_ctr ;
1592
- }
1593
-
1594
1566
table mcast_source_filter_ipv4 {
1595
1567
key = {
1596
- hdr .ipv4 .src_addr : lpm ;
1597
- hdr .ipv4 .dst_addr : exact ;
1568
+ hdr .inner_ipv4 .src_addr : lpm ;
1569
+ hdr .inner_ipv4 .dst_addr : exact ;
1598
1570
}
1599
1571
actions = {
1600
1572
allow_source_mcastv4 ;
@@ -1609,17 +1581,17 @@ control MulticastIngress (
1609
1581
key = { hdr .ipv6 .dst_addr : exact ; }
1610
1582
actions = {
1611
1583
configure_mcastv6 ;
1612
- drop_mcastv6_no_group ;
1584
+ drop_mcastv6_admin_scoped_no_group ;
1613
1585
}
1614
- default_action = drop_mcastv6_no_group ;
1586
+ default_action = drop_mcastv6_admin_scoped_no_group ;
1615
1587
const size = IPV6_MULTICAST_TABLE_SIZE ;
1616
1588
counters = mcast_ipv6_ctr ;
1617
1589
}
1618
1590
1619
1591
table mcast_source_filter_ipv6 {
1620
1592
key = {
1621
- hdr .ipv6 .src_addr : exact ;
1622
- hdr .ipv6 .dst_addr : exact ;
1593
+ hdr .inner_ipv6 .src_addr : exact ;
1594
+ hdr .inner_ipv6 .dst_addr : exact ;
1623
1595
}
1624
1596
actions = {
1625
1597
allow_source_mcastv6 ;
@@ -1650,7 +1622,6 @@ control MulticastIngress (
1650
1622
1651
1623
table mcast_tag_check {
1652
1624
key = {
1653
- hdr .ipv6 .isValid () : ternary ;
1654
1625
ig_tm_md .mcast_grp_a : ternary ;
1655
1626
ig_tm_md .mcast_grp_b : ternary ;
1656
1627
hdr .geneve .isValid () : ternary ;
@@ -1666,50 +1637,46 @@ control MulticastIngress (
1666
1637
}
1667
1638
1668
1639
const entries = {
1669
- ( true , _ , _ , true , true , MULTICAST_TAG_EXTERNAL ) : invalidate_underlay_grp_and_set_decap ;
1670
- ( true , _ , _ , true , true , MULTICAST_TAG_UNDERLAY ) : invalidate_external_grp ;
1671
- ( true , _ , _ , true , true , MULTICAST_TAG_UNDERLAY_EXTERNAL ) : NoAction ;
1672
- ( _ , 0 , _ , _ , _ , _ ) : invalidate_external_grp ;
1673
- ( _ , _ , 0 , _ , _ , _ ) : invalidate_underlay_grp ;
1674
- ( _ , 0 , 0 , _ , _ , _ ) : invalidate_grps ;
1640
+ ( _ , _ , true , true , MULTICAST_TAG_EXTERNAL ) : invalidate_underlay_grp_and_set_decap ;
1641
+ ( _ , _ , true , true , MULTICAST_TAG_UNDERLAY ) : invalidate_external_grp ;
1642
+ ( _ , _ , true , true , MULTICAST_TAG_UNDERLAY_EXTERNAL ) : NoAction ;
1643
+ ( 0 , _ , _ , _ , _ ) : invalidate_external_grp ;
1644
+ ( _ , 0 , _ , _ , _ ) : invalidate_underlay_grp ;
1645
+ ( 0 , 0 , _ , _ , _ ) : invalidate_grps ;
1675
1646
}
1676
1647
1677
1648
const size = 6 ;
1678
1649
}
1679
1650
1680
1651
// Note: SSM tables currently take one extra stage in the pipeline (17->18).
1681
1652
apply {
1682
- if (hdr .ipv4 .isValid ()) {
1683
- // Check if the destination address is an IPv4 SSM multicast
1653
+ if (hdr .geneve . isValid () && hdr . inner_ipv4 .isValid ()) {
1654
+ // Check if the inner destination address is an IPv4 SSM multicast
1684
1655
// address.
1685
- if (hdr .ipv4 .dst_addr [31 :24 ] == 8 w0xe8 ) {
1656
+ if (hdr .inner_ipv4 .dst_addr [31 :24 ] == 8 w0xe8 ) {
1686
1657
mcast_source_filter_ipv4 .apply ();
1687
- if (meta .allow_source_mcast ) {
1688
- mcast_replication_ipv4 .apply ();
1689
- }
1690
1658
} else {
1691
- // Otherwise, apply the multicast replication table for
1692
- // non-SSM multicast addresses.
1693
- mcast_replication_ipv4 .apply ();
1659
+ meta .allow_source_mcast = true ;
1694
1660
}
1695
- } else if (hdr .ipv6 .isValid ()) {
1696
- // Check if the destination address is an IPv6 SSM multicast
1661
+ } else if (hdr .geneve . isValid () && hdr . inner_ipv6 .isValid ()) {
1662
+ // Check if the inner destination address is an IPv6 SSM multicast
1697
1663
// address.
1698
- if ((hdr .ipv6 .dst_addr [127 :120 ] == 8 w0xff )
1699
- && ((hdr .ipv6 .dst_addr [119 :116 ] == 4 w0x3 ))) {
1664
+ if ((hdr .inner_ipv6 .dst_addr [127 :120 ] == 8 w0xff )
1665
+ && ((hdr .inner_ipv6 .dst_addr [119 :116 ] == 4 w0x3 ))) {
1700
1666
mcast_source_filter_ipv6 .apply ();
1701
- if (meta .allow_source_mcast ) {
1702
- // Then, apply the multicast replication table.
1703
- mcast_replication_ipv6 .apply ();
1704
- }
1705
1667
} else {
1706
- // Otherwise, apply the multicast replication table for
1707
- // non-SSM multicast addresses.
1708
- mcast_replication_ipv6 .apply ();
1668
+ meta .allow_source_mcast = true ;
1709
1669
}
1670
+ } else if (hdr .ipv4 .isValid ()) {
1671
+ drop_mcastv4_no_group ();
1672
+ } else if (hdr .ipv6 .isValid ()) {
1673
+ drop_mcastv6_no_group ();
1710
1674
}
1711
1675
1712
- mcast_tag_check .apply ();
1676
+ if (hdr .ipv6 .isValid () && meta .allow_source_mcast ) {
1677
+ mcast_replication_ipv6 .apply ();
1678
+ mcast_tag_check .apply ();
1679
+ }
1713
1680
}
1714
1681
}
1715
1682
0 commit comments