Thomas Vachuska

ONOS-1736 - Modified PacketManager to register packet request flows using the co…

…re app id, instead of the requesting app id. This is to prevent packet request flows from vanishing when app removes all its flows. This is a provisional fix until packet requests allow removal via reference counting or a similar tracking strategy.

Change-Id: Ib0e53ae8c6b5ae030a9c17a34407a5897027127b
...@@ -24,8 +24,15 @@ import java.util.Set; ...@@ -24,8 +24,15 @@ import java.util.Set;
24 */ 24 */
25 public interface CoreService { 25 public interface CoreService {
26 26
27 - public static final ProviderId CORE_PROVIDER_ID = 27 + /**
28 - new ProviderId("core", "org.onosproject.core"); 28 + * Name of the core "application".
29 + */
30 + public static final String CORE_APP_NAME = "org.onosproject.core";
31 +
32 + /**
33 + * Identifier of the core "provider".
34 + */
35 + public static final ProviderId CORE_PROVIDER_ID = new ProviderId("core", CORE_APP_NAME);
29 36
30 /** 37 /**
31 * Returns the product version. 38 * Returns the product version.
......
...@@ -70,6 +70,7 @@ public class CoreManager implements CoreService { ...@@ -70,6 +70,7 @@ public class CoreManager implements CoreService {
70 70
71 @Activate 71 @Activate
72 public void activate() { 72 public void activate() {
73 + registerApplication(CORE_APP_NAME);
73 cfgService.registerProperties(getClass()); 74 cfgService.registerProperties(getClass());
74 List<String> versionLines = Tools.slurp(VERSION_FILE); 75 List<String> versionLines = Tools.slurp(VERSION_FILE);
75 if (versionLines != null && !versionLines.isEmpty()) { 76 if (versionLines != null && !versionLines.isEmpty()) {
......
...@@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Reference;
22 import org.apache.felix.scr.annotations.ReferenceCardinality; 22 import org.apache.felix.scr.annotations.ReferenceCardinality;
23 import org.apache.felix.scr.annotations.Service; 23 import org.apache.felix.scr.annotations.Service;
24 import org.onosproject.core.ApplicationId; 24 import org.onosproject.core.ApplicationId;
25 +import org.onosproject.core.CoreService;
25 import org.onosproject.net.Device; 26 import org.onosproject.net.Device;
26 import org.onosproject.net.device.DeviceEvent; 27 import org.onosproject.net.device.DeviceEvent;
27 import org.onosproject.net.device.DeviceListener; 28 import org.onosproject.net.device.DeviceListener;
...@@ -61,14 +62,17 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -61,14 +62,17 @@ import static org.slf4j.LoggerFactory.getLogger;
61 @Component(immediate = true) 62 @Component(immediate = true)
62 @Service 63 @Service
63 public class PacketManager 64 public class PacketManager
64 -extends AbstractProviderRegistry<PacketProvider, PacketProviderService> 65 + extends AbstractProviderRegistry<PacketProvider, PacketProviderService>
65 -implements PacketService, PacketProviderRegistry { 66 + implements PacketService, PacketProviderRegistry {
66 67
67 private final Logger log = getLogger(getClass()); 68 private final Logger log = getLogger(getClass());
68 69
69 private final PacketStoreDelegate delegate = new InternalStoreDelegate(); 70 private final PacketStoreDelegate delegate = new InternalStoreDelegate();
70 71
71 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 72 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
73 + private CoreService coreService;
74 +
75 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
72 private DeviceService deviceService; 76 private DeviceService deviceService;
73 77
74 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 78 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
...@@ -81,8 +85,11 @@ implements PacketService, PacketProviderRegistry { ...@@ -81,8 +85,11 @@ implements PacketService, PacketProviderRegistry {
81 85
82 private final Map<Integer, PacketProcessor> processors = new ConcurrentHashMap<>(); 86 private final Map<Integer, PacketProcessor> processors = new ConcurrentHashMap<>();
83 87
88 + private ApplicationId appId;
89 +
84 @Activate 90 @Activate
85 public void activate() { 91 public void activate() {
92 + appId = coreService.getAppId(CoreService.CORE_APP_NAME);
86 store.setDelegate(delegate); 93 store.setDelegate(delegate);
87 deviceService.addListener(deviceListener); 94 deviceService.addListener(deviceListener);
88 log.info("Started"); 95 log.info("Started");
...@@ -162,16 +169,10 @@ implements PacketService, PacketProviderRegistry { ...@@ -162,16 +169,10 @@ implements PacketService, PacketProviderRegistry {
162 return; 169 return;
163 } 170 }
164 171
165 - TrafficTreatment treatment = DefaultTrafficTreatment.builder() 172 + TrafficTreatment treatment = DefaultTrafficTreatment.builder().punt().build();
166 - .punt() 173 + FlowRule flow = new DefaultFlowRule(device.id(), request.selector(), treatment,
167 - .build();
168 -
169 - FlowRule flow = new DefaultFlowRule(device.id(),
170 - request.selector(),
171 - treatment,
172 request.priority().priorityValue(), 174 request.priority().priorityValue(),
173 - request.appId(), 175 + appId, 0, true, request.tableType());
174 - 0, true, request.tableType());
175 176
176 flowService.applyFlowRules(flow); 177 flowService.applyFlowRules(flow);
177 } 178 }
......