Charles Chan
Committed by Charles Chan

Only pop internally assigned VLANs before sending ARP to controller

This is a fix for gerrit 10292 (commit ec8e06) which was not implemented correctly

Change-Id: If227860120c1e10a3ffbd0f8fb630490734ab751
...@@ -249,7 +249,7 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline { ...@@ -249,7 +249,7 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline {
249 VlanIdCriterion vidCriterion, 249 VlanIdCriterion vidCriterion,
250 VlanId assignedVlan, 250 VlanId assignedVlan,
251 ApplicationId applicationId) { 251 ApplicationId applicationId) {
252 - List<FlowRule> rules = new ArrayList<FlowRule>(); 252 + List<FlowRule> rules = new ArrayList<>();
253 TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); 253 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
254 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); 254 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
255 selector.matchVlanId(vidCriterion.vlanId()); 255 selector.matchVlanId(vidCriterion.vlanId());
...@@ -258,6 +258,24 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline { ...@@ -258,6 +258,24 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline {
258 if (vidCriterion.vlanId() == VlanId.NONE) { 258 if (vidCriterion.vlanId() == VlanId.NONE) {
259 // untagged packets are assigned vlans 259 // untagged packets are assigned vlans
260 treatment.pushVlan().setVlanId(assignedVlan); 260 treatment.pushVlan().setVlanId(assignedVlan);
261 +
262 + // Emulating OFDPA behavior by popping off internal assigned VLAN
263 + // before sending to controller
264 + TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder()
265 + .matchEthType(Ethernet.TYPE_ARP)
266 + .matchVlanId(assignedVlan);
267 + TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder()
268 + .popVlan()
269 + .punt();
270 + FlowRule internalVlan = DefaultFlowRule.builder()
271 + .forDevice(deviceId)
272 + .withSelector(sbuilder.build())
273 + .withTreatment(tbuilder.build())
274 + .withPriority(PacketPriority.CONTROL.priorityValue() + 1)
275 + .fromApp(applicationId)
276 + .makePermanent()
277 + .forTable(ACL_TABLE).build();
278 + rules.add(internalVlan);
261 } 279 }
262 280
263 // ofdpa cannot match on ALL portnumber, so we need to use separate 281 // ofdpa cannot match on ALL portnumber, so we need to use separate
...@@ -287,24 +305,6 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline { ...@@ -287,24 +305,6 @@ public class CpqdOfdpa2Pipeline extends Ofdpa2Pipeline {
287 rules.add(rule); 305 rules.add(rule);
288 } 306 }
289 307
290 - // Emulating OFDPA behavior by popping off internal assigned VLAN
291 - // before sending to controller
292 - TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder()
293 - .matchEthType(Ethernet.TYPE_ARP)
294 - .matchVlanId(assignedVlan);
295 - TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder()
296 - .popVlan()
297 - .punt();
298 - FlowRule internalVlan = DefaultFlowRule.builder()
299 - .forDevice(deviceId)
300 - .withSelector(sbuilder.build())
301 - .withTreatment(tbuilder.build())
302 - .withPriority(PacketPriority.CONTROL.priorityValue() + 1)
303 - .fromApp(applicationId)
304 - .makePermanent()
305 - .forTable(ACL_TABLE).build();
306 - rules.add(internalVlan);
307 -
308 return rules; 308 return rules;
309 } 309 }
310 310
......