Committed by
Gerrit Code Review
fix corsa pipeline divergence : need to differentiate between write and apply instructions.
Change-Id: I477d27d6e52a8e09744614e5f5aa843dd26331e0
Showing
9 changed files
with
59 additions
and
60 deletions
... | @@ -415,28 +415,6 @@ public class BgpRouter { | ... | @@ -415,28 +415,6 @@ public class BgpRouter { |
415 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); | 415 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
416 | FlowRule rule; | 416 | FlowRule rule; |
417 | 417 | ||
418 | - selector.matchEthType(Ethernet.TYPE_IPV4); | ||
419 | - treatment.transition(FlowRule.Type.VLAN); | ||
420 | - | ||
421 | - rule = new DefaultFlowRule(deviceId, selector.build(), treatment.build(), CONTROLLER_PRIORITY, | ||
422 | - appId, 0, true, FlowRule.Type.VLAN_MPLS); | ||
423 | - | ||
424 | - ops = install ? ops.add(rule) : ops.remove(rule); | ||
425 | - | ||
426 | - selector = DefaultTrafficSelector.builder(); | ||
427 | - treatment = DefaultTrafficTreatment.builder(); | ||
428 | - | ||
429 | - selector.matchEthType(Ethernet.TYPE_ARP); | ||
430 | - treatment.transition(FlowRule.Type.VLAN); | ||
431 | - | ||
432 | - rule = new DefaultFlowRule(deviceId, selector.build(), | ||
433 | - treatment.build(), CONTROLLER_PRIORITY, | ||
434 | - appId, 0, true, FlowRule.Type.VLAN_MPLS); | ||
435 | - | ||
436 | - ops = install ? ops.add(rule) : ops.remove(rule); | ||
437 | - | ||
438 | - selector = DefaultTrafficSelector.builder(); | ||
439 | - treatment = DefaultTrafficTreatment.builder(); | ||
440 | 418 | ||
441 | selector.matchEthType(Ethernet.TYPE_VLAN); | 419 | selector.matchEthType(Ethernet.TYPE_VLAN); |
442 | treatment.transition(FlowRule.Type.VLAN); | 420 | treatment.transition(FlowRule.Type.VLAN); |
... | @@ -447,18 +425,6 @@ public class BgpRouter { | ... | @@ -447,18 +425,6 @@ public class BgpRouter { |
447 | 425 | ||
448 | ops = install ? ops.add(rule) : ops.remove(rule); | 426 | ops = install ? ops.add(rule) : ops.remove(rule); |
449 | 427 | ||
450 | - //Drop rule | ||
451 | - selector = DefaultTrafficSelector.builder(); | ||
452 | - treatment = DefaultTrafficTreatment.builder(); | ||
453 | - | ||
454 | - treatment.drop(); | ||
455 | - | ||
456 | - rule = new DefaultFlowRule(deviceId, selector.build(), | ||
457 | - treatment.build(), DROP_PRIORITY, appId, | ||
458 | - 0, true, FlowRule.Type.VLAN_MPLS); | ||
459 | - | ||
460 | - ops = install ? ops.add(rule) : ops.remove(rule); | ||
461 | - | ||
462 | flowService.apply(ops.build(new FlowRuleOperationsContext() { | 428 | flowService.apply(ops.build(new FlowRuleOperationsContext() { |
463 | @Override | 429 | @Override |
464 | public void onSuccess(FlowRuleOperations ops) { | 430 | public void onSuccess(FlowRuleOperations ops) { |
... | @@ -487,7 +453,7 @@ public class BgpRouter { | ... | @@ -487,7 +453,7 @@ public class BgpRouter { |
487 | treatment = DefaultTrafficTreatment.builder(); | 453 | treatment = DefaultTrafficTreatment.builder(); |
488 | 454 | ||
489 | selector.matchVlanId(vid); | 455 | selector.matchVlanId(vid); |
490 | - treatment.popVlan(); | 456 | + treatment.stripVlan(); |
491 | treatment.transition(Type.ETHER); | 457 | treatment.transition(Type.ETHER); |
492 | 458 | ||
493 | rule = new DefaultFlowRule(deviceId, selector.build(), | 459 | rule = new DefaultFlowRule(deviceId, selector.build(), | ... | ... |
... | @@ -21,15 +21,11 @@ import org.onlab.packet.IpAddress; | ... | @@ -21,15 +21,11 @@ import org.onlab.packet.IpAddress; |
21 | import org.onlab.packet.TCP; | 21 | import org.onlab.packet.TCP; |
22 | import org.onosproject.core.ApplicationId; | 22 | import org.onosproject.core.ApplicationId; |
23 | import org.onosproject.net.ConnectPoint; | 23 | import org.onosproject.net.ConnectPoint; |
24 | -import org.onosproject.net.flow.DefaultTrafficSelector; | ||
25 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 24 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
26 | -import org.onosproject.net.flow.FlowRule; | ||
27 | -import org.onosproject.net.flow.TrafficSelector; | ||
28 | import org.onosproject.net.flow.TrafficTreatment; | 25 | import org.onosproject.net.flow.TrafficTreatment; |
29 | import org.onosproject.net.packet.DefaultOutboundPacket; | 26 | import org.onosproject.net.packet.DefaultOutboundPacket; |
30 | import org.onosproject.net.packet.OutboundPacket; | 27 | import org.onosproject.net.packet.OutboundPacket; |
31 | import org.onosproject.net.packet.PacketContext; | 28 | import org.onosproject.net.packet.PacketContext; |
32 | -import org.onosproject.net.packet.PacketPriority; | ||
33 | import org.onosproject.net.packet.PacketProcessor; | 29 | import org.onosproject.net.packet.PacketProcessor; |
34 | import org.onosproject.net.packet.PacketService; | 30 | import org.onosproject.net.packet.PacketService; |
35 | import org.onosproject.routing.config.BgpPeer; | 31 | import org.onosproject.routing.config.BgpPeer; |
... | @@ -65,26 +61,6 @@ public class TunnellingConnectivityManager { | ... | @@ -65,26 +61,6 @@ public class TunnellingConnectivityManager { |
65 | 61 | ||
66 | public void start() { | 62 | public void start() { |
67 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 3); | 63 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 3); |
68 | - | ||
69 | - TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | ||
70 | - | ||
71 | - // Request packets with BGP port as their TCP source port | ||
72 | - selector.matchEthType(Ethernet.TYPE_IPV4); | ||
73 | - selector.matchIPProtocol(IPv4.PROTOCOL_TCP); | ||
74 | - selector.matchTcpSrc(BGP_PORT); | ||
75 | - | ||
76 | - packetService.requestPackets(selector.build(), PacketPriority.CONTROL, | ||
77 | - appId, FlowRule.Type.DEFAULT); | ||
78 | - | ||
79 | - selector = DefaultTrafficSelector.builder(); | ||
80 | - | ||
81 | - // Request packets with BGP port as their TCP destination port | ||
82 | - selector.matchEthType(Ethernet.TYPE_IPV4); | ||
83 | - selector.matchIPProtocol(IPv4.PROTOCOL_TCP); | ||
84 | - selector.matchTcpDst(BGP_PORT); | ||
85 | - | ||
86 | - packetService.requestPackets(selector.build(), PacketPriority.CONTROL, | ||
87 | - appId, FlowRule.Type.DEFAULT); | ||
88 | } | 64 | } |
89 | 65 | ||
90 | public void stop() { | 66 | public void stop() { | ... | ... |
... | @@ -189,6 +189,10 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -189,6 +189,10 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
189 | return add(Instructions.modVlanPcp(pcp)); | 189 | return add(Instructions.modVlanPcp(pcp)); |
190 | } | 190 | } |
191 | 191 | ||
192 | + public Builder stripVlan() { | ||
193 | + return add(Instructions.stripVlanId()); | ||
194 | + } | ||
195 | + | ||
192 | @Override | 196 | @Override |
193 | public Builder setIpSrc(IpAddress addr) { | 197 | public Builder setIpSrc(IpAddress addr) { |
194 | return add(Instructions.modL3Src(addr)); | 198 | return add(Instructions.modL3Src(addr)); | ... | ... |
... | @@ -106,6 +106,12 @@ public interface TrafficTreatment { | ... | @@ -106,6 +106,12 @@ public interface TrafficTreatment { |
106 | public Builder setVlanPcp(Byte pcp); | 106 | public Builder setVlanPcp(Byte pcp); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | + * Strips the vlan tag if there is one. | ||
110 | + * @return a treatment builder | ||
111 | + */ | ||
112 | + public Builder stripVlan(); | ||
113 | + | ||
114 | + /** | ||
109 | * Sets the src l3 address. | 115 | * Sets the src l3 address. |
110 | * | 116 | * |
111 | * @param addr an ip | 117 | * @param addr an ip | ... | ... |
... | @@ -130,6 +130,14 @@ public final class Instructions { | ... | @@ -130,6 +130,14 @@ public final class Instructions { |
130 | } | 130 | } |
131 | 131 | ||
132 | /** | 132 | /** |
133 | + * Strips the VLAN tag if one is present. | ||
134 | + * @return a L2 modification | ||
135 | + */ | ||
136 | + public static L2ModificationInstruction stripVlanId() { | ||
137 | + return new StripVlanInstruction(); | ||
138 | + } | ||
139 | + | ||
140 | + /** | ||
133 | * Creates a MPLS label modification. | 141 | * Creates a MPLS label modification. |
134 | * @param mplsLabel to set. | 142 | * @param mplsLabel to set. |
135 | * @return a L2 Modification | 143 | * @return a L2 Modification | ... | ... |
... | @@ -53,6 +53,11 @@ public abstract class L2ModificationInstruction implements Instruction { | ... | @@ -53,6 +53,11 @@ public abstract class L2ModificationInstruction implements Instruction { |
53 | VLAN_PCP, | 53 | VLAN_PCP, |
54 | 54 | ||
55 | /** | 55 | /** |
56 | + * Strips the vlan. | ||
57 | + */ | ||
58 | + STRIP_VLAN, | ||
59 | + | ||
60 | + /** | ||
56 | * MPLS Label modification. | 61 | * MPLS Label modification. |
57 | */ | 62 | */ |
58 | MPLS_LABEL, | 63 | MPLS_LABEL, |
... | @@ -273,6 +278,33 @@ public abstract class L2ModificationInstruction implements Instruction { | ... | @@ -273,6 +278,33 @@ public abstract class L2ModificationInstruction implements Instruction { |
273 | } | 278 | } |
274 | } | 279 | } |
275 | 280 | ||
281 | + public static final class StripVlanInstruction extends L2ModificationInstruction { | ||
282 | + | ||
283 | + @Override | ||
284 | + public L2SubType subtype() { | ||
285 | + return L2SubType.STRIP_VLAN; | ||
286 | + } | ||
287 | + | ||
288 | + @Override | ||
289 | + public String toString() { | ||
290 | + return subtype().toString(); | ||
291 | + } | ||
292 | + | ||
293 | + @Override | ||
294 | + public int hashCode() { | ||
295 | + return Objects.hash(type(), subtype()); | ||
296 | + } | ||
297 | + | ||
298 | + @Override | ||
299 | + public boolean equals(Object obj) { | ||
300 | + if (this == obj) { | ||
301 | + return true; | ||
302 | + } | ||
303 | + | ||
304 | + return false; | ||
305 | + } | ||
306 | + } | ||
307 | + | ||
276 | /** | 308 | /** |
277 | * Represents a VLAN POP modification instruction. | 309 | * Represents a VLAN POP modification instruction. |
278 | */ | 310 | */ | ... | ... |
... | @@ -268,6 +268,9 @@ public class FlowEntryBuilder { | ... | @@ -268,6 +268,9 @@ public class FlowEntryBuilder { |
268 | case POP_VLAN: | 268 | case POP_VLAN: |
269 | builder.popVlan(); | 269 | builder.popVlan(); |
270 | break; | 270 | break; |
271 | + case STRIP_VLAN: | ||
272 | + builder.stripVlan(); | ||
273 | + break; | ||
271 | case SET_TP_DST: | 274 | case SET_TP_DST: |
272 | case SET_TP_SRC: | 275 | case SET_TP_SRC: |
273 | case POP_PBB: | 276 | case POP_PBB: |
... | @@ -280,7 +283,7 @@ public class FlowEntryBuilder { | ... | @@ -280,7 +283,7 @@ public class FlowEntryBuilder { |
280 | case SET_NW_TOS: | 283 | case SET_NW_TOS: |
281 | case SET_NW_TTL: | 284 | case SET_NW_TTL: |
282 | case SET_QUEUE: | 285 | case SET_QUEUE: |
283 | - case STRIP_VLAN: | 286 | + |
284 | case ENQUEUE: | 287 | case ENQUEUE: |
285 | default: | 288 | default: |
286 | log.warn("Action type {} not yet implemented.", act.getType()); | 289 | log.warn("Action type {} not yet implemented.", act.getType()); | ... | ... |
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java
... | @@ -207,6 +207,8 @@ public class FlowModBuilderVer10 extends FlowModBuilder { | ... | @@ -207,6 +207,8 @@ public class FlowModBuilderVer10 extends FlowModBuilder { |
207 | case VLAN_PCP: | 207 | case VLAN_PCP: |
208 | ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m; | 208 | ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m; |
209 | return factory().actions().setVlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); | 209 | return factory().actions().setVlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); |
210 | + case STRIP_VLAN: | ||
211 | + return factory().actions().stripVlan(); | ||
210 | default: | 212 | default: |
211 | log.warn("Unimplemented action type {}.", l2m.subtype()); | 213 | log.warn("Unimplemented action type {}.", l2m.subtype()); |
212 | break; | 214 | break; | ... | ... |
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
... | @@ -319,6 +319,8 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -319,6 +319,8 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
319 | (PushHeaderInstructions) l2m; | 319 | (PushHeaderInstructions) l2m; |
320 | return factory().actions().popMpls(EthType.of(popHeaderInstructions | 320 | return factory().actions().popMpls(EthType.of(popHeaderInstructions |
321 | .ethernetType())); | 321 | .ethernetType())); |
322 | + case STRIP_VLAN: | ||
323 | + return factory().actions().stripVlan(); | ||
322 | case MPLS_LABEL: | 324 | case MPLS_LABEL: |
323 | ModMplsLabelInstruction mplsLabel = | 325 | ModMplsLabelInstruction mplsLabel = |
324 | (ModMplsLabelInstruction) l2m; | 326 | (ModMplsLabelInstruction) l2m; | ... | ... |
-
Please register or login to post a comment