Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 17 | package org.onosproject.drivers.p4runtime; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 18 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableList; |
| 20 | import com.google.common.collect.Lists; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 21 | import com.google.common.collect.Maps; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 22 | import org.onosproject.net.flow.DefaultFlowEntry; |
| 23 | import org.onosproject.net.flow.FlowEntry; |
| 24 | import org.onosproject.net.flow.FlowRule; |
| 25 | import org.onosproject.net.flow.FlowRuleProgrammable; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 26 | import org.onosproject.net.pi.model.PiPipelineInterpreter; |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 27 | import org.onosproject.net.pi.model.PiPipelineModel; |
| 28 | import org.onosproject.net.pi.model.PiTableModel; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 29 | import org.onosproject.net.pi.runtime.PiFlowRuleTranslationService; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 30 | import org.onosproject.net.pi.runtime.PiTableEntry; |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 31 | import org.onosproject.net.pi.runtime.PiTableId; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 32 | import org.onosproject.p4runtime.api.P4RuntimeClient.WriteOperationType; |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 33 | import org.onosproject.p4runtime.api.P4RuntimeFlowRuleWrapper; |
| 34 | import org.onosproject.p4runtime.api.P4RuntimeTableEntryReference; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 35 | |
| 36 | import java.util.Collection; |
| 37 | import java.util.Collections; |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 38 | import java.util.List; |
| 39 | import java.util.concurrent.ConcurrentMap; |
| 40 | import java.util.concurrent.ExecutionException; |
| 41 | import java.util.concurrent.locks.Lock; |
| 42 | import java.util.concurrent.locks.ReentrantLock; |
Carmelo Cascone | fe99be9 | 2017-09-11 21:55:54 +0200 | [diff] [blame] | 43 | import java.util.stream.Collectors; |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 44 | |
| 45 | import static com.google.common.collect.Lists.newArrayList; |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 46 | import static org.onosproject.drivers.p4runtime.P4RuntimeFlowRuleProgrammable.Operation.APPLY; |
| 47 | import static org.onosproject.drivers.p4runtime.P4RuntimeFlowRuleProgrammable.Operation.REMOVE; |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 48 | import static org.onosproject.net.flow.FlowEntry.FlowEntryState.ADDED; |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 49 | import static org.onosproject.p4runtime.api.P4RuntimeClient.WriteOperationType.*; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 50 | |
| 51 | /** |
Carmelo Cascone | e3a7c74 | 2017-09-01 01:25:52 +0200 | [diff] [blame] | 52 | * Implementation of the flow rule programmable behaviour for P4Runtime. |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 53 | */ |
Carmelo Cascone | e3a7c74 | 2017-09-01 01:25:52 +0200 | [diff] [blame] | 54 | public class P4RuntimeFlowRuleProgrammable extends AbstractP4RuntimeHandlerBehaviour implements FlowRuleProgrammable { |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 55 | |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 56 | /* |
| 57 | When updating an existing rule, if true, we issue a DELETE operation before inserting the new one, otherwise we |
| 58 | issue a MODIFY operation. This is useful fore devices that do not support MODIFY operations for table entries. |
| 59 | */ |
Carmelo Cascone | fe99be9 | 2017-09-11 21:55:54 +0200 | [diff] [blame] | 60 | // TODO: make this attribute configurable by child drivers (e.g. BMv2 or Tofino) |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 61 | private boolean deleteEntryBeforeUpdate = true; |
| 62 | |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 63 | /* |
| 64 | If true, we ignore re-installing rules that are already known in the ENTRY_STORE, i.e. same match key and action. |
| 65 | */ |
Carmelo Cascone | fe99be9 | 2017-09-11 21:55:54 +0200 | [diff] [blame] | 66 | // TODO: can remove this check as soon as the multi-apply-per-same-flow rule bug is fixed. |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 67 | private boolean checkEntryStoreBeforeUpdate = true; |
| 68 | |
Carmelo Cascone | fe99be9 | 2017-09-11 21:55:54 +0200 | [diff] [blame] | 69 | /* |
| 70 | If true, we avoid querying the device and return the content of the ENTRY_STORE. |
| 71 | */ |
| 72 | // TODO: can remove this check as soon as the BMv2 bug when reading ECMP entries is fixed. |
| 73 | private boolean ignoreDeviceWhenGet = true; |
| 74 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 75 | // Needed to synchronize operations over the same table entry. |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 76 | private static final ConcurrentMap<P4RuntimeTableEntryReference, Lock> ENTRY_LOCKS = Maps.newConcurrentMap(); |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 77 | |
| 78 | // TODO: replace with distributed store. |
Carmelo Cascone | 2cad9ef | 2017-08-01 21:52:07 +0200 | [diff] [blame] | 79 | // Can reuse old BMv2TableEntryService from ONOS 1.6 |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 80 | private static final ConcurrentMap<P4RuntimeTableEntryReference, P4RuntimeFlowRuleWrapper> ENTRY_STORE = |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 81 | Maps.newConcurrentMap(); |
| 82 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 83 | private PiPipelineModel pipelineModel; |
| 84 | private PiPipelineInterpreter interpreter; |
| 85 | private PiFlowRuleTranslationService piFlowRuleTranslationService; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 86 | |
Carmelo Cascone | e3a7c74 | 2017-09-01 01:25:52 +0200 | [diff] [blame] | 87 | @Override |
| 88 | protected boolean setupBehaviour() { |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 89 | |
Carmelo Cascone | e3a7c74 | 2017-09-01 01:25:52 +0200 | [diff] [blame] | 90 | if (!super.setupBehaviour()) { |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 91 | return false; |
| 92 | } |
| 93 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 94 | if (!device.is(PiPipelineInterpreter.class)) { |
| 95 | log.warn("Unable to get interpreter of {}", deviceId); |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 96 | return false; |
| 97 | } |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 98 | interpreter = device.as(PiPipelineInterpreter.class); |
Carmelo Cascone | e3a7c74 | 2017-09-01 01:25:52 +0200 | [diff] [blame] | 99 | pipelineModel = pipeconf.pipelineModel(); |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 100 | piFlowRuleTranslationService = handler().get(PiFlowRuleTranslationService.class); |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 101 | return true; |
| 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public Collection<FlowEntry> getFlowEntries() { |
| 106 | |
Carmelo Cascone | e3a7c74 | 2017-09-01 01:25:52 +0200 | [diff] [blame] | 107 | if (!setupBehaviour()) { |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 108 | return Collections.emptyList(); |
| 109 | } |
| 110 | |
Carmelo Cascone | fe99be9 | 2017-09-11 21:55:54 +0200 | [diff] [blame] | 111 | if (ignoreDeviceWhenGet) { |
| 112 | return ENTRY_STORE.values().stream() |
| 113 | .filter(frWrapper -> frWrapper.rule().deviceId().equals(this.deviceId)) |
| 114 | .map(frWrapper -> new DefaultFlowEntry(frWrapper.rule(), ADDED, frWrapper.lifeInSeconds(), |
| 115 | 0, 0)) |
| 116 | .collect(Collectors.toList()); |
| 117 | } |
| 118 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 119 | ImmutableList.Builder<FlowEntry> resultBuilder = ImmutableList.builder(); |
| 120 | List<PiTableEntry> inconsistentEntries = Lists.newArrayList(); |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 121 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 122 | for (PiTableModel tableModel : pipelineModel.tables()) { |
| 123 | |
| 124 | PiTableId piTableId = PiTableId.of(tableModel.name()); |
| 125 | |
| 126 | // Only dump tables that are exposed by the interpreter. |
| 127 | // The reason is that some P4 targets (e.g. BMv2's simple_switch) use more table than those defined in the |
| 128 | // P4 program, to implement other capabilities, e.g. action execution in control flow. |
| 129 | if (!interpreter.mapPiTableId(piTableId).isPresent()) { |
| 130 | continue; // next table |
| 131 | } |
| 132 | |
| 133 | Collection<PiTableEntry> installedEntries; |
| 134 | try { |
| 135 | installedEntries = client.dumpTable(piTableId, pipeconf).get(); |
| 136 | } catch (InterruptedException | ExecutionException e) { |
| 137 | log.error("Exception while dumping table {} of {}", piTableId, deviceId, e); |
| 138 | return Collections.emptyList(); |
| 139 | } |
| 140 | |
| 141 | for (PiTableEntry installedEntry : installedEntries) { |
| 142 | |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 143 | P4RuntimeTableEntryReference entryRef = new P4RuntimeTableEntryReference(deviceId, piTableId, |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 144 | installedEntry.matchKey()); |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 145 | |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 146 | P4RuntimeFlowRuleWrapper frWrapper = ENTRY_STORE.get(entryRef); |
| 147 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 148 | |
| 149 | if (frWrapper == null) { |
| 150 | // Inconsistent entry |
| 151 | inconsistentEntries.add(installedEntry); |
| 152 | continue; // next one. |
| 153 | } |
| 154 | |
| 155 | // TODO: implement table entry counter retrieval. |
| 156 | long bytes = 0L; |
| 157 | long packets = 0L; |
| 158 | |
| 159 | FlowEntry entry = new DefaultFlowEntry(frWrapper.rule(), ADDED, frWrapper.lifeInSeconds(), |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 160 | packets, bytes); |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 161 | resultBuilder.add(entry); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | if (inconsistentEntries.size() > 0) { |
| 166 | log.warn("Found {} entries in {} that are not known by table entry service," + |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 167 | " removing them", inconsistentEntries.size(), deviceId); |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 168 | inconsistentEntries.forEach(entry -> log.debug(entry.toString())); |
| 169 | // Async remove them. |
| 170 | client.writeTableEntries(inconsistentEntries, DELETE, pipeconf); |
| 171 | } |
| 172 | |
| 173 | return resultBuilder.build(); |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | @Override |
| 177 | public Collection<FlowRule> applyFlowRules(Collection<FlowRule> rules) { |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 178 | return processFlowRules(rules, APPLY); |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | @Override |
| 182 | public Collection<FlowRule> removeFlowRules(Collection<FlowRule> rules) { |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 183 | return processFlowRules(rules, REMOVE); |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 184 | } |
| 185 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 186 | private Collection<FlowRule> processFlowRules(Collection<FlowRule> rules, Operation operation) { |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 187 | |
Carmelo Cascone | e3a7c74 | 2017-09-01 01:25:52 +0200 | [diff] [blame] | 188 | if (!setupBehaviour()) { |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 189 | return Collections.emptyList(); |
| 190 | } |
| 191 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 192 | ImmutableList.Builder<FlowRule> processedFlowRuleListBuilder = ImmutableList.builder(); |
| 193 | |
| 194 | // TODO: send write operations in bulk (e.g. all entries to insert, modify or delete). |
| 195 | // Instead of calling the client for each one of them. |
| 196 | |
| 197 | for (FlowRule rule : rules) { |
| 198 | |
| 199 | PiTableEntry piTableEntry; |
| 200 | |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 201 | try { |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 202 | piTableEntry = piFlowRuleTranslationService.translate(rule, pipeconf); |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 203 | } catch (PiFlowRuleTranslationService.PiFlowRuleTranslationException e) { |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 204 | log.warn("Unable to translate flow rule: {} - {}", e.getMessage(), rule); |
| 205 | continue; // next rule |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 206 | } |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 207 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 208 | PiTableId tableId = piTableEntry.table(); |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 209 | P4RuntimeTableEntryReference entryRef = new P4RuntimeTableEntryReference(deviceId, |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 210 | tableId, piTableEntry.matchKey()); |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 211 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 212 | Lock lock = ENTRY_LOCKS.computeIfAbsent(entryRef, k -> new ReentrantLock()); |
| 213 | lock.lock(); |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 214 | |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 215 | try { |
| 216 | |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 217 | P4RuntimeFlowRuleWrapper frWrapper = ENTRY_STORE.get(entryRef); |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 218 | WriteOperationType opType = null; |
| 219 | boolean doApply = true; |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 220 | |
Andrea Campanella | 0288c87 | 2017-08-07 18:32:51 +0200 | [diff] [blame] | 221 | if (operation == APPLY) { |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 222 | if (frWrapper == null) { |
| 223 | // Entry is first-timer. |
| 224 | opType = INSERT; |
| 225 | } else { |
| 226 | // This match key already exists in the device. |
| 227 | if (checkEntryStoreBeforeUpdate && |
| 228 | piTableEntry.action().equals(frWrapper.piTableEntry().action())) { |
| 229 | doApply = false; |
| 230 | log.debug("Ignoring re-apply of existing entry: {}", piTableEntry); |
| 231 | } |
| 232 | if (doApply) { |
| 233 | if (deleteEntryBeforeUpdate) { |
| 234 | // We've seen some strange error when trying to modify existing flow rules. |
| 235 | // Remove before re-adding the modified one. |
| 236 | try { |
| 237 | if (client.writeTableEntries(newArrayList(piTableEntry), DELETE, pipeconf).get()) { |
| 238 | frWrapper = null; |
| 239 | } else { |
| 240 | log.warn("Unable to DELETE table entry (before re-adding) in {}: {}", |
| 241 | deviceId, piTableEntry); |
| 242 | } |
| 243 | } catch (InterruptedException | ExecutionException e) { |
| 244 | log.warn("Exception while deleting table entry:", operation.name(), e); |
| 245 | } |
| 246 | opType = INSERT; |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 247 | } else { |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 248 | opType = MODIFY; |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 249 | } |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 250 | } |
| 251 | } |
| 252 | } else { |
| 253 | opType = DELETE; |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 254 | } |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 255 | |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 256 | if (doApply) { |
| 257 | try { |
| 258 | if (client.writeTableEntries(newArrayList(piTableEntry), opType, pipeconf).get()) { |
| 259 | processedFlowRuleListBuilder.add(rule); |
| 260 | if (operation == APPLY) { |
| 261 | frWrapper = new P4RuntimeFlowRuleWrapper(rule, piTableEntry, |
| 262 | System.currentTimeMillis()); |
| 263 | } else { |
| 264 | frWrapper = null; |
| 265 | } |
| 266 | } else { |
| 267 | log.warn("Unable to {} table entry in {}: {}", opType.name(), deviceId, piTableEntry); |
| 268 | } |
| 269 | } catch (InterruptedException | ExecutionException e) { |
| 270 | log.warn("Exception while performing {} table entry operation:", operation.name(), e); |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 271 | } |
Carmelo Cascone | 2308e52 | 2017-08-25 02:35:12 +0200 | [diff] [blame] | 272 | } else { |
| 273 | processedFlowRuleListBuilder.add(rule); |
Carmelo Cascone | 0b22d8f | 2017-07-31 07:22:27 +0200 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | // Update entryRef binding in table entry service. |
| 277 | if (frWrapper != null) { |
| 278 | ENTRY_STORE.put(entryRef, frWrapper); |
| 279 | } else { |
| 280 | ENTRY_STORE.remove(entryRef); |
| 281 | } |
| 282 | |
| 283 | } finally { |
| 284 | lock.unlock(); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | return processedFlowRuleListBuilder.build(); |
| 289 | } |
| 290 | |
| 291 | enum Operation { |
| 292 | APPLY, REMOVE |
Frank Wang | 0e80508 | 2017-07-21 14:37:35 +0800 | [diff] [blame] | 293 | } |
| 294 | } |