use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class OpenstackVtapManager method updateHostbyType.
/**
* Updates device list of vtaps with respect to the host changes.
*
* @param newHost new host instance
* @param oldHost old host instance
*/
private void updateHostbyType(Type type, Host newHost, Host oldHost) {
getVtaps(type).forEach(vtap -> {
IpPrefix prefix = (type == Type.VTAP_TX) ? vtap.vtapCriterion().srcIpPrefix() : vtap.vtapCriterion().dstIpPrefix();
int hostDiff = hostCompareIp(newHost, oldHost, prefix);
if (hostDiff < 0) {
oldHost.locations().stream().map(HostLocation::deviceId).forEach(deviceId -> store.removeDeviceFromVtap(vtap.id(), type, deviceId));
} else if (hostDiff > 0) {
newHost.locations().stream().map(HostLocation::deviceId).filter(deviceId -> Objects.nonNull(osNodeService.node(deviceId))).forEach(deviceId -> store.addDeviceToVtap(vtap.id(), type, deviceId));
}
});
}
use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class PimInterface method processJoinPrune.
/**
* Process an incoming PIM JoinPrune message.
*
* @param ethPkt the Ethernet packet header.
*/
public void processJoinPrune(Ethernet ethPkt) {
IPv4 ip = (IPv4) ethPkt.getPayload();
checkNotNull(ip);
PIM pim = (PIM) ip.getPayload();
checkNotNull(pim);
PIMJoinPrune jpHdr = (PIMJoinPrune) pim.getPayload();
checkNotNull(jpHdr);
/*
* The Join/Prune messages are grouped by Group address. We'll walk each group address
* where we will possibly have to walk a list of source address for the joins and prunes.
*/
Collection<PIMJoinPruneGroup> jpgs = jpHdr.getJoinPrunes();
for (PIMJoinPruneGroup jpg : jpgs) {
IpPrefix gpfx = jpg.getGroup();
// Walk the joins first.
for (IpPrefix spfx : jpg.getJoins().values()) {
// We may need
}
for (IpPrefix spfx : jpg.getPrunes().values()) {
// TODO: this is where we many need to remove multi-cast state and possibly intents.
}
}
}
use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class SdnIpReactiveRouting method packetReactiveProcessor.
/**
* Routes packet reactively.
*
* @param dstIpAddress the destination IP address of a packet
* @param srcIpAddress the source IP address of a packet
* @param srcConnectPoint the connect point where a packet comes from
* @param srcMacAddress the source MAC address of a packet
*/
private void packetReactiveProcessor(IpAddress dstIpAddress, IpAddress srcIpAddress, ConnectPoint srcConnectPoint, MacAddress srcMacAddress) {
checkNotNull(dstIpAddress);
checkNotNull(srcIpAddress);
checkNotNull(srcConnectPoint);
checkNotNull(srcMacAddress);
//
// Step1: Try to update the existing intent first if it exists.
//
IpPrefix ipPrefix = null;
Route route = null;
if (config.isIpAddressLocal(dstIpAddress)) {
if (dstIpAddress.isIp4()) {
ipPrefix = IpPrefix.valueOf(dstIpAddress, Ip4Address.BIT_LENGTH);
} else {
ipPrefix = IpPrefix.valueOf(dstIpAddress, Ip6Address.BIT_LENGTH);
}
} else {
// Get IP prefix from BGP route table
route = routeService.longestPrefixMatch(dstIpAddress);
if (route != null) {
ipPrefix = route.prefix();
}
}
if (ipPrefix != null && intentRequestListener.mp2pIntentExists(ipPrefix)) {
intentRequestListener.updateExistingMp2pIntent(ipPrefix, srcConnectPoint);
return;
}
//
// Step2: There is no existing intent for the destination IP address.
// Check whether it is necessary to create a new one. If necessary then
// create a new one.
//
TrafficType trafficType = trafficTypeClassifier(srcConnectPoint, dstIpAddress);
switch(trafficType) {
case HOST_TO_INTERNET:
// The Step 1 has already handled it. We do not need to do anything here.
if (route != null) {
intentRequestListener.setUpConnectivityHostToInternet(srcIpAddress, ipPrefix, route.nextHop());
}
break;
case INTERNET_TO_HOST:
intentRequestListener.setUpConnectivityInternetToHost(dstIpAddress);
break;
case HOST_TO_HOST:
intentRequestListener.setUpConnectivityHostToHost(dstIpAddress, srcIpAddress, srcMacAddress, srcConnectPoint);
break;
case INTERNET_TO_INTERNET:
log.trace("This is transit traffic, " + "the intent should be preinstalled already");
break;
case DROP:
// We need a new type of intent here.
break;
case UNKNOWN:
log.trace("This is unknown traffic, so we do nothing");
break;
default:
break;
}
}
use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class RouteConfig method getRoutes.
/**
* Returns all routes in this configuration.
*
* @return A set of route.
*/
public Set<Route> getRoutes() {
ImmutableSet.Builder<Route> routes = ImmutableSet.builder();
array.forEach(route -> {
try {
IpPrefix prefix = IpPrefix.valueOf(route.path(PREFIX).asText());
IpAddress nextHop = IpAddress.valueOf(route.path(NEXTHOP).asText());
routes.add(new Route(Route.Source.STATIC, prefix, nextHop));
} catch (IllegalArgumentException e) {
// Ignores routes that cannot be parsed correctly
}
});
return routes.build();
}
use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class FpmManager method updateAcceptRouteFlag.
@Override
public void updateAcceptRouteFlag(Collection<FpmPeerAcceptRoutes> modifiedPeers) {
modifiedPeers.forEach(modifiedPeer -> {
log.debug("FPM connection to {} is disabled", modifiedPeer);
NodeId localNode = clusterService.getLocalNode().id();
log.debug("Peer Flag {}", modifiedPeer.isAcceptRoutes());
peers.compute(modifiedPeer.peer(), (p, infos) -> {
if (infos == null) {
return null;
}
Iterator<FpmConnectionInfo> iterator = infos.iterator();
if (iterator.hasNext()) {
FpmConnectionInfo connectionInfo = iterator.next();
if (connectionInfo.isAcceptRoutes() == modifiedPeer.isAcceptRoutes()) {
return null;
}
localPeers.remove(modifiedPeer.peer());
infos.remove(connectionInfo);
infos.add(new FpmConnectionInfo(localNode, modifiedPeer.peer(), System.currentTimeMillis(), modifiedPeer.isAcceptRoutes()));
localPeers.put(modifiedPeer.peer(), infos);
}
Map<IpPrefix, Route> routes = fpmRoutes.get(modifiedPeer.peer());
if (routes != null && !modifiedPeer.isAcceptRoutes()) {
updateRouteStore(Lists.newArrayList(), routes.values());
} else {
updateRouteStore(routes.values(), Lists.newArrayList());
}
return infos;
});
});
}
Aggregations