Hyunsun Moon
Committed by Gerrit Code Review

Added TUNNEL_ID and TUNNEL_IPV4_DST case to GroupBucketEntryBuilder

Change-Id: Ia784ceb6cc70ca1a0f9eb4b20eee7c90caafdf92
...@@ -23,14 +23,22 @@ import org.onlab.packet.MplsLabel; ...@@ -23,14 +23,22 @@ import org.onlab.packet.MplsLabel;
23 import org.onlab.packet.VlanId; 23 import org.onlab.packet.VlanId;
24 import org.onosproject.core.DefaultGroupId; 24 import org.onosproject.core.DefaultGroupId;
25 import org.onosproject.core.GroupId; 25 import org.onosproject.core.GroupId;
26 +import org.onosproject.net.DeviceId;
26 import org.onosproject.net.Lambda; 27 import org.onosproject.net.Lambda;
27 import org.onosproject.net.PortNumber; 28 import org.onosproject.net.PortNumber;
29 +import org.onosproject.net.driver.DefaultDriverData;
30 +import org.onosproject.net.driver.DefaultDriverHandler;
31 +import org.onosproject.net.driver.Driver;
32 +import org.onosproject.net.driver.DriverHandler;
33 +import org.onosproject.net.driver.DriverService;
28 import org.onosproject.net.flow.DefaultTrafficTreatment; 34 import org.onosproject.net.flow.DefaultTrafficTreatment;
29 import org.onosproject.net.flow.TrafficTreatment; 35 import org.onosproject.net.flow.TrafficTreatment;
30 import org.onosproject.net.flow.instructions.Instructions; 36 import org.onosproject.net.flow.instructions.Instructions;
31 import org.onosproject.net.group.DefaultGroupBucket; 37 import org.onosproject.net.group.DefaultGroupBucket;
32 import org.onosproject.net.group.GroupBucket; 38 import org.onosproject.net.group.GroupBucket;
33 import org.onosproject.net.group.GroupBuckets; 39 import org.onosproject.net.group.GroupBuckets;
40 +import org.onosproject.openflow.controller.Dpid;
41 +import org.onosproject.openflow.controller.ExtensionTreatmentInterpreter;
34 import org.projectfloodlight.openflow.protocol.OFBucket; 42 import org.projectfloodlight.openflow.protocol.OFBucket;
35 import org.projectfloodlight.openflow.protocol.OFGroupType; 43 import org.projectfloodlight.openflow.protocol.OFGroupType;
36 import org.projectfloodlight.openflow.protocol.action.OFAction; 44 import org.projectfloodlight.openflow.protocol.action.OFAction;
...@@ -56,6 +64,7 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; ...@@ -56,6 +64,7 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic;
56 import org.projectfloodlight.openflow.types.IPv4Address; 64 import org.projectfloodlight.openflow.types.IPv4Address;
57 import org.projectfloodlight.openflow.types.OFVlanVidMatch; 65 import org.projectfloodlight.openflow.types.OFVlanVidMatch;
58 import org.projectfloodlight.openflow.types.U32; 66 import org.projectfloodlight.openflow.types.U32;
67 +import org.projectfloodlight.openflow.types.U64;
59 import org.projectfloodlight.openflow.types.U8; 68 import org.projectfloodlight.openflow.types.U8;
60 import org.projectfloodlight.openflow.types.VlanPcp; 69 import org.projectfloodlight.openflow.types.VlanPcp;
61 import org.slf4j.Logger; 70 import org.slf4j.Logger;
...@@ -69,20 +78,28 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -69,20 +78,28 @@ import static org.slf4j.LoggerFactory.getLogger;
69 */ 78 */
70 public class GroupBucketEntryBuilder { 79 public class GroupBucketEntryBuilder {
71 80
81 + private Dpid dpid;
72 private List<OFBucket> ofBuckets; 82 private List<OFBucket> ofBuckets;
73 private OFGroupType type; 83 private OFGroupType type;
84 + private DriverService driverService;
74 85
75 private final Logger log = getLogger(getClass()); 86 private final Logger log = getLogger(getClass());
76 87
88 +
77 /** 89 /**
78 * Creates a builder. 90 * Creates a builder.
79 * 91 *
92 + * @param dpid dpid
80 * @param ofBuckets list of OFBucket 93 * @param ofBuckets list of OFBucket
81 * @param type Group type 94 * @param type Group type
95 + * @param driverService driver service
82 */ 96 */
83 - public GroupBucketEntryBuilder(List<OFBucket> ofBuckets, OFGroupType type) { 97 + public GroupBucketEntryBuilder(Dpid dpid, List<OFBucket> ofBuckets, OFGroupType type,
98 + DriverService driverService) {
99 + this.dpid = dpid;
84 this.ofBuckets = ofBuckets; 100 this.ofBuckets = ofBuckets;
85 this.type = type; 101 this.type = type;
102 + this.driverService = driverService;
86 } 103 }
87 104
88 /** 105 /**
...@@ -192,7 +209,7 @@ public class GroupBucketEntryBuilder { ...@@ -192,7 +209,7 @@ public class GroupBucketEntryBuilder {
192 break; 209 break;
193 case SET_FIELD: 210 case SET_FIELD:
194 OFActionSetField setField = (OFActionSetField) act; 211 OFActionSetField setField = (OFActionSetField) act;
195 - handleSetField(builder, setField.getField()); 212 + handleSetField(builder, setField);
196 break; 213 break;
197 case POP_MPLS: 214 case POP_MPLS:
198 OFActionPopMpls popMpls = (OFActionPopMpls) act; 215 OFActionPopMpls popMpls = (OFActionPopMpls) act;
...@@ -243,7 +260,8 @@ public class GroupBucketEntryBuilder { ...@@ -243,7 +260,8 @@ public class GroupBucketEntryBuilder {
243 return builder.build(); 260 return builder.build();
244 } 261 }
245 262
246 - private void handleSetField(TrafficTreatment.Builder builder, OFOxm<?> oxm) { 263 + private void handleSetField(TrafficTreatment.Builder builder, OFActionSetField action) {
264 + OFOxm<?> oxm = action.getField();
247 switch (oxm.getMatchField().id) { 265 switch (oxm.getMatchField().id) {
248 case VLAN_PCP: 266 case VLAN_PCP:
249 @SuppressWarnings("unchecked") 267 @SuppressWarnings("unchecked")
...@@ -287,6 +305,18 @@ public class GroupBucketEntryBuilder { ...@@ -287,6 +305,18 @@ public class GroupBucketEntryBuilder {
287 OFOxm<U8> mplsBos = (OFOxm<U8>) oxm; 305 OFOxm<U8> mplsBos = (OFOxm<U8>) oxm;
288 builder.setMplsBos(mplsBos.getValue() == U8.ZERO ? false : true); 306 builder.setMplsBos(mplsBos.getValue() == U8.ZERO ? false : true);
289 break; 307 break;
308 + case TUNNEL_ID:
309 + @SuppressWarnings("unchecked")
310 + OFOxm<U64> tunnelId = (OFOxm<U64>) oxm;
311 + builder.setTunnelId(tunnelId.getValue().getValue());
312 + break;
313 + case TUNNEL_IPV4_DST:
314 + DriverHandler driver = getDriver(dpid);
315 + ExtensionTreatmentInterpreter interpreter = driver.behaviour(ExtensionTreatmentInterpreter.class);
316 + if (interpreter != null) {
317 + builder.extension(interpreter.mapAction(action), DeviceId.deviceId(Dpid.uri(dpid)));
318 + }
319 + break;
290 case ARP_OP: 320 case ARP_OP:
291 case ARP_SHA: 321 case ARP_SHA:
292 case ARP_SPA: 322 case ARP_SPA:
...@@ -336,7 +366,6 @@ public class GroupBucketEntryBuilder { ...@@ -336,7 +366,6 @@ public class GroupBucketEntryBuilder {
336 case SCTP_SRC: 366 case SCTP_SRC:
337 case TCP_DST: 367 case TCP_DST:
338 case TCP_SRC: 368 case TCP_SRC:
339 - case TUNNEL_ID:
340 case UDP_DST: 369 case UDP_DST:
341 case UDP_SRC: 370 case UDP_SRC:
342 default: 371 default:
...@@ -344,4 +373,11 @@ public class GroupBucketEntryBuilder { ...@@ -344,4 +373,11 @@ public class GroupBucketEntryBuilder {
344 break; 373 break;
345 } 374 }
346 } 375 }
376 +
377 + private DriverHandler getDriver(Dpid dpid) {
378 + DeviceId deviceId = DeviceId.deviceId(Dpid.uri(dpid));
379 + Driver driver = driverService.getDriver(deviceId);
380 + DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
381 + return handler;
382 + }
347 } 383 }
......
...@@ -225,14 +225,14 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv ...@@ -225,14 +225,14 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
225 OFGroupDescStatsReply groupDescStatsReply) { 225 OFGroupDescStatsReply groupDescStatsReply) {
226 226
227 Map<Integer, Group> groups = Maps.newHashMap(); 227 Map<Integer, Group> groups = Maps.newHashMap();
228 - 228 + Dpid dpid = Dpid.dpid(deviceId.uri());
229 229
230 for (OFGroupDescStatsEntry entry: groupDescStatsReply.getEntries()) { 230 for (OFGroupDescStatsEntry entry: groupDescStatsReply.getEntries()) {
231 int id = entry.getGroup().getGroupNumber(); 231 int id = entry.getGroup().getGroupNumber();
232 GroupId groupId = new DefaultGroupId(id); 232 GroupId groupId = new DefaultGroupId(id);
233 GroupDescription.Type type = getGroupType(entry.getGroupType()); 233 GroupDescription.Type type = getGroupType(entry.getGroupType());
234 - GroupBuckets buckets = new GroupBucketEntryBuilder(entry.getBuckets(), 234 + GroupBuckets buckets = new GroupBucketEntryBuilder(dpid, entry.getBuckets(),
235 - entry.getGroupType()).build(); 235 + entry.getGroupType(), driverService).build();
236 DefaultGroup group = new DefaultGroup(groupId, deviceId, type, buckets); 236 DefaultGroup group = new DefaultGroup(groupId, deviceId, type, buckets);
237 groups.put(id, group); 237 groups.put(id, group);
238 } 238 }
......