[VOL-4050] Logging ONU Serial Number on ONOS Olt App
Change-Id: Icaf2a1c368c62420880b753ebd395a88962e725d
diff --git a/impl/src/main/java/org/opencord/olt/impl/Olt.java b/impl/src/main/java/org/opencord/olt/impl/Olt.java
index a74699c..70a3753 100644
--- a/impl/src/main/java/org/opencord/olt/impl/Olt.java
+++ b/impl/src/main/java/org/opencord/olt/impl/Olt.java
@@ -58,6 +58,7 @@
import org.onosproject.store.service.StorageService;
import org.opencord.olt.AccessDeviceEvent;
import org.opencord.olt.AccessDeviceListener;
+import org.opencord.olt.AccessDevicePort;
import org.opencord.olt.AccessDeviceService;
import org.opencord.olt.AccessSubscriberId;
import org.opencord.olt.internalapi.AccessDeviceFlowService;
@@ -237,6 +238,8 @@
.register(KryoNamespaces.API)
.register(UniTagInformation.class)
.register(SubscriberFlowInfo.class)
+ .register(AccessDevicePort.class)
+ .register(AccessDevicePort.Type.class)
.register(LinkedBlockingQueue.class)
.build();
@@ -255,6 +258,8 @@
KryoNamespace macSerializer = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(SubscriberFlowInfo.class)
+ .register(AccessDevicePort.class)
+ .register(AccessDevicePort.Type.class)
.register(UniTagInformation.class)
.build();
@@ -356,9 +361,9 @@
public boolean provisionSubscriber(ConnectPoint connectPoint) {
log.info("Call to provision subscriber at {}", connectPoint);
DeviceId deviceId = connectPoint.deviceId();
- PortNumber subscriberPortNo = connectPoint.port();
- checkNotNull(deviceService.getPort(deviceId, subscriberPortNo),
- "Invalid connect point:" + connectPoint);
+ Port subscriberPortOnos = deviceService.getPort(deviceId, connectPoint.port());
+ checkNotNull(subscriberPortOnos, "Invalid connect point:" + connectPoint);
+ AccessDevicePort subscriberPort = new AccessDevicePort(subscriberPortOnos, AccessDevicePort.Type.UNI);
if (isSubscriberInstalled(connectPoint)) {
log.warn("Subscriber at {} already provisioned or in the process .."
@@ -374,7 +379,7 @@
}
// Get the uplink port
- Port uplinkPort = getUplinkPort(deviceService.getDevice(deviceId));
+ AccessDevicePort uplinkPort = getUplinkPort(deviceService.getDevice(deviceId));
if (uplinkPort == null) {
log.warn(NO_UPLINK_PORT, deviceId);
return false;
@@ -383,8 +388,7 @@
// delete Eapol authentication flow with default bandwidth
// wait until Eapol rule with defaultBpId is removed to install subscriber-based rules
// retry deletion if it fails/times-out
- retryExecutor.execute(new DeleteEapolInstallSub(connectPoint,
- uplinkPort, sub, 1));
+ retryExecutor.execute(new DeleteEapolInstallSub(subscriberPort, uplinkPort, sub, 1));
return true;
}
@@ -412,15 +416,15 @@
}
private class DeleteEapolInstallSub implements Runnable {
- ConnectPoint cp;
- Port uplinkPort;
+ AccessDevicePort subscriberPort;
+ AccessDevicePort uplinkPort;
SubscriberAndDeviceInformation sub;
private int attemptNumber;
- DeleteEapolInstallSub(ConnectPoint cp, Port uplinkPort,
+ DeleteEapolInstallSub(AccessDevicePort subscriberPort, AccessDevicePort uplinkPort,
SubscriberAndDeviceInformation sub,
int attemptNumber) {
- this.cp = cp;
+ this.subscriberPort = subscriberPort;
this.uplinkPort = uplinkPort;
this.sub = sub;
this.attemptNumber = attemptNumber;
@@ -429,34 +433,36 @@
@Override
public void run() {
CompletableFuture<ObjectiveError> filterFuture = new CompletableFuture<>();
- oltFlowService.processEapolFilteringObjectives(cp.deviceId(), cp.port(),
+ oltFlowService.processEapolFilteringObjectives(subscriberPort,
defaultBpId, filterFuture,
VlanId.vlanId(EAPOL_DEFAULT_VLAN),
false);
filterFuture.thenAcceptAsync(filterStatus -> {
if (filterStatus == null) {
log.info("Default eapol flow deleted in attempt {} of {}"
- + "... provisioning subscriber flows {}",
- attemptNumber, eapolDeleteRetryMaxAttempts, cp);
+ + "... provisioning subscriber flows on {}",
+ attemptNumber, eapolDeleteRetryMaxAttempts, subscriberPort);
// FIXME this is needed to prevent that default EAPOL flow removal and
// data plane flows install are received by the device at the same time
provisionExecutor.schedule(
- () -> provisionUniTagList(cp, uplinkPort.number(), sub),
+ () -> provisionUniTagList(subscriberPort, uplinkPort, sub),
provisionDelay, TimeUnit.MILLISECONDS);
} else {
if (attemptNumber <= eapolDeleteRetryMaxAttempts) {
- log.warn("The filtering future failed {} for subscriber {}"
+ log.warn("The filtering future failed {} for subscriber on {}"
+ "... retrying {} of {} attempts",
- filterStatus, cp, attemptNumber, eapolDeleteRetryMaxAttempts);
+ filterStatus, subscriberPort, attemptNumber, eapolDeleteRetryMaxAttempts);
retryExecutor.execute(
- new DeleteEapolInstallSub(cp, uplinkPort, sub,
+ new DeleteEapolInstallSub(subscriberPort, uplinkPort, sub,
attemptNumber + 1));
} else {
- log.error("The filtering future failed {} for subscriber {}"
+ log.error("The filtering future failed {} for subscriber on {}"
+ "after {} attempts. Subscriber provisioning failed",
- filterStatus, cp, eapolDeleteRetryMaxAttempts);
- sub.uniTagList().forEach(ut -> failedSubs.put(cp, ut));
+ filterStatus, subscriberPort, eapolDeleteRetryMaxAttempts);
+ sub.uniTagList().forEach(ut ->
+ failedSubs.put(
+ new ConnectPoint(subscriberPort.deviceId(), subscriberPort.number()), ut));
}
}
});
@@ -466,13 +472,22 @@
@Override
public boolean removeSubscriber(ConnectPoint connectPoint) {
- log.info("Call to un-provision subscriber at {}", connectPoint);
+ Port subscriberPort = deviceService.getPort(connectPoint);
+ if (subscriberPort == null) {
+ log.error("Subscriber port not found at: {}", connectPoint);
+ return false;
+ }
+ return removeSubscriber(new AccessDevicePort(subscriberPort, AccessDevicePort.Type.UNI));
+ }
+
+ private boolean removeSubscriber(AccessDevicePort subscriberPort) {
+ log.info("Call to un-provision subscriber at {}", subscriberPort);
// Get the subscriber connected to this port from the local cache
// If we don't know about the subscriber there's no need to remove it
- DeviceId deviceId = connectPoint.deviceId();
- PortNumber subscriberPortNo = connectPoint.port();
+ DeviceId deviceId = subscriberPort.deviceId();
+ ConnectPoint connectPoint = new ConnectPoint(deviceId, subscriberPort.number());
Collection<? extends UniTagInformation> uniTagInformationSet = programmedSubs.get(connectPoint).value();
if (uniTagInformationSet == null || uniTagInformationSet.isEmpty()) {
log.warn("Subscriber on connectionPoint {} was not previously programmed, " +
@@ -481,7 +496,7 @@
}
// Get the uplink port
- Port uplinkPort = getUplinkPort(deviceService.getDevice(deviceId));
+ AccessDevicePort uplinkPort = getUplinkPort(deviceService.getDevice(deviceId));
if (uplinkPort == null) {
log.warn(NO_UPLINK_PORT, deviceId);
return false;
@@ -493,17 +508,16 @@
continue;
}
- unprovisionVlans(deviceId, uplinkPort.number(), subscriberPortNo, uniTag);
+ unprovisionVlans(uplinkPort, subscriberPort, uniTag);
// remove eapol with subscriber bandwidth profile
- oltFlowService.processEapolFilteringObjectives(deviceId, subscriberPortNo,
+ oltFlowService.processEapolFilteringObjectives(subscriberPort,
uniTag.getUpstreamBandwidthProfile(),
null, uniTag.getPonCTag(), false);
- Port port = deviceService.getPort(deviceId, subscriberPortNo);
- if (port != null && port.isEnabled()) {
+ if (subscriberPort.port() != null && subscriberPort.isEnabled()) {
// reinstall eapol with default bandwidth profile
- oltFlowService.processEapolFilteringObjectives(deviceId, subscriberPortNo, defaultBpId,
+ oltFlowService.processEapolFilteringObjectives(subscriberPort, defaultBpId,
null, VlanId.vlanId(EAPOL_DEFAULT_VLAN), true);
} else {
log.debug("Port {} is no longer enabled or it's unavailable. Not "
@@ -518,22 +532,23 @@
public boolean provisionSubscriber(AccessSubscriberId subscriberId, Optional<VlanId> sTag,
Optional<VlanId> cTag, Optional<Integer> tpId) {
- log.info("Provisioning subscriber using subscriberId {}, sTag {}, cTag {}, tpId {}" +
- "", subscriberId, sTag, cTag, tpId);
+ log.info("Provisioning subscriber using subscriberId {}, sTag {}, cTag {}, tpId {}",
+ subscriberId, sTag, cTag, tpId);
// Check if we can find the connect point to which this subscriber is connected
- ConnectPoint subsPort = findSubscriberConnectPoint(subscriberId.toString());
- if (subsPort == null) {
+ ConnectPoint cp = findSubscriberConnectPoint(subscriberId.toString());
+ if (cp == null) {
log.warn("ConnectPoint for {} not found", subscriberId);
return false;
}
+ AccessDevicePort subscriberPort = new AccessDevicePort(deviceService.getPort(cp), AccessDevicePort.Type.UNI);
if (!sTag.isPresent() && !cTag.isPresent()) {
- return provisionSubscriber(subsPort);
+ return provisionSubscriber(cp);
} else if (sTag.isPresent() && cTag.isPresent() && tpId.isPresent()) {
- Port uplinkPort = getUplinkPort(deviceService.getDevice(subsPort.deviceId()));
+ AccessDevicePort uplinkPort = getUplinkPort(deviceService.getDevice(cp.deviceId()));
if (uplinkPort == null) {
- log.warn(NO_UPLINK_PORT, subsPort.deviceId());
+ log.warn(NO_UPLINK_PORT, cp.deviceId());
return false;
}
@@ -541,12 +556,11 @@
//wait until Eapol rule with defaultBpId is removed to install subscriber-based rules
//install subscriber flows
CompletableFuture<ObjectiveError> filterFuture = new CompletableFuture<>();
- oltFlowService.processEapolFilteringObjectives(subsPort.deviceId(), subsPort.port(), defaultBpId,
+ oltFlowService.processEapolFilteringObjectives(subscriberPort, defaultBpId,
filterFuture, VlanId.vlanId(EAPOL_DEFAULT_VLAN), false);
filterFuture.thenAcceptAsync(filterStatus -> {
if (filterStatus == null) {
- provisionUniTagInformation(subsPort.deviceId(), uplinkPort.number(), subsPort.port(),
- cTag.get(), sTag.get(), tpId.get());
+ provisionUniTagInformation(uplinkPort, subscriberPort, cTag.get(), sTag.get(), tpId.get());
}
});
return true;
@@ -560,30 +574,32 @@
public boolean removeSubscriber(AccessSubscriberId subscriberId, Optional<VlanId> sTag,
Optional<VlanId> cTag, Optional<Integer> tpId) {
// Check if we can find the connect point to which this subscriber is connected
- ConnectPoint subsPort = findSubscriberConnectPoint(subscriberId.toString());
- if (subsPort == null) {
+ ConnectPoint cp = findSubscriberConnectPoint(subscriberId.toString());
+ if (cp == null) {
log.warn("ConnectPoint for {} not found", subscriberId);
return false;
}
+ AccessDevicePort subscriberPort = new AccessDevicePort(deviceService.getPort(cp), AccessDevicePort.Type.UNI);
if (!sTag.isPresent() && !cTag.isPresent()) {
- return removeSubscriber(subsPort);
+ return removeSubscriber(cp);
} else if (sTag.isPresent() && cTag.isPresent() && tpId.isPresent()) {
// Get the uplink port
- Port uplinkPort = getUplinkPort(deviceService.getDevice(subsPort.deviceId()));
+ AccessDevicePort uplinkPort = getUplinkPort(deviceService.getDevice(cp.deviceId()));
if (uplinkPort == null) {
- log.warn(NO_UPLINK_PORT, subsPort.deviceId());
+ log.warn(NO_UPLINK_PORT, cp.deviceId());
return false;
}
- Optional<UniTagInformation> tagInfo = getUniTagInformation(subsPort, cTag.get(), sTag.get(), tpId.get());
+ Optional<UniTagInformation> tagInfo = getUniTagInformation(subscriberPort, cTag.get(),
+ sTag.get(), tpId.get());
if (!tagInfo.isPresent()) {
- log.warn("UniTagInformation does not exist for Device/Port {}, cTag {}, sTag {}, tpId {}",
- subsPort, cTag, sTag, tpId);
+ log.warn("UniTagInformation does not exist for {}, cTag {}, sTag {}, tpId {}",
+ subscriberPort, cTag, sTag, tpId);
return false;
}
- unprovisionVlans(subsPort.deviceId(), uplinkPort.number(), subsPort.port(), tagInfo.get());
+ unprovisionVlans(uplinkPort, subscriberPort, tagInfo.get());
return true;
} else {
log.warn("Removing subscriber is not possible - please check the provided information" +
@@ -663,15 +679,13 @@
/**
* Removes subscriber vlan flows.
*
- * @param deviceId the device identifier
* @param uplink uplink port of the OLT
* @param subscriberPort uni port
* @param uniTag uni tag information
*/
- private void unprovisionVlans(DeviceId deviceId, PortNumber uplink,
- PortNumber subscriberPort, UniTagInformation uniTag) {
-
- log.info("Unprovisioning vlans for {} at {}/{}", uniTag, deviceId, subscriberPort);
+ private void unprovisionVlans(AccessDevicePort uplink, AccessDevicePort subscriberPort, UniTagInformation uniTag) {
+ log.info("Unprovisioning vlans for {} at {}", uniTag, subscriberPort);
+ DeviceId deviceId = subscriberPort.deviceId();
CompletableFuture<ObjectiveError> downFuture = new CompletableFuture<>();
CompletableFuture<ObjectiveError> upFuture = new CompletableFuture<>();
@@ -685,13 +699,14 @@
.getMeterIdFromBpMapping(deviceId, uniTag.getDownstreamBandwidthProfile());
Optional<SubscriberFlowInfo> waitingMacSubFlowInfo =
- getAndRemoveWaitingMacSubFlowInfoForCTag(new ConnectPoint(deviceId, subscriberPort), subscriberVlan);
+ getAndRemoveWaitingMacSubFlowInfoForCTag(new ConnectPoint(deviceId, subscriberPort.number()),
+ subscriberVlan);
if (waitingMacSubFlowInfo.isPresent()) {
// only dhcp objectives applied previously, so only dhcp uninstallation objective will be processed
log.debug("Waiting MAC service removed and dhcp uninstallation objective will be processed. " +
"waitingMacSubFlowInfo:{}", waitingMacSubFlowInfo.get());
CompletableFuture<ObjectiveError> dhcpFuture = new CompletableFuture<>();
- oltFlowService.processDhcpFilteringObjectives(deviceId, subscriberPort,
+ oltFlowService.processDhcpFilteringObjectives(subscriberPort,
upstreamMeterId, uniTag, false, true, Optional.of(dhcpFuture));
dhcpFuture.thenAcceptAsync(dhcpStatus -> {
AccessDeviceEvent.Type type;
@@ -700,20 +715,19 @@
log.debug("Dhcp uninstallation objective was processed successfully for cTag {}, sTag {}, " +
"tpId {} and Device/Port:{}", uniTag.getPonCTag(), uniTag.getPonSTag(),
uniTag.getTechnologyProfileId(), subscriberPort);
- updateProgrammedSubscriber(new ConnectPoint(deviceId, subscriberPort), uniTag, false);
+ updateProgrammedSubscriber(subscriberPort, uniTag, false);
} else {
type = AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_UNREGISTRATION_FAILED;
log.error("Dhcp uninstallation objective was failed for cTag {}, sTag {}, " +
"tpId {} and Device/Port:{} :{}", uniTag.getPonCTag(), uniTag.getPonSTag(),
uniTag.getTechnologyProfileId(), subscriberPort, dhcpStatus);
}
- post(new AccessDeviceEvent(type, deviceId, deviceService.getPort(deviceId, subscriberPort),
+ post(new AccessDeviceEvent(type, deviceId, subscriberPort.port(),
deviceVlan, subscriberVlan, uniTag.getTechnologyProfileId()));
});
return;
} else {
- log.debug("There is no waiting MAC service for dev/port: {}/{} and subscriberVlan: {}",
- deviceId, subscriberPort, subscriberVlan);
+ log.debug("There is no waiting MAC service for {} and subscriberVlan: {}", subscriberPort, subscriberVlan);
}
ForwardingObjective.Builder upFwd =
@@ -723,12 +737,10 @@
ForwardingObjective.Builder downFwd =
oltFlowService.createDownBuilder(uplink, subscriberPort, downstreamMeterId, uniTag, macAddress);
- oltFlowService.processIgmpFilteringObjectives(deviceId, subscriberPort,
- upstreamMeterId, uniTag, false, true);
- oltFlowService.processDhcpFilteringObjectives(deviceId, subscriberPort,
- upstreamMeterId, uniTag, false, true, Optional.empty());
- oltFlowService.processPPPoEDFilteringObjectives(deviceId, subscriberPort,
- upstreamMeterId, uniTag, false, true);
+ oltFlowService.processIgmpFilteringObjectives(subscriberPort, upstreamMeterId, uniTag, false, true);
+ oltFlowService.processDhcpFilteringObjectives(subscriberPort,
+ upstreamMeterId, uniTag, false, true, Optional.empty());
+ oltFlowService.processPPPoEDFilteringObjectives(subscriberPort, upstreamMeterId, uniTag, false, true);
flowObjectiveService.forward(deviceId, upFwd.remove(new ObjectiveContext() {
@Override
@@ -757,23 +769,19 @@
upFuture.thenAcceptBothAsync(downFuture, (upStatus, downStatus) -> {
AccessDeviceEvent.Type type = AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_UNREGISTERED;
if (upStatus == null && downStatus == null) {
- log.debug("Uni tag information is unregistered successfully for cTag {}, sTag {}, tpId {}, and" +
- "Device/Port{}", uniTag.getPonCTag(), uniTag.getPonSTag(),
- uniTag.getTechnologyProfileId(), subscriberPort);
- updateProgrammedSubscriber(new ConnectPoint(deviceId, subscriberPort), uniTag, false);
+ log.debug("Uni tag information is unregistered successfully for cTag {}, sTag {}, tpId {} on {}",
+ uniTag.getPonCTag(), uniTag.getPonSTag(), uniTag.getTechnologyProfileId(), subscriberPort);
+ updateProgrammedSubscriber(subscriberPort, uniTag, false);
} else if (downStatus != null) {
- log.error("Subscriber with vlan {} on device {} " +
- "on port {} failed downstream uninstallation: {}",
- subscriberVlan, deviceId, subscriberPort, downStatus);
+ log.error("Subscriber with vlan {} on {} failed downstream uninstallation: {}",
+ subscriberVlan, subscriberPort, downStatus);
type = AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_UNREGISTRATION_FAILED;
} else if (upStatus != null) {
- log.error("Subscriber with vlan {} on device {} " +
- "on port {} failed upstream uninstallation: {}",
- subscriberVlan, deviceId, subscriberPort, upStatus);
+ log.error("Subscriber with vlan {} on {} failed upstream uninstallation: {}",
+ subscriberVlan, subscriberPort, upStatus);
type = AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_UNREGISTRATION_FAILED;
}
- Port port = deviceService.getPort(deviceId, subscriberPort);
- post(new AccessDeviceEvent(type, deviceId, port, deviceVlan, subscriberVlan,
+ post(new AccessDeviceEvent(type, deviceId, subscriberPort.port(), deviceVlan, subscriberVlan,
uniTag.getTechnologyProfileId()));
}, oltInstallers);
}
@@ -797,29 +805,25 @@
/**
* Adds subscriber vlan flows, dhcp, eapol and igmp trap flows for the related uni port.
*
- * @param connectPoint the connection point of the subscriber
+ * @param subPort the connection point of the subscriber
* @param uplinkPort uplink port of the OLT (the nni port)
* @param sub subscriber information that includes s, c tags, tech profile and bandwidth profile references
*/
- private void provisionUniTagList(ConnectPoint connectPoint, PortNumber uplinkPort,
+ private void provisionUniTagList(AccessDevicePort subPort, AccessDevicePort uplinkPort,
SubscriberAndDeviceInformation sub) {
- log.debug("Provisioning vlans for subscriber on dev/port: {}", connectPoint.toString());
+ log.debug("Provisioning vlans for subscriber on {}", subPort);
if (log.isTraceEnabled()) {
log.trace("Subscriber informations {}", sub);
}
if (sub.uniTagList() == null || sub.uniTagList().isEmpty()) {
- log.warn("Unitaglist doesn't exist for the subscriber {} on dev/port {}",
- sub.id(), connectPoint.toString());
+ log.warn("Unitaglist doesn't exist for the subscriber {} on {}", sub.id(), subPort);
return;
}
- DeviceId deviceId = connectPoint.deviceId();
- PortNumber subscriberPort = connectPoint.port();
-
for (UniTagInformation uniTag : sub.uniTagList()) {
- handleSubscriberFlows(deviceId, uplinkPort, subscriberPort, uniTag);
+ handleSubscriberFlows(uplinkPort, subPort, uniTag);
}
}
@@ -827,58 +831,53 @@
* Finds the uni tag information and provisions the found information.
* If the uni tag information is not found, returns
*
- * @param deviceId the access device id
* @param uplinkPort the nni port
* @param subscriberPort the uni port
* @param innerVlan the pon c tag
* @param outerVlan the pon s tag
* @param tpId the technology profile id
*/
- private void provisionUniTagInformation(DeviceId deviceId, PortNumber uplinkPort,
- PortNumber subscriberPort,
+ private void provisionUniTagInformation(AccessDevicePort uplinkPort,
+ AccessDevicePort subscriberPort,
VlanId innerVlan,
VlanId outerVlan,
Integer tpId) {
- ConnectPoint cp = new ConnectPoint(deviceId, subscriberPort);
- Optional<UniTagInformation> gotTagInformation = getUniTagInformation(cp, innerVlan, outerVlan, tpId);
+ Optional<UniTagInformation> gotTagInformation = getUniTagInformation(subscriberPort, innerVlan,
+ outerVlan, tpId);
if (!gotTagInformation.isPresent()) {
return;
}
UniTagInformation tagInformation = gotTagInformation.get();
- handleSubscriberFlows(deviceId, uplinkPort, subscriberPort, tagInformation);
+ handleSubscriberFlows(uplinkPort, subscriberPort, tagInformation);
}
- private void updateProgrammedSubscriber(ConnectPoint connectPoint, UniTagInformation tagInformation, Boolean add) {
+ private void updateProgrammedSubscriber(AccessDevicePort port, UniTagInformation tagInformation, boolean add) {
if (add) {
- programmedSubs.put(connectPoint, tagInformation);
+ programmedSubs.put(new ConnectPoint(port.deviceId(), port.number()), tagInformation);
} else {
- programmedSubs.remove(connectPoint, tagInformation);
+ programmedSubs.remove(new ConnectPoint(port.deviceId(), port.number()), tagInformation);
}
}
/**
* Installs a uni tag information flow.
*
- * @param deviceId the access device id
* @param uplinkPort the nni port
* @param subscriberPort the uni port
* @param tagInfo the uni tag information
*/
- private void handleSubscriberFlows(DeviceId deviceId, PortNumber uplinkPort, PortNumber subscriberPort,
+ private void handleSubscriberFlows(AccessDevicePort uplinkPort, AccessDevicePort subscriberPort,
UniTagInformation tagInfo) {
-
- log.debug("Provisioning vlan-based flows for the uniTagInformation {} on dev/port {}/{}",
- tagInfo, deviceId, subscriberPort);
-
- Port port = deviceService.getPort(deviceId, subscriberPort);
+ log.debug("Provisioning vlan-based flows for the uniTagInformation {} on {}", tagInfo, subscriberPort);
+ DeviceId deviceId = subscriberPort.deviceId();
if (multicastServiceName.equals(tagInfo.getServiceName())) {
// IGMP flows are taken care of along with VOD service
// Please note that for each service, Subscriber Registered event will be sent
- post(new AccessDeviceEvent(AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_REGISTERED,
- deviceId, port, tagInfo.getPonSTag(), tagInfo.getPonCTag(),
- tagInfo.getTechnologyProfileId()));
+ post(new AccessDeviceEvent(AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_REGISTERED, deviceId,
+ subscriberPort.port(), tagInfo.getPonSTag(), tagInfo.getPonCTag(),
+ tagInfo.getTechnologyProfileId()));
return;
}
@@ -888,18 +887,15 @@
getBandwidthProfileInformation(tagInfo.getDownstreamBandwidthProfile());
if (upstreamBpInfo == null) {
log.warn("No meter installed since no Upstream BW Profile definition found for "
- + "ctag {} stag {} tpId {} and dev/port: {}/{}",
- tagInfo.getPonCTag(), tagInfo.getPonSTag(),
- tagInfo.getTechnologyProfileId(), deviceId,
- subscriberPort);
+ + "ctag {} stag {} tpId {} on {}",
+ tagInfo.getPonCTag(), tagInfo.getPonSTag(), tagInfo.getTechnologyProfileId(), subscriberPort);
return;
}
if (downstreamBpInfo == null) {
log.warn("No meter installed since no Downstream BW Profile definition found for "
- + "ctag {} stag {} tpId {} and dev/port: {}/{}",
+ + "ctag {} stag {} tpId {} on {}",
tagInfo.getPonCTag(), tagInfo.getPonSTag(),
- tagInfo.getTechnologyProfileId(), deviceId,
- subscriberPort);
+ tagInfo.getTechnologyProfileId(), subscriberPort);
return;
}
@@ -908,16 +904,16 @@
.getMeterIdFromBpMapping(deviceId, upstreamBpInfo.id());
MeterId downMeterId = oltMeterService
.getMeterIdFromBpMapping(deviceId, downstreamBpInfo.id());
- SubscriberFlowInfo fi = new SubscriberFlowInfo(deviceId, uplinkPort, subscriberPort,
+ SubscriberFlowInfo fi = new SubscriberFlowInfo(uplinkPort, subscriberPort,
tagInfo, downMeterId, upMeterId,
downstreamBpInfo.id(), upstreamBpInfo.id());
if (upMeterId != null && downMeterId != null) {
- log.debug("Meters are existing for upstream {} and downstream {} on dev/port {}/{}",
- upstreamBpInfo.id(), downstreamBpInfo.id(), deviceId, subscriberPort);
+ log.debug("Meters are existing for upstream {} and downstream {} on {}",
+ upstreamBpInfo.id(), downstreamBpInfo.id(), subscriberPort);
handleSubFlowsWithMeters(fi);
} else {
- log.debug("Adding {} on {}/{} to pending subs", fi, deviceId, subscriberPort);
+ log.debug("Adding {} on {} to pending subs", fi, subscriberPort);
// one or both meters are not ready. It's possible they are in the process of being
// created for other subscribers that share the same bandwidth profile.
pendingSubscribersForDevice.compute(deviceId, (id, queue) -> {
@@ -925,17 +921,17 @@
queue = new LinkedBlockingQueue<>();
}
queue.add(fi);
- log.info("Added {} to pending subscribers on {}/{}", fi, deviceId, subscriberPort);
+ log.info("Added {} to pending subscribers on {}", fi, subscriberPort);
return queue;
});
// queue up the meters to be created
if (upMeterId == null) {
- log.debug("Missing meter for upstream {} on {}/{}", upstreamBpInfo.id(), deviceId, subscriberPort);
+ log.debug("Missing meter for upstream {} on {}", upstreamBpInfo.id(), subscriberPort);
checkAndCreateDevMeter(deviceId, upstreamBpInfo);
}
if (downMeterId == null) {
- log.debug("Missing meter for downstream {} on {}/{}", downstreamBpInfo.id(), deviceId, subscriberPort);
+ log.debug("Missing meter for downstream {} on {}", downstreamBpInfo.id(), subscriberPort);
checkAndCreateDevMeter(deviceId, downstreamBpInfo);
}
}
@@ -980,8 +976,8 @@
if (upMeterId != null && downMeterId != null) {
log.debug("Provisioning subscriber after meter {} " +
"installation and both meters are present " +
- "upstream {} and downstream {} on {}/{}",
- meterId, upMeterId, downMeterId, deviceId, fi.getUniPort());
+ "upstream {} and downstream {} on {}",
+ meterId, upMeterId, downMeterId, fi.getUniPort());
// put in the meterIds because when fi was first
// created there may or may not have been a meterId
// depending on whether the meter was created or
@@ -994,9 +990,8 @@
oltMeterService.removeFromPendingMeters(deviceId, bwpInfo);
} else {
// meter install failed
- log.error("Addition of subscriber {} on {}/{} failed due to meter " +
- "{} with result {}", fi, deviceId, fi.getUniPort(),
- meterId, result);
+ log.error("Addition of subscriber {} on {} failed due to meter " +
+ "{} with result {}", fi, fi.getUniPort(), meterId, result);
queue.remove(fi);
oltMeterService.removeFromPendingMeters(deviceId, bwpInfo);
}
@@ -1021,7 +1016,8 @@
Optional<MacAddress> macAddress =
getMacAddress(subscriberFlowInfo.getDevId(), subscriberFlowInfo.getUniPort(), tagInfo);
if (subscriberFlowInfo.getTagInfo().getEnableMacLearning()) {
- ConnectPoint cp = new ConnectPoint(subscriberFlowInfo.getDevId(), subscriberFlowInfo.getUniPort());
+ ConnectPoint cp = new ConnectPoint(subscriberFlowInfo.getDevId(),
+ subscriberFlowInfo.getUniPort().number());
if (macAddress.isPresent()) {
log.debug("MAC Address {} obtained for {}", macAddress.get(), subscriberFlowInfo);
} else {
@@ -1030,9 +1026,8 @@
}
CompletableFuture<ObjectiveError> dhcpFuture = new CompletableFuture<>();
- oltFlowService.processDhcpFilteringObjectives(subscriberFlowInfo.getDevId(),
- subscriberFlowInfo.getUniPort(), subscriberFlowInfo.getUpId(),
- tagInfo, true, true, Optional.of(dhcpFuture));
+ oltFlowService.processDhcpFilteringObjectives(subscriberFlowInfo.getUniPort(),
+ subscriberFlowInfo.getUpId(), tagInfo, true, true, Optional.of(dhcpFuture));
dhcpFuture.thenAcceptAsync(dhcpStatus -> {
if (dhcpStatus != null) {
log.error("Dhcp Objective failed for {}: {}", subscriberFlowInfo, dhcpStatus);
@@ -1040,8 +1035,7 @@
waitingMacSubscribers.remove(cp, subscriberFlowInfo);
}
post(new AccessDeviceEvent(AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_REGISTRATION_FAILED,
- subscriberFlowInfo.getDevId(),
- deviceService.getPort(subscriberFlowInfo.getDevId(), subscriberFlowInfo.getUniPort()),
+ subscriberFlowInfo.getDevId(), subscriberFlowInfo.getUniPort().port(),
tagInfo.getPonSTag(), tagInfo.getPonCTag(), tagInfo.getTechnologyProfileId()));
} else {
log.debug("Dhcp Objective success for: {}", subscriberFlowInfo);
@@ -1062,20 +1056,19 @@
}
private void continueProvisioningSubs(SubscriberFlowInfo subscriberFlowInfo, Optional<MacAddress> macAddress) {
- log.debug("Provisioning subscriber flows on {}/{} based on {}",
- subscriberFlowInfo.getDevId(), subscriberFlowInfo.getUniPort(), subscriberFlowInfo);
+ AccessDevicePort uniPort = subscriberFlowInfo.getUniPort();
+ log.debug("Provisioning subscriber flows on {} based on {}", uniPort, subscriberFlowInfo);
UniTagInformation tagInfo = subscriberFlowInfo.getTagInfo();
CompletableFuture<ObjectiveError> upFuture = new CompletableFuture<>();
CompletableFuture<ObjectiveError> downFuture = new CompletableFuture<>();
ForwardingObjective.Builder upFwd =
- oltFlowService.createUpBuilder(subscriberFlowInfo.getNniPort(), subscriberFlowInfo.getUniPort(),
+ oltFlowService.createUpBuilder(subscriberFlowInfo.getNniPort(), uniPort,
subscriberFlowInfo.getUpId(), subscriberFlowInfo.getTagInfo());
flowObjectiveService.forward(subscriberFlowInfo.getDevId(), upFwd.add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
- log.debug("Upstream HSIA flow {} installed successfully on {}/{}",
- subscriberFlowInfo, subscriberFlowInfo.getDevId(), subscriberFlowInfo.getUniPort());
+ log.debug("Upstream HSIA flow {} installed successfully on {}", subscriberFlowInfo, uniPort);
upFuture.complete(null);
}
@@ -1086,13 +1079,12 @@
}));
ForwardingObjective.Builder downFwd =
- oltFlowService.createDownBuilder(subscriberFlowInfo.getNniPort(), subscriberFlowInfo.getUniPort(),
+ oltFlowService.createDownBuilder(subscriberFlowInfo.getNniPort(), uniPort,
subscriberFlowInfo.getDownId(), subscriberFlowInfo.getTagInfo(), macAddress);
flowObjectiveService.forward(subscriberFlowInfo.getDevId(), downFwd.add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
- log.debug("Downstream HSIA flow {} installed successfully on {}/{}",
- subscriberFlowInfo, subscriberFlowInfo.getDevId(), subscriberFlowInfo.getUniPort());
+ log.debug("Downstream HSIA flow {} installed successfully on {}", subscriberFlowInfo, uniPort);
downFuture.complete(null);
}
@@ -1105,47 +1097,32 @@
upFuture.thenAcceptBothAsync(downFuture, (upStatus, downStatus) -> {
AccessDeviceEvent.Type type = AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_REGISTERED;
if (downStatus != null) {
- log.error("Flow with innervlan {} and outerVlan {} on {}/{} failed downstream installation: {}",
- tagInfo.getPonCTag(), tagInfo.getPonSTag(), subscriberFlowInfo.getDevId(),
- subscriberFlowInfo.getUniPort(), downStatus);
+ log.error("Flow with innervlan {} and outerVlan {} on {} failed downstream installation: {}",
+ tagInfo.getPonCTag(), tagInfo.getPonSTag(), uniPort, downStatus);
type = AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_REGISTRATION_FAILED;
} else if (upStatus != null) {
- log.error("Flow with innervlan {} and outerVlan {} on {}/{} failed upstream installation: {}",
- tagInfo.getPonCTag(), tagInfo.getPonSTag(), subscriberFlowInfo.getDevId(),
- subscriberFlowInfo.getUniPort(), upStatus);
+ log.error("Flow with innervlan {} and outerVlan {} on {} failed upstream installation: {}",
+ tagInfo.getPonCTag(), tagInfo.getPonSTag(), uniPort, upStatus);
type = AccessDeviceEvent.Type.SUBSCRIBER_UNI_TAG_REGISTRATION_FAILED;
} else {
- log.debug("Upstream and downstream data plane flows are installed successfully " +
- "for {}/{}", subscriberFlowInfo.getDevId(), subscriberFlowInfo.getUniPort());
- oltFlowService.processEapolFilteringObjectives(subscriberFlowInfo.getDevId(),
- subscriberFlowInfo.getUniPort(),
- tagInfo.getUpstreamBandwidthProfile(),
+ log.debug("Upstream and downstream data plane flows are installed successfully on {}", uniPort);
+ oltFlowService.processEapolFilteringObjectives(uniPort, tagInfo.getUpstreamBandwidthProfile(),
null, tagInfo.getPonCTag(), true);
if (!tagInfo.getEnableMacLearning()) {
- oltFlowService.processDhcpFilteringObjectives(subscriberFlowInfo.getDevId(),
- subscriberFlowInfo.getUniPort(),
- subscriberFlowInfo.getUpId(),
+ oltFlowService.processDhcpFilteringObjectives(uniPort, subscriberFlowInfo.getUpId(),
tagInfo, true, true, Optional.empty());
}
- oltFlowService.processIgmpFilteringObjectives(subscriberFlowInfo.getDevId(),
- subscriberFlowInfo.getUniPort(),
- subscriberFlowInfo.getUpId(),
+ oltFlowService.processIgmpFilteringObjectives(uniPort, subscriberFlowInfo.getUpId(),
tagInfo, true, true);
- oltFlowService.processPPPoEDFilteringObjectives(subscriberFlowInfo.getDevId(),
- subscriberFlowInfo.getUniPort(),
- subscriberFlowInfo.getUpId(),
+ oltFlowService.processPPPoEDFilteringObjectives(uniPort, subscriberFlowInfo.getUpId(),
tagInfo, true, true);
- updateProgrammedSubscriber(new ConnectPoint(subscriberFlowInfo.getDevId(),
- subscriberFlowInfo.getUniPort()),
- tagInfo, true);
+ updateProgrammedSubscriber(uniPort, tagInfo, true);
}
- post(new AccessDeviceEvent(type, subscriberFlowInfo.getDevId(),
- deviceService.getPort(subscriberFlowInfo.getDevId(),
- subscriberFlowInfo.getUniPort()),
+ post(new AccessDeviceEvent(type, subscriberFlowInfo.getDevId(), uniPort.port(),
tagInfo.getPonSTag(), tagInfo.getPonCTag(),
tagInfo.getTechnologyProfileId()));
}, oltInstallers);
@@ -1155,27 +1132,26 @@
* Gets mac address from tag info if present, else checks the host service.
*
* @param deviceId device ID
- * @param portNumber uni port
+ * @param port uni port
* @param tagInformation tag info
* @return MAC Address of subscriber
*/
- private Optional<MacAddress> getMacAddress(DeviceId deviceId, PortNumber portNumber,
+ private Optional<MacAddress> getMacAddress(DeviceId deviceId, AccessDevicePort port,
UniTagInformation tagInformation) {
if (isMacAddressValid(tagInformation)) {
- log.debug("Got MAC Address {} from the uniTagInformation for dev/port {}/{} and cTag {}",
- tagInformation.getConfiguredMacAddress(), deviceId, portNumber, tagInformation.getPonCTag());
+ log.debug("Got MAC Address {} from the uniTagInformation for {} and cTag {}",
+ tagInformation.getConfiguredMacAddress(), port, tagInformation.getPonCTag());
return Optional.of(MacAddress.valueOf(tagInformation.getConfiguredMacAddress()));
} else if (tagInformation.getEnableMacLearning()) {
- Optional<Host> optHost = hostService.getConnectedHosts(new ConnectPoint(deviceId, portNumber))
+ Optional<Host> optHost = hostService.getConnectedHosts(new ConnectPoint(deviceId, port.number()))
.stream().filter(host -> host.vlan().equals(tagInformation.getPonCTag())).findFirst();
if (optHost.isPresent()) {
- log.debug("Got MAC Address {} from the hostService for dev/port {}/{} and cTag {}",
- optHost.get().mac(), deviceId, portNumber, tagInformation.getPonCTag());
+ log.debug("Got MAC Address {} from the hostService for {} and cTag {}",
+ optHost.get().mac(), port, tagInformation.getPonCTag());
return Optional.of(optHost.get().mac());
}
}
- log.debug("Could not obtain MAC Address for dev/port {}/{} and cTag {}", deviceId, portNumber,
- tagInformation.getPonCTag());
+ log.debug("Could not obtain MAC Address for {} and cTag {}", port, tagInformation.getPonCTag());
return Optional.empty();
}
@@ -1190,25 +1166,25 @@
* using the pon c tag, pon s tag and the technology profile id
* May return Optional<null>
*
- * @param cp the connection point of the subscriber
+ * @param port port of the subscriber
* @param innerVlan pon c tag
* @param outerVlan pon s tag
* @param tpId the technology profile id
* @return the found uni tag information
*/
- private Optional<UniTagInformation> getUniTagInformation(ConnectPoint cp, VlanId innerVlan, VlanId outerVlan,
- int tpId) {
- log.debug("Getting uni tag information for cp: {}, innerVlan: {}, outerVlan: {}, tpId: {}",
- cp.toString(), innerVlan, outerVlan, tpId);
- SubscriberAndDeviceInformation subInfo = getSubscriber(cp);
+ private Optional<UniTagInformation> getUniTagInformation(AccessDevicePort port, VlanId innerVlan,
+ VlanId outerVlan, int tpId) {
+ log.debug("Getting uni tag information for {}, innerVlan: {}, outerVlan: {}, tpId: {}",
+ port, innerVlan, outerVlan, tpId);
+ SubscriberAndDeviceInformation subInfo = getSubscriber(new ConnectPoint(port.deviceId(), port.number()));
if (subInfo == null) {
- log.warn("Subscriber information doesn't exist for the connect point {}", cp.toString());
+ log.warn("Subscriber information doesn't exist for {}", port);
return Optional.empty();
}
List<UniTagInformation> uniTagList = subInfo.uniTagList();
if (uniTagList == null) {
- log.warn("Uni tag list is not found for the subscriber {} on {}", subInfo.id(), cp.toString());
+ log.warn("Uni tag list is not found for the subscriber {} on {}", subInfo.id(), port);
return Optional.empty();
}
@@ -1223,7 +1199,7 @@
if (service == null) {
log.warn("SADIS doesn't include the service with ponCtag {} ponStag {} and tpId {} on {}",
- innerVlan, outerVlan, tpId, cp.toString());
+ innerVlan, outerVlan, tpId, port);
return Optional.empty();
}
@@ -1249,16 +1225,17 @@
continue;
}
if (isUniPort(dev, p)) {
+ AccessDevicePort port = new AccessDevicePort(p, AccessDevicePort.Type.UNI);
if (!programmedSubs.containsKey(new ConnectPoint(dev.id(), p.number()))) {
- log.info("Creating Eapol on {}/{}", dev.id(), p.number());
- oltFlowService.processEapolFilteringObjectives(dev.id(), p.number(), defaultBpId, null,
+ log.info("Creating Eapol on {}", port);
+ oltFlowService.processEapolFilteringObjectives(port, defaultBpId, null,
VlanId.vlanId(EAPOL_DEFAULT_VLAN), true);
} else {
- log.debug("Subscriber Eapol on {}/{} is already provisioned, not installing default",
- dev.id(), p.number());
+ log.debug("Subscriber Eapol on {} is already provisioned, not installing default", port);
}
} else {
- oltFlowService.processNniFilteringObjectives(dev.id(), p.number(), true);
+ AccessDevicePort port = new AccessDevicePort(p, AccessDevicePort.Type.NNI);
+ oltFlowService.processNniFilteringObjectives(port, true);
}
}
}
@@ -1274,7 +1251,7 @@
* @param dev Device to look for
* @return The uplink Port of the OLT
*/
- private Port getUplinkPort(Device dev) {
+ private AccessDevicePort getUplinkPort(Device dev) {
// check if this device is provisioned in Sadis
SubscriberAndDeviceInformation deviceInfo = getOltInfo(dev);
log.trace("getUplinkPort: deviceInfo {}", deviceInfo);
@@ -1290,7 +1267,7 @@
.findFirst();
if (optionalPort.isPresent()) {
log.trace("getUplinkPort: Found port {}", optionalPort.get());
- return optionalPort.get();
+ return new AccessDevicePort(optionalPort.get(), AccessDevicePort.Type.NNI);
}
log.warn("getUplinkPort: " + NO_UPLINK_PORT, dev.id());
@@ -1322,7 +1299,7 @@
* @return true if the given port is a uni port
*/
private boolean isUniPort(Device d, Port p) {
- Port ulPort = getUplinkPort(d);
+ AccessDevicePort ulPort = getUplinkPort(d);
if (ulPort != null) {
return (ulPort.number().toLong() != p.number().toLong());
}
@@ -1398,8 +1375,10 @@
break;
case HOST_UPDATED:
if (event.prevSubject() != null && !event.prevSubject().mac().equals(event.subject().mac())) {
- log.debug("Subscriber's MAC address changed. devId/port: {}/{} vlan: {}",
- host.location().deviceId(), host.location().port(), host.vlan());
+ log.debug("Subscriber's MAC address changed from {} to {}. " +
+ "devId/portNumber: {}/{} vlan: {}", event.prevSubject().mac(),
+ event.subject().mac(), host.location().deviceId(), host.location().port(),
+ host.vlan());
// TODO handle subscriber MAC Address changed
} else {
log.debug("Unhandled HOST_UPDATED event: {}", event);
@@ -1425,7 +1404,7 @@
eventExecutor.execute(() -> {
DeviceId devId = event.subject().id();
Device dev = event.subject();
- Port port = event.port();
+ Port p = event.port();
DeviceEvent.Type eventType = event.type();
if (DeviceEvent.Type.PORT_STATS_UPDATED.equals(eventType) ||
@@ -1464,6 +1443,14 @@
return;
}
}
+ AccessDevicePort port = null;
+ if (p != null) {
+ if (isUniPort(dev, p)) {
+ port = new AccessDevicePort(p, AccessDevicePort.Type.UNI);
+ } else {
+ port = new AccessDevicePort(p, AccessDevicePort.Type.NNI);
+ }
+ }
switch (event.type()) {
//TODO: Port handling and bookkeeping should be improved once
@@ -1473,12 +1460,12 @@
log.warn("Received {} for disconnected device {}, ignoring", event, devId);
return;
}
- if (isUniPort(dev, port)) {
- post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_ADDED, devId, port));
+ if (port.type().equals(AccessDevicePort.Type.UNI)) {
+ post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_ADDED, devId, port.port()));
if (port.isEnabled() && !port.number().equals(PortNumber.LOCAL)) {
- log.info("eapol will be sent for port added {}/{}", devId, port);
- oltFlowService.processEapolFilteringObjectives(devId, port.number(), defaultBpId,
+ log.info("eapol will be sent for port added {}", port);
+ oltFlowService.processEapolFilteringObjectives(port, defaultBpId,
null,
VlanId.vlanId(EAPOL_DEFAULT_VLAN),
true);
@@ -1486,29 +1473,28 @@
} else {
SubscriberAndDeviceInformation deviceInfo = getOltInfo(dev);
if (deviceInfo != null) {
- oltFlowService.processNniFilteringObjectives(dev.id(), port.number(), true);
+ oltFlowService.processNniFilteringObjectives(port, true);
}
}
break;
case PORT_REMOVED:
- if (isUniPort(dev, port)) {
+ if (port.type().equals(AccessDevicePort.Type.UNI)) {
// if no subscriber is provisioned we need to remove the default EAPOL
// if a subscriber was provisioned the default EAPOL will not be there and we can skip.
// The EAPOL with subscriber tag will be removed by removeSubscriber call.
Collection<? extends UniTagInformation> uniTagInformationSet =
- programmedSubs.get(new ConnectPoint(port.element().id(), port.number())).value();
+ programmedSubs.get(new ConnectPoint(port.deviceId(), port.number())).value();
if (uniTagInformationSet == null || uniTagInformationSet.isEmpty()) {
- log.info("No subscriber provisioned on port {}/{} in PORT_REMOVED event, " +
- "removing default EAPOL flow", devId, port);
- oltFlowService.processEapolFilteringObjectives(devId, port.number(), defaultBpId,
- null,
+ log.info("No subscriber provisioned on port {} in PORT_REMOVED event, " +
+ "removing default EAPOL flow", port);
+ oltFlowService.processEapolFilteringObjectives(port, defaultBpId, null,
VlanId.vlanId(EAPOL_DEFAULT_VLAN),
false);
} else {
- removeSubscriber(new ConnectPoint(devId, port.number()));
+ removeSubscriber(port);
}
- post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_REMOVED, devId, port));
+ post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_REMOVED, devId, port.port()));
}
break;
case PORT_UPDATED:
@@ -1516,13 +1502,11 @@
log.warn("Received {} for disconnected device {}, ignoring", event, devId);
return;
}
- if (!isUniPort(dev, port)) {
+ if (port.type().equals(AccessDevicePort.Type.NNI)) {
SubscriberAndDeviceInformation deviceInfo = getOltInfo(dev);
if (deviceInfo != null && port.isEnabled()) {
- log.debug("NNI dev/port {}/{} enabled", dev.id(),
- port.number());
- oltFlowService.processNniFilteringObjectives(dev.id(),
- port.number(), true);
+ log.debug("NNI {} enabled", port);
+ oltFlowService.processNniFilteringObjectives(port, true);
}
return;
}
@@ -1530,27 +1514,25 @@
Collection<? extends UniTagInformation> uniTagInformationSet = programmedSubs.get(cp).value();
if (uniTagInformationSet == null || uniTagInformationSet.isEmpty()) {
if (!port.number().equals(PortNumber.LOCAL)) {
- log.info("eapol will be {} for dev/port updated {}/{} with default vlan {}",
- (port.isEnabled()) ? "added" : "removed",
- devId, port.number(), EAPOL_DEFAULT_VLAN);
- oltFlowService.processEapolFilteringObjectives(devId, port.number(), defaultBpId,
- null,
+ log.info("eapol will be {} updated for {} with default vlan {}",
+ (port.isEnabled()) ? "added" : "removed", port, EAPOL_DEFAULT_VLAN);
+ oltFlowService.processEapolFilteringObjectives(port, defaultBpId, null,
VlanId.vlanId(EAPOL_DEFAULT_VLAN),
port.isEnabled());
}
} else {
- log.info("eapol will be {} for dev/port updated {}/{}",
- (port.isEnabled()) ? "added" : "removed",
- devId, port.number());
- uniTagInformationSet.forEach(uniTag ->
- oltFlowService.processEapolFilteringObjectives(devId, port.number(),
- uniTag.getUpstreamBandwidthProfile(), null,
- uniTag.getPonCTag(), port.isEnabled()));
+ log.info("eapol will be {} updated for {}", (port.isEnabled()) ? "added" : "removed",
+ port);
+ for (UniTagInformation uniTag : uniTagInformationSet) {
+ oltFlowService.processEapolFilteringObjectives(port,
+ uniTag.getUpstreamBandwidthProfile(), null,
+ uniTag.getPonCTag(), port.isEnabled());
+ }
}
if (port.isEnabled()) {
- post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_ADDED, devId, port));
+ post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_ADDED, devId, port.port()));
} else {
- post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_REMOVED, devId, port));
+ post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_REMOVED, devId, port.port()));
}
break;
case DEVICE_ADDED:
diff --git a/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java b/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
index fed9546..83919a4 100644
--- a/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
+++ b/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
@@ -27,10 +27,8 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.flow.DefaultTrafficSelector;
@@ -50,6 +48,7 @@
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
+import org.opencord.olt.AccessDevicePort;
import org.opencord.olt.internalapi.AccessDeviceFlowService;
import org.opencord.olt.internalapi.AccessDeviceMeterService;
import org.opencord.sadis.BandwidthProfileInformation;
@@ -189,6 +188,8 @@
.register(KryoNamespaces.API)
.register(UniTagInformation.class)
.register(SubscriberFlowInfo.class)
+ .register(AccessDevicePort.class)
+ .register(AccessDevicePort.Type.class)
.register(LinkedBlockingQueue.class)
.build();
pendingEapolForDevice = storageService.<DeviceId, BlockingQueue<SubscriberFlowInfo>>consistentMapBuilder()
@@ -268,7 +269,7 @@
}
@Override
- public void processDhcpFilteringObjectives(DeviceId devId, PortNumber port,
+ public void processDhcpFilteringObjectives(AccessDevicePort port,
MeterId upstreamMeterId,
UniTagInformation tagInformation,
boolean install,
@@ -277,17 +278,15 @@
if (upstream) {
// for UNI ports
if (tagInformation != null && !tagInformation.getIsDhcpRequired()) {
- log.debug("Dhcp provisioning is disabled for UNI port {} on "
- + "device {} for service {}", port, devId,
- tagInformation.getServiceName());
+ log.debug("Dhcp provisioning is disabled for UNI port {} for service {}",
+ port, tagInformation.getServiceName());
dhcpFuture.ifPresent(f -> f.complete(null));
return;
}
} else {
// for NNI ports
if (!enableDhcpOnNni) {
- log.debug("Dhcp provisioning is disabled for NNI port {} on "
- + "device {}", port, devId);
+ log.debug("Dhcp provisioning is disabled for NNI port {}", port);
dhcpFuture.ifPresent(f -> f.complete(null));
return;
}
@@ -306,7 +305,7 @@
EthType ethType = EthType.EtherType.IPV4.ethType();
byte protocol = IPv4.PROTOCOL_UDP;
- addDhcpFilteringObjectives(devId, port, udpSrc, udpDst, ethType,
+ addDhcpFilteringObjectives(port, udpSrc, udpDst, ethType,
upstreamMeterId, techProfileId, protocol, cTag, unitagMatch,
vlanPcp, upstream, install, dhcpFuture);
}
@@ -318,13 +317,13 @@
EthType ethType = EthType.EtherType.IPV6.ethType();
byte protocol = IPv6.PROTOCOL_UDP;
- addDhcpFilteringObjectives(devId, port, udpSrc, udpDst, ethType,
+ addDhcpFilteringObjectives(port, udpSrc, udpDst, ethType,
upstreamMeterId, techProfileId, protocol, cTag, unitagMatch,
vlanPcp, upstream, install, dhcpFuture);
}
}
- private void addDhcpFilteringObjectives(DeviceId devId, PortNumber port, int udpSrc, int udpDst,
+ private void addDhcpFilteringObjectives(AccessDevicePort port, int udpSrc, int udpDst,
EthType ethType, MeterId upstreamMeterId, int techProfileId, byte protocol,
VlanId cTag, VlanId unitagMatch,
Byte vlanPcp, boolean upstream,
@@ -342,7 +341,7 @@
}
FilteringObjective.Builder dhcpUpstreamBuilder = (install ? builder.permit() : builder.deny())
- .withKey(Criteria.matchInPort(port))
+ .withKey(Criteria.matchInPort(port.number()))
.addCondition(Criteria.matchEthType(ethType))
.addCondition(Criteria.matchIPProtocol(protocol))
.addCondition(Criteria.matchUdpSrc(TpPort.tpPort(udpSrc)))
@@ -368,27 +367,27 @@
FilteringObjective dhcpUpstream = dhcpUpstreamBuilder.add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
- log.info("DHCP {} filter for dev/port {}/{} {}.",
- (ethType.equals(EthType.EtherType.IPV4.ethType())) ? V4 : V6,
- devId, port, (install) ? INSTALLED : REMOVED);
+ log.info("DHCP {} filter for {} {}.",
+ (ethType.equals(EthType.EtherType.IPV4.ethType())) ? V4 : V6, port,
+ (install) ? INSTALLED : REMOVED);
dhcpFuture.ifPresent(f -> f.complete(null));
}
@Override
public void onError(Objective objective, ObjectiveError error) {
- log.error("DHCP {} filter for dev/port {}/{} failed {} because {}",
- (ethType.equals(EthType.EtherType.IPV4.ethType())) ? V4 : V6,
- devId, port, (install) ? INSTALLATION : REMOVAL,
+ log.error("DHCP {} filter for {} failed {} because {}",
+ (ethType.equals(EthType.EtherType.IPV4.ethType())) ? V4 : V6, port,
+ (install) ? INSTALLATION : REMOVAL,
error);
dhcpFuture.ifPresent(f -> f.complete(error));
}
});
- flowObjectiveService.filter(devId, dhcpUpstream);
+ flowObjectiveService.filter(port.deviceId(), dhcpUpstream);
}
@Override
- public void processPPPoEDFilteringObjectives(DeviceId devId, PortNumber portNumber,
+ public void processPPPoEDFilteringObjectives(AccessDevicePort port,
MeterId upstreamMeterId,
UniTagInformation tagInformation,
boolean install,
@@ -425,7 +424,7 @@
}
DefaultFilteringObjective.Builder pppoedBuilder = (install ? builder.permit() : builder.deny())
- .withKey(Criteria.matchInPort(portNumber))
+ .withKey(Criteria.matchInPort(port.number()))
.addCondition(Criteria.matchEthType(EthType.EtherType.PPPoED.ethType()))
.fromApp(appId)
.withPriority(10000);
@@ -445,21 +444,20 @@
.add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
- log.info("PPPoED filter for {} on {} {}.",
- devId, portNumber, (install) ? INSTALLED : REMOVED);
+ log.info("PPPoED filter for {} {}.", port, (install) ? INSTALLED : REMOVED);
}
@Override
public void onError(Objective objective, ObjectiveError error) {
- log.info("PPPoED filter for {} on {} failed {} because {}",
- devId, portNumber, (install) ? INSTALLATION : REMOVAL, error);
+ log.info("PPPoED filter for {} failed {} because {}", port,
+ (install) ? INSTALLATION : REMOVAL, error);
}
});
- flowObjectiveService.filter(devId, pppoed);
+ flowObjectiveService.filter(port.deviceId(), pppoed);
}
@Override
- public void processIgmpFilteringObjectives(DeviceId devId, PortNumber port,
+ public void processIgmpFilteringObjectives(AccessDevicePort port,
MeterId upstreamMeterId,
UniTagInformation tagInformation,
boolean install,
@@ -467,22 +465,19 @@
if (upstream) {
// for UNI ports
if (tagInformation != null && !tagInformation.getIsIgmpRequired()) {
- log.debug("Igmp provisioning is disabled for UNI port {} on "
- + "device {} for service {}", port, devId,
- tagInformation.getServiceName());
+ log.debug("Igmp provisioning is disabled for UNI port {} for service {}",
+ port, tagInformation.getServiceName());
return;
}
} else {
// for NNI ports
if (!enableIgmpOnNni) {
- log.debug("Igmp provisioning is disabled for NNI port {} on device {}",
- port, devId);
+ log.debug("Igmp provisioning is disabled for NNI port {}", port);
return;
}
}
- log.debug("{} IGMP flows on {}:{}", (install) ?
- "Installing" : "Removing", devId, port);
+ log.debug("{} IGMP flows on {}", (install) ? "Installing" : "Removing", port);
DefaultFilteringObjective.Builder filterBuilder = DefaultFilteringObjective.builder();
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
if (upstream) {
@@ -513,7 +508,7 @@
filterBuilder = install ? filterBuilder.permit() : filterBuilder.deny();
FilteringObjective igmp = filterBuilder
- .withKey(Criteria.matchInPort(port))
+ .withKey(Criteria.matchInPort(port.number()))
.addCondition(Criteria.matchEthType(EthType.EtherType.IPV4.ethType()))
.addCondition(Criteria.matchIPProtocol(IPv4.PROTOCOL_IGMP))
.withMeta(treatmentBuilder
@@ -523,61 +518,60 @@
.add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
- log.info("Igmp filter for dev/port {}/{} {}.",
- devId, port, (install) ? INSTALLED : REMOVED);
+ log.info("Igmp filter for {} {}.", port, (install) ? INSTALLED : REMOVED);
}
@Override
public void onError(Objective objective, ObjectiveError error) {
- log.error("Igmp filter for dev/port {}/{} failed {} because {}.",
- devId, port, (install) ? INSTALLATION : REMOVAL,
+ log.error("Igmp filter for {} failed {} because {}.", port, (install) ? INSTALLATION : REMOVAL,
error);
}
});
- flowObjectiveService.filter(devId, igmp);
+ flowObjectiveService.filter(port.deviceId(), igmp);
}
@Override
- public void processEapolFilteringObjectives(DeviceId devId, PortNumber portNumber, String bpId,
+ public void processEapolFilteringObjectives(AccessDevicePort port, String bpId,
CompletableFuture<ObjectiveError> filterFuture,
VlanId vlanId, boolean install) {
if (!enableEapol) {
- log.debug("Eapol filtering is disabled. Completing filteringFuture immediately for the device {}", devId);
+ log.debug("Eapol filtering is disabled. Completing filteringFuture immediately for the device {}",
+ port.deviceId());
if (filterFuture != null) {
filterFuture.complete(null);
}
return;
}
- log.info("Processing EAPOL with Bandwidth profile {} on {}/{}", bpId,
- devId, portNumber);
+ log.info("Processing EAPOL with Bandwidth profile {} on {}", bpId, port);
BandwidthProfileInformation bpInfo = getBandwidthProfileInformation(bpId);
if (bpInfo == null) {
log.warn("Bandwidth profile {} is not found. Authentication flow"
- + " will not be installed on {}/{}", bpId, devId, portNumber);
+ + " will not be installed on {}", bpId, port);
if (filterFuture != null) {
filterFuture.complete(ObjectiveError.BADPARAMS);
}
return;
}
- ConnectPoint cp = new ConnectPoint(devId, portNumber);
+ ConnectPoint cp = new ConnectPoint(port.deviceId(), port.number());
DefaultFilteringObjective.Builder filterBuilder = DefaultFilteringObjective.builder();
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
CompletableFuture<Object> meterFuture = new CompletableFuture<>();
// check if meter exists and create it only for an install
- final MeterId meterId = oltMeterService.getMeterIdFromBpMapping(devId, bpInfo.id());
- log.info("Meter id {} for Bandwidth profile {} associated to EAPOL on {}", meterId, bpInfo.id(), devId);
+ final MeterId meterId = oltMeterService.getMeterIdFromBpMapping(port.deviceId(), bpInfo.id());
+ log.info("Meter id {} for Bandwidth profile {} associated to EAPOL on {}",
+ meterId, bpInfo.id(), port.deviceId());
if (meterId == null) {
if (install) {
- log.debug("Need to install meter for EAPOL with bwp {} on dev/port {}", bpInfo.id(), cp.toString());
- SubscriberFlowInfo fi = new SubscriberFlowInfo(devId, null, cp.port(),
+ log.debug("Need to install meter for EAPOL with bwp {} on {}", bpInfo.id(), port);
+ SubscriberFlowInfo fi = new SubscriberFlowInfo(null, port,
new UniTagInformation.Builder()
.setPonCTag(vlanId).build(),
null, null,
null, bpInfo.id());
- pendingEapolForDevice.compute(devId, (id, queue) -> {
+ pendingEapolForDevice.compute(port.deviceId(), (id, queue) -> {
if (queue == null) {
queue = new LinkedBlockingQueue<>();
}
@@ -586,11 +580,10 @@
});
//If false the meter is already being installed, skipping installation
- if (!oltMeterService.checkAndAddPendingMeter(devId, bpInfo)) {
+ if (!oltMeterService.checkAndAddPendingMeter(port.deviceId(), bpInfo)) {
return;
}
- MeterId innerMeterId = oltMeterService.createMeter(devId, bpInfo,
- meterFuture);
+ MeterId innerMeterId = oltMeterService.createMeter(port.deviceId(), bpInfo, meterFuture);
fi.setUpMeterId(innerMeterId);
} else {
// this case should not happen as the request to remove an eapol
@@ -598,8 +591,8 @@
// Nevertheless we can still delete the flow as we only need the
// correct 'match' to do so.
log.warn("Unknown meter id for bp {}, still proceeding with "
- + "delete of eapol flow for {}", bpInfo.id(), cp.toString());
- SubscriberFlowInfo fi = new SubscriberFlowInfo(devId, null, cp.port(),
+ + "delete of eapol flow on {}", bpInfo.id(), port);
+ SubscriberFlowInfo fi = new SubscriberFlowInfo(null, port,
new UniTagInformation.Builder()
.setPonCTag(vlanId).build(),
null, meterId,
@@ -607,8 +600,8 @@
handleEapol(filterFuture, install, cp, filterBuilder, treatmentBuilder, fi, meterId);
}
} else {
- log.debug("Meter {} was previously created for bp {} on {}", meterId, bpInfo.id(), cp.toString());
- SubscriberFlowInfo fi = new SubscriberFlowInfo(devId, null, cp.port(),
+ log.debug("Meter {} was previously created for bp {} on {}", meterId, bpInfo.id(), port);
+ SubscriberFlowInfo fi = new SubscriberFlowInfo(null, port,
new UniTagInformation.Builder()
.setPonCTag(vlanId).build(),
null, meterId,
@@ -619,33 +612,34 @@
}
meterFuture.thenAcceptAsync(result -> {
//for each pending eapol flow we check if the meter is there.
- BlockingQueue<SubscriberFlowInfo> queue = pendingEapolForDevice.get(devId);
+ BlockingQueue<SubscriberFlowInfo> queue = pendingEapolForDevice.get(port.deviceId());
if (queue != null) {
while (true) {
SubscriberFlowInfo fi = queue.remove();
if (fi == null) {
- pendingEapolForDevice.replace(devId, queue);
+ pendingEapolForDevice.replace(port.deviceId(), queue);
break;
}
//TODO this might return the reference and not the actual object
// so it can be actually swapped underneath us.
- log.debug("handing pending eapol on {}/{} for {}", fi.getDevId(), fi.getUniPort(), fi);
+ log.debug("handing pending eapol on {} for {}", fi.getUniPort(), fi);
if (result == null) {
MeterId mId = oltMeterService
- .getMeterIdFromBpMapping(devId, fi.getUpBpInfo());
+ .getMeterIdFromBpMapping(port.deviceId(), fi.getUpBpInfo());
if (mId != null) {
- log.debug("Meter installation completed for subscriber on {}, handling EAPOL trap flow",
- cp.toString());
+ log.debug("Meter installation completed for subscriber on {}, " +
+ "handling EAPOL trap flow", port);
handleEapol(filterFuture, install, cp, filterBuilder, treatmentBuilder, fi, mId);
}
} else {
log.warn("Meter installation error while sending EAPOL trap flow to {}. " +
- "Result {} and MeterId {}", cp.toString(), result, meterId);
+ "Result {} and MeterId {}", port, result,
+ meterId);
}
- oltMeterService.removeFromPendingMeters(devId, bpInfo);
+ oltMeterService.removeFromPendingMeters(port.deviceId(), bpInfo);
}
} else {
- log.info("No pending EAPOLs on {}", devId);
+ log.info("No pending EAPOLs on {}", port.deviceId());
}
});
}
@@ -655,17 +649,17 @@
DefaultFilteringObjective.Builder filterBuilder,
TrafficTreatment.Builder treatmentBuilder,
SubscriberFlowInfo fi, MeterId mId) {
- log.info("Meter {} for {} on {}/{} exists. {} EAPOL trap flow",
- mId, fi.getUpBpInfo(), fi.getDevId(), fi.getUniPort(),
+ log.info("Meter {} for {} on {} exists. {} EAPOL trap flow",
+ mId, fi.getUpBpInfo(), fi.getUniPort(),
(install) ? "Installing" : "Removing");
- int techProfileId = getDefaultTechProfileId(fi.getDevId(), fi.getUniPort());
+ int techProfileId = getDefaultTechProfileId(fi.getUniPort());
// can happen in case of removal
if (mId != null) {
treatmentBuilder.meter(mId);
}
//Authentication trap flow uses only tech profile id as write metadata value
FilteringObjective eapol = (install ? filterBuilder.permit() : filterBuilder.deny())
- .withKey(Criteria.matchInPort(fi.getUniPort()))
+ .withKey(Criteria.matchInPort(fi.getUniPort().number()))
.addCondition(Criteria.matchEthType(EthType.EtherType.EAPOL.ethType()))
.withMeta(treatmentBuilder
.writeMetadata(createTechProfValueForWm(
@@ -680,9 +674,8 @@
.add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
- log.info("Eapol filter {} for {} on {}/{} with meter {}.",
- objective.id(), (install) ? INSTALLED : REMOVED,
- fi.getDevId(), fi.getUniPort(), mId);
+ log.info("Eapol filter {} for {} on {} with meter {}.",
+ objective.id(), (install) ? INSTALLED : REMOVED, fi.getUniPort(), mId);
if (filterFuture != null) {
filterFuture.complete(null);
}
@@ -690,9 +683,8 @@
@Override
public void onError(Objective objective, ObjectiveError error) {
- log.error("Eapol filter {} for {}/{} with meter {} " +
- "failed {} because {}", objective.id(),
- fi.getDevId(), fi.getUniPort(), mId,
+ log.error("Eapol filter {} for {} with meter {} " +
+ "failed {} because {}", objective.id(), fi.getUniPort(), mId,
(install) ? INSTALLATION : REMOVAL,
error);
if (filterFuture != null) {
@@ -707,27 +699,26 @@
* Installs trap filtering objectives for particular traffic types on an
* NNI port.
*
- * @param devId device ID
- * @param port port number
+ * @param nniPort NNI port
* @param install true to install, false to remove
*/
@Override
- public void processNniFilteringObjectives(DeviceId devId, PortNumber port, boolean install) {
- log.info("{} flows for NNI port {} on device {}",
- install ? "Adding" : "Removing", port, devId);
- processLldpFilteringObjective(devId, port, install);
- processDhcpFilteringObjectives(devId, port, null, null, install, false, Optional.empty());
- processIgmpFilteringObjectives(devId, port, null, null, install, false);
- processPPPoEDFilteringObjectives(devId, port, null, null, install, false);
+ public void processNniFilteringObjectives(AccessDevicePort nniPort, boolean install) {
+ log.info("{} flows for NNI port {}",
+ install ? "Adding" : "Removing", nniPort);
+ processLldpFilteringObjective(nniPort, install);
+ processDhcpFilteringObjectives(nniPort, null, null, install, false, Optional.empty());
+ processIgmpFilteringObjectives(nniPort, null, null, install, false);
+ processPPPoEDFilteringObjectives(nniPort, null, null, install, false);
}
@Override
- public void processLldpFilteringObjective(DeviceId devId, PortNumber port, boolean install) {
+ public void processLldpFilteringObjective(AccessDevicePort port, boolean install) {
DefaultFilteringObjective.Builder builder = DefaultFilteringObjective.builder();
FilteringObjective lldp = (install ? builder.permit() : builder.deny())
- .withKey(Criteria.matchInPort(port))
+ .withKey(Criteria.matchInPort(port.number()))
.addCondition(Criteria.matchEthType(EthType.EtherType.LLDP.ethType()))
.withMeta(DefaultTrafficTreatment.builder()
.setOutput(PortNumber.CONTROLLER).build())
@@ -736,31 +727,29 @@
.add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
- log.info("LLDP filter for dev/port {}/{} {}.",
- devId, port, (install) ? INSTALLED : REMOVED);
+ log.info("LLDP filter for {} {}.", port, (install) ? INSTALLED : REMOVED);
}
@Override
public void onError(Objective objective, ObjectiveError error) {
- log.error("LLDP filter for dev/port {}/{} failed {} because {}",
- devId, port, (install) ? INSTALLATION : REMOVAL,
+ log.error("LLDP filter for {} failed {} because {}", port, (install) ? INSTALLATION : REMOVAL,
error);
}
});
- flowObjectiveService.filter(devId, lldp);
+ flowObjectiveService.filter(port.deviceId(), lldp);
}
@Override
- public ForwardingObjective.Builder createTransparentBuilder(PortNumber uplinkPort,
- PortNumber subscriberPort,
+ public ForwardingObjective.Builder createTransparentBuilder(AccessDevicePort uplinkPort,
+ AccessDevicePort subscriberPort,
MeterId meterId,
UniTagInformation tagInfo,
boolean upstream) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchVlanId(tagInfo.getPonSTag())
- .matchInPort(upstream ? subscriberPort : uplinkPort)
+ .matchInPort(upstream ? subscriberPort.number() : uplinkPort.number())
.matchInnerVlanId(tagInfo.getPonCTag())
.build();
@@ -770,22 +759,23 @@
}
TrafficTreatment treatment = tBuilder
- .setOutput(upstream ? uplinkPort : subscriberPort)
+ .setOutput(upstream ? uplinkPort.number() : subscriberPort.number())
.writeMetadata(createMetadata(upstream ? tagInfo.getPonSTag() : tagInfo.getPonCTag(),
- tagInfo.getTechnologyProfileId(), upstream ? uplinkPort : subscriberPort), 0)
+ tagInfo.getTechnologyProfileId(),
+ upstream ? uplinkPort.number() : subscriberPort.number()), 0)
.build();
return createForwardingObjectiveBuilder(selector, treatment, MIN_PRIORITY);
}
@Override
- public ForwardingObjective.Builder createUpBuilder(PortNumber uplinkPort,
- PortNumber subscriberPort,
+ public ForwardingObjective.Builder createUpBuilder(AccessDevicePort uplinkPort,
+ AccessDevicePort subscriberPort,
MeterId upstreamMeterId,
UniTagInformation uniTagInformation) {
TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(subscriberPort)
+ .matchInPort(subscriberPort.number())
.matchVlanId(uniTagInformation.getUniTagMatch())
.build();
@@ -807,9 +797,9 @@
treatmentBuilder.setVlanPcp((byte) uniTagInformation.getUsPonSTagPriority());
}
- treatmentBuilder.setOutput(uplinkPort)
+ treatmentBuilder.setOutput(uplinkPort.number())
.writeMetadata(createMetadata(uniTagInformation.getPonCTag(),
- uniTagInformation.getTechnologyProfileId(), uplinkPort), 0L);
+ uniTagInformation.getTechnologyProfileId(), uplinkPort.number()), 0L);
if (upstreamMeterId != null) {
treatmentBuilder.meter(upstreamMeterId);
@@ -819,8 +809,8 @@
}
@Override
- public ForwardingObjective.Builder createDownBuilder(PortNumber uplinkPort,
- PortNumber subscriberPort,
+ public ForwardingObjective.Builder createDownBuilder(AccessDevicePort uplinkPort,
+ AccessDevicePort subscriberPort,
MeterId downstreamMeterId,
UniTagInformation tagInformation,
Optional<MacAddress> macAddress) {
@@ -828,7 +818,7 @@
//subscriberVlan can be any valid Vlan here including ANY to make sure the packet is tagged
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder()
.matchVlanId(tagInformation.getPonSTag())
- .matchInPort(uplinkPort)
+ .matchInPort(uplinkPort.number())
.matchInnerVlanId(tagInformation.getPonCTag());
@@ -844,11 +834,11 @@
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder()
.popVlan()
- .setOutput(subscriberPort);
+ .setOutput(subscriberPort.number());
treatmentBuilder.writeMetadata(createMetadata(tagInformation.getPonCTag(),
tagInformation.getTechnologyProfileId(),
- subscriberPort), 0);
+ subscriberPort.number()), 0);
// Upstream pbit is used to remark inner vlan pbit.
// Upstream is used to avoid trusting the BNG to send the packet with correct pbit.
@@ -919,18 +909,16 @@
* If multiple services are found in uniServiceList, returns default tech profile id
* If one service is found, returns the found one
*
- * @param devId
- * @param portNumber
+ * @param port uni port
* @return the default technology profile id
*/
- private int getDefaultTechProfileId(DeviceId devId, PortNumber portNumber) {
+ private int getDefaultTechProfileId(AccessDevicePort port) {
if (subsService == null) {
log.warn(SADIS_NOT_RUNNING);
return defaultTechProfileId;
}
- Port port = deviceService.getPort(devId, portNumber);
if (port != null) {
- SubscriberAndDeviceInformation info = subsService.get(port.annotations().value(AnnotationKeys.PORT_NAME));
+ SubscriberAndDeviceInformation info = subsService.get(port.name());
if (info != null && info.uniTagList().size() == 1) {
return info.uniTagList().get(0).getTechnologyProfileId();
}
diff --git a/impl/src/main/java/org/opencord/olt/impl/SubscriberFlowInfo.java b/impl/src/main/java/org/opencord/olt/impl/SubscriberFlowInfo.java
index 1ac5b08..444f45f 100644
--- a/impl/src/main/java/org/opencord/olt/impl/SubscriberFlowInfo.java
+++ b/impl/src/main/java/org/opencord/olt/impl/SubscriberFlowInfo.java
@@ -16,8 +16,8 @@
package org.opencord.olt.impl;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
import org.onosproject.net.meter.MeterId;
+import org.opencord.olt.AccessDevicePort;
import org.opencord.sadis.UniTagInformation;
import java.util.Objects;
@@ -27,8 +27,8 @@
*/
class SubscriberFlowInfo {
private final DeviceId devId;
- private final PortNumber nniPort;
- private final PortNumber uniPort;
+ private final AccessDevicePort nniPort;
+ private final AccessDevicePort uniPort;
private final UniTagInformation tagInfo;
private MeterId downId;
private MeterId upId;
@@ -37,7 +37,6 @@
/**
* Builds the mapper of information.
- * @param devId the device id
* @param nniPort the nni port
* @param uniPort the uni port
* @param tagInfo the tag info
@@ -46,10 +45,10 @@
* @param downBpInfo the downstream bandwidth profile
* @param upBpInfo the upstream bandwidth profile
*/
- SubscriberFlowInfo(DeviceId devId, PortNumber nniPort, PortNumber uniPort,
+ SubscriberFlowInfo(AccessDevicePort nniPort, AccessDevicePort uniPort,
UniTagInformation tagInfo, MeterId downId, MeterId upId,
String downBpInfo, String upBpInfo) {
- this.devId = devId;
+ this.devId = uniPort.deviceId();
this.nniPort = nniPort;
this.uniPort = uniPort;
this.tagInfo = tagInfo;
@@ -73,7 +72,7 @@
*
* @return nni port
*/
- PortNumber getNniPort() {
+ AccessDevicePort getNniPort() {
return nniPort;
}
@@ -82,7 +81,7 @@
*
* @return uni port
*/
- PortNumber getUniPort() {
+ AccessDevicePort getUniPort() {
return uniPort;
}