Configure segmentrouting routes for P4 SGPW
diff --git a/apps/fpcagent/BUCK b/apps/fpcagent/BUCK
index 89f208a..e72614c 100644
--- a/apps/fpcagent/BUCK
+++ b/apps/fpcagent/BUCK
@@ -11,6 +11,7 @@
'//apps/restconf/utils:onos-apps-restconf-utils',
'//apps/config:onos-apps-config',
'//apps/restconf/api:onos-apps-restconf-api',
+ '//apps/route-service/api:onos-apps-route-service-api',
'//fpcagent/models/fpcagent:onos-fpcagent-models-fpcagent',
'//models/common:onos-models-common',
'//lib:javax.ws.rs-api',
@@ -52,6 +53,7 @@
'org.onosproject.config',
'org.onosproject.restconf',
'org.onosproject.protocols.restconfserver',
+ 'org.onosproject.segmentrouting',
]
osgi_jar(
@@ -71,73 +73,73 @@
)
remote_jar (
- name = 'json',
- out = 'json-20090211.jar',
- url = 'mvn:org.json:json:jar:20090211',
- sha1 = 'c183aa3a2a6250293808bba12262c8920ce5a51c',
- maven_coords = 'org.json:json:jar:NON-OSGI:20090211',
- visibility = [ 'PUBLIC' ],
+ name = 'json',
+ out = 'json-20090211.jar',
+ url = 'mvn:org.json:json:jar:20090211',
+ sha1 = 'c183aa3a2a6250293808bba12262c8920ce5a51c',
+ maven_coords = 'org.json:json:jar:NON-OSGI:20090211',
+ visibility = [ 'PUBLIC' ],
)
remote_jar (
- name = 'zeromq',
- out = 'jeromq-0.3.5.jar',
- url = 'mvn:org.zeromq:jeromq:jar:0.3.5',
- sha1 = '39a79082570d114bb5433762e836e4dd9c38b03d',
- maven_coords = 'org.zeromq:jeromq:0.3.5',
- visibility = [ 'PUBLIC' ],
+ name = 'zeromq',
+ out = 'jeromq-0.3.5.jar',
+ url = 'mvn:org.zeromq:jeromq:jar:0.3.5',
+ sha1 = '39a79082570d114bb5433762e836e4dd9c38b03d',
+ maven_coords = 'org.zeromq:jeromq:0.3.5',
+ visibility = [ 'PUBLIC' ],
)
remote_jar (
- name = 'javax.servlet-api-custom',
- out = 'javax.servlet-api-3.0.1.jar',
- url = 'mvn:javax.servlet:javax.servlet-api:jar:3.0.1',
- sha1 = '6bf0ebb7efd993e222fc1112377b5e92a13b38dd',
- maven_coords = 'javax.servlet:javax.servlet-api:3.0.1',
- visibility = [ 'PUBLIC' ],
+ name = 'javax.servlet-api-custom',
+ out = 'javax.servlet-api-3.0.1.jar',
+ url = 'mvn:javax.servlet:javax.servlet-api:jar:3.0.1',
+ sha1 = '6bf0ebb7efd993e222fc1112377b5e92a13b38dd',
+ maven_coords = 'javax.servlet:javax.servlet-api:3.0.1',
+ visibility = [ 'PUBLIC' ],
)
remote_jar (
- name = 'jetty-util-custom',
- out = 'jetty-util-8.1.19.v20160209.jar',
- url = 'mvn:org.eclipse.jetty:jetty-util:jar:8.1.19.v20160209',
- sha1 = 'c88071e72998e6355d719d35ff001d9c327a971a',
- maven_coords = 'org.eclipse.jetty:jetty-util:8.1.19.v20160209',
- visibility = [ 'PUBLIC' ],
+ name = 'jetty-util-custom',
+ out = 'jetty-util-8.1.19.v20160209.jar',
+ url = 'mvn:org.eclipse.jetty:jetty-util:jar:8.1.19.v20160209',
+ sha1 = 'c88071e72998e6355d719d35ff001d9c327a971a',
+ maven_coords = 'org.eclipse.jetty:jetty-util:8.1.19.v20160209',
+ visibility = [ 'PUBLIC' ],
)
remote_jar (
- name = 'jetty-server-custom',
- out = 'jetty-server-8.1.19.v20160209.jar',
- url = 'mvn:org.eclipse.jetty:jetty-server:jar:8.1.19.v20160209',
- sha1 = 'e4100696c994e26148fd0b62c8a866a606be1540',
- maven_coords = 'org.eclipse.jetty:jetty-server:8.1.19.v20160209',
- visibility = [ 'PUBLIC' ],
+ name = 'jetty-server-custom',
+ out = 'jetty-server-8.1.19.v20160209.jar',
+ url = 'mvn:org.eclipse.jetty:jetty-server:jar:8.1.19.v20160209',
+ sha1 = 'e4100696c994e26148fd0b62c8a866a606be1540',
+ maven_coords = 'org.eclipse.jetty:jetty-server:8.1.19.v20160209',
+ visibility = [ 'PUBLIC' ],
)
remote_jar (
- name = 'jetty-servlet-custom',
- out = 'jetty-servlet-8.1.19.v20160209.jar',
- url = 'mvn:org.eclipse.jetty:jetty-servlet:jar:8.1.19.v20160209',
- sha1 = '6872c3fc289de8f26a43b101741b33af36590cb4',
- maven_coords = 'org.eclipse.jetty:jetty-servlet:8.1.19.v20160209',
- visibility = [ 'PUBLIC' ],
+ name = 'jetty-servlet-custom',
+ out = 'jetty-servlet-8.1.19.v20160209.jar',
+ url = 'mvn:org.eclipse.jetty:jetty-servlet:jar:8.1.19.v20160209',
+ sha1 = '6872c3fc289de8f26a43b101741b33af36590cb4',
+ maven_coords = 'org.eclipse.jetty:jetty-servlet:8.1.19.v20160209',
+ visibility = [ 'PUBLIC' ],
)
remote_jar (
- name = 'jetty-http-custom',
- out = 'jetty-http-8.1.19.v20160209.jar',
- url = 'mvn:org.eclipse.jetty:jetty-http:jar:8.1.19.v20160209',
- sha1 = 'f08c189eab9a45810644ec35440f1a0c8aa0c4e0',
- maven_coords = 'org.eclipse.jetty:jetty-http:8.1.19.v20160209',
- visibility = [ 'PUBLIC' ],
+ name = 'jetty-http-custom',
+ out = 'jetty-http-8.1.19.v20160209.jar',
+ url = 'mvn:org.eclipse.jetty:jetty-http:jar:8.1.19.v20160209',
+ sha1 = 'f08c189eab9a45810644ec35440f1a0c8aa0c4e0',
+ maven_coords = 'org.eclipse.jetty:jetty-http:8.1.19.v20160209',
+ visibility = [ 'PUBLIC' ],
)
remote_jar (
- name = 'jetty-io-custom',
- out = 'jetty-io-8.1.19.v20160209.jar',
- url = 'mvn:org.eclipse.jetty:jetty-io:jar:8.1.19.v20160209',
- sha1 = 'c35e77e419169b4c8ad5fa3429865f2c8541e972',
- maven_coords = 'org.eclipse.jetty:jetty-io:8.1.19.v20160209',
- visibility = [ 'PUBLIC' ],
+ name = 'jetty-io-custom',
+ out = 'jetty-io-8.1.19.v20160209.jar',
+ url = 'mvn:org.eclipse.jetty:jetty-io:jar:8.1.19.v20160209',
+ sha1 = 'c35e77e419169b4c8ad5fa3429865f2c8541e972',
+ maven_coords = 'org.eclipse.jetty:jetty-io:8.1.19.v20160209',
+ visibility = [ 'PUBLIC' ],
)
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
index ac82649..0634472 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
@@ -46,7 +46,9 @@
import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.config.basics.SubjectFactories;
import org.onosproject.net.flow.FlowRuleService;
+import org.onosproject.net.intf.InterfaceAdminService;
import org.onosproject.restconf.api.RestconfService;
+import org.onosproject.routeservice.RouteStore;
import org.onosproject.yang.model.ModelConverter;
import org.onosproject.yang.model.RpcRegistry;
import org.slf4j.Logger;
@@ -104,6 +106,12 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private FlowRuleService flowRuleService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ private RouteStore routeStore;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ private InterfaceAdminService interfaceAdminService;
+
/* Variables */
private IdGenerator notificationIds;
private FpcConfig fpcConfig;
@@ -133,7 +141,8 @@
ParseStream.createInstance().open();
NbEventWorkerManager.createInstance(20).open();
DpnNgicCommunicator.createInstance();
- DpnP4Communicator.createInstance(applicationId, flowRuleService);
+ DpnP4Communicator.createInstance(applicationId, flowRuleService,
+ routeStore, interfaceAdminService);
log.info("FPC Service Started");
}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java
index dbaa7ac..9f8bad6 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java
@@ -16,10 +16,13 @@
package org.onosproject.fpcagent.protocols;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.onlab.packet.Ip4Address;
+import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
+import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
@@ -28,12 +31,17 @@
import org.onosproject.net.flow.FlowRuleOperations;
import org.onosproject.net.flow.FlowRuleService;
import org.onosproject.net.flow.criteria.PiCriterion;
+import org.onosproject.net.host.InterfaceIpAddress;
+import org.onosproject.net.intf.Interface;
+import org.onosproject.net.intf.InterfaceAdminService;
import org.onosproject.net.pi.model.PiActionId;
import org.onosproject.net.pi.model.PiActionParamId;
import org.onosproject.net.pi.model.PiMatchFieldId;
import org.onosproject.net.pi.model.PiTableId;
import org.onosproject.net.pi.runtime.PiAction;
import org.onosproject.net.pi.runtime.PiActionParam;
+import org.onosproject.routeservice.Route;
+import org.onosproject.routeservice.RouteStore;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.P4DpnControlProtocol;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.OpIdentifier;
@@ -42,6 +50,8 @@
import java.math.BigInteger;
import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
@@ -94,20 +104,29 @@
private static DpnP4Communicator _instance;
- private ApplicationId appId;
+ private final ApplicationId appId;
private DeviceId deviceId;
private ClientIdentifier clientId;
- private FlowRuleService flowRuleService;
+ private final FlowRuleService flowRuleService;
+ private final RouteStore routeStore;
+ private final InterfaceAdminService interfaceService;
- private DpnP4Communicator(ApplicationId appId, FlowRuleService flowRuleService) {
+ private DpnP4Communicator(ApplicationId appId,
+ FlowRuleService flowRuleService,
+ RouteStore routeStore,
+ InterfaceAdminService interfaceService) {
this.appId = checkNotNull(appId);
this.flowRuleService = checkNotNull(flowRuleService);
+ this.routeStore = routeStore;
+ this.interfaceService = interfaceService;
this.deviceId = null;
}
- public static DpnP4Communicator createInstance(ApplicationId appId, FlowRuleService flowRuleService) {
+ public static DpnP4Communicator createInstance(
+ ApplicationId appId, FlowRuleService flowRuleService,
+ RouteStore routeStore, InterfaceAdminService interfaceService) {
if (_instance == null) {
- _instance = new DpnP4Communicator(appId, flowRuleService);
+ _instance = new DpnP4Communicator(appId, flowRuleService, routeStore, interfaceService);
}
return _instance;
}
@@ -206,6 +225,19 @@
.add(dlSessLookupRule(ueAddr, s1UEnodebTeid,
s1UEnodebIpv4, s1USgwIpv4));
+ // Segment routing configuration
+ Route route = new Route(Route.Source.STATIC, ueAddr.toIpPrefix(), s1UEnodebIpv4);
+ routeStore.updateRoute(route);
+
+ List<InterfaceIpAddress> ifaceIpAddrList = Lists.newArrayList();
+ ifaceIpAddrList.add(InterfaceIpAddress.valueOf(s1USgwIpv4.toString()));
+ Interface intf = new Interface(
+ "s1u-sgw",
+ ConnectPoint.deviceConnectPoint(deviceId.toString() + "/" + 144),
+ ifaceIpAddrList, null, VlanId.NONE, VlanId.vlanId((short) 20),
+ Collections.emptySet(), VlanId.NONE);
+ interfaceService.add(intf);
+
applySessionRules(sessionId);
sendNotification(