use of org.onosproject.net.flowobjective.ObjectiveError in project trellis-control by opennetworkinglab.
the class DefaultL2TunnelHandler method tearDownConnectionPoints.
/**
* Tears down connection points of pseudowires. We can either tear down both connection points,
* or each one of them.
*
* @param l2TunnelId The tunnel id for this pseudowire.
* @param tearDownFirst Boolean, true if we want to tear down cp1
* @param tearDownSecond Boolean, true if we want to tear down cp2
* @param pending Boolean, if true remove only pseudowire from pending stores since no flows/groups
* in the network, else remove flows/groups in the devices also.
* @return Result of tearing down the pseudowire, SUCCESS if everything was ok
* a descriptive error otherwise.
*/
private Result tearDownConnectionPoints(long l2TunnelId, boolean tearDownFirst, boolean tearDownSecond, boolean pending) {
Result res;
CompletableFuture<ObjectiveError> fwdInitNextFuture = new CompletableFuture<>();
CompletableFuture<ObjectiveError> fwdTermNextFuture = new CompletableFuture<>();
CompletableFuture<ObjectiveError> revInitNextFuture = new CompletableFuture<>();
CompletableFuture<ObjectiveError> revTermNextFuture = new CompletableFuture<>();
if (l2TunnelId == 0) {
log.error("Removal process : Tunnel id cannot be 0");
return Result.WRONG_PARAMETERS.appendError("Pseudowire id can not be 0.");
}
res = checkIfPwExists(l2TunnelId, pending);
if (res != Result.SUCCESS) {
return res;
}
// remove and get the tunnel and the policy from the appropriate store
// if null, return error.
Versioned<L2Tunnel> l2TunnelVersioned = pending ? pendingL2TunnelStore.remove(Long.toString(l2TunnelId)) : l2TunnelStore.remove(Long.toString(l2TunnelId));
Versioned<L2TunnelPolicy> l2TunnelPolicyVersioned = pending ? pendingL2PolicyStore.remove(Long.toString(l2TunnelId)) : l2PolicyStore.remove(Long.toString(l2TunnelId));
if ((l2TunnelVersioned == null) || (l2TunnelPolicyVersioned == null)) {
log.warn("Removal process : Policy and/or tunnel missing for tunnel id {}", l2TunnelId);
return Result.INTERNAL_ERROR.appendError("Policy and/or tunnel missing for pseudowire!");
}
L2TunnelDescription pwToRemove = new DefaultL2TunnelDescription(l2TunnelVersioned.value(), l2TunnelPolicyVersioned.value());
if (pending) {
// in pending state
return Result.SUCCESS;
}
// remove flows/groups involving with this pseudowire
if (tearDownFirst) {
log.info("Removal process : Tearing down forward direction of pseudowire {}", l2TunnelId);
VlanId egressVlan = determineEgressVlan(pwToRemove.l2TunnelPolicy().cP1OuterTag(), pwToRemove.l2TunnelPolicy().cP1InnerTag(), pwToRemove.l2TunnelPolicy().cP2OuterTag(), pwToRemove.l2TunnelPolicy().cP2InnerTag());
deletePolicy(l2TunnelId, pwToRemove.l2TunnelPolicy().cP1(), pwToRemove.l2TunnelPolicy().cP1InnerTag(), pwToRemove.l2TunnelPolicy().cP1OuterTag(), egressVlan, fwdInitNextFuture, FWD);
fwdInitNextFuture.thenAcceptAsync(status -> {
if (status == null) {
// Finally we will tear down the pseudo wire.
tearDownPseudoWireInit(l2TunnelId, pwToRemove.l2TunnelPolicy().cP1(), fwdTermNextFuture, FWD);
}
});
fwdTermNextFuture.thenAcceptAsync(status -> {
if (status == null) {
tearDownPseudoWireTerm(pwToRemove.l2Tunnel(), pwToRemove.l2TunnelPolicy().cP2(), null, FWD);
}
});
}
if (tearDownSecond) {
log.info("Removal process : Tearing down reverse direction of pseudowire {}", l2TunnelId);
VlanId egressVlan = determineEgressVlan(pwToRemove.l2TunnelPolicy().cP2OuterTag(), pwToRemove.l2TunnelPolicy().cP2InnerTag(), pwToRemove.l2TunnelPolicy().cP1OuterTag(), pwToRemove.l2TunnelPolicy().cP1InnerTag());
// We do the same operations on the reverse side.
deletePolicy(l2TunnelId, pwToRemove.l2TunnelPolicy().cP2(), pwToRemove.l2TunnelPolicy().cP2InnerTag(), pwToRemove.l2TunnelPolicy().cP2OuterTag(), egressVlan, revInitNextFuture, REV);
revInitNextFuture.thenAcceptAsync(status -> {
if (status == null) {
tearDownPseudoWireInit(l2TunnelId, pwToRemove.l2TunnelPolicy().cP2(), revTermNextFuture, REV);
}
});
revTermNextFuture.thenAcceptAsync(status -> {
if (status == null) {
tearDownPseudoWireTerm(pwToRemove.l2Tunnel(), pwToRemove.l2TunnelPolicy().cP1(), null, REV);
}
});
}
return Result.SUCCESS;
}
use of org.onosproject.net.flowobjective.ObjectiveError in project trellis-control by opennetworkinglab.
the class DefaultL2TunnelHandler method deletePolicy.
/**
* Deletes a given policy using the parameter supplied.
*
* @param tunnelId the tunnel id
* @param ingress the ingress point
* @param ingressInner the ingress inner vlan id
* @param ingressOuter the ingress outer vlan id
* @param future to perform the async operation
* @param direction the direction: forward or reverse
*/
private void deletePolicy(long tunnelId, ConnectPoint ingress, VlanId ingressInner, VlanId ingressOuter, VlanId egressVlan, CompletableFuture<ObjectiveError> future, Direction direction) {
String key = generateKey(tunnelId, direction);
if (!l2InitiationNextObjStore.containsKey(key)) {
log.error("Abort delete of policy for tunnel {}: next does not exist in the store", tunnelId);
if (future != null) {
future.complete(null);
}
return;
}
NextObjective nextObjective = l2InitiationNextObjStore.get(key).value();
int nextId = nextObjective.id();
List<Objective> objectives = Lists.newArrayList();
// We create the forwarding objective.
ForwardingObjective.Builder fwdBuilder = createInitFwdObjective(tunnelId, ingress.port(), nextId);
ObjectiveContext context = new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
log.debug("Previous fwdObj for policy {} removed", tunnelId);
if (future != null) {
future.complete(null);
}
}
@Override
public void onError(Objective objective, ObjectiveError error) {
log.error("Failed to remove previous fwdObj for policy {}: {}", tunnelId, error);
if (future != null) {
future.complete(error);
}
}
};
objectives.add(fwdBuilder.remove(context));
// We create the filtering objective to define the
// permit traffic in the switch
FilteringObjective.Builder filtBuilder = createFiltObjective(ingress.port(), ingressInner, ingressOuter);
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setTunnelId(tunnelId).setVlanId(egressVlan);
filtBuilder.withMeta(treatment.build());
context = new DefaultObjectiveContext((objective) -> log.debug("FilterObj for policy {} revoked", tunnelId), (objective, error) -> log.warn("Failed to revoke filterObj for policy {}", tunnelId, error));
objectives.add(filtBuilder.remove(context));
for (Objective objective : objectives) {
if (objective instanceof ForwardingObjective) {
srManager.flowObjectiveService.forward(ingress.deviceId(), (ForwardingObjective) objective);
} else {
srManager.flowObjectiveService.filter(ingress.deviceId(), (FilteringObjective) objective);
}
}
}
use of org.onosproject.net.flowobjective.ObjectiveError in project trellis-control by opennetworkinglab.
the class XconnectManager method revokeFwd.
/**
* Revokes bridging forwarding objectives for given XConnect.
*
* @param key XConnect store key
* @param nextId next objective id
* @param fwdFuture completable future for this forwarding objective operation
*/
private void revokeFwd(XconnectKey key, int nextId, CompletableFuture<ObjectiveError> fwdFuture) {
ForwardingObjective.Builder fwdObjBuilder = fwdObjBuilder(key, nextId);
ObjectiveContext context = new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
log.debug("Previous FwdObj for {} removed", key);
if (fwdFuture != null) {
fwdFuture.complete(null);
}
}
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to remove previous FwdObj for {}: {}", key, error);
if (fwdFuture != null) {
fwdFuture.complete(error);
}
}
};
flowObjectiveService.forward(key.deviceId(), fwdObjBuilder.remove(context));
}
use of org.onosproject.net.flowobjective.ObjectiveError in project trellis-control by opennetworkinglab.
the class RoutingRulePopulator method populateArpNdpPunts.
/**
* Creates forwarding objectives to punt ARP and NDP packets, to the controller.
* Furthermore, these are applied only by the master instance. Deferred actions
* are not cleared such that packets can be flooded in the cross connect use case
*
* @param deviceId the switch dpid for the router
*/
void populateArpNdpPunts(DeviceId deviceId) {
// We are not the master just skip.
if (!srManager.shouldProgram(deviceId)) {
log.debug("Not installing ARP/NDP punts - not handling programming for dev:{} ", deviceId);
return;
}
ForwardingObjective fwdObj;
// We punt all ARP packets towards the controller.
fwdObj = arpFwdObjective(null, true, ARP_NDP_PRIORITY).add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install forwarding objective to punt ARP to {}: {}", deviceId, error);
}
});
srManager.flowObjectiveService.forward(deviceId, fwdObj);
if (isIpv6Configured(deviceId)) {
// We punt all NDP packets towards the controller.
ndpFwdObjective(null, true, ARP_NDP_PRIORITY).forEach(builder -> {
ForwardingObjective obj = builder.add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install forwarding objective to punt NDP to {}: {}", deviceId, error);
}
});
srManager.flowObjectiveService.forward(deviceId, obj);
});
}
srManager.getPairLocalPort(deviceId).ifPresent(port -> {
ForwardingObjective pairFwdObj;
// Do not punt ARP packets from pair port
pairFwdObj = arpFwdObjective(port, false, PacketPriority.CONTROL.priorityValue() + 1).add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install forwarding objective to ignore ARP to {}: {}", deviceId, error);
}
});
srManager.flowObjectiveService.forward(deviceId, pairFwdObj);
if (isIpv6Configured(deviceId)) {
// Do not punt NDP packets from pair port
ndpFwdObjective(port, false, PacketPriority.CONTROL.priorityValue() + 1).forEach(builder -> {
ForwardingObjective obj = builder.add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install forwarding objective to ignore ARP to {}: {}", deviceId, error);
}
});
srManager.flowObjectiveService.forward(deviceId, obj);
});
// Do not forward DAD packets from pair port
pairFwdObj = dad6FwdObjective(port, PacketPriority.CONTROL.priorityValue() + 2).add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install forwarding objective to drop DAD to {}: {}", deviceId, error);
}
});
srManager.flowObjectiveService.forward(deviceId, pairFwdObj);
}
});
}
use of org.onosproject.net.flowobjective.ObjectiveError in project fabric-tna by stratum.
the class FabricPipeliner method next.
@Override
public void next(NextObjective obj) {
if (obj.op() == Objective.Operation.VERIFY) {
if (obj.type() != NextObjective.Type.HASHED) {
log.warn("VERIFY operation not yet supported for NextObjective {}, will return failure :(", obj.type());
fail(obj, ObjectiveError.UNSUPPORTED);
return;
}
if (log.isTraceEnabled()) {
log.trace("Verify NextObjective {} in dev {}", obj, deviceId);
}
ObjectiveError error = handleVerify(obj);
if (error == null) {
success(obj);
} else {
fail(obj, error);
}
return;
}
if (obj.op() == Objective.Operation.MODIFY && obj.type() != NextObjective.Type.SIMPLE) {
log.warn("MODIFY operation not yet supported for {} NextObjective, will return failure :(", obj.type());
if (log.isTraceEnabled()) {
log.trace("Objective {}", obj);
}
fail(obj, ObjectiveError.UNSUPPORTED);
return;
}
final ObjectiveTranslation result = nextTranslator.translate(obj);
handleResult(obj, result);
}
Aggregations