use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class OpenstackTroubleshootManager method setNorthSouthIcmpReplyRule.
/**
* Installs/uninstalls a flow rule to match north-south ICMP reply packets,
* direct all ICMP reply packets to the controller.
*
* @param port instance port
* @param gw gateway node
* @param install installation flag
*/
private void setNorthSouthIcmpReplyRule(InstancePort port, OpenstackNode gw, boolean install) {
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(IpPrefix.valueOf(port.ipAddress(), PREFIX_LENGTH)).matchIPProtocol(IPv4.PROTOCOL_ICMP).matchIcmpType(ICMP.TYPE_ECHO_REPLY).matchTunnelId(getSegId(osNetworkService, port)).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setIpSrc(instancePortService.floatingIp(port.portId())).setEthSrc(port.macAddress()).setEthDst(DEFAULT_EXTERNAL_ROUTER_MAC).punt().build();
osFlowRuleService.setRule(appId, gw.intgBridge(), selector, treatment, PRIORITY_ICMP_PROBE_RULE, GW_COMMON_TABLE, install);
}
use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class SimpleFabricForwarding method buildBrcIntents.
// Build Boadcast Intents for a L2 Network.
private Set<SinglePointToMultiPointIntent> buildBrcIntents(FabricNetwork fabricNetwork) {
Set<Interface> interfaces = fabricNetwork.interfaces();
if (interfaces.size() < 2 || !fabricNetwork.isForward() || !fabricNetwork.isBroadcast()) {
return ImmutableSet.of();
}
Set<SinglePointToMultiPointIntent> brcIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
// Generates broadcast Intents from any network interface to other
// network interface from the L2 Network.
interfaces.forEach(src -> {
FilteredConnectPoint srcFcp = buildFilteredConnectedPoint(src);
Set<FilteredConnectPoint> dstFcps = interfaces.stream().filter(iface -> !iface.equals(src)).map(this::buildFilteredConnectedPoint).collect(Collectors.toSet());
Key key = buildKey(fabricNetwork.name(), "BCAST", srcFcp.connectPoint(), MacAddress.BROADCAST);
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.BROADCAST).build();
SinglePointToMultiPointIntent.Builder intentBuilder = SinglePointToMultiPointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoint(srcFcp).filteredEgressPoints(dstFcps).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_BROADCAST).resourceGroup(resourceGroup);
brcIntents.add(intentBuilder.build());
});
return brcIntents;
}
use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class SimpleFabricForwarding method buildUniIntents.
// Builds unicast Intents for a L2 Network.
private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork, Set<Host> hosts) {
Set<Interface> interfaces = fabricNetwork.interfaces();
if (!fabricNetwork.isForward() || interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(this::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(host.mac()).build();
MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoints(srcFcps).filteredEgressPoint(hostFcp).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_UNICAST).resourceGroup(resourceGroup);
uniIntents.add(intentBuilder.build());
});
return uniIntents;
}
use of org.onosproject.net.flow.TrafficSelector 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.flow.TrafficSelector in project onos by opennetworkinglab.
the class FilteredConnectPointSerializer method read.
@Override
public FilteredConnectPoint read(Kryo kryo, Input input, Class<FilteredConnectPoint> type) {
ConnectPoint connectPoint = (ConnectPoint) kryo.readClassAndObject(input);
TrafficSelector trafficSelector = (TrafficSelector) kryo.readClassAndObject(input);
return new FilteredConnectPoint(connectPoint, trafficSelector);
}
Aggregations