use of org.onosproject.openstacktroubleshoot.api.Reachability in project onos by opennetworkinglab.
the class OpenstackTroubleshootManager method handleIcmpEchoReply.
/**
* Handles ICMP ECHO REPLY packets.
*
* @param ipPacket IP packet
* @param icmp ICMP packet
*/
private void handleIcmpEchoReply(IPv4 ipPacket, ICMP icmp) {
String icmpKey = icmpId(icmp);
String srcIp = IPv4.fromIPv4Address(ipPacket.getDestinationAddress());
String dstIp = IPv4.fromIPv4Address(ipPacket.getSourceAddress());
Reachability reachability = DefaultReachability.builder().srcIp(IpAddress.valueOf(srcIp)).dstIp(IpAddress.valueOf(dstIp)).isReachable(false).build();
icmpReachabilityMap.computeIfPresent(icmpKey, (key, value) -> {
if (value.equals(reachability)) {
log.debug("src: {}, dst: {} is reachable!", value.dstIp(), value.srcIp());
return DefaultReachability.builder().srcIp(IpAddress.valueOf(srcIp)).dstIp(IpAddress.valueOf(dstIp)).isReachable(true).build();
}
return reachability;
});
}
use of org.onosproject.openstacktroubleshoot.api.Reachability in project onos by opennetworkinglab.
the class OpenstackTroubleshootManager method probeEastWest.
@Override
public Reachability probeEastWest(InstancePort srcPort, InstancePort dstPort) {
Reachability.Builder rBuilder = DefaultReachability.builder().srcIp(srcPort.ipAddress()).dstIp(dstPort.ipAddress());
if (srcPort.equals(dstPort)) {
// self probing should always return true
rBuilder.isReachable(true);
return rBuilder.build();
} else {
if (srcPort.state() == ACTIVE && dstPort.state() == ACTIVE) {
// we immediately return unreachable state
if (!osNetworkService.networkType(srcPort.networkId()).equals(osNetworkService.networkType(dstPort.networkId()))) {
rBuilder.isReachable(false);
return rBuilder.build();
}
// install flow rules to enforce ICMP_REQUEST to be tagged and direct to ACL table
eventExecutor.execute(() -> setVidTagRule(srcPort, true));
// install flow rules to enforce forwarding ICMP_REPLY to controller
eventExecutor.execute(() -> setEastWestIcmpReplyRule(srcPort, true));
timeoutPredicate(1, VID_TAG_RULE_INSTALL_TIMEOUT_MS, this::checkVidTagRule, srcPort.ipAddress().toString());
timeoutPredicate(1, ICMP_RULE_INSTALL_TIMEOUT_MS, this::checkEastWestIcmpReplyRule, srcPort.ipAddress().toString());
// send out ICMP ECHO request
sendIcmpEchoRequest(srcPort, dstPort, null, Direction.EAST_WEST);
BooleanSupplier checkReachability = () -> icmpReachabilityMap.asJavaMap().values().stream().allMatch(Reachability::isReachable);
timeoutSupplier(1, ICMP_REPLY_TIMEOUT_MS, checkReachability);
// uninstall ICMP_REQUEST VID tagging rules
eventExecutor.execute(() -> setVidTagRule(srcPort, false));
// uninstall ICMP_REPLY enforcing rules
eventExecutor.execute(() -> setEastWestIcmpReplyRule(srcPort, false));
return icmpReachabilityMap.asJavaMap().get(String.valueOf(icmpIdCounter.get()));
} else {
rBuilder.isReachable(false);
return rBuilder.build();
}
}
}
use of org.onosproject.openstacktroubleshoot.api.Reachability in project onos by opennetworkinglab.
the class OpenstackTroubleshootManager method probeNorthSouth.
@Override
public Reachability probeNorthSouth(InstancePort port) {
Optional<OpenstackNode> gw = osNodeService.completeNodes(GATEWAY).stream().findFirst();
if (!gw.isPresent()) {
log.warn("Gateway is not available to troubleshoot north-south traffic.");
return null;
}
// install flow rules to enforce forwarding ICMP_REPLY to controller
eventExecutor.execute(() -> setNorthSouthIcmpReplyRule(port, gw.get(), true));
timeoutPredicate(1, ICMP_RULE_INSTALL_TIMEOUT_MS, this::checkNorthSouthIcmpReplyRule, port.ipAddress().toString());
// send out ICMP ECHO request
sendIcmpEchoRequest(null, port, gw.get(), Direction.NORTH_SOUTH);
BooleanSupplier checkReachability = () -> icmpReachabilityMap.asJavaMap().values().stream().allMatch(Reachability::isReachable);
timeoutSupplier(1, ICMP_REPLY_TIMEOUT_MS, checkReachability);
// uninstall ICMP_REPLY enforcing rules
eventExecutor.execute(() -> setNorthSouthIcmpReplyRule(port, gw.get(), false));
return icmpReachabilityMap.asJavaMap().get(String.valueOf(icmpIdCounter.get()));
}
use of org.onosproject.openstacktroubleshoot.api.Reachability in project onos by opennetworkinglab.
the class OpenstackTroubleshootManager method buildIcmpOutputPacket.
/**
* Builds ICMP Outbound packet.
*
* @param srcPort source instance port
* @param dstPort destination instance port
* @param icmpId ICMP identifier
* @param icmpSeq ICMP sequence number
*/
private OutboundPacket buildIcmpOutputPacket(InstancePort srcPort, InstancePort dstPort, OpenstackNode gateway, short icmpId, short icmpSeq, Direction direction) {
Ethernet ethFrame;
IpAddress srcIp;
IpAddress dstIp;
DeviceId deviceId;
if (direction == Direction.EAST_WEST) {
ethFrame = constructEastWestIcmpPacket(srcPort, dstPort, icmpId, icmpSeq);
srcIp = srcPort.ipAddress();
dstIp = dstPort.ipAddress();
deviceId = srcPort.deviceId();
} else if (direction == Direction.NORTH_SOUTH) {
ethFrame = constructNorthSouthIcmpPacket(dstPort, icmpId, icmpSeq);
srcIp = clusterService.getLocalNode().ip();
dstIp = instancePortService.floatingIp(dstPort.portId());
deviceId = gateway.intgBridge();
} else {
log.warn("Invalid traffic direction {}", direction);
return null;
}
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
// we send out the packet to ingress table (index is 0) of source OVS
// to enforce the Outbound packet to go through the ingress and egress
// pipeline
tBuilder.setOutput(TABLE);
Reachability reachability = DefaultReachability.builder().srcIp(srcIp).dstIp(dstIp).isReachable(false).build();
icmpReachabilityMap.put(String.valueOf(icmpId), reachability);
icmpIds.add(String.valueOf(icmpId));
return new DefaultOutboundPacket(deviceId, tBuilder.build(), ByteBuffer.wrap(ethFrame.serialize()));
}
use of org.onosproject.openstacktroubleshoot.api.Reachability in project onos by opennetworkinglab.
the class DefaultReachabilityTest method testConstruction.
/**
* Test object construction.
*/
@Test
public void testConstruction() {
Reachability reachability = reachability1;
assertEquals(reachability.srcIp(), IP_ADDRESS_1_1);
assertEquals(reachability.dstIp(), IP_ADDRESS_1_2);
assertTrue(reachability.isReachable());
}
Aggregations