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