Jonathan Hart | 0961fe8 | 2014-04-03 09:56:25 -0700 | [diff] [blame] | 1 | package net.onrc.onos.apps.forwarding; |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 2 | |
Jonathan Hart | 41d1e91 | 2013-11-24 16:50:25 -0800 | [diff] [blame] | 3 | import java.util.ArrayList; |
Jonathan Hart | e93aed4 | 2013-12-05 18:39:50 -0800 | [diff] [blame] | 4 | import java.util.Collection; |
Jonathan Hart | d33a6cf | 2013-12-10 14:29:08 -0800 | [diff] [blame] | 5 | import java.util.HashMap; |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 6 | import java.util.Iterator; |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 7 | import java.util.LinkedList; |
Jonathan Hart | 41d1e91 | 2013-11-24 16:50:25 -0800 | [diff] [blame] | 8 | import java.util.List; |
Jonathan Hart | e93aed4 | 2013-12-05 18:39:50 -0800 | [diff] [blame] | 9 | import java.util.Map; |
TeruU | 417fe02 | 2014-02-04 12:59:30 -0800 | [diff] [blame] | 10 | import java.util.concurrent.Executors; |
| 11 | import java.util.concurrent.ScheduledExecutorService; |
| 12 | import java.util.concurrent.TimeUnit; |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 13 | |
Jonathan Hart | e93aed4 | 2013-12-05 18:39:50 -0800 | [diff] [blame] | 14 | import net.floodlightcontroller.core.module.FloodlightModuleContext; |
| 15 | import net.floodlightcontroller.core.module.IFloodlightModule; |
| 16 | import net.floodlightcontroller.core.module.IFloodlightService; |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 17 | import net.floodlightcontroller.util.MACAddress; |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 18 | import net.onrc.onos.api.packet.IPacketListener; |
| 19 | import net.onrc.onos.api.packet.IPacketService; |
Jonathan Hart | 0961fe8 | 2014-04-03 09:56:25 -0700 | [diff] [blame] | 20 | import net.onrc.onos.apps.proxyarp.IProxyArpService; |
Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 21 | import net.onrc.onos.core.devicemanager.IOnosDeviceService; |
Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 22 | import net.onrc.onos.core.intent.Intent; |
Jonathan Hart | a99ec67 | 2014-04-03 11:30:34 -0700 | [diff] [blame] | 23 | import net.onrc.onos.core.intent.Intent.IntentState; |
Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 24 | import net.onrc.onos.core.intent.IntentMap; |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 25 | import net.onrc.onos.core.intent.IntentMap.ChangedEvent; |
| 26 | import net.onrc.onos.core.intent.IntentMap.ChangedListener; |
Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 27 | import net.onrc.onos.core.intent.IntentOperation; |
| 28 | import net.onrc.onos.core.intent.IntentOperationList; |
| 29 | import net.onrc.onos.core.intent.PathIntent; |
| 30 | import net.onrc.onos.core.intent.ShortestPathIntent; |
Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 31 | import net.onrc.onos.core.intent.runtime.IPathCalcRuntimeService; |
Jonathan Hart | deda0ba | 2014-04-03 11:14:12 -0700 | [diff] [blame] | 32 | import net.onrc.onos.core.packet.Ethernet; |
| 33 | import net.onrc.onos.core.registry.IControllerRegistryService; |
Jonathan Hart | 472062d | 2014-04-03 10:56:48 -0700 | [diff] [blame] | 34 | import net.onrc.onos.core.topology.Device; |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 35 | import net.onrc.onos.core.topology.ITopologyService; |
Jonathan Hart | 472062d | 2014-04-03 10:56:48 -0700 | [diff] [blame] | 36 | import net.onrc.onos.core.topology.LinkEvent; |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 37 | import net.onrc.onos.core.topology.Port; |
Jonathan Hart | 472062d | 2014-04-03 10:56:48 -0700 | [diff] [blame] | 38 | import net.onrc.onos.core.topology.Switch; |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 39 | import net.onrc.onos.core.topology.Topology; |
Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 40 | import net.onrc.onos.core.util.Dpid; |
| 41 | import net.onrc.onos.core.util.FlowPath; |
Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 42 | import net.onrc.onos.core.util.SwitchPort; |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 43 | |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 44 | import org.openflow.util.HexString; |
| 45 | import org.slf4j.Logger; |
| 46 | import org.slf4j.LoggerFactory; |
| 47 | |
Jonathan Hart | d857ad6 | 2013-12-14 18:08:17 -0800 | [diff] [blame] | 48 | import com.google.common.collect.LinkedListMultimap; |
| 49 | import com.google.common.collect.ListMultimap; |
Jonathan Hart | 5e44878 | 2013-12-10 12:36:35 -0800 | [diff] [blame] | 50 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 51 | public class Forwarding implements /*IOFMessageListener,*/ IFloodlightModule, |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 52 | IForwardingService, IPacketListener, ChangedListener { |
Ray Milkey | ec83894 | 2014-04-09 11:28:43 -0700 | [diff] [blame] | 53 | private static final Logger log = LoggerFactory.getLogger(Forwarding.class); |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 54 | |
Ray Milkey | 2476cac | 2014-04-08 11:03:21 -0700 | [diff] [blame] | 55 | private static final int SLEEP_TIME_FOR_DB_DEVICE_INSTALLED = 100; // milliseconds |
Ray Milkey | ec83894 | 2014-04-09 11:28:43 -0700 | [diff] [blame] | 56 | private static final int NUMBER_OF_THREAD_FOR_EXECUTOR = 1; |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 57 | private static final int SRC_SWITCH_TIMEOUT_ADJUST_SECOND = 2; |
| 58 | private static final int DEFAULT_IDLE_TIMEOUT = 5; |
| 59 | private int idleTimeout = DEFAULT_IDLE_TIMEOUT; |
Pavlin Radoslavov | 902fe52 | 2014-03-31 10:11:31 -0700 | [diff] [blame] | 60 | |
Jonathan Hart | c00f5c2 | 2014-06-10 15:14:40 -0700 | [diff] [blame] | 61 | private static final ScheduledExecutorService EXECUTOR_SERVICE = |
| 62 | Executors.newScheduledThreadPool(NUMBER_OF_THREAD_FOR_EXECUTOR); |
Jonathan Hart | e93aed4 | 2013-12-05 18:39:50 -0800 | [diff] [blame] | 63 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 64 | private final String callerId = "Forwarding"; |
Jonathan Hart | e93aed4 | 2013-12-05 18:39:50 -0800 | [diff] [blame] | 65 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 66 | private IPacketService packetService; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 67 | private IControllerRegistryService controllerRegistryService; |
| 68 | |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 69 | private ITopologyService topologyService; |
| 70 | private Topology topology; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 71 | private IPathCalcRuntimeService pathRuntime; |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 72 | private IntentMap pathIntentMap; |
| 73 | private IntentMap highLevelIntentMap; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 74 | |
| 75 | // TODO it seems there is a Guava collection that will time out entries. |
| 76 | // We should see if this will work here. |
| 77 | private Map<Path, PushedFlow> pendingFlows; |
| 78 | private ListMultimap<String, PacketToPush> waitingPackets; |
| 79 | |
| 80 | private final Object lock = new Object(); |
| 81 | |
Jonathan Hart | 8ed69c5 | 2014-04-09 13:29:16 -0700 | [diff] [blame] | 82 | private static class PacketToPush { |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 83 | public final Ethernet eth; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 84 | public final long dpid; |
| 85 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 86 | public PacketToPush(Ethernet eth, long dpid) { |
| 87 | this.eth = eth; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 88 | this.dpid = dpid; |
| 89 | } |
| 90 | } |
| 91 | |
Jonathan Hart | 8ed69c5 | 2014-04-09 13:29:16 -0700 | [diff] [blame] | 92 | private static class PushedFlow { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 93 | public final String intentId; |
| 94 | public boolean installed = false; |
| 95 | public short firstOutPort; |
| 96 | |
| 97 | public PushedFlow(String flowId) { |
| 98 | this.intentId = flowId; |
| 99 | } |
| 100 | } |
| 101 | |
Jonathan Hart | 8ed69c5 | 2014-04-09 13:29:16 -0700 | [diff] [blame] | 102 | private static final class Path { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 103 | public final MACAddress srcMac; |
| 104 | public final MACAddress dstMac; |
| 105 | |
| 106 | public Path(MACAddress srcMac, MACAddress dstMac) { |
| 107 | this.srcMac = srcMac; |
| 108 | this.dstMac = dstMac; |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public boolean equals(Object other) { |
| 113 | if (!(other instanceof Path)) { |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | Path otherPath = (Path) other; |
| 118 | return srcMac.equals(otherPath.srcMac) && |
| 119 | dstMac.equals(otherPath.dstMac); |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public int hashCode() { |
| 124 | int hash = 17; |
| 125 | hash = 31 * hash + srcMac.hashCode(); |
| 126 | hash = 31 * hash + dstMac.hashCode(); |
| 127 | return hash; |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | public String toString() { |
| 132 | return "(" + srcMac + ") => (" + dstMac + ")"; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public Collection<Class<? extends IFloodlightService>> getModuleServices() { |
| 138 | List<Class<? extends IFloodlightService>> services = |
| 139 | new ArrayList<Class<? extends IFloodlightService>>(1); |
| 140 | services.add(IForwardingService.class); |
| 141 | return services; |
| 142 | } |
| 143 | |
| 144 | @Override |
| 145 | public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() { |
| 146 | Map<Class<? extends IFloodlightService>, IFloodlightService> impls = |
| 147 | new HashMap<Class<? extends IFloodlightService>, IFloodlightService>(1); |
| 148 | impls.put(IForwardingService.class, this); |
| 149 | return impls; |
| 150 | } |
| 151 | |
| 152 | @Override |
| 153 | public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { |
| 154 | List<Class<? extends IFloodlightService>> dependencies = |
| 155 | new ArrayList<Class<? extends IFloodlightService>>(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 156 | dependencies.add(IControllerRegistryService.class); |
| 157 | dependencies.add(IOnosDeviceService.class); |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 158 | dependencies.add(ITopologyService.class); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 159 | dependencies.add(IPathCalcRuntimeService.class); |
| 160 | // We don't use the IProxyArpService directly, but reactive forwarding |
| 161 | // requires it to be loaded and answering ARP requests |
| 162 | dependencies.add(IProxyArpService.class); |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 163 | dependencies.add(IPacketService.class); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 164 | return dependencies; |
| 165 | } |
| 166 | |
| 167 | @Override |
| 168 | public void init(FloodlightModuleContext context) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 169 | controllerRegistryService = context.getServiceImpl(IControllerRegistryService.class); |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 170 | topologyService = context.getServiceImpl(ITopologyService.class); |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 171 | pathRuntime = context.getServiceImpl(IPathCalcRuntimeService.class); |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 172 | packetService = context.getServiceImpl(IPacketService.class); |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 173 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 174 | pendingFlows = new HashMap<Path, PushedFlow>(); |
| 175 | waitingPackets = LinkedListMultimap.create(); |
| 176 | } |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 177 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 178 | @Override |
| 179 | public void startUp(FloodlightModuleContext context) { |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 180 | Map<String, String> configOptions = context.getConfigParams(this); |
| 181 | |
| 182 | try { |
| 183 | if (Integer.parseInt(configOptions.get("idletimeout")) > 0) { |
| 184 | idleTimeout = Integer.parseInt(configOptions.get("idletimeout")); |
| 185 | log.info("idle_timeout for Forwarding is set to {}.", idleTimeout); |
| 186 | } else { |
| 187 | log.info("idle_timeout for Forwarding is less than 0. Use default {}.", idleTimeout); |
| 188 | } |
| 189 | } catch (NumberFormatException e) { |
| 190 | log.info("idle_timeout related config options were not set. Use default."); |
| 191 | } |
| 192 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 193 | packetService.registerPacketListener(this); |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 194 | |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 195 | topology = topologyService.getTopology(); |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 196 | highLevelIntentMap = pathRuntime.getHighLevelIntents(); |
| 197 | pathIntentMap = pathRuntime.getPathIntents(); |
| 198 | pathIntentMap.addChangeListener(this); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 199 | } |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 200 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 201 | @Override |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 202 | public void receive(Switch sw, Port inPort, Ethernet eth) { |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 203 | if (log.isTraceEnabled()) { |
| 204 | log.trace("Receive PACKET_IN swId {}, portId {}", sw.getDpid(), inPort.getNumber()); |
| 205 | } |
TeruU | 417fe02 | 2014-02-04 12:59:30 -0800 | [diff] [blame] | 206 | |
Ray Milkey | 5c9f2db | 2014-04-09 10:31:21 -0700 | [diff] [blame] | 207 | if (eth.getEtherType() != Ethernet.TYPE_IPV4) { |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 208 | // Only handle IPv4 packets right now |
| 209 | return; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 210 | } |
TeruU | 417fe02 | 2014-02-04 12:59:30 -0800 | [diff] [blame] | 211 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 212 | if (eth.isBroadcast() || eth.isMulticast()) { |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 213 | handleBroadcast(sw, inPort, eth); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 214 | } else { |
| 215 | // Unicast |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 216 | handlePacketIn(sw, inPort, eth); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 217 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 218 | } |
TeruU | 417fe02 | 2014-02-04 12:59:30 -0800 | [diff] [blame] | 219 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 220 | private void handleBroadcast(Switch sw, Port inPort, Ethernet eth) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 221 | if (log.isTraceEnabled()) { |
| 222 | log.trace("Sending broadcast packet to other ONOS instances"); |
| 223 | } |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 224 | |
Jonathan Hart | e3702f2 | 2014-04-29 02:56:56 -0700 | [diff] [blame] | 225 | packetService.broadcastPacketOutEdge(eth, |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 226 | new SwitchPort(sw.getDpid(), inPort.getNumber().shortValue())); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 227 | } |
Pavlin Radoslavov | a3818db | 2014-03-20 19:26:08 -0700 | [diff] [blame] | 228 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 229 | private void handlePacketIn(Switch sw, Port inPort, Ethernet eth) { |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 230 | if (log.isTraceEnabled()) { |
| 231 | log.trace("Start handlePacketIn swId {}, portId {}", sw.getDpid(), inPort.getNumber()); |
| 232 | } |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 233 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 234 | String destinationMac = |
| 235 | HexString.toHexString(eth.getDestinationMACAddress()); |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 236 | |
Jonathan Hart | c00f5c2 | 2014-06-10 15:14:40 -0700 | [diff] [blame] | 237 | // FIXME getDeviceByMac() is a blocking call, so it may be better way |
| 238 | // to handle it to avoid the condition. |
| 239 | Device deviceObject = topology.getDeviceByMac( |
| 240 | MACAddress.valueOf(destinationMac)); |
TeruU | 6464af0 | 2014-02-06 21:38:45 -0800 | [diff] [blame] | 241 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 242 | if (deviceObject == null) { |
| 243 | log.debug("No device entry found for {}", |
| 244 | destinationMac); |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 245 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 246 | //Device is not in the DB, so wait it until the device is added. |
Jonathan Hart | c00f5c2 | 2014-06-10 15:14:40 -0700 | [diff] [blame] | 247 | EXECUTOR_SERVICE.schedule(new WaitDeviceArp(sw, inPort, eth), |
| 248 | SLEEP_TIME_FOR_DB_DEVICE_INSTALLED, TimeUnit.MILLISECONDS); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 249 | return; |
| 250 | } |
Pavlin Radoslavov | 7208e9a | 2013-12-11 14:31:07 -0800 | [diff] [blame] | 251 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 252 | continueHandlePacketIn(sw, inPort, eth, deviceObject); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 253 | } |
TeruU | 417fe02 | 2014-02-04 12:59:30 -0800 | [diff] [blame] | 254 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 255 | private class WaitDeviceArp implements Runnable { |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 256 | Switch sw; |
| 257 | Port inPort; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 258 | Ethernet eth; |
TeruU | 417fe02 | 2014-02-04 12:59:30 -0800 | [diff] [blame] | 259 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 260 | public WaitDeviceArp(Switch sw, Port inPort, Ethernet eth) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 261 | super(); |
| 262 | this.sw = sw; |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 263 | this.inPort = inPort; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 264 | this.eth = eth; |
| 265 | } |
TeruU | 417fe02 | 2014-02-04 12:59:30 -0800 | [diff] [blame] | 266 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 267 | @Override |
| 268 | public void run() { |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 269 | Device deviceObject = topology.getDeviceByMac(MACAddress.valueOf(eth.getDestinationMACAddress())); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 270 | if (deviceObject == null) { |
Jonathan Hart | c00f5c2 | 2014-06-10 15:14:40 -0700 | [diff] [blame] | 271 | log.debug("wait {}ms and device was not found. " + |
| 272 | "Send broadcast packet and the thread finish.", |
| 273 | SLEEP_TIME_FOR_DB_DEVICE_INSTALLED); |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 274 | handleBroadcast(sw, inPort, eth); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 275 | return; |
| 276 | } |
Jonathan Hart | c00f5c2 | 2014-06-10 15:14:40 -0700 | [diff] [blame] | 277 | log.debug("wait {}ms and device {} was found, continue", |
| 278 | SLEEP_TIME_FOR_DB_DEVICE_INSTALLED, deviceObject.getMacAddress()); |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 279 | continueHandlePacketIn(sw, inPort, eth, deviceObject); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 280 | } |
| 281 | } |
Jonathan Hart | 0444d93 | 2014-01-22 15:06:17 -0800 | [diff] [blame] | 282 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 283 | private void continueHandlePacketIn(Switch sw, Port inPort, Ethernet eth, Device deviceObject) { |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 284 | |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 285 | log.trace("Start continuehandlePacketIn"); |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 286 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 287 | //Iterator<IPortObject> ports = deviceObject.getAttachedPorts().iterator(); |
| 288 | Iterator<net.onrc.onos.core.topology.Port> ports = deviceObject.getAttachmentPoints().iterator(); |
| 289 | if (!ports.hasNext()) { |
| 290 | log.debug("No attachment point found for device {} - broadcasting packet", |
| 291 | deviceObject.getMacAddress()); |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 292 | handleBroadcast(sw, inPort, eth); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 293 | return; |
| 294 | } |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 295 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 296 | //This code assumes the device has only one port. It should be problem. |
| 297 | net.onrc.onos.core.topology.Port portObject = ports.next(); |
| 298 | short destinationPort = portObject.getNumber().shortValue(); |
| 299 | Switch switchObject = portObject.getSwitch(); |
| 300 | long destinationDpid = switchObject.getDpid(); |
| 301 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 302 | // TODO eliminate cast |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 303 | SwitchPort srcSwitchPort = new SwitchPort( |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 304 | new Dpid(sw.getDpid()), |
| 305 | new net.onrc.onos.core.util.Port((short) inPort.getNumber().longValue())); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 306 | SwitchPort dstSwitchPort = new SwitchPort( |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 307 | new Dpid(destinationDpid), |
| 308 | new net.onrc.onos.core.util.Port(destinationPort)); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 309 | |
| 310 | MACAddress srcMacAddress = MACAddress.valueOf(eth.getSourceMACAddress()); |
| 311 | MACAddress dstMacAddress = MACAddress.valueOf(eth.getDestinationMACAddress()); |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 312 | Path pathspec = new Path(srcMacAddress, dstMacAddress); |
| 313 | IntentOperationList operations = new IntentOperationList(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 314 | |
| 315 | synchronized (lock) { |
| 316 | //TODO check concurrency |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 317 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 318 | PushedFlow existingFlow = pendingFlows.get(pathspec); |
| 319 | |
| 320 | //A path is installed side by side to reduce a path timeout and a wrong state. |
| 321 | if (existingFlow != null) { |
| 322 | // We've already start to install a flow for this pair of MAC addresses |
| 323 | if (log.isDebugEnabled()) { |
| 324 | log.debug("Found existing the same pathspec {}, intent ID is {}", |
| 325 | pathspec, |
| 326 | existingFlow.intentId); |
| 327 | } |
| 328 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 329 | // Find the correct port here. We just assume the PI is from |
| 330 | // the first hop switch, but this is definitely not always |
| 331 | // the case. We'll have to retrieve the flow from HZ every time |
| 332 | // because it could change (be rerouted) sometimes. |
| 333 | if (existingFlow.installed) { |
| 334 | // Flow has been sent to the switches so it is safe to |
| 335 | // send a packet out now |
| 336 | |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 337 | // TODO Here highLevelIntentMap and pathIntentMap would be problem, |
| 338 | // because it doesn't have global information as of May 2014. |
| 339 | // However usually these lines here is used when we got packet-in and this class think |
| 340 | // the path for the packet is installed already, so it is pretty rare. |
| 341 | // I will leave it for now, and will work in the next step. |
| 342 | Intent highLevelIntent = highLevelIntentMap.getIntent(existingFlow.intentId); |
| 343 | if (highLevelIntent == null) { |
| 344 | log.debug("Intent ID {} is null in HighLevelIntentMap. return.", existingFlow.intentId); |
| 345 | return; |
| 346 | } |
| 347 | |
| 348 | if (highLevelIntent.getState() != IntentState.INST_ACK) { |
| 349 | log.debug("Intent ID {}'s state is not INST_ACK. return.", existingFlow.intentId); |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | ShortestPathIntent spfIntent = null; |
| 354 | if (highLevelIntent instanceof ShortestPathIntent) { |
| 355 | spfIntent = (ShortestPathIntent) highLevelIntent; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 356 | } else { |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 357 | log.debug("Intent ID {} is not PathIntent or null. return.", existingFlow.intentId); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 358 | return; |
| 359 | } |
| 360 | |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 361 | PathIntent pathIntent = (PathIntent) pathIntentMap.getIntent(spfIntent.getPathIntentId()); |
| 362 | if (pathIntent == null) { |
| 363 | log.debug("PathIntent ID {} is null in PathIntentMap. return.", existingFlow.intentId); |
| 364 | return; |
| 365 | } |
| 366 | |
| 367 | if (pathIntent.getState() != IntentState.INST_ACK) { |
| 368 | log.debug("Intent ID {}'s state is not INST_ACK. return.", existingFlow.intentId); |
| 369 | return; |
| 370 | } |
| 371 | |
| 372 | boolean isflowEntryForThisSwitch = false; |
Yuta HIGUCHI | 1fc395e | 2014-05-13 14:06:28 -0700 | [diff] [blame] | 373 | net.onrc.onos.core.intent.Path path = pathIntent.getPath(); |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 374 | long outPort = -1; |
| 375 | |
| 376 | if (spfIntent.getDstSwitchDpid() == sw.getDpid()) { |
| 377 | log.trace("The packet-in sw dpid {} is on the path.", sw.getDpid()); |
| 378 | isflowEntryForThisSwitch = true; |
| 379 | outPort = spfIntent.getDstPortNumber(); |
| 380 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 381 | |
Ray Milkey | 7f1567c | 2014-04-08 13:53:32 -0700 | [diff] [blame] | 382 | for (Iterator<LinkEvent> i = path.iterator(); i.hasNext();) { |
Ray Milkey | 149693c | 2014-05-20 14:58:53 -0700 | [diff] [blame] | 383 | LinkEvent le = i.next(); |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 384 | |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 385 | if (le.getSrc().dpid.equals(sw.getDpid())) { |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 386 | log.trace("The packet-in sw dpid {} is on the path.", sw.getDpid()); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 387 | isflowEntryForThisSwitch = true; |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 388 | outPort = le.getSrc().getNumber(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 389 | break; |
| 390 | } |
| 391 | } |
| 392 | |
Ray Milkey | 6c4f2fe | 2014-04-11 09:47:23 -0700 | [diff] [blame] | 393 | if (!isflowEntryForThisSwitch) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 394 | // If we don't find a flow entry for that switch, then we're |
| 395 | // in the middle of a rerouting (or something's gone wrong). |
| 396 | // This packet will be dropped as a victim of the rerouting. |
| 397 | log.debug("Dropping packet on flow {} between {}-{}", |
| 398 | existingFlow.intentId, |
| 399 | srcMacAddress, dstMacAddress); |
| 400 | } else { |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 401 | if (outPort < 0) { |
| 402 | outPort = existingFlow.firstOutPort; |
| 403 | } |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 404 | |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 405 | log.debug("Sending packet out from sw {}, outport{}", sw.getDpid(), outPort); |
Jonathan Hart | e3702f2 | 2014-04-29 02:56:56 -0700 | [diff] [blame] | 406 | packetService.sendPacket(eth, new SwitchPort( |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 407 | sw.getDpid(), (short) outPort)); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 408 | } |
| 409 | } else { |
| 410 | // Flow path has not yet been installed to switches so save the |
| 411 | // packet out for later |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 412 | log.trace("Put a packet into the waiting list. flowId {}", existingFlow.intentId); |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 413 | waitingPackets.put(existingFlow.intentId, new PacketToPush(eth, sw.getDpid())); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 414 | } |
| 415 | return; |
| 416 | } |
| 417 | |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 418 | String intentId = Long.toString(controllerRegistryService.getNextUniqueId()); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 419 | ShortestPathIntent intent = new ShortestPathIntent(intentId, |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 420 | sw.getDpid(), inPort.getNumber(), srcMacAddress.toLong(), |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 421 | destinationDpid, destinationPort, dstMacAddress.toLong()); |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 422 | |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 423 | intent.setIdleTimeout(idleTimeout + SRC_SWITCH_TIMEOUT_ADJUST_SECOND); |
| 424 | intent.setFirstSwitchIdleTimeout(idleTimeout); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 425 | IntentOperation.Operator operator = IntentOperation.Operator.ADD; |
| 426 | operations.add(operator, intent); |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 427 | log.debug("Adding new flow between {} at {} and {} at {}", |
| 428 | new Object[]{srcMacAddress, srcSwitchPort, dstMacAddress, dstSwitchPort}); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 429 | |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 430 | // Add to waiting lists |
| 431 | waitingPackets.put(intentId, new PacketToPush(eth, sw.getDpid())); |
| 432 | log.trace("Put a Packet in the wating list. intent ID {}, related pathspec {}", intentId, pathspec); |
| 433 | pendingFlows.put(pathspec, new PushedFlow(intentId)); |
| 434 | log.trace("Put a Path {} in the pending flow, intent ID {}", pathspec, intentId); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 435 | } |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 436 | pathRuntime.executeIntentOperations(operations); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 437 | } |
| 438 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 439 | @Override |
| 440 | public void flowsInstalled(Collection<FlowPath> installedFlowPaths) { |
| 441 | } |
| 442 | |
| 443 | @Override |
| 444 | public void flowRemoved(FlowPath removedFlowPath) { |
| 445 | } |
| 446 | |
| 447 | public void flowRemoved(PathIntent removedIntent) { |
| 448 | if (log.isTraceEnabled()) { |
| 449 | log.trace("Path {} was removed", removedIntent.getParentIntent().getId()); |
| 450 | } |
| 451 | |
| 452 | ShortestPathIntent spfIntent = (ShortestPathIntent) removedIntent.getParentIntent(); |
| 453 | MACAddress srcMacAddress = MACAddress.valueOf(spfIntent.getSrcMac()); |
| 454 | MACAddress dstMacAddress = MACAddress.valueOf(spfIntent.getDstMac()); |
| 455 | Path removedPath = new Path(srcMacAddress, dstMacAddress); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 456 | synchronized (lock) { |
| 457 | // There *shouldn't* be any packets queued if the flow has |
| 458 | // just been removed. |
| 459 | List<PacketToPush> packets = waitingPackets.removeAll(spfIntent.getId()); |
| 460 | if (!packets.isEmpty()) { |
| 461 | log.warn("Removed flow {} has packets queued.", spfIntent.getId()); |
| 462 | } |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 463 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 464 | pendingFlows.remove(removedPath); |
| 465 | log.debug("Removed from the pendingFlow: Path {}, Flow ID {}", removedPath, spfIntent.getId()); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | private void flowInstalled(PathIntent installedPath) { |
| 470 | if (log.isTraceEnabled()) { |
Jonathan Hart | c00f5c2 | 2014-06-10 15:14:40 -0700 | [diff] [blame] | 471 | log.trace("Installed intent ID {}, path {}", |
| 472 | installedPath.getParentIntent().getId(), installedPath.getPath()); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | ShortestPathIntent spfIntent = (ShortestPathIntent) installedPath.getParentIntent(); |
| 476 | MACAddress srcMacAddress = MACAddress.valueOf(spfIntent.getSrcMac()); |
| 477 | MACAddress dstMacAddress = MACAddress.valueOf(spfIntent.getDstMac()); |
| 478 | Path path = new Path(srcMacAddress, dstMacAddress); |
| 479 | log.debug("Path spec {}", path); |
| 480 | |
| 481 | // TODO waiting packets should time out. We could request a path that |
| 482 | // can't be installed right now because of a network partition. The path |
| 483 | // may eventually be installed, but we may have received thousands of |
| 484 | // packets in the meantime and probably don't want to send very old packets. |
| 485 | |
| 486 | List<PacketToPush> packets = null; |
Yuta HIGUCHI | 1fc395e | 2014-05-13 14:06:28 -0700 | [diff] [blame] | 487 | net.onrc.onos.core.intent.Path graphPath = installedPath.getPath(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 488 | |
TeruU | 220c45e | 2014-04-10 18:56:26 -0700 | [diff] [blame] | 489 | short outPort; |
| 490 | if (graphPath.isEmpty()) { |
| 491 | outPort = (short) spfIntent.getDstPortNumber(); |
| 492 | log.debug("Path is empty. Maybe devices on the same switch. outPort {}", outPort); |
| 493 | } else { |
| 494 | outPort = graphPath.get(0).getSrc().getNumber().shortValue(); |
| 495 | log.debug("path{}, outPort {}", graphPath, outPort); |
| 496 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 497 | |
| 498 | PushedFlow existingFlow = null; |
| 499 | |
| 500 | synchronized (lock) { |
| 501 | existingFlow = pendingFlows.get(path); |
| 502 | |
| 503 | if (existingFlow != null) { |
| 504 | existingFlow.installed = true; |
| 505 | existingFlow.firstOutPort = outPort; |
| 506 | } else { |
| 507 | log.debug("ExistingFlow {} is null", path); |
| 508 | return; |
| 509 | } |
| 510 | |
| 511 | //Check both existing flow are installed status. |
| 512 | if (existingFlow.installed) { |
| 513 | packets = waitingPackets.removeAll(existingFlow.intentId); |
| 514 | if (log.isDebugEnabled()) { |
| 515 | log.debug("removed my packets {} to push from waitingPackets. outPort {} size {}", |
| 516 | existingFlow.intentId, existingFlow.firstOutPort, packets.size()); |
| 517 | } |
| 518 | } else { |
| 519 | log.debug("Forward or reverse flows hasn't been pushed yet. return"); |
| 520 | return; |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | for (PacketToPush packet : packets) { |
| 525 | log.debug("Start packetToPush to sw {}, outPort {}, path {}", packet.dpid, existingFlow.firstOutPort, path); |
Jonathan Hart | e3702f2 | 2014-04-29 02:56:56 -0700 | [diff] [blame] | 526 | packetService.sendPacket(packet.eth, new SwitchPort( |
| 527 | packet.dpid, existingFlow.firstOutPort)); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 528 | } |
| 529 | } |
| 530 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 531 | @Override |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 532 | public void intentsChange(LinkedList<ChangedEvent> events) { |
| 533 | for (ChangedEvent event : events) { |
| 534 | log.debug("path intent ID {}, eventType {}", event.intent.getId() , event.eventType); |
TeruU | 9e53066 | 2014-05-18 11:49:37 -0700 | [diff] [blame] | 535 | PathIntent pathIntent = (PathIntent) pathIntentMap.getIntent(event.intent.getId()); |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 536 | if (pathIntent == null) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 537 | continue; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 538 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 539 | |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 540 | if (!(pathIntent.getParentIntent() instanceof ShortestPathIntent)) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 541 | continue; |
Ray Milkey | b29e626 | 2014-04-09 16:02:14 -0700 | [diff] [blame] | 542 | } |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 543 | |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 544 | switch(event.eventType) { |
| 545 | case ADDED: |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 546 | break; |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 547 | case REMOVED: |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 548 | break; |
TeruU | f911165 | 2014-05-14 23:10:35 -0700 | [diff] [blame] | 549 | case STATE_CHANGED: |
| 550 | IntentState state = pathIntent.getState(); |
| 551 | switch (state) { |
| 552 | case INST_REQ: |
| 553 | break; |
| 554 | case INST_ACK: |
| 555 | flowInstalled(pathIntent); |
| 556 | break; |
| 557 | case INST_NACK: |
| 558 | break; |
| 559 | case DEL_REQ: |
| 560 | break; |
| 561 | case DEL_ACK: |
| 562 | flowRemoved(pathIntent); |
| 563 | break; |
| 564 | case DEL_PENDING: |
| 565 | break; |
| 566 | default: |
| 567 | break; |
| 568 | } |
Ray Milkey | 149693c | 2014-05-20 14:58:53 -0700 | [diff] [blame] | 569 | break; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 570 | default: |
| 571 | break; |
| 572 | } |
| 573 | } |
| 574 | } |
Jonathan Hart | 1caaa93 | 2013-11-04 15:28:28 -0800 | [diff] [blame] | 575 | } |