use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.
the class RoutingRulePopulator method revokeRoute.
/**
* Removes IP rules for a route when the next hop is gone.
* This method should not be invoked directly without going through DefaultRoutingHandler.
*
* @param deviceId device ID of the device that next hop attaches to
* @param prefix IP prefix of the route
* @param hostMac MAC address of the next hop
* @param hostVlanId Vlan ID of the nexthop
* @param outPort port that next hop attaches to
* @param directHost host is of type direct or indirect
* @return future that carries the flow objective if succeeded, null if otherwise
*/
CompletableFuture<Objective> revokeRoute(DeviceId deviceId, IpPrefix prefix, MacAddress hostMac, VlanId hostVlanId, PortNumber outPort, boolean directHost) {
log.debug("Revoke IP table entry for route {} at {}:{}", prefix, deviceId, outPort);
ForwardingObjective.Builder fwdBuilder;
try {
fwdBuilder = routingFwdObjBuilder(deviceId, prefix, hostMac, hostVlanId, outPort, null, null, directHost, true);
} catch (DeviceConfigNotFoundException e) {
log.warn(e.getMessage() + " Aborting revokeIpRuleForHost.");
return CompletableFuture.completedFuture(null);
}
if (fwdBuilder == null) {
log.warn("Aborting host routing table entries due " + "to error for dev:{} route:{}", deviceId, prefix);
return CompletableFuture.completedFuture(null);
}
CompletableFuture<Objective> future = new CompletableFuture<>();
ObjectiveContext context = new DefaultObjectiveContext((objective) -> {
log.debug("IP rule for route {} revoked", prefix);
future.complete(objective);
}, (objective, error) -> {
log.warn("Failed to revoke IP rule for route {}: {}", prefix, error);
future.complete(null);
});
srManager.flowObjectiveService.forward(deviceId, fwdBuilder.remove(context));
return future;
}
use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.
the class RoutingRulePopulator method populateMplsRule.
/**
* Populates MPLS flow rules in the target device to point towards the
* destination device.
*
* @param targetSwId target device ID of the switch to set the rules
* @param destSwId destination switch device ID
* @param nextHops next hops switch ID list
* @param routerIp the router ip of the destination switch
* @return true if all rules are set successfully, false otherwise
*/
boolean populateMplsRule(DeviceId targetSwId, DeviceId destSwId, Set<DeviceId> nextHops, IpAddress routerIp) {
int segmentId;
try {
if (routerIp.isIp4()) {
segmentId = config.getIPv4SegmentId(destSwId);
} else {
segmentId = config.getIPv6SegmentId(destSwId);
}
} catch (DeviceConfigNotFoundException e) {
log.warn(e.getMessage() + " Aborting populateMplsRule.");
return false;
}
List<ForwardingObjective> fwdObjs = new ArrayList<>();
Collection<ForwardingObjective> fwdObjsMpls;
// Generates the transit rules used by the standard "routing".
fwdObjsMpls = handleMpls(targetSwId, destSwId, nextHops, segmentId, routerIp, true);
if (fwdObjsMpls.isEmpty()) {
return false;
}
fwdObjs.addAll(fwdObjsMpls);
// Generates the transit rules used by the MPLS Pwaas.
int pwSrLabel;
try {
pwSrLabel = config.getPWRoutingLabel(destSwId);
} catch (DeviceConfigNotFoundException e) {
log.warn(e.getMessage() + " Aborting populateMplsRule. No label for PseudoWire traffic.");
return false;
}
fwdObjsMpls = handleMpls(targetSwId, destSwId, nextHops, pwSrLabel, routerIp, false);
if (fwdObjsMpls.isEmpty()) {
return false;
}
fwdObjs.addAll(fwdObjsMpls);
for (ForwardingObjective fwdObj : fwdObjs) {
log.debug("Sending MPLS fwd obj {} for SID {}-> next {} in sw: {}", fwdObj.id(), segmentId, fwdObj.nextId(), targetSwId);
srManager.flowObjectiveService.forward(targetSwId, fwdObj);
rulePopulationCounter.incrementAndGet();
}
return true;
}
use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.
the class RoutingRulePopulator method populateRoute.
/**
* Populates IP rules for a route that has direct connection to the switch.
* This method should not be invoked directly without going through DefaultRoutingHandler.
*
* @param deviceId device ID of the device that next hop attaches to
* @param prefix IP prefix of the route
* @param hostMac MAC address of the next hop
* @param hostVlanId Vlan ID of the nexthop
* @param outPort port where the next hop attaches to
* @param directHost host is of type direct or indirect
* @return future that carries the flow objective if succeeded, null if otherwise
*/
CompletableFuture<Objective> populateRoute(DeviceId deviceId, IpPrefix prefix, MacAddress hostMac, VlanId hostVlanId, PortNumber outPort, boolean directHost) {
log.debug("Populate direct routing entry for route {} at {}:{}", prefix, deviceId, outPort);
ForwardingObjective.Builder fwdBuilder;
try {
fwdBuilder = routingFwdObjBuilder(deviceId, prefix, hostMac, hostVlanId, outPort, null, null, directHost, false);
} catch (DeviceConfigNotFoundException e) {
log.warn(e.getMessage() + " Aborting direct populateRoute");
return CompletableFuture.completedFuture(null);
}
if (fwdBuilder == null) {
log.warn("Aborting host routing table entry due " + "to error for dev:{} route:{}", deviceId, prefix);
return CompletableFuture.completedFuture(null);
}
int nextId = fwdBuilder.add().nextId();
CompletableFuture<Objective> future = new CompletableFuture<>();
ObjectiveContext context = new DefaultObjectiveContext((objective) -> {
log.debug("Direct routing rule for route {} populated. nextId={}", prefix, nextId);
future.complete(objective);
}, (objective, error) -> {
log.warn("Failed to populate direct routing rule for route {}: {}", prefix, error);
future.complete(null);
});
srManager.flowObjectiveService.forward(deviceId, fwdBuilder.add(context));
rulePopulationCounter.incrementAndGet();
return future;
}
use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.
the class SegmentRoutingManager method processDeviceAddedInternal.
private void processDeviceAddedInternal(DeviceId deviceId) {
// Irrespective of whether the local is leading the programming or not for this device,
// we need to create a SR-group-handler instance. This is because in a
// multi-instance setup, any instance can initiate forwarding/next-objectives
// for any switch (even if this instance is a SLAVE or not even connected
// to the switch). To handle this, a default-group-handler instance is necessary
// per switch.
log.debug("Current groupHandlerMap devs: {}", groupHandlerMap.keySet());
if (groupHandlerMap.get(deviceId) == null) {
DefaultGroupHandler groupHandler;
try {
groupHandler = DefaultGroupHandler.createGroupHandler(deviceId, appId, deviceConfiguration, linkService, flowObjectiveService, this);
} catch (DeviceConfigNotFoundException e) {
log.warn(e.getMessage() + " Aborting processDeviceAdded.");
return;
}
log.debug("updating groupHandlerMap with new grpHdlr for device: {}", deviceId);
groupHandlerMap.put(deviceId, groupHandler);
}
if (shouldProgram(deviceId)) {
defaultRoutingHandler.populatePortAddressingRules(deviceId);
DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId);
groupHandler.createGroupsFromVlanConfig();
routingRulePopulator.populateSubnetBroadcastRule(deviceId);
}
appCfgHandler.init(deviceId);
}
use of org.onosproject.segmentrouting.config.DeviceConfigNotFoundException in project trellis-control by opennetworkinglab.
the class SegmentRoutingNeighbourHandler method getSenderInfo.
/**
* Retrieve router (device) info.
*
* @param mac where to copy the mac
* @param ip where to copy the ip
* @param deviceId the device id
* @param targetAddress the target address
* @return true if it was possible to get the necessary info.
* False for errors
*/
protected boolean getSenderInfo(byte[] mac, byte[] ip, DeviceId deviceId, IpAddress targetAddress) {
byte[] senderMacAddress;
byte[] senderIpAddress;
IpAddress sender;
try {
senderMacAddress = config.getDeviceMac(deviceId).toBytes();
if (targetAddress.isIp4()) {
sender = config.getRouterIpAddressForASubnetHost(targetAddress.getIp4Address());
} else {
sender = config.getRouterIpAddressForASubnetHost(targetAddress.getIp6Address());
}
// If sender is null we abort.
if (sender == null) {
log.warn("Sender ip is null. Aborting getSenderInfo");
return false;
}
senderIpAddress = sender.toOctets();
} catch (DeviceConfigNotFoundException e) {
log.warn(e.getMessage() + " Aborting getSenderInfo");
return false;
}
System.arraycopy(senderMacAddress, 0, mac, 0, senderMacAddress.length);
System.arraycopy(senderIpAddress, 0, ip, 0, senderIpAddress.length);
return true;
}
Aggregations