use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.
the class SimpleFabricRouting method ipPacketReactiveProcessor.
/**
* Routes packet reactively.
*/
private void ipPacketReactiveProcessor(PacketContext context, Ethernet ethPkt, ConnectPoint srcCp, IpAddress srcIp, IpAddress dstIp, byte ipProto) {
/* check reactive handling and forward packet */
log.trace("ip packet: srcCp={} srcIp={} dstIp={} ipProto={}", srcCp, srcIp, dstIp, ipProto);
EncapsulationType encap = EncapsulationType.NONE;
// prefix and nextHop for local Subnet
IpPrefix srcPrefix = srcIp.toIpPrefix();
IpPrefix dstPrefix = dstIp.toIpPrefix();
IpAddress srcNextHop = srcIp;
IpAddress dstNextHop = dstIp;
MacAddress treatmentSrcMac = ethPkt.getDestinationMAC();
int borderRoutePrefixLength = 0;
boolean updateMac = simpleFabric.isVirtualGatewayMac(ethPkt.getDestinationMAC());
// check subnet local or route
FabricSubnet srcSubnet = simpleFabric.fabricSubnet(srcIp);
if (srcSubnet == null) {
FabricRoute route = simpleFabric.fabricRoute(srcIp);
if (route == null) {
log.warn("unknown srcIp; drop: srcCp={} srcIp={} dstIp={} ipProto={}", srcCp, srcIp, dstIp, ipProto);
return;
}
srcPrefix = route.prefix();
srcNextHop = route.nextHop();
borderRoutePrefixLength = route.prefix().prefixLength();
}
FabricSubnet dstSubnet = simpleFabric.fabricSubnet(dstIp);
if (dstSubnet == null) {
FabricRoute route = simpleFabric.fabricRoute(dstIp);
if (route == null) {
log.warn("unknown dstIp; drop: srcCp={} srcIp={} dstIp={} ipProto={}", srcCp, srcIp, dstIp, ipProto);
return;
}
dstPrefix = route.prefix();
dstNextHop = route.nextHop();
borderRoutePrefixLength = route.prefix().prefixLength();
}
if (dstSubnet != null) {
// destination is local subnet ip
if (ALLOW_ETH_ADDRESS_SELECTOR && dstSubnet.equals(srcSubnet)) {
// NOTE: if ALLOW_ETH_ADDRESS_SELECTOR=false; isForward is always false
FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(dstSubnet.networkName());
treatmentSrcMac = ethPkt.getSourceMAC();
if (fabricNetwork != null && fabricNetwork.isForward()) {
// NOTE: no reactive route action but do forward packet for L2Forward do not handle packet
// update mac only if dstMac is virtualGatewayMac, else assume valid mac already for the l2 network
log.info("LOCAL FORWARD ONLY: " + "srcCp={} srcIp={} dstIp={} srcMac={} dstMac={} vlanId={} ipProto={} updateMac={}", context.inPacket().receivedFrom(), srcIp, dstIp, ethPkt.getSourceMAC(), ethPkt.getDestinationMAC(), ethPkt.getVlanID(), ipProto, updateMac);
forwardPacketToDstIp(context, dstIp, treatmentSrcMac, updateMac);
return;
}
}
encap = dstSubnet.encapsulation();
if (encap == EncapsulationType.NONE && srcSubnet != null) {
encap = srcSubnet.encapsulation();
}
} else {
// destination is external network
if (srcSubnet == null) {
// both are externel network
log.warn("INVALID PACKET: srcIp and dstIp are both NON-LOCAL: " + "srcCP={} srcIp={} dstIp={} srcMac={} dstMac={} vlanId={} ipProto={} updateMac={}", context.inPacket().receivedFrom(), srcIp, dstIp, ethPkt.getSourceMAC(), ethPkt.getDestinationMAC(), ethPkt.getVlanID(), ipProto, updateMac);
return;
}
encap = srcSubnet.encapsulation();
}
log.info("REGI AND FORWARD: " + "srcCP={} srcIp={} dstIp={} srcMac={} dstMac={} vlanId={} ipProto={} updateMac={}", context.inPacket().receivedFrom(), srcIp, dstIp, ethPkt.getSourceMAC(), ethPkt.getDestinationMAC(), ethPkt.getVlanID(), ipProto, updateMac);
setUpConnectivity(srcCp, ipProto, srcPrefix, dstPrefix, dstNextHop, treatmentSrcMac, encap, updateMac, dstSubnet != null, borderRoutePrefixLength);
forwardPacketToDstIp(context, dstNextHop, treatmentSrcMac, updateMac);
}
Aggregations