Match VLAN_VID in TMAC table for mcast flows

Matching VLAN_VID in TMAC table is mandatory on QMX switches
XGS switches support optional VLAN_VID matching so this patch is effective for both platforms

In addition,
- Take native vlan into account when assigning VLAN for untagged multicast traffic
- Fix a bug that puts wrong eth_type in TMAC table

Change-Id: I19caf2d6d69096a96b75cb528b6ed37b28d7d988
This commit is contained in:
Charles Chan 2017-10-20 19:09:16 -07:00 committed by Charles Chan
parent 525ff40850
commit b4879a558c
4 changed files with 42 additions and 30 deletions

View File

@ -774,7 +774,7 @@ public class McastHandler {
}
// Reuse unicast VLAN if the port has subnet configured
if (cp != null) {
VlanId untaggedVlan = srManager.getUntaggedVlanId(cp);
VlanId untaggedVlan = srManager.getInternalVlanId(cp);
return (untaggedVlan != null) ? untaggedVlan : INTERNAL_VLAN;
}
// Use DEFAULT_VLAN if none of the above matches

View File

@ -326,7 +326,7 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline {
// Multicast MAC
if (ethCriterion.mask() != null) {
return processMcastEthDstFilter(ethCriterion, applicationId);
return processMcastEthDstFilter(ethCriterion, assignedVlan, applicationId);
}
//handling untagged packets via assigned VLAN

View File

@ -98,7 +98,7 @@ public class CpqdOfdpa2VlanPipeline extends CpqdOfdpa2Pipeline {
// Multicast MAC
if (ethCriterion.mask() != null) {
return processMcastEthDstFilter(ethCriterion, applicationId);
return processMcastEthDstFilter(ethCriterion, assignedVlan, applicationId);
}
//handling untagged packets via assigned VLAN

View File

@ -93,6 +93,8 @@ import java.util.concurrent.TimeUnit;
import static java.util.concurrent.Executors.newScheduledThreadPool;
import static org.onlab.packet.MacAddress.BROADCAST;
import static org.onlab.packet.MacAddress.IPV4_MULTICAST;
import static org.onlab.packet.MacAddress.IPV6_MULTICAST;
import static org.onlab.packet.MacAddress.NONE;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.*;
@ -637,7 +639,7 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline
// Multicast MAC
if (ethCriterion.mask() != null) {
return processMcastEthDstFilter(ethCriterion, applicationId);
return processMcastEthDstFilter(ethCriterion, assignedVlan, applicationId);
}
//handling untagged packets via assigned VLAN
@ -870,37 +872,47 @@ public class Ofdpa2Pipeline extends AbstractHandlerBehaviour implements Pipeline
}
protected List<FlowRule> processMcastEthDstFilter(EthCriterion ethCriterion,
VlanId assignedVlan,
ApplicationId applicationId) {
ImmutableList.Builder<FlowRule> builder = ImmutableList.builder();
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
treatment.transition(MULTICAST_ROUTING_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(DEFAULT_PRIORITY)
.fromApp(applicationId)
.makePermanent()
.forTable(TMAC_TABLE).build();
builder.add(rule);
FlowRule rule;
selector = DefaultTrafficSelector.builder();
treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV6);
selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
treatment.transition(MULTICAST_ROUTING_TABLE);
rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(DEFAULT_PRIORITY)
.fromApp(applicationId)
.makePermanent()
.forTable(TMAC_TABLE).build();
return builder.add(rule).build();
if (IPV4_MULTICAST.equals(ethCriterion.mac())) {
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
selector.matchVlanId(assignedVlan);
treatment.transition(MULTICAST_ROUTING_TABLE);
rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(DEFAULT_PRIORITY)
.fromApp(applicationId)
.makePermanent()
.forTable(TMAC_TABLE).build();
builder.add(rule);
}
if (IPV6_MULTICAST.equals(ethCriterion.mac())) {
selector = DefaultTrafficSelector.builder();
treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV6);
selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
selector.matchVlanId(assignedVlan);
treatment.transition(MULTICAST_ROUTING_TABLE);
rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(DEFAULT_PRIORITY)
.fromApp(applicationId)
.makePermanent()
.forTable(TMAC_TABLE).build();
builder.add(rule);
}
return builder.build();
}
private Collection<FlowRule> processForward(ForwardingObjective fwd) {