Add push VLAN treatment and use it in BgpRouter groups
Change-Id: I8c241fd776cdddd77969413736bd786c0d5a4828
Showing
7 changed files
with
100 additions
and
46 deletions
... | @@ -20,17 +20,17 @@ import com.google.common.collect.HashMultimap; | ... | @@ -20,17 +20,17 @@ import com.google.common.collect.HashMultimap; |
20 | import com.google.common.collect.Maps; | 20 | import com.google.common.collect.Maps; |
21 | import com.google.common.collect.Multimap; | 21 | import com.google.common.collect.Multimap; |
22 | import com.google.common.collect.Multiset; | 22 | import com.google.common.collect.Multiset; |
23 | - | ||
24 | import org.apache.felix.scr.annotations.Activate; | 23 | import org.apache.felix.scr.annotations.Activate; |
25 | import org.apache.felix.scr.annotations.Component; | 24 | import org.apache.felix.scr.annotations.Component; |
26 | import org.apache.felix.scr.annotations.Deactivate; | 25 | import org.apache.felix.scr.annotations.Deactivate; |
27 | import org.apache.felix.scr.annotations.Reference; | 26 | import org.apache.felix.scr.annotations.Reference; |
28 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 27 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
29 | import org.onlab.packet.Ethernet; | 28 | import org.onlab.packet.Ethernet; |
30 | -import org.onlab.packet.MacAddress; | ||
31 | import org.onlab.packet.IpAddress; | 29 | import org.onlab.packet.IpAddress; |
32 | import org.onlab.packet.IpPrefix; | 30 | import org.onlab.packet.IpPrefix; |
31 | +import org.onlab.packet.MacAddress; | ||
33 | import org.onlab.packet.VlanId; | 32 | import org.onlab.packet.VlanId; |
33 | +import org.onosproject.config.NetworkConfigService; | ||
34 | import org.onosproject.core.ApplicationId; | 34 | import org.onosproject.core.ApplicationId; |
35 | import org.onosproject.core.CoreService; | 35 | import org.onosproject.core.CoreService; |
36 | import org.onosproject.net.DeviceId; | 36 | import org.onosproject.net.DeviceId; |
... | @@ -39,12 +39,12 @@ import org.onosproject.net.flow.DefaultFlowRule; | ... | @@ -39,12 +39,12 @@ import org.onosproject.net.flow.DefaultFlowRule; |
39 | import org.onosproject.net.flow.DefaultTrafficSelector; | 39 | import org.onosproject.net.flow.DefaultTrafficSelector; |
40 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 40 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
41 | import org.onosproject.net.flow.FlowRule; | 41 | import org.onosproject.net.flow.FlowRule; |
42 | +import org.onosproject.net.flow.FlowRule.Type; | ||
42 | import org.onosproject.net.flow.FlowRuleOperations; | 43 | import org.onosproject.net.flow.FlowRuleOperations; |
43 | import org.onosproject.net.flow.FlowRuleOperationsContext; | 44 | import org.onosproject.net.flow.FlowRuleOperationsContext; |
44 | import org.onosproject.net.flow.FlowRuleService; | 45 | import org.onosproject.net.flow.FlowRuleService; |
45 | import org.onosproject.net.flow.TrafficSelector; | 46 | import org.onosproject.net.flow.TrafficSelector; |
46 | import org.onosproject.net.flow.TrafficTreatment; | 47 | import org.onosproject.net.flow.TrafficTreatment; |
47 | -import org.onosproject.net.flow.FlowRule.Type; | ||
48 | import org.onosproject.net.group.DefaultGroupBucket; | 48 | import org.onosproject.net.group.DefaultGroupBucket; |
49 | import org.onosproject.net.group.DefaultGroupDescription; | 49 | import org.onosproject.net.group.DefaultGroupDescription; |
50 | import org.onosproject.net.group.Group; | 50 | import org.onosproject.net.group.Group; |
... | @@ -64,7 +64,6 @@ import org.onosproject.routing.RoutingService; | ... | @@ -64,7 +64,6 @@ import org.onosproject.routing.RoutingService; |
64 | import org.onosproject.routing.config.BgpSpeaker; | 64 | import org.onosproject.routing.config.BgpSpeaker; |
65 | import org.onosproject.routing.config.Interface; | 65 | import org.onosproject.routing.config.Interface; |
66 | import org.onosproject.routing.config.RoutingConfigurationService; | 66 | import org.onosproject.routing.config.RoutingConfigurationService; |
67 | -import org.onosproject.config.NetworkConfigService; | ||
68 | import org.slf4j.Logger; | 67 | import org.slf4j.Logger; |
69 | import org.slf4j.LoggerFactory; | 68 | import org.slf4j.LoggerFactory; |
70 | 69 | ||
... | @@ -264,6 +263,7 @@ public class BgpRouter { | ... | @@ -264,6 +263,7 @@ public class BgpRouter { |
264 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() | 263 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() |
265 | .setEthSrc(egressIntf.mac()) | 264 | .setEthSrc(egressIntf.mac()) |
266 | .setEthDst(nextHop.mac()) | 265 | .setEthDst(nextHop.mac()) |
266 | + .pushVlan() | ||
267 | .setVlanId(egressIntf.vlan()) | 267 | .setVlanId(egressIntf.vlan()) |
268 | .setOutput(egressIntf.connectPoint().port()) | 268 | .setOutput(egressIntf.connectPoint().port()) |
269 | .build(); | 269 | .build(); |
... | @@ -334,7 +334,6 @@ public class BgpRouter { | ... | @@ -334,7 +334,6 @@ public class BgpRouter { |
334 | processTableFive(install); | 334 | processTableFive(install); |
335 | processTableSix(install); | 335 | processTableSix(install); |
336 | processTableNine(install); | 336 | processTableNine(install); |
337 | - | ||
338 | } | 337 | } |
339 | 338 | ||
340 | private void getIntefaceConfig(Set<Interface> intfs) { | 339 | private void getIntefaceConfig(Set<Interface> intfs) { |
... | @@ -416,7 +415,6 @@ public class BgpRouter { | ... | @@ -416,7 +415,6 @@ public class BgpRouter { |
416 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); | 415 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
417 | FlowRule rule; | 416 | FlowRule rule; |
418 | 417 | ||
419 | - | ||
420 | selector.matchEthType(Ethernet.TYPE_VLAN); | 418 | selector.matchEthType(Ethernet.TYPE_VLAN); |
421 | treatment.transition(FlowRule.Type.VLAN); | 419 | treatment.transition(FlowRule.Type.VLAN); |
422 | 420 | ... | ... |
... | @@ -300,6 +300,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -300,6 +300,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
300 | } | 300 | } |
301 | 301 | ||
302 | @Override | 302 | @Override |
303 | + public Builder pushVlan() { | ||
304 | + return add(Instructions.pushVlan()); | ||
305 | + } | ||
306 | + | ||
307 | + @Override | ||
303 | public Builder transition(FlowRule.Type type) { | 308 | public Builder transition(FlowRule.Type type) { |
304 | return add(Instructions.transition(type)); | 309 | return add(Instructions.transition(type)); |
305 | } | 310 | } | ... | ... |
... | @@ -15,18 +15,17 @@ | ... | @@ -15,18 +15,17 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.flow; | 16 | package org.onosproject.net.flow; |
17 | 17 | ||
18 | -import java.util.List; | ||
19 | - | ||
20 | -import org.onosproject.core.GroupId; | ||
21 | -import org.onosproject.net.PortNumber; | ||
22 | -import org.onosproject.net.flow.DefaultTrafficTreatment.Builder; | ||
23 | -import org.onosproject.net.flow.instructions.Instruction; | ||
24 | import org.onlab.packet.IpAddress; | 18 | import org.onlab.packet.IpAddress; |
25 | import org.onlab.packet.MacAddress; | 19 | import org.onlab.packet.MacAddress; |
26 | import org.onlab.packet.MplsLabel; | 20 | import org.onlab.packet.MplsLabel; |
27 | import org.onlab.packet.VlanId; | 21 | import org.onlab.packet.VlanId; |
22 | +import org.onosproject.core.GroupId; | ||
23 | +import org.onosproject.net.PortNumber; | ||
24 | +import org.onosproject.net.flow.instructions.Instruction; | ||
28 | import org.onosproject.net.flow.instructions.Instructions; | 25 | import org.onosproject.net.flow.instructions.Instructions; |
29 | 26 | ||
27 | +import java.util.List; | ||
28 | + | ||
30 | /** | 29 | /** |
31 | * Abstraction of network traffic treatment. | 30 | * Abstraction of network traffic treatment. |
32 | */ | 31 | */ |
... | @@ -247,6 +246,13 @@ public interface TrafficTreatment { | ... | @@ -247,6 +246,13 @@ public interface TrafficTreatment { |
247 | public Builder popVlan(); | 246 | public Builder popVlan(); |
248 | 247 | ||
249 | /** | 248 | /** |
249 | + * Pushes a new VLAN tag. | ||
250 | + * | ||
251 | + * @return a treatment builder. | ||
252 | + */ | ||
253 | + public Builder pushVlan(); | ||
254 | + | ||
255 | + /** | ||
250 | * Any instructions preceded by this method call will be deferred. | 256 | * Any instructions preceded by this method call will be deferred. |
251 | * @return a treatment builder | 257 | * @return a treatment builder |
252 | */ | 258 | */ | ... | ... |
... | @@ -15,12 +15,11 @@ | ... | @@ -15,12 +15,11 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.flow.instructions; | 16 | package org.onosproject.net.flow.instructions; |
17 | 17 | ||
18 | -import static com.google.common.base.MoreObjects.toStringHelper; | 18 | +import org.onlab.packet.Ethernet; |
19 | -import static com.google.common.base.Preconditions.checkNotNull; | 19 | +import org.onlab.packet.IpAddress; |
20 | -import static org.onosproject.net.flow.instructions.L2ModificationInstruction.*; | 20 | +import org.onlab.packet.MacAddress; |
21 | - | 21 | +import org.onlab.packet.MplsLabel; |
22 | -import java.util.Objects; | 22 | +import org.onlab.packet.VlanId; |
23 | - | ||
24 | import org.onosproject.core.GroupId; | 23 | import org.onosproject.core.GroupId; |
25 | import org.onosproject.net.PortNumber; | 24 | import org.onosproject.net.PortNumber; |
26 | import org.onosproject.net.flow.FlowRule; | 25 | import org.onosproject.net.flow.FlowRule; |
... | @@ -33,11 +32,17 @@ import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInst | ... | @@ -33,11 +32,17 @@ import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInst |
33 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction; | 32 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction; |
34 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModTtlInstruction; | 33 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModTtlInstruction; |
35 | 34 | ||
36 | -import org.onlab.packet.Ethernet; | 35 | +import java.util.Objects; |
37 | -import org.onlab.packet.IpAddress; | 36 | + |
38 | -import org.onlab.packet.MacAddress; | 37 | +import static com.google.common.base.MoreObjects.toStringHelper; |
39 | -import org.onlab.packet.MplsLabel; | 38 | +import static com.google.common.base.Preconditions.checkNotNull; |
40 | -import org.onlab.packet.VlanId; | 39 | +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction; |
40 | +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsTtlInstruction; | ||
41 | +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction; | ||
42 | +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; | ||
43 | +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.PopVlanInstruction; | ||
44 | +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions; | ||
45 | +import static org.onosproject.net.flow.instructions.L2ModificationInstruction.StripVlanInstruction; | ||
41 | 46 | ||
42 | /** | 47 | /** |
43 | * Factory class for creating various traffic treatment instructions. | 48 | * Factory class for creating various traffic treatment instructions. |
... | @@ -62,6 +67,7 @@ public final class Instructions { | ... | @@ -62,6 +67,7 @@ public final class Instructions { |
62 | 67 | ||
63 | /** | 68 | /** |
64 | * Creates a drop instruction. | 69 | * Creates a drop instruction. |
70 | + * | ||
65 | * @return drop instruction | 71 | * @return drop instruction |
66 | */ | 72 | */ |
67 | public static DropInstruction createDrop() { | 73 | public static DropInstruction createDrop() { |
... | @@ -81,7 +87,8 @@ public final class Instructions { | ... | @@ -81,7 +87,8 @@ public final class Instructions { |
81 | 87 | ||
82 | /** | 88 | /** |
83 | * Creates a l0 modification. | 89 | * Creates a l0 modification. |
84 | - * @param lambda the lambda to modify to. | 90 | + * |
91 | + * @param lambda the lambda to modify to | ||
85 | * @return a l0 modification | 92 | * @return a l0 modification |
86 | */ | 93 | */ |
87 | public static L0ModificationInstruction modL0Lambda(short lambda) { | 94 | public static L0ModificationInstruction modL0Lambda(short lambda) { |
... | @@ -91,7 +98,8 @@ public final class Instructions { | ... | @@ -91,7 +98,8 @@ public final class Instructions { |
91 | 98 | ||
92 | /** | 99 | /** |
93 | * Creates a l2 src modification. | 100 | * Creates a l2 src modification. |
94 | - * @param addr the mac address to modify to. | 101 | + * |
102 | + * @param addr the mac address to modify to | ||
95 | * @return a l2 modification | 103 | * @return a l2 modification |
96 | */ | 104 | */ |
97 | public static L2ModificationInstruction modL2Src(MacAddress addr) { | 105 | public static L2ModificationInstruction modL2Src(MacAddress addr) { |
... | @@ -101,7 +109,8 @@ public final class Instructions { | ... | @@ -101,7 +109,8 @@ public final class Instructions { |
101 | 109 | ||
102 | /** | 110 | /** |
103 | * Creates a L2 dst modification. | 111 | * Creates a L2 dst modification. |
104 | - * @param addr the mac address to modify to. | 112 | + * |
113 | + * @param addr the mac address to modify to | ||
105 | * @return a L2 modification | 114 | * @return a L2 modification |
106 | */ | 115 | */ |
107 | public static L2ModificationInstruction modL2Dst(MacAddress addr) { | 116 | public static L2ModificationInstruction modL2Dst(MacAddress addr) { |
... | @@ -110,8 +119,9 @@ public final class Instructions { | ... | @@ -110,8 +119,9 @@ public final class Instructions { |
110 | } | 119 | } |
111 | 120 | ||
112 | /** | 121 | /** |
113 | - * Creates a Vlan id modification. | 122 | + * Creates a VLAN ID modification. |
114 | - * @param vlanId the vlan id to modify to. | 123 | + * |
124 | + * @param vlanId the VLAN ID to modify to | ||
115 | * @return a L2 modification | 125 | * @return a L2 modification |
116 | */ | 126 | */ |
117 | public static L2ModificationInstruction modVlanId(VlanId vlanId) { | 127 | public static L2ModificationInstruction modVlanId(VlanId vlanId) { |
... | @@ -120,8 +130,9 @@ public final class Instructions { | ... | @@ -120,8 +130,9 @@ public final class Instructions { |
120 | } | 130 | } |
121 | 131 | ||
122 | /** | 132 | /** |
123 | - * Creates a Vlan pcp modification. | 133 | + * Creates a VLAN PCP modification. |
124 | - * @param vlanPcp the pcp to modify to. | 134 | + * |
135 | + * @param vlanPcp the PCP to modify to | ||
125 | * @return a L2 modification | 136 | * @return a L2 modification |
126 | */ | 137 | */ |
127 | public static L2ModificationInstruction modVlanPcp(Byte vlanPcp) { | 138 | public static L2ModificationInstruction modVlanPcp(Byte vlanPcp) { |
... | @@ -131,6 +142,7 @@ public final class Instructions { | ... | @@ -131,6 +142,7 @@ public final class Instructions { |
131 | 142 | ||
132 | /** | 143 | /** |
133 | * Strips the VLAN tag if one is present. | 144 | * Strips the VLAN tag if one is present. |
145 | + * | ||
134 | * @return a L2 modification | 146 | * @return a L2 modification |
135 | */ | 147 | */ |
136 | public static L2ModificationInstruction stripVlanId() { | 148 | public static L2ModificationInstruction stripVlanId() { |
... | @@ -139,7 +151,8 @@ public final class Instructions { | ... | @@ -139,7 +151,8 @@ public final class Instructions { |
139 | 151 | ||
140 | /** | 152 | /** |
141 | * Creates a MPLS label modification. | 153 | * Creates a MPLS label modification. |
142 | - * @param mplsLabel to set. | 154 | + * |
155 | + * @param mplsLabel MPLS label to set | ||
143 | * @return a L2 Modification | 156 | * @return a L2 Modification |
144 | */ | 157 | */ |
145 | public static L2ModificationInstruction modMplsLabel(MplsLabel mplsLabel) { | 158 | public static L2ModificationInstruction modMplsLabel(MplsLabel mplsLabel) { |
... | @@ -148,7 +161,7 @@ public final class Instructions { | ... | @@ -148,7 +161,7 @@ public final class Instructions { |
148 | } | 161 | } |
149 | 162 | ||
150 | /** | 163 | /** |
151 | - * Creates a MPLS TTL modification. | 164 | + * Creates a MPLS decrement TTL modification. |
152 | * | 165 | * |
153 | * @return a L2 Modification | 166 | * @return a L2 Modification |
154 | */ | 167 | */ |
... | @@ -211,7 +224,8 @@ public final class Instructions { | ... | @@ -211,7 +224,8 @@ public final class Instructions { |
211 | } | 224 | } |
212 | 225 | ||
213 | /** | 226 | /** |
214 | - * Creates a L3 TTL modification. | 227 | + * Creates a L3 decrement TTL modification. |
228 | + * | ||
215 | * @return a L3 modification | 229 | * @return a L3 modification |
216 | */ | 230 | */ |
217 | public static L3ModificationInstruction decNwTtl() { | 231 | public static L3ModificationInstruction decNwTtl() { |
... | @@ -219,7 +233,8 @@ public final class Instructions { | ... | @@ -219,7 +233,8 @@ public final class Instructions { |
219 | } | 233 | } |
220 | 234 | ||
221 | /** | 235 | /** |
222 | - * Creates a L3 TTL modification. | 236 | + * Creates a L3 copy TTL to outer header modification. |
237 | + * | ||
223 | * @return a L3 modification | 238 | * @return a L3 modification |
224 | */ | 239 | */ |
225 | public static L3ModificationInstruction copyTtlOut() { | 240 | public static L3ModificationInstruction copyTtlOut() { |
... | @@ -227,7 +242,8 @@ public final class Instructions { | ... | @@ -227,7 +242,8 @@ public final class Instructions { |
227 | } | 242 | } |
228 | 243 | ||
229 | /** | 244 | /** |
230 | - * Creates a L3 TTL modification. | 245 | + * Creates a L3 copy TTL to inner header modification. |
246 | + * | ||
231 | * @return a L3 modification | 247 | * @return a L3 modification |
232 | */ | 248 | */ |
233 | public static L3ModificationInstruction copyTtlIn() { | 249 | public static L3ModificationInstruction copyTtlIn() { |
... | @@ -235,7 +251,8 @@ public final class Instructions { | ... | @@ -235,7 +251,8 @@ public final class Instructions { |
235 | } | 251 | } |
236 | 252 | ||
237 | /** | 253 | /** |
238 | - * Creates a mpls header instruction. | 254 | + * Creates a push MPLS header instruction. |
255 | + * | ||
239 | * @return a L2 modification. | 256 | * @return a L2 modification. |
240 | */ | 257 | */ |
241 | public static Instruction pushMpls() { | 258 | public static Instruction pushMpls() { |
... | @@ -244,7 +261,8 @@ public final class Instructions { | ... | @@ -244,7 +261,8 @@ public final class Instructions { |
244 | } | 261 | } |
245 | 262 | ||
246 | /** | 263 | /** |
247 | - * Creates a mpls header instruction. | 264 | + * Creates a pop MPLS header instruction. |
265 | + * | ||
248 | * @return a L2 modification. | 266 | * @return a L2 modification. |
249 | */ | 267 | */ |
250 | public static Instruction popMpls() { | 268 | public static Instruction popMpls() { |
... | @@ -253,7 +271,7 @@ public final class Instructions { | ... | @@ -253,7 +271,7 @@ public final class Instructions { |
253 | } | 271 | } |
254 | 272 | ||
255 | /** | 273 | /** |
256 | - * Creates a mpls header instruction. | 274 | + * Creates a pop MPLS header instruction with a particular ethertype. |
257 | * | 275 | * |
258 | * @param etherType Ethernet type to set | 276 | * @param etherType Ethernet type to set |
259 | * @return a L2 modification. | 277 | * @return a L2 modification. |
... | @@ -264,15 +282,26 @@ public final class Instructions { | ... | @@ -264,15 +282,26 @@ public final class Instructions { |
264 | } | 282 | } |
265 | 283 | ||
266 | /** | 284 | /** |
267 | - * Creates a vlan header instruction. | 285 | + * Creates a pop VLAN header instruction. |
268 | - * @return a L2 modification. | 286 | + * |
287 | + * @return a L2 modification | ||
269 | */ | 288 | */ |
270 | public static Instruction popVlan() { | 289 | public static Instruction popVlan() { |
271 | return new PopVlanInstruction(L2SubType.VLAN_POP); | 290 | return new PopVlanInstruction(L2SubType.VLAN_POP); |
272 | } | 291 | } |
273 | 292 | ||
274 | /** | 293 | /** |
294 | + * Creates a push VLAN header instruction. | ||
295 | + * | ||
296 | + * @return a L2 modification | ||
297 | + */ | ||
298 | + public static Instruction pushVlan() { | ||
299 | + return new PushHeaderInstructions(L2SubType.VLAN_PUSH, Ethernet.TYPE_VLAN); | ||
300 | + } | ||
301 | + | ||
302 | + /** | ||
275 | * Sends the packet to the table described in 'type'. | 303 | * Sends the packet to the table described in 'type'. |
304 | + * | ||
276 | * @param type flow rule table type | 305 | * @param type flow rule table type |
277 | * @return table type transition instruction | 306 | * @return table type transition instruction |
278 | */ | 307 | */ |
... | @@ -296,7 +325,6 @@ public final class Instructions { | ... | @@ -296,7 +325,6 @@ public final class Instructions { |
296 | @Override | 325 | @Override |
297 | public String toString() { | 326 | public String toString() { |
298 | return toStringHelper(type().toString()).toString(); | 327 | return toStringHelper(type().toString()).toString(); |
299 | - | ||
300 | } | 328 | } |
301 | 329 | ||
302 | @Override | 330 | @Override | ... | ... |
... | @@ -15,14 +15,14 @@ | ... | @@ -15,14 +15,14 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.flow.instructions; | 16 | package org.onosproject.net.flow.instructions; |
17 | 17 | ||
18 | -import static com.google.common.base.MoreObjects.toStringHelper; | ||
19 | - | ||
20 | -import java.util.Objects; | ||
21 | - | ||
22 | import org.onlab.packet.MacAddress; | 18 | import org.onlab.packet.MacAddress; |
23 | import org.onlab.packet.MplsLabel; | 19 | import org.onlab.packet.MplsLabel; |
24 | import org.onlab.packet.VlanId; | 20 | import org.onlab.packet.VlanId; |
25 | 21 | ||
22 | +import java.util.Objects; | ||
23 | + | ||
24 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
25 | + | ||
26 | /** | 26 | /** |
27 | * Abstraction of a single traffic treatment step. | 27 | * Abstraction of a single traffic treatment step. |
28 | */ | 28 | */ |
... | @@ -80,7 +80,12 @@ public abstract class L2ModificationInstruction implements Instruction { | ... | @@ -80,7 +80,12 @@ public abstract class L2ModificationInstruction implements Instruction { |
80 | /** | 80 | /** |
81 | * VLAN Pop modification. | 81 | * VLAN Pop modification. |
82 | */ | 82 | */ |
83 | - VLAN_POP | 83 | + VLAN_POP, |
84 | + | ||
85 | + /** | ||
86 | + * VLAN Push modification. | ||
87 | + */ | ||
88 | + VLAN_PUSH | ||
84 | } | 89 | } |
85 | 90 | ||
86 | // TODO: Create factory class 'Instructions' that will have various factory | 91 | // TODO: Create factory class 'Instructions' that will have various factory | ... | ... |
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
... | @@ -345,6 +345,10 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -345,6 +345,10 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
345 | return factory().actions().decMplsTtl(); | 345 | return factory().actions().decMplsTtl(); |
346 | case VLAN_POP: | 346 | case VLAN_POP: |
347 | return factory().actions().popVlan(); | 347 | return factory().actions().popVlan(); |
348 | + case VLAN_PUSH: | ||
349 | + PushHeaderInstructions pushVlanInstruction = (PushHeaderInstructions) l2m; | ||
350 | + return factory().actions().pushVlan( | ||
351 | + EthType.of(pushVlanInstruction.ethernetType())); | ||
348 | default: | 352 | default: |
349 | log.warn("Unimplemented action type {}.", l2m.subtype()); | 353 | log.warn("Unimplemented action type {}.", l2m.subtype()); |
350 | break; | 354 | break; | ... | ... |
... | @@ -183,6 +183,7 @@ public final class GroupModBuilder { | ... | @@ -183,6 +183,7 @@ public final class GroupModBuilder { |
183 | if (treatment == null) { | 183 | if (treatment == null) { |
184 | return actions; | 184 | return actions; |
185 | } | 185 | } |
186 | + | ||
186 | for (Instruction i : treatment.instructions()) { | 187 | for (Instruction i : treatment.instructions()) { |
187 | switch (i.type()) { | 188 | switch (i.type()) { |
188 | case DROP: | 189 | case DROP: |
... | @@ -254,6 +255,13 @@ public final class GroupModBuilder { | ... | @@ -254,6 +255,13 @@ public final class GroupModBuilder { |
254 | (L2ModificationInstruction.ModVlanPcpInstruction) l2m; | 255 | (L2ModificationInstruction.ModVlanPcpInstruction) l2m; |
255 | oxm = factory.oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); | 256 | oxm = factory.oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); |
256 | break; | 257 | break; |
258 | + case VLAN_POP: | ||
259 | + return factory.actions().popVlan(); | ||
260 | + case VLAN_PUSH: | ||
261 | + L2ModificationInstruction.PushHeaderInstructions pushVlanInstruction | ||
262 | + = (L2ModificationInstruction.PushHeaderInstructions) l2m; | ||
263 | + return factory.actions().pushVlan( | ||
264 | + EthType.of(pushVlanInstruction.ethernetType())); | ||
257 | case MPLS_PUSH: | 265 | case MPLS_PUSH: |
258 | L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions = | 266 | L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions = |
259 | (L2ModificationInstruction.PushHeaderInstructions) l2m; | 267 | (L2ModificationInstruction.PushHeaderInstructions) l2m; | ... | ... |
-
Please register or login to post a comment