ONOS-7251 - Initial implementation of fabric.p4 L2 broadcast feature.
Thrift client cherry-picked from the commit dd5792ac9ee38a702c3128a34224852b5c284687
Change-Id: I989f2b2074485a892195889a7c976b518510da88
diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/ForwardingFunctionType.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/ForwardingFunctionType.java
index 3cf015d..0349cc7 100644
--- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/ForwardingFunctionType.java
+++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/ForwardingFunctionType.java
@@ -19,7 +19,9 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
+import org.onlab.packet.MacAddress;
import org.onosproject.net.flow.criteria.Criterion;
+import org.onosproject.net.flow.criteria.EthCriterion;
import org.onosproject.net.flowobjective.ForwardingObjective;
import java.util.Map;
@@ -114,14 +116,35 @@
*/
public static ForwardingFunctionType getForwardingFunctionType(ForwardingObjective fwd) {
Set<Criterion.Type> criteriaType = Sets.newHashSet();
- fwd.selector().criteria().stream().map(Criterion::type)
+ //omit the criterion of ethDst type with the value of MacAddress.NONE since it indicates L2 broadcast
+ //if not, the objective is treated as L2 unicast
+ fwd.selector().criteria().stream().filter(criterion -> !ethDstIndicatesBroadcast(criterion))
+ .map(Criterion::type)
.forEach(criteriaType::add);
if (fwd.meta() != null) {
- fwd.meta().criteria().stream().map(Criterion::type)
+ fwd.meta().criteria().stream().filter(criterion -> !ethDstIndicatesBroadcast(criterion))
+ .map(Criterion::type)
.forEach(criteriaType::add);
}
return FFT_MAP.getOrDefault(criteriaType, UNSUPPORTED);
}
+
+ /**
+ * Segment Routing (SR) app. sets ethDst criterion to MacAddress.NONE for broadcast rules
+ * and demands drivers to treat the flow rules containing this criterion as broadcast rule.
+ *
+ * This method checks the type and value of the criterion and detects whether it constitutes
+ * broadcast or not.
+ *
+ * For more details check RoutingRulePopulator.updateSubnetBroadcastRule method of SR app.
+ *
+ * @param criterion Criterion object
+ * @return true if the type is ETH_DST and the mac value equals to MacAddress.NONE; false otherwise.
+ */
+ private static boolean ethDstIndicatesBroadcast(Criterion criterion) {
+ return criterion.type().equals(Criterion.Type.ETH_DST) &&
+ ((EthCriterion) criterion).mac().equals(MacAddress.NONE);
+ }
}