8
8
import org .onlab .packet .Ip4Prefix ;
9
9
import org .onosproject .core .ApplicationId ;
10
10
import org .onosproject .net .DeviceId ;
11
- import org .onosproject .net .behaviour .upf .GtpTunnelPeer ;
12
- import org .onosproject .net .behaviour .upf .SessionDownlink ;
13
- import org .onosproject .net .behaviour .upf .SessionUplink ;
11
+ import org .onosproject .net .behaviour .upf .UpfGtpTunnelPeer ;
12
+ import org .onosproject .net .behaviour .upf .UpfSessionDownlink ;
13
+ import org .onosproject .net .behaviour .upf .UpfSessionUplink ;
14
14
import org .onosproject .net .behaviour .upf .UpfApplication ;
15
15
import org .onosproject .net .behaviour .upf .UpfInterface ;
16
16
import org .onosproject .net .behaviour .upf .UpfProgrammableException ;
95
95
*/
96
96
public class FabricUpfTranslator {
97
97
98
- // FIXME: slice ID should come from UP4
99
- private static final SliceId SLICE_MOBILE = SliceId .DEFAULT ;
100
-
101
98
/**
102
99
* Returns true if the given table entry is a GTP tunnel peer rule from the
103
100
* physical fabric pipeline, and false otherwise.
@@ -107,7 +104,7 @@ public class FabricUpfTranslator {
107
104
*/
108
105
public boolean isFabricGtpTunnelPeer (FlowRule entry ) {
109
106
// we return egress tunnel_peers table, because only this table
110
- // contains all necessary information to create GtpTunnelPeer instance.
107
+ // contains all necessary information to create UpfGtpTunnelPeer instance.
111
108
return entry .table ().equals (FABRIC_EGRESS_SPGW_EG_TUNNEL_PEERS );
112
109
}
113
110
@@ -186,16 +183,16 @@ private void assertTableId(FlowRule entry, PiTableId tableId) throws UpfProgramm
186
183
}
187
184
188
185
/**
189
- * Translate a fabric.p4 GTP tunnel peer table entry to a GtpTunnelPeer instance for easier handling.
186
+ * Translate a fabric.p4 GTP tunnel peer table entry to a UpfGtpTunnelPeer instance for easier handling.
190
187
*
191
188
* @param entry the fabric.p4 entry to translate, the method expects FlowRule from eg_tunnel_peers table.
192
- * @return the corresponding GtpTunnelPeer
189
+ * @return the corresponding UpfGtpTunnelPeer
193
190
* @throws UpfProgrammableException if the entry cannot be translated
194
191
*/
195
- public GtpTunnelPeer fabricEntryToGtpTunnelPeer (FlowRule entry )
192
+ public UpfGtpTunnelPeer fabricEntryToGtpTunnelPeer (FlowRule entry )
196
193
throws UpfProgrammableException {
197
194
assertTableId (entry , FABRIC_EGRESS_SPGW_EG_TUNNEL_PEERS );
198
- GtpTunnelPeer .Builder builder = GtpTunnelPeer .builder ();
195
+ UpfGtpTunnelPeer .Builder builder = UpfGtpTunnelPeer .builder ();
199
196
200
197
Pair <PiCriterion , PiTableAction > matchActionPair = FabricUpfTranslatorUtil .fabricEntryToPiPair (entry );
201
198
PiCriterion match = matchActionPair .getLeft ();
@@ -204,7 +201,7 @@ public GtpTunnelPeer fabricEntryToGtpTunnelPeer(FlowRule entry)
204
201
205
202
if (!action .id ().equals (FABRIC_EGRESS_SPGW_LOAD_TUNNEL_PARAMS )) {
206
203
throw new UpfProgrammableException (
207
- "Invalid action provided, cannot build GtpTunnelPeer instance: " + action .id ());
204
+ "Invalid action provided, cannot build UpfGtpTunnelPeer instance: " + action .id ());
208
205
}
209
206
210
207
builder .withSrcAddr (FabricUpfTranslatorUtil .getParamAddress (action , TUNNEL_SRC_ADDR ))
@@ -221,10 +218,10 @@ public GtpTunnelPeer fabricEntryToGtpTunnelPeer(FlowRule entry)
221
218
* @return the corresponding UeSession
222
219
* @throws UpfProgrammableException if the entry cannot be translated
223
220
*/
224
- public SessionUplink fabricEntryToUeSessionUplink (FlowRule entry )
221
+ public UpfSessionUplink fabricEntryToUeSessionUplink (FlowRule entry )
225
222
throws UpfProgrammableException {
226
223
assertTableId (entry , FABRIC_INGRESS_SPGW_UPLINK_SESSIONS );
227
- SessionUplink .Builder builder = SessionUplink .builder ();
224
+ UpfSessionUplink .Builder builder = UpfSessionUplink .builder ();
228
225
229
226
Pair <PiCriterion , PiTableAction > matchActionPair = FabricUpfTranslatorUtil .fabricEntryToPiPair (entry );
230
227
PiCriterion match = matchActionPair .getLeft ();
@@ -250,10 +247,10 @@ public SessionUplink fabricEntryToUeSessionUplink(FlowRule entry)
250
247
* @return the corresponding UeSession
251
248
* @throws UpfProgrammableException if the entry cannot be translated
252
249
*/
253
- public SessionDownlink fabricEntryToUeSessionDownlink (FlowRule entry )
250
+ public UpfSessionDownlink fabricEntryToUeSessionDownlink (FlowRule entry )
254
251
throws UpfProgrammableException {
255
252
assertTableId (entry , FABRIC_INGRESS_SPGW_DOWNLINK_SESSIONS );
256
- SessionDownlink .Builder builder = SessionDownlink .builder ();
253
+ UpfSessionDownlink .Builder builder = UpfSessionDownlink .builder ();
257
254
Pair <PiCriterion , PiTableAction > matchActionPair = FabricUpfTranslatorUtil .fabricEntryToPiPair (entry );
258
255
PiCriterion match = matchActionPair .getLeft ();
259
256
PiAction action = (PiAction ) matchActionPair .getRight ();
@@ -365,7 +362,8 @@ public UpfInterface fabricEntryToInterface(FlowRule entry)
365
362
PiAction action = (PiAction ) matchActionPair .getRight ();
366
363
367
364
var ifaceBuilder = UpfInterface .builder ()
368
- .setPrefix (FabricUpfTranslatorUtil .getFieldPrefix (match , HDR_IPV4_DST_ADDR ));
365
+ .setPrefix (FabricUpfTranslatorUtil .getFieldPrefix (match , HDR_IPV4_DST_ADDR ))
366
+ .setSliceId (FabricUpfTranslatorUtil .getParamByte (action , SLICE_ID ));
369
367
370
368
if (action .id ().equals (FABRIC_INGRESS_SPGW_IFACE_ACCESS )) {
371
369
ifaceBuilder .setAccess ();
@@ -388,6 +386,7 @@ public UpfApplication fabricEntryToUpfApplication(FlowRule entry)
388
386
PiAction action = (PiAction ) matchActionPair .getRight ();
389
387
UpfApplication .Builder appFilteringBuilder = UpfApplication .builder ()
390
388
.withAppId (FabricUpfTranslatorUtil .getParamByte (action , APP_ID ))
389
+ .withSliceId (FabricUpfTranslatorUtil .getFieldInt (match , HDR_SLICE_ID ))
391
390
.withPriority (entry .priority ());
392
391
if (FabricUpfTranslatorUtil .fieldIsPresent (match , HDR_APP_IPV4_ADDR )) {
393
392
appFilteringBuilder .withIp4Prefix (FabricUpfTranslatorUtil .getFieldPrefix (match , HDR_APP_IPV4_ADDR ));
@@ -402,7 +401,7 @@ public UpfApplication fabricEntryToUpfApplication(FlowRule entry)
402
401
}
403
402
404
403
/**
405
- * Translate a GtpTunnelPeer to two FlowRules to be inserted into the fabric.p4 pipeline.
404
+ * Translate a UpfGtpTunnelPeer to two FlowRules to be inserted into the fabric.p4 pipeline.
406
405
*
407
406
* @param gtpTunnelPeer the GTP tunnel peer to be translated
408
407
* @param deviceId the ID of the device the FlowRule should be installed on
@@ -411,7 +410,7 @@ public UpfApplication fabricEntryToUpfApplication(FlowRule entry)
411
410
* @return a pair of FlowRules translated from GTP tunnel peer
412
411
* @throws UpfProgrammableException if the interface cannot be translated
413
412
*/
414
- public Pair <FlowRule , FlowRule > gtpTunnelPeerToFabricEntry (GtpTunnelPeer gtpTunnelPeer , DeviceId deviceId ,
413
+ public Pair <FlowRule , FlowRule > gtpTunnelPeerToFabricEntry (UpfGtpTunnelPeer gtpTunnelPeer , DeviceId deviceId ,
415
414
ApplicationId appId , int priority )
416
415
throws UpfProgrammableException {
417
416
FlowRule ingressEntry ;
@@ -465,7 +464,7 @@ public Pair<FlowRule, FlowRule> gtpTunnelPeerToFabricEntry(GtpTunnelPeer gtpTunn
465
464
* @return the uplink ue session translated to a FlowRule
466
465
* @throws UpfProgrammableException if the UE session cannot be translated
467
466
*/
468
- public FlowRule sessionUplinkToFabricEntry (SessionUplink ueSession , DeviceId deviceId ,
467
+ public FlowRule sessionUplinkToFabricEntry (UpfSessionUplink ueSession , DeviceId deviceId ,
469
468
ApplicationId appId , int priority )
470
469
throws UpfProgrammableException {
471
470
final PiCriterion match ;
@@ -501,7 +500,7 @@ public FlowRule sessionUplinkToFabricEntry(SessionUplink ueSession, DeviceId dev
501
500
* @return the downlink ue session translated to a FlowRule
502
501
* @throws UpfProgrammableException if the UE session cannot be translated
503
502
*/
504
- public FlowRule sessionDownlinkToFabricEntry (SessionDownlink ueSession , DeviceId deviceId ,
503
+ public FlowRule sessionDownlinkToFabricEntry (UpfSessionDownlink ueSession , DeviceId deviceId ,
505
504
ApplicationId appId , int priority )
506
505
throws UpfProgrammableException {
507
506
final PiCriterion match ;
@@ -662,7 +661,7 @@ public FlowRule interfaceToFabricEntry(UpfInterface upfInterface, DeviceId devic
662
661
.build ();
663
662
PiAction action = PiAction .builder ()
664
663
.withId (actionId )
665
- .withParameter (new PiActionParam (SLICE_ID , SLICE_MOBILE .id ()))
664
+ .withParameter (new PiActionParam (SLICE_ID , SliceId . of ( upfInterface . sliceId ()) .id ()))
666
665
.build ();
667
666
return DefaultFlowRule .builder ()
668
667
.forDevice (deviceId ).fromApp (appId ).makePermanent ()
@@ -692,7 +691,7 @@ public FlowRule upfApplicationToFabricEntry(
692
691
693
692
public PiCriterion buildApplicationCriterion (UpfApplication appFilter ) {
694
693
PiCriterion .Builder matchBuilder = PiCriterion .builder ();
695
- matchBuilder .matchExact (HDR_SLICE_ID , SLICE_MOBILE .id ());
694
+ matchBuilder .matchExact (HDR_SLICE_ID , SliceId . of ( appFilter . sliceId ()) .id ());
696
695
if (appFilter .ip4Prefix ().isPresent ()) {
697
696
Ip4Prefix ip4Prefix = appFilter .ip4Prefix ().get ();
698
697
matchBuilder .matchLpm (HDR_APP_IPV4_ADDR , ip4Prefix .address ().toOctets (), ip4Prefix .prefixLength ());
0 commit comments