ONOS dependency is changed; New Version is created for this app; Comments are added to understand the write metadata value
the solution to supporting the authentication flows would be to support using a default Technology Profile (propose using TP ID = 64) The default tech profile 64 would be a single TCONT with a single GEM.
Change-Id: Ic978f099e2546e435bebadce8dee41e4ac38399a
diff --git a/app/src/main/java/org/opencord/olt/impl/Olt.java b/app/src/main/java/org/opencord/olt/impl/Olt.java
index a611723..1e00237 100644
--- a/app/src/main/java/org/opencord/olt/impl/Olt.java
+++ b/app/src/main/java/org/opencord/olt/impl/Olt.java
@@ -116,6 +116,8 @@
private static final String APP_NAME = "org.opencord.olt";
private static final short DEFAULT_VLAN = 0;
+ private static final int DEFAULT_TP_ID = 10;
+ private static final String DEFAULT_BP_ID = "Default";
private static final String ADDITIONAL_VLANS = "additional-vlans";
private final Logger log = getLogger(getClass());
@@ -169,6 +171,14 @@
label = "Deleting Meters based on flow count statistics")
protected boolean deleteMeters = false;
+ @Property(name = "defaultTechProfileId", intValue = DEFAULT_TP_ID,
+ label = "Default technology profile id that is used for authentication trap flows")
+ protected int defaultTechProfileId = DEFAULT_TP_ID;
+
+ @Property(name = "defaultBpId", value = DEFAULT_BP_ID,
+ label = "Default bandwidth profile id that is used for authentication trap flows")
+ protected String defaultBpId = DEFAULT_BP_ID;
+
private final DeviceListener deviceListener = new InternalDeviceListener();
private final MeterListener meterListener = new InternalMeterListener();
@@ -258,13 +268,19 @@
}
log.info("DHCP Settings [enableDhcpOnProvisioning: {}, enableDhcpV4: {}, enableDhcpV6: {}]",
- enableDhcpOnProvisioning, enableDhcpV4, enableDhcpV6);
+ enableDhcpOnProvisioning, enableDhcpV4, enableDhcpV6);
Boolean d = Tools.isPropertyEnabled(properties, "deleteMeters");
if (d != null) {
deleteMeters = d;
}
+ String tpId = get(properties, "defaultTechProfileId");
+ defaultTechProfileId = isNullOrEmpty(s) ? DEFAULT_TP_ID : Integer.parseInt(tpId.trim());
+
+ String bpId = get(properties, "defaultBpId");
+ defaultBpId = bpId;
+
} catch (Exception e) {
defaultVlan = DEFAULT_VLAN;
}
@@ -415,7 +431,7 @@
if (getOltInfo(d) == null) {
continue; // not an olt, or not configured in sadis
}
- for (Port p: deviceService.getPorts(d.id())) {
+ for (Port p : deviceService.getPorts(d.id())) {
if (isUniPort(d, p) && p.isEnabled()) {
ConnectPoint cp = new ConnectPoint(d.id(), p.number());
@@ -647,10 +663,8 @@
meterBands.add(createMeterBand(bpInfo.committedInformationRate(), bpInfo.committedBurstSize()));
meterBands.add(createMeterBand(bpInfo.exceededInformationRate(), bpInfo.exceededBurstSize()));
+ meterBands.add(createMeterBand(bpInfo.assuredInformationRate(), 0L));
- if (bpInfo.assuredInformationRate() != 0) {
- meterBands.add(createMeterBand(bpInfo.assuredInformationRate(), 0L));
- }
return meterBands;
}
@@ -684,9 +698,7 @@
downstreamTreatmentBuilder.meter(meterId);
}
- if (techProfId != -1) {
- downstreamTreatmentBuilder.transition(techProfId);
- }
+ downstreamTreatmentBuilder.writeMetadata(createMetadata(subscriberVlan, techProfId, subscriberPort), 0);
return DefaultForwardingObjective.builder()
.withFlag(ForwardingObjective.Flag.VERSATILE)
@@ -729,10 +741,7 @@
upstreamTreatmentBuilder.meter(meterId);
}
- if (technologyProfileId != -1) {
- upstreamTreatmentBuilder.transition(technologyProfileId);
-
- }
+ upstreamTreatmentBuilder.writeMetadata(createMetadata(deviceVlan, technologyProfileId, uplinkPort), 0L);
return DefaultForwardingObjective.builder()
.withFlag(ForwardingObjective.Flag.VERSATILE)
@@ -742,6 +751,7 @@
.fromApp(appId)
.withTreatment(upstreamTreatmentBuilder.build());
}
+
private void provisionTransparentFlows(DeviceId deviceId, PortNumber uplinkPort,
PortNumber subscriberPort,
VlanId innerVlan,
@@ -905,11 +915,22 @@
return;
}
DefaultFilteringObjective.Builder builder = DefaultFilteringObjective.builder();
+ TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
+ BandwidthProfileInformation defaultBpInfo = getBandwidthProfileInformation(defaultBpId);
+ if (defaultBpInfo != null) {
+ MeterId meterId = createMeter(devId, defaultBpInfo);
+ treatmentBuilder.meter(meterId);
+ } else {
+ log.warn("Default bandwidth profile is not found. Authentication flow will be installed without meter");
+ }
+
+ //Authentication trap flow uses only tech profile id as metadata
FilteringObjective eapol = (install ? builder.permit() : builder.deny())
.withKey(Criteria.matchInPort(port))
.addCondition(Criteria.matchEthType(EthType.EtherType.EAPOL.ethType()))
- .withMeta(DefaultTrafficTreatment.builder()
+ .withMeta(treatmentBuilder
+ .writeMetadata((long) defaultTechProfileId << 32, 0)
.setOutput(PortNumber.CONTROLLER).build())
.fromApp(appId)
.withPriority(10000)
@@ -936,8 +957,8 @@
* Installs trap filtering objectives for particular traffic types on an
* NNI port.
*
- * @param devId device ID
- * @param port port number
+ * @param devId device ID
+ * @param port port number
* @param install true to install, false to remove
*/
private void processNniFilteringObjectives(DeviceId devId, PortNumber port, boolean install) {
@@ -982,11 +1003,11 @@
/**
* Trap dhcp packets to the controller.
*
- * @param devId the device identifier
- * @param port the port for which this trap flow is designated
- * @param install true to install the flow, false to remove the flow
+ * @param devId the device identifier
+ * @param port the port for which this trap flow is designated
+ * @param install true to install the flow, false to remove the flow
* @param upstream true if trapped packets are flowing upstream towards
- * server, false if packets are flowing dowstream towards client
+ * server, false if packets are flowing dowstream towards client
*/
private void processDhcpFilteringObjectives(DeviceId devId, PortNumber port,
boolean install,
@@ -1040,16 +1061,16 @@
@Override
public void onSuccess(Objective objective) {
log.info("DHCP {} filter for device {} on port {} {}.",
- (ethType.equals(EthType.EtherType.IPV4.ethType())) ? "v4" : "v6",
- devId, port, (install) ? "installed" : "removed");
+ (ethType.equals(EthType.EtherType.IPV4.ethType())) ? "v4" : "v6",
+ devId, port, (install) ? "installed" : "removed");
}
@Override
public void onError(Objective objective, ObjectiveError error) {
log.info("DHCP {} filter for device {} on port {} failed {} because {}",
- (ethType.equals(EthType.EtherType.IPV4.ethType())) ? "v4" : "v6",
- devId, port, (install) ? "installation" : "removal",
- error);
+ (ethType.equals(EthType.EtherType.IPV4.ethType())) ? "v4" : "v6",
+ devId, port, (install) ? "installation" : "removal",
+ error);
}
});
@@ -1121,7 +1142,7 @@
/**
* Get the uplink for of the OLT device.
- *
+ * <p>
* This assumes that the OLT has a single uplink port. When more uplink ports need to be supported
* this logic needs to be changed
*
@@ -1138,7 +1159,7 @@
return null;
}
// Return the port that has been configured as the uplink port of this OLT in Sadis
- for (Port p: deviceService.getPorts(dev.id())) {
+ for (Port p : deviceService.getPorts(dev.id())) {
if (p.number().toLong() == deviceInfo.uplinkPort()) {
log.debug("getUplinkPort: Found port {}", p);
return p;
@@ -1162,6 +1183,23 @@
return subsService.get(portName);
}
+ /**
+ * Write metadata instruction value (metadata) is 8 bytes.
+ *
+ * MS 2 bytes: C Tag
+ * Next 2 bytes: Technology Profile Id
+ * Next 4 bytes: Port number (uni or nni)
+ */
+
+ private Long createMetadata(VlanId innerVlan, int techProfileId, PortNumber egressPort) {
+
+ if (techProfileId == -1) {
+ techProfileId = DEFAULT_TP_ID;
+ }
+
+ return ((long) (innerVlan.id()) << 48 | (long) techProfileId << 32) | egressPort.toLong();
+ }
+
private boolean isUniPort(Device d, Port p) {
Port ulPort = getUplinkPort(d);
if (ulPort != null) {