[VOL-4050] Logging ONU Serial Number on ONOS Olt App
Change-Id: Icaf2a1c368c62420880b753ebd395a88962e725d
diff --git a/api/src/main/java/org/opencord/olt/AccessDevicePort.java b/api/src/main/java/org/opencord/olt/AccessDevicePort.java
new file mode 100644
index 0000000..8a1665d
--- /dev/null
+++ b/api/src/main/java/org/opencord/olt/AccessDevicePort.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.opencord.olt;
+
+import org.onosproject.net.AnnotationKeys;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+
+/**
+ * OLT device port.
+ */
+public class AccessDevicePort {
+
+ Port port;
+ Type type;
+
+ /**
+ * OLT Port Type.
+ */
+ public enum Type {
+ NNI,
+ UNI,
+ }
+
+ /**
+ * Creates an AccessDevicePort with given ONOS port object and OLT port type.
+ *
+ * @param port ONOS port
+ * @param type OLT port type
+ */
+ public AccessDevicePort(Port port, Type type) {
+ this.port = port;
+ this.type = type;
+ }
+
+ /**
+ * Get ONOS Port object.
+ *
+ * @return ONOS port
+ */
+ public Port port() {
+ return this.port;
+ }
+
+ /**
+ * Get OLT port Type.
+ *
+ * @return OLT port type
+ */
+ public Type type() {
+ return this.type;
+ }
+
+ /**
+ * Check port is enabled state on ONOS.
+ *
+ * @return is Access Device Port enabled
+ */
+ public boolean isEnabled() {
+ return this.port.isEnabled();
+ }
+
+ /**
+ * Get Device ID of OLT which the port is connected.
+ *
+ * @return OLT Device ID
+ */
+ public DeviceId deviceId() {
+ return (DeviceId) this.port.element().id();
+ }
+
+ /**
+ * Get port number.
+ *
+ * @return port number
+ */
+ public PortNumber number() {
+ return this.port.number();
+ }
+
+ /**
+ * Get port name which is combination of serial number and uni index.
+ *
+ * @return port name (ex: BBSM00010001-1)
+ */
+ public String name() {
+ return this.port.annotations().value(AnnotationKeys.PORT_NAME);
+ }
+
+ @Override
+ public String toString() {
+ return deviceId().toString() + '/' + number() + '[' + name() + ']';
+ }
+
+}
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;
}
diff --git a/impl/src/main/java/org/opencord/olt/internalapi/AccessDeviceFlowService.java b/impl/src/main/java/org/opencord/olt/internalapi/AccessDeviceFlowService.java
index e3a612c..0012e28 100644
--- a/impl/src/main/java/org/opencord/olt/internalapi/AccessDeviceFlowService.java
+++ b/impl/src/main/java/org/opencord/olt/internalapi/AccessDeviceFlowService.java
@@ -18,10 +18,10 @@
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.flowobjective.ObjectiveError;
import org.onosproject.net.meter.MeterId;
+import org.opencord.olt.AccessDevicePort;
import org.opencord.sadis.UniTagInformation;
import java.util.Optional;
@@ -35,7 +35,6 @@
/**
* Provisions or removes trap-to-controller DHCP packets.
*
- * @param devId the target device identifier
* @param port the uni port for which this trap flow is designated
* @param upstreamMeterId the upstream meter id that includes the upstream
* bandwidth profile values such as PIR,CIR. If no meter id needs to be referenced,
@@ -46,7 +45,7 @@
* server, false if packets are flowing downstream towards client
* @param dhcpFuture gets result of dhcp objective when complete
*/
- void processDhcpFilteringObjectives(DeviceId devId, PortNumber port,
+ void processDhcpFilteringObjectives(AccessDevicePort port,
MeterId upstreamMeterId,
UniTagInformation tagInformation,
boolean install,
@@ -56,14 +55,13 @@
/**
* Trap igmp packets to the controller.
*
- * @param devId Device identifier to send the flow
* @param port Uni Port number
* @param upstreamMeterId upstream meter id that represents the upstream bandwidth profile
* @param tagInformation the uni tag information of the subscriber
* @param install the indicator to install or to remove the flow
* @param upstream determines the direction of the flow
*/
- void processIgmpFilteringObjectives(DeviceId devId, PortNumber port,
+ void processIgmpFilteringObjectives(AccessDevicePort port,
MeterId upstreamMeterId,
UniTagInformation tagInformation,
boolean install,
@@ -72,22 +70,20 @@
/**
* Trap eapol authentication packets to the controller.
*
- * @param devId the device identifier
- * @param portNumber the port for which this trap flow is designated
+ * @param port the port for which this trap flow is designated
* @param bpId bandwidth profile id to add the related meter to the flow
* @param filterFuture completable future for this filtering objective operation
* @param vlanId the default or customer tag for a subscriber
* @param install true to install the flow, false to remove the flow
*/
- void processEapolFilteringObjectives(DeviceId devId, PortNumber portNumber, String bpId,
+ void processEapolFilteringObjectives(AccessDevicePort port, String bpId,
CompletableFuture<ObjectiveError> filterFuture,
VlanId vlanId, boolean install);
/**
* Trap PPPoE discovery packets to the controller.
*
- * @param devId the target device identifier
- * @param portNumber the uni port for which this trap flow is designated
+ * @param port the uni port for which this trap flow is designated
* @param upstreamMeterId the upstream meter id that includes the upstream
* bandwidth profile values such as PIR,CIR. If no meter id needs to be referenced,
* null can be sent
@@ -96,28 +92,26 @@
* @param upstream true if trapped packets are flowing upstream towards
* server, false if packets are flowing downstream towards client
**/
- void processPPPoEDFilteringObjectives(DeviceId devId, PortNumber portNumber,
+ void processPPPoEDFilteringObjectives(AccessDevicePort port,
MeterId upstreamMeterId, UniTagInformation tagInformation,
boolean install, boolean upstream);
/**
* Trap lldp 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
*/
- void processLldpFilteringObjective(DeviceId devId, PortNumber port, boolean install);
+ void processLldpFilteringObjective(AccessDevicePort port, boolean install);
/**
* Installs trap filtering objectives for particular traffic types (LLDP, IGMP and DHCP) on an
* NNI port.
*
- * @param devId device ID
* @param port port number
* @param install true to install, false to remove
*/
- void processNniFilteringObjectives(DeviceId devId, PortNumber port, boolean install);
+ void processNniFilteringObjectives(AccessDevicePort port, boolean install);
/**
* Creates a ForwardingObjective builder with double-tag match criteria and output
@@ -131,8 +125,8 @@
* @param upstream true to create upstream, false to create downstream builder
* @return ForwardingObjective.Builder
*/
- ForwardingObjective.Builder createTransparentBuilder(PortNumber uplinkPort,
- PortNumber subscriberPort,
+ ForwardingObjective.Builder createTransparentBuilder(AccessDevicePort uplinkPort,
+ AccessDevicePort subscriberPort,
MeterId meterId,
UniTagInformation tagInfo,
boolean upstream);
@@ -147,8 +141,8 @@
* @param uniTagInformation the uni tag information
* @return ForwardingObjective.Builder
*/
- ForwardingObjective.Builder createUpBuilder(PortNumber uplinkPort,
- PortNumber subscriberPort,
+ ForwardingObjective.Builder createUpBuilder(AccessDevicePort uplinkPort,
+ AccessDevicePort subscriberPort,
MeterId upstreamMeterId,
UniTagInformation uniTagInformation);
@@ -163,8 +157,8 @@
* @param macAddress the mac address
* @return ForwardingObjective.Builder
*/
- ForwardingObjective.Builder createDownBuilder(PortNumber uplinkPort,
- PortNumber subscriberPort,
+ ForwardingObjective.Builder createDownBuilder(AccessDevicePort uplinkPort,
+ AccessDevicePort subscriberPort,
MeterId downstreamMeterId,
UniTagInformation tagInformation,
Optional<MacAddress> macAddress);
diff --git a/impl/src/test/java/org/opencord/olt/impl/OltFlowTest.java b/impl/src/test/java/org/opencord/olt/impl/OltFlowTest.java
index 2947bf3..7ae3c8c 100644
--- a/impl/src/test/java/org/opencord/olt/impl/OltFlowTest.java
+++ b/impl/src/test/java/org/opencord/olt/impl/OltFlowTest.java
@@ -34,6 +34,9 @@
import org.onosproject.cluster.RoleInfo;
import org.onosproject.mastership.MastershipInfo;
import org.onosproject.mastership.MastershipListener;
+import org.onosproject.net.AnnotationKeys;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultPort;
import org.onosproject.net.DeviceId;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.PortNumber;
@@ -55,6 +58,7 @@
import org.onosproject.net.flowobjective.Objective;
import org.onosproject.net.meter.MeterId;
import org.onosproject.net.meter.MeterKey;
+import org.opencord.olt.AccessDevicePort;
import org.opencord.sadis.BandwidthProfileInformation;
import org.opencord.sadis.UniTagInformation;
@@ -65,9 +69,15 @@
public class OltFlowTest extends TestBase {
private OltFlowService oltFlowService;
- PortNumber uniPortNumber = PortNumber.portNumber(1);
- PortNumber uniPortNumber2 = PortNumber.portNumber(2);
- PortNumber nniPortNumber = PortNumber.portNumber(65535);
+ AccessDevicePort uniPort1 = new AccessDevicePort(new DefaultPort(olt, PortNumber.portNumber(1), true,
+ DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, "BBSM00010001-1").build()),
+ AccessDevicePort.Type.UNI);
+ AccessDevicePort uniPort2 = new AccessDevicePort(new DefaultPort(olt, PortNumber.portNumber(2), true,
+ DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, "BBSM00010002-1").build()),
+ AccessDevicePort.Type.UNI);
+ AccessDevicePort nniPort = new AccessDevicePort(new DefaultPort(olt, PortNumber.portNumber(65535), true,
+ DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, "nni-1048576").build()),
+ AccessDevicePort.Type.NNI);
MacAddress macAddress = MacAddress.valueOf("00:00:00:00:0a:0b");
@@ -125,57 +135,58 @@
@Test
public void testDhcpFiltering() {
+ System.out.println(uniPort1);
oltFlowService.flowObjectiveService.clearQueue();
// ensure upstream dhcp traps can be added and removed
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processDhcpFilteringObjectives(uniPort1,
usMeterId, uniTagInfo,
true, true, Optional.empty());
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 1;
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processDhcpFilteringObjectives(uniPort1,
usMeterId, uniTagInfo,
false, true, Optional.empty());
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 2;
// Ensure upstream flow has no pcp unless properly specified.
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, uniPortNumber2,
+ oltFlowService.processDhcpFilteringObjectives(uniPort2,
usMeterId, uniTagInfoNoPcp,
true, true, Optional.empty());
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 3;
// ensure upstream flows are not added if uniTagInfo is missing dhcp requirement
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processDhcpFilteringObjectives(uniPort1,
usMeterId, uniTagInfoNoDhcpNoIgmp,
true, true, Optional.empty());
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 3;
// ensure downstream traps don't succeed without global config for nni ports
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, nniPortNumber,
+ oltFlowService.processDhcpFilteringObjectives(nniPort,
null, null,
true, false, Optional.empty());
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, nniPortNumber,
+ oltFlowService.processDhcpFilteringObjectives(nniPort,
null, null,
false, false, Optional.empty());
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 3;
// do global config for nni ports and now it should succeed
oltFlowService.enableDhcpOnNni = true;
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, nniPortNumber,
+ oltFlowService.processDhcpFilteringObjectives(nniPort,
null, null,
true, false, Optional.empty());
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, nniPortNumber,
+ oltFlowService.processDhcpFilteringObjectives(nniPort,
null, null,
false, false, Optional.empty());
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 5;
// turn on DHCPv6 and we should get 2 flows
oltFlowService.enableDhcpV6 = true;
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processDhcpFilteringObjectives(uniPort1,
usMeterId, uniTagInfo,
true, true, Optional.empty());
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 7;
// turn off DHCPv4 and it's only v6
oltFlowService.enableDhcpV4 = false;
- oltFlowService.processDhcpFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processDhcpFilteringObjectives(uniPort1,
usMeterId, uniTagInfo,
true, true, Optional.empty());
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 8;
@@ -192,28 +203,28 @@
// ensure pppoed traps are not added if global config is off.
oltFlowService.enablePppoe = false;
- oltFlowService.processPPPoEDFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processPPPoEDFilteringObjectives(uniPort1,
usMeterId, uniTagInfo,
true, true);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 0;
// ensure upstream pppoed traps can be added and removed
oltFlowService.enablePppoe = true;
- oltFlowService.processPPPoEDFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processPPPoEDFilteringObjectives(uniPort1,
usMeterId, uniTagInfo,
true, true);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 1;
- oltFlowService.processPPPoEDFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processPPPoEDFilteringObjectives(uniPort1,
usMeterId, uniTagInfo,
false, true);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 2;
// ensure downstream pppoed traps can be added and removed
- oltFlowService.processPPPoEDFilteringObjectives(DEVICE_ID_1, nniPortNumber,
+ oltFlowService.processPPPoEDFilteringObjectives(nniPort,
null, null,
true, false);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 3;
- oltFlowService.processPPPoEDFilteringObjectives(DEVICE_ID_1, nniPortNumber,
+ oltFlowService.processPPPoEDFilteringObjectives(nniPort,
null, null,
false, false);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 4;
@@ -227,30 +238,30 @@
oltFlowService.flowObjectiveService.clearQueue();
// ensure igmp flows can be added and removed
- oltFlowService.processIgmpFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processIgmpFilteringObjectives(uniPort1,
usMeterId, uniTagInfo,
true, true);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 1;
- oltFlowService.processIgmpFilteringObjectives(DEVICE_ID_1, uniPortNumber, usMeterId,
+ oltFlowService.processIgmpFilteringObjectives(uniPort1, usMeterId,
uniTagInfo,
false, true);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 2;
// ensure igmp flow is not added if uniTag has no igmp requirement
- oltFlowService.processIgmpFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processIgmpFilteringObjectives(uniPort1,
usMeterId, uniTagInfoNoDhcpNoIgmp,
true, true);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 2;
//ensure igmp flow on NNI fails without global setting
- oltFlowService.processIgmpFilteringObjectives(DEVICE_ID_1, nniPortNumber,
+ oltFlowService.processIgmpFilteringObjectives(nniPort,
null, null,
true, false);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 2;
// igmp trap on NNI should succeed with global config
oltFlowService.enableIgmpOnNni = true;
- oltFlowService.processIgmpFilteringObjectives(DEVICE_ID_1, nniPortNumber,
+ oltFlowService.processIgmpFilteringObjectives(nniPort,
null, null,
true, false);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives().size() == 3;
@@ -265,20 +276,20 @@
oltFlowService.enableEapol = true;
//will install
- oltFlowService.processEapolFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processEapolFilteringObjectives(uniPort1,
uniTagInfo.getUpstreamBandwidthProfile(), new CompletableFuture<>(),
uniTagInfo.getUniTagMatch(), true);
//bp profile doesn't exist
- oltFlowService.processEapolFilteringObjectives(DEVICE_ID_1, uniPortNumber,
+ oltFlowService.processEapolFilteringObjectives(uniPort1,
uniTagInfo.getDownstreamBandwidthProfile(), new CompletableFuture<>(),
uniTagInfo.getUniTagMatch(), true);
}
@Test
public void testLldpFiltering() {
- oltFlowService.processLldpFilteringObjective(DEVICE_ID_1, nniPortNumber, true);
- oltFlowService.processLldpFilteringObjective(DEVICE_ID_1, nniPortNumber, false);
+ oltFlowService.processLldpFilteringObjective(nniPort, true);
+ oltFlowService.processLldpFilteringObjective(nniPort, false);
}
@Test
@@ -286,10 +297,10 @@
oltFlowService.flowObjectiveService.clearQueue();
oltFlowService.enableDhcpOnNni = true;
oltFlowService.enableIgmpOnNni = true;
- oltFlowService.processNniFilteringObjectives(DEVICE_ID_1, nniPortNumber, true);
+ oltFlowService.processNniFilteringObjectives(nniPort, true);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives()
.size() == 3;
- oltFlowService.processNniFilteringObjectives(DEVICE_ID_1, nniPortNumber, false);
+ oltFlowService.processNniFilteringObjectives(nniPort, false);
assert oltFlowService.flowObjectiveService.getPendingFlowObjectives()
.size() == 6;
oltFlowService.flowObjectiveService.clearQueue();
@@ -298,14 +309,14 @@
@Test
public void testUpBuilder() {
ForwardingObjective objective =
- oltFlowService.createUpBuilder(nniPortNumber, uniPortNumber, usMeterId, uniTagInfo).add();
+ oltFlowService.createUpBuilder(nniPort, uniPort1, usMeterId, uniTagInfo).add();
checkObjective(objective, true);
}
@Test
public void testDownBuilder() {
ForwardingObjective objective =
- oltFlowService.createDownBuilder(nniPortNumber, uniPortNumber, dsMeterId, uniTagInfo,
+ oltFlowService.createDownBuilder(nniPort, uniPort1, dsMeterId, uniTagInfo,
Optional.of(macAddress)).remove();
checkObjective(objective, false);
}
@@ -413,7 +424,7 @@
if (ethType.ethType().equals(EthType.EtherType.LLDP.ethType()) ||
- portCriterion.port().equals(nniPortNumber)) {
+ portCriterion.port().equals(nniPort.number())) {
assert meter == null;
assert writeMetadata == null;
assert vlanIdCriterion == null;
diff --git a/impl/src/test/java/org/opencord/olt/impl/TestBase.java b/impl/src/test/java/org/opencord/olt/impl/TestBase.java
index 9e14ee7..5153d10 100644
--- a/impl/src/test/java/org/opencord/olt/impl/TestBase.java
+++ b/impl/src/test/java/org/opencord/olt/impl/TestBase.java
@@ -18,9 +18,12 @@
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multiset;
+import org.onlab.packet.ChassisId;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
import org.onosproject.core.DefaultApplicationId;
+import org.onosproject.net.DefaultDevice;
+import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.meter.MeterId;
import org.onosproject.store.service.AsyncConsistentMultimap;
@@ -55,6 +58,9 @@
protected String dsBpId = "HSIA-DS";
protected DefaultApplicationId appId = new DefaultApplicationId(1, "OltServices");
+ protected static Device olt = new DefaultDevice(null, DeviceId.deviceId(OLT_DEV_ID), Device.Type.SWITCH,
+ "VOLTHA Project", "open_pon", "open_pon", "BBSIM_OLT_1", new ChassisId("a0a0a0a0a01"));
+
Map<String, BandwidthProfileInformation> bpInformation = Maps.newConcurrentMap();
protected void addBandwidthProfile(String id) {