use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class SdnIpFib method removeInterface.
/*
* Handles the case in which an existing interface gets removed.
*/
private void removeInterface(Interface intf) {
synchronized (this) {
for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : routeIntents.entrySet()) {
// Retrieve the IP prefix and intent possibly affected
IpPrefix prefix = entry.getKey();
MultiPointToSinglePointIntent intent = entry.getValue();
// The interface removed might be an ingress interface, so the
// selector needs to match on the interface tagging params and
// on the prefix
TrafficSelector.Builder ingressSelector = buildIngressTrafficSelector(intf, prefix);
FilteredConnectPoint removedIngressFilteredCP = new FilteredConnectPoint(intf.connectPoint(), ingressSelector.build());
// The interface removed might be an egress interface, so the
// selector needs to match only on the interface tagging params
TrafficSelector.Builder selector = buildTrafficSelector(intf);
FilteredConnectPoint removedEgressFilteredCP = new FilteredConnectPoint(intf.connectPoint(), selector.build());
if (intent.filteredEgressPoint().equals(removedEgressFilteredCP)) {
// The interface is an egress interface for the intent.
// This intent just lost its head. Remove it and let higher
// layer routing reroute
intentSynchronizer.withdraw(routeIntents.remove(entry.getKey()));
} else {
if (intent.filteredIngressPoints().contains(removedIngressFilteredCP)) {
// The FilteredConnectPoint is an ingress
// FilteredConnectPoint for the intent
Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet(intent.filteredIngressPoints());
// Remove FilteredConnectPoint from the existing set
ingressFilteredCPs.remove(removedIngressFilteredCP);
if (!ingressFilteredCPs.isEmpty()) {
// There are still ingress points. Create a new
// intent and resubmit
MultiPointToSinglePointIntent newIntent = MultiPointToSinglePointIntent.builder(intent).filteredIngressPoints(ingressFilteredCPs).build();
routeIntents.put(entry.getKey(), newIntent);
intentSynchronizer.submit(newIntent);
} else {
// No more ingress FilteredConnectPoint. Withdraw
// the intent
intentSynchronizer.withdraw(routeIntents.remove(entry.getKey()));
}
}
}
}
}
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class PeerConnectivityManagerTest method icmpPathintentConstructor.
/**
* Constructs a BGP intent and put it into the intentList.
* <p/>
* The purpose of this method is too simplify the setUpBgpIntents() method,
* and to make the setUpBgpIntents() easy to read.
*
* @param srcVlanId ingress VlanId
* @param dstVlanId egress VlanId
* @param srcPrefix source IP prefix to match
* @param dstPrefix destination IP prefix to match
* @param srcConnectPoint source connect point for PointToPointIntent
* @param dstConnectPoint destination connect point for PointToPointIntent
*/
private void icmpPathintentConstructor(VlanId srcVlanId, VlanId dstVlanId, String srcPrefix, String dstPrefix, ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) {
TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_ICMP).matchIPSrc(IpPrefix.valueOf(srcPrefix)).matchIPDst(IpPrefix.valueOf(dstPrefix));
if (!srcVlanId.equals(VlanId.NONE)) {
builder.matchVlanId(srcVlanId);
}
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
if (!dstVlanId.equals(VlanId.NONE)) {
treatment.setVlanId(dstVlanId);
}
Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0] + "-" + "icmp", APPID);
PointToPointIntent intent = PointToPointIntent.builder().appId(APPID).key(key).selector(builder.build()).treatment(treatment.build()).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).build();
intentList.add(intent);
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class PeerConnectivityManagerTest method bgpPathintentConstructor.
/**
* Constructs a BGP intent and put it into the intentList.
* <p/>
* The purpose of this method is too simplify the setUpBgpIntents() method,
* and to make the setUpBgpIntents() easy to read.
*
* @param srcVlanId ingress VlanId
* @param dstVlanId egress VlanId
* @param srcPrefix source IP prefix to match
* @param dstPrefix destination IP prefix to match
* @param srcTcpPort source TCP port to match
* @param dstTcpPort destination TCP port to match
* @param srcConnectPoint source connect point for PointToPointIntent
* @param dstConnectPoint destination connect point for PointToPointIntent
*/
private void bgpPathintentConstructor(VlanId srcVlanId, VlanId dstVlanId, String srcPrefix, String dstPrefix, Short srcTcpPort, Short dstTcpPort, ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) {
TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_TCP).matchIPSrc(IpPrefix.valueOf(srcPrefix)).matchIPDst(IpPrefix.valueOf(dstPrefix));
if (!srcVlanId.equals(VlanId.NONE)) {
builder.matchVlanId(srcVlanId);
}
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
if (!dstVlanId.equals(VlanId.NONE)) {
treatment.setVlanId(dstVlanId);
}
if (srcTcpPort != null) {
builder.matchTcpSrc(TpPort.tpPort(srcTcpPort));
}
if (dstTcpPort != null) {
builder.matchTcpDst(TpPort.tpPort(dstTcpPort));
}
Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0] + "-" + ((srcTcpPort == null) ? "dst" : "src"), APPID);
PointToPointIntent intent = PointToPointIntent.builder().appId(APPID).key(key).selector(builder.build()).treatment(treatment.build()).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).build();
intentList.add(intent);
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class VplsIntentTest method generateVplsUni.
/**
* Generates a list of expected mp2sp intents for a given VPLS.
*
* @param fcPoints the filtered connect point
* @param hosts the hosts
* @param name the name of the VPLS
* @param encap the encapsulation type
* @return the list of expected mp2sp intents for the given VPLS
*/
private List<MultiPointToSinglePointIntent> generateVplsUni(Set<FilteredConnectPoint> fcPoints, Set<Host> hosts, String name, EncapsulationType encap) {
List<MultiPointToSinglePointIntent> intents = Lists.newArrayList();
hosts.forEach(host -> {
FilteredConnectPoint hostPoint = getHostPoint(host, fcPoints);
Set<FilteredConnectPoint> otherPoints = fcPoints.stream().filter(fcp -> !fcp.equals(hostPoint)).collect(Collectors.toSet());
Key uniKey = buildKey(VplsIntentUtility.PREFIX_UNICAST, host.location(), name, host.mac());
intents.add(buildUniIntent(uniKey, otherPoints, hostPoint, host, encap));
});
return intents;
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class TestProtectionEndpointIntentCommand method output.
private FilteredConnectPoint output(DeviceId did, String portNumberStr, String vlanStr) {
ConnectPoint cp = new ConnectPoint(did, PortNumber.fromString(portNumberStr));
if (deviceService.getPort(cp) == null) {
print("Unknown port: %s", cp);
}
if (vlanStr == null) {
return new FilteredConnectPoint(cp);
} else {
VlanId vlan = VlanId.vlanId(vlanStr);
TrafficSelector sel = DefaultTrafficSelector.builder().matchVlanId(vlan).build();
return new FilteredConnectPoint(cp, sel);
}
}
Aggregations