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 PeerConnectivityManager method buildIntents.
/**
* Builds the required intents between a BGP speaker and an external router.
*
* @param portOne the BGP speaker connect point
* @param vlanOne the BGP speaker VLAN
* @param ipOne the BGP speaker IP address
* @param portTwo the external BGP peer connect point
* @param vlanTwo the external BGP peer VLAN
* @param ipTwo the external BGP peer IP address
* @param encap the encapsulation type
* @return the intents to install
*/
private Collection<PointToPointIntent> buildIntents(ConnectPoint portOne, VlanId vlanOne, IpAddress ipOne, ConnectPoint portTwo, VlanId vlanTwo, IpAddress ipTwo, EncapsulationType encap) {
List<PointToPointIntent> intents = new ArrayList<>();
TrafficTreatment.Builder treatmentToPeer = DefaultTrafficTreatment.builder();
TrafficTreatment.Builder treatmentToSpeaker = DefaultTrafficTreatment.builder();
PointToPointIntent.Builder intentBuilder;
TrafficSelector selector;
Key key;
byte tcpProtocol;
byte icmpProtocol;
if (ipOne.isIp4()) {
tcpProtocol = IPv4.PROTOCOL_TCP;
icmpProtocol = IPv4.PROTOCOL_ICMP;
} else {
tcpProtocol = IPv6.PROTOCOL_TCP;
icmpProtocol = IPv6.PROTOCOL_ICMP6;
}
// Add VLAN treatment for traffic going from BGP speaker to BGP peer
treatmentToPeer = applyVlanTreatment(vlanOne, vlanTwo, treatmentToPeer);
// Path from BGP speaker to BGP peer matching destination TCP port 179
selector = buildSelector(tcpProtocol, vlanOne, ipOne, ipTwo, null, BGP_PORT);
key = buildKey(ipOne, ipTwo, SUFFIX_DST);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// Path from BGP speaker to BGP peer matching source TCP port 179
selector = buildSelector(tcpProtocol, vlanOne, ipOne, ipTwo, BGP_PORT, null);
key = buildKey(ipOne, ipTwo, SUFFIX_SRC);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// ICMP path from BGP speaker to BGP peer
selector = buildSelector(icmpProtocol, vlanOne, ipOne, ipTwo, null, null);
key = buildKey(ipOne, ipTwo, SUFFIX_ICMP);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// Add VLAN treatment for traffic going from BGP peer to BGP speaker
treatmentToSpeaker = applyVlanTreatment(vlanTwo, vlanOne, treatmentToSpeaker);
// Path from BGP peer to BGP speaker matching destination TCP port 179
selector = buildSelector(tcpProtocol, vlanTwo, ipTwo, ipOne, null, BGP_PORT);
key = buildKey(ipTwo, ipOne, SUFFIX_DST);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// Path from BGP peer to BGP speaker matching source TCP port 179
selector = buildSelector(tcpProtocol, vlanTwo, ipTwo, ipOne, BGP_PORT, null);
key = buildKey(ipTwo, ipOne, SUFFIX_SRC);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// ICMP path from BGP peer to BGP speaker
selector = buildSelector(icmpProtocol, vlanTwo, ipTwo, ipOne, null, null);
key = buildKey(ipTwo, ipOne, SUFFIX_ICMP);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
return intents;
}
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 SdnIpFibTest method createIntentToThreeSrcOneTwoFour.
/*
* Builds a MultiPointToSinglePointIntent with dest sw3 (no VLAN Id) and src
* sw1, sw2, sw4.
*/
private MultiPointToSinglePointIntent createIntentToThreeSrcOneTwoFour(IpPrefix ipPrefix) {
// Build the expected treatment
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
treatmentBuilder.setEthDst(MAC3);
// Build the expected egress FilteredConnectPoint
FilteredConnectPoint egressFilteredCP = new FilteredConnectPoint(SW3_ETH1);
// Build the expected selectors
Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
// Build the expected ingress FilteredConnectPoint for sw1
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchVlanId(VLAN10);
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPDst(ipPrefix);
FilteredConnectPoint ingressFilteredCP = new FilteredConnectPoint(SW1_ETH1, selector.build());
ingressFilteredCPs.add(ingressFilteredCP);
// Build the expected ingress FilteredConnectPoint for sw2
selector = DefaultTrafficSelector.builder();
selector.matchVlanId(VLAN20);
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPDst(ipPrefix);
ingressFilteredCP = new FilteredConnectPoint(SW2_ETH1, selector.build());
ingressFilteredCPs.add(ingressFilteredCP);
// Build the expected ingress FilteredConnectPoint for sw4
selector = DefaultTrafficSelector.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPDst(ipPrefix);
ingressFilteredCP = new FilteredConnectPoint(SW4_ETH1, selector.build());
ingressFilteredCPs.add(ingressFilteredCP);
// Build the expected intent
MultiPointToSinglePointIntent intent = MultiPointToSinglePointIntent.builder().appId(APPID).key(Key.of(ipPrefix.toString(), APPID)).filteredIngressPoints(ingressFilteredCPs).filteredEgressPoint(egressFilteredCP).treatment(treatmentBuilder.build()).constraints(SdnIpFib.CONSTRAINTS).build();
return intent;
}
Aggregations