add flowrule to specific ip for userdata
Change-Id: Ia38af7556cc0e04c173f3c337a8dd17f49a20eba
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ClassifierService.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ClassifierService.java
index 7715b9d..fffa2fb 100644
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ClassifierService.java
+++ b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ClassifierService.java
@@ -16,6 +16,7 @@
package org.onosproject.vtn.table;
import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
@@ -102,4 +103,20 @@
SegmentationId actionVni,
Objective.Operation type);
+ /**
+ * Assemble the Userdata Classifier table rules.
+ * Match: subnet ip prefix and destination ip.
+ * Action: add flow rule to specific ip for userdata.
+ *
+ * @param deviceId Device Id
+ * @param ipPrefix source ip prefix
+ * @param dstIp userdata ip
+ * @param dstmac dst mac
+ * @param actionVni the vni of the source network (l2vni)
+ * @param type the operation type of the flow rules
+ */
+ void programUserdataClassifierRules(DeviceId deviceId, IpPrefix ipPrefix,
+ IpAddress dstIp, MacAddress dstmac,
+ SegmentationId actionVni,
+ Objective.Operation type);
}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java
index e60c217..030c783 100644
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java
+++ b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java
@@ -56,7 +56,7 @@
private static final int ARP_CLASSIFIER_PRIORITY = 60000;
private static final int L3_CLASSIFIER_PRIORITY = 0xffff;
private static final int L2_CLASSIFIER_PRIORITY = 50000;
-
+ private static final int USERDATA_CLASSIFIER_PRIORITY = 65535;
private final FlowObjectiveService flowObjectiveService;
private final ApplicationId appId;
@@ -193,4 +193,29 @@
}
}
+ @Override
+ public void programUserdataClassifierRules(DeviceId deviceId,
+ IpPrefix ipPrefix,
+ IpAddress dstIp,
+ MacAddress dstmac,
+ SegmentationId actionVni,
+ Objective.Operation type) {
+ TrafficSelector selector = DefaultTrafficSelector.builder()
+ .matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(ipPrefix)
+ .matchIPDst(IpPrefix.valueOf(dstIp, 32)).build();
+ TrafficTreatment treatment = DefaultTrafficTreatment.builder()
+ .setTunnelId(Long.parseLong(actionVni.segmentationId()))
+ .setEthDst(dstmac).build();
+ ForwardingObjective.Builder objective = DefaultForwardingObjective
+ .builder().withTreatment(treatment).withSelector(selector)
+ .fromApp(appId).withFlag(Flag.SPECIFIC)
+ .withPriority(USERDATA_CLASSIFIER_PRIORITY);
+ if (type.equals(Objective.Operation.ADD)) {
+ log.debug("UserdataClassifierRules-->ADD");
+ flowObjectiveService.forward(deviceId, objective.add());
+ } else {
+ log.debug("UserdataClassifierRules-->REMOVE");
+ flowObjectiveService.forward(deviceId, objective.remove());
+ }
+ }
}