use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class SimpleFabricRouting method setUpConnectivity.
/**
* Update intents for connectivity.
*
* ToHost: dstPrefix = dstHostIp.toIpPrefix(), nextHopIp = destHostIp
* ToInternet: dstPrefix = route.prefix(), nextHopIp = route.nextHopIp
* returns intent submitted or not
*/
private boolean setUpConnectivity(ConnectPoint srcCp, byte ipProto, IpPrefix srcPrefix, IpPrefix dstPrefix, IpAddress nextHopIp, MacAddress treatmentSrcMac, EncapsulationType encap, boolean updateMac, boolean isDstLocalSubnet, int borderRoutePrefixLength) {
if (!(simpleFabric.fabricNetwork(srcCp, VlanId.NONE) != null || (REACTIVE_ALLOW_LINK_CP && !linkService.getIngressLinks(srcCp).isEmpty()))) {
log.warn("NO REGI for srcCp not in DefaultFabricNetwork; srcCp={} srcPrefix={} dstPrefix={} nextHopIp={}", srcCp, srcPrefix, dstPrefix, nextHopIp);
return false;
}
MacAddress nextHopMac = null;
ConnectPoint egressPoint = null;
for (Host host : hostService.getHostsByIp(nextHopIp)) {
if (host.mac() != null) {
nextHopMac = host.mac();
egressPoint = host.location();
break;
}
}
if (nextHopMac == null || egressPoint == null) {
log.info("NO REGI for unknown nextHop Cp and Mac: srcPrefix={} dstPrefix={} nextHopIp={}", srcPrefix, dstPrefix, nextHopIp);
hostService.startMonitoringIp(nextHopIp);
simpleFabric.requestMac(nextHopIp);
return false;
}
TrafficTreatment treatment;
if (updateMac && ALLOW_ETH_ADDRESS_SELECTOR) {
treatment = generateSetMacTreatment(nextHopMac, treatmentSrcMac);
} else {
treatment = DefaultTrafficTreatment.builder().build();
}
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
if (dstPrefix.isIp4()) {
selector.matchEthType(Ethernet.TYPE_IPV4);
if (REACTIVE_SINGLE_TO_SINGLE && srcPrefix.prefixLength() > 0) {
selector.matchIPSrc(srcPrefix);
}
if (dstPrefix.prefixLength() > 0) {
selector.matchIPDst(dstPrefix);
}
if (ipProto != 0 && REACTIVE_MATCH_IP_PROTO) {
selector.matchIPProtocol(ipProto);
}
} else {
selector.matchEthType(Ethernet.TYPE_IPV6);
if (REACTIVE_SINGLE_TO_SINGLE && srcPrefix.prefixLength() > 0) {
selector.matchIPv6Src(srcPrefix);
}
if (dstPrefix.prefixLength() > 0) {
selector.matchIPv6Dst(dstPrefix);
}
if (ipProto != 0 && REACTIVE_MATCH_IP_PROTO) {
selector.matchIPProtocol(ipProto);
}
}
Key key;
String keyProtoTag = "";
if (REACTIVE_MATCH_IP_PROTO) {
keyProtoTag = "-p" + ipProto;
}
if (REACTIVE_SINGLE_TO_SINGLE) {
// allocate intent per (srcPrefix, dstPrefix)
key = Key.of(srcPrefix.toString() + "-to-" + dstPrefix.toString() + keyProtoTag, appId);
} else {
// allocate intent per (srcDeviceId, dstPrefix)
key = Key.of(srcCp.deviceId().toString() + "-to-" + dstPrefix.toString() + keyProtoTag, appId);
}
// check and merge already existing ingress points
Set<FilteredConnectPoint> ingressPoints = new HashSet<>();
MultiPointToSinglePointIntent existingIntent = (MultiPointToSinglePointIntent) intentService.getIntent(key);
if (existingIntent != null) {
ingressPoints.addAll(existingIntent.filteredIngressPoints());
if (// alread exists and dst not changed
!ingressPoints.add(new FilteredConnectPoint(srcCp)) && egressPoint.equals(existingIntent.egressPoint()) && treatment.equals(existingIntent.treatment())) {
log.warn("srcCP is already in mp2p intent: srcPrefix={} dstPrefix={} srcCp={}", srcPrefix, dstPrefix, srcCp);
return false;
}
log.info("update mp2p intent: srcPrefix={} dstPrefix={} srcCp={}", srcPrefix, dstPrefix, srcCp);
} else {
log.info("create mp2p intent: srcPrefix={} dstPrefix={} srcCp={}", srcPrefix, dstPrefix, srcCp);
ingressPoints.add(new FilteredConnectPoint(srcCp));
}
// priority for forwarding case
int priority = reactivePriority(true, isDstLocalSubnet, borderRoutePrefixLength);
MultiPointToSinglePointIntent newIntent = MultiPointToSinglePointIntent.builder().key(key).appId(appId).selector(selector.build()).treatment(treatment).filteredIngressPoints(ingressPoints).filteredEgressPoint(new FilteredConnectPoint(egressPoint)).priority(priority).constraints(buildConstraints(reactiveConstraints, encap)).build();
log.info("submit mp2p intent: srcPrefix={} dstPrefix={} srcCp={} " + "newIntent={} nextHopIp={} nextHopMac={} priority={}", srcPrefix, dstPrefix, ingressPoints, newIntent, nextHopIp, nextHopMac, priority);
toBePurgedIntentKeys.remove(newIntent.key());
intentService.submit(newIntent);
return true;
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class VbngManager method srcMatchIntentGenerator.
/**
* PointToPointIntent Generator.
* <p>
* The intent will match the source IP address in packet, rewrite the
* source IP address, and rewrite the destination MAC address.
* </p>
*
* @param srcIpAddress the source IP address in packet to match
* @param newSrcIpAddress the new source IP address to set
* @param dstMacAddress the destination MAC address to set
* @param dstConnectPoint the egress point
* @param srcConnectPoint the ingress point
* @return a PointToPointIntent
*/
private PointToPointIntent srcMatchIntentGenerator(IpAddress srcIpAddress, IpAddress newSrcIpAddress, MacAddress dstMacAddress, ConnectPoint dstConnectPoint, ConnectPoint srcConnectPoint) {
checkNotNull(srcIpAddress);
checkNotNull(newSrcIpAddress);
checkNotNull(dstMacAddress);
checkNotNull(dstConnectPoint);
checkNotNull(srcConnectPoint);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPSrc(IpPrefix.valueOf(srcIpAddress, IpPrefix.MAX_INET_MASK_LENGTH));
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.setEthDst(dstMacAddress);
treatment.setIpSrc(newSrcIpAddress);
Key key = Key.of(srcIpAddress.toString() + "MatchSrc", appId);
PointToPointIntent intent = PointToPointIntent.builder().appId(appId).key(key).selector(selector.build()).treatment(treatment.build()).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).build();
log.info("Generated a PointToPointIntent for traffic from local host " + ": {}", intent);
return intent;
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class VbngManager method dstMatchIntentGenerator.
/**
* PointToPointIntent Generator.
* <p>
* The intent will match the destination IP address in packet, rewrite the
* destination IP address, and rewrite the destination MAC address.
* </p>
*
* @param dstIpAddress the destination IP address in packet to match
* @param newDstIpAddress the new destination IP address to set
* @param dstMacAddress the destination MAC address to set
* @param dstConnectPoint the egress point
* @param srcConnectPoint the ingress point
* @return a PointToPointIntent
*/
private PointToPointIntent dstMatchIntentGenerator(IpAddress dstIpAddress, IpAddress newDstIpAddress, MacAddress dstMacAddress, ConnectPoint dstConnectPoint, ConnectPoint srcConnectPoint) {
checkNotNull(dstIpAddress);
checkNotNull(newDstIpAddress);
checkNotNull(dstMacAddress);
checkNotNull(dstConnectPoint);
checkNotNull(srcConnectPoint);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPDst(IpPrefix.valueOf(dstIpAddress, IpPrefix.MAX_INET_MASK_LENGTH));
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.setEthDst(dstMacAddress);
treatment.setIpDst(newDstIpAddress);
Key key = Key.of(newDstIpAddress.toString() + "MatchDst", appId);
PointToPointIntent intent = PointToPointIntent.builder().appId(appId).key(key).selector(selector.build()).treatment(treatment.build()).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).build();
log.info("Generated a PointToPointIntent for traffic to local host " + ": {}", intent);
return intent;
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class VplsIntentUtility method buildBrcIntents.
/**
* Builds broadcast Intents for a VPLS.
*
* @param vplsData the VPLS
* @param appId the application id for Intents
* @return broadcast Intents for the VPLS
*/
public static Set<Intent> buildBrcIntents(VplsData vplsData, ApplicationId appId) {
Set<Interface> interfaces = vplsData.interfaces();
// At least two or more network interfaces to build broadcast Intents
if (interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<Intent> brcIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
// Generates broadcast Intents from any network interface to other
// network interface from the VPLS.
interfaces.forEach(src -> {
FilteredConnectPoint srcFcp = VplsIntentUtility.buildFilteredConnectedPoint(src);
Set<FilteredConnectPoint> dstFcps = interfaces.stream().filter(iface -> !iface.equals(src)).map(VplsIntentUtility::buildFilteredConnectedPoint).collect(Collectors.toSet());
Key key = VplsIntentUtility.buildKey(PREFIX_BROADCAST, srcFcp.connectPoint(), vplsData.name(), MacAddress.BROADCAST, appId);
Intent brcIntent = buildBrcIntent(key, appId, srcFcp, dstFcps, vplsData.encapsulationType(), resourceGroup);
brcIntents.add(brcIntent);
});
return brcIntents;
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class VplsIntentUtility method buildUniIntents.
/**
* Builds unicast Intents for a VPLS.
*
* @param vplsData the VPLS
* @param hosts the hosts of the VPLS
* @param appId application ID for Intents
* @return unicast Intents for the VPLS
*/
public static Set<Intent> buildUniIntents(VplsData vplsData, Set<Host> hosts, ApplicationId appId) {
Set<Interface> interfaces = vplsData.interfaces();
if (interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<Intent> uniIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(VplsIntentUtility::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
Key key = buildKey(PREFIX_UNICAST, hostFcp.connectPoint(), vplsData.name(), host.mac(), appId);
Intent uniIntent = buildUniIntent(key, appId, srcFcps, hostFcp, host, vplsData.encapsulationType(), resourceGroup);
uniIntents.add(uniIntent);
});
return uniIntents;
}
Aggregations