Jonathan Hart
Committed by Gerrit Code Review

Move AAA app to OLT

Change-Id: Ie1e41353177c8755f25bca1476b41df1f2826288
......@@ -232,6 +232,14 @@ public class AAA {
selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort());
packetService.requestPackets(selector.build(),
CONTROL, appId);
TrafficSelector radSelector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.IPV4.ethType().toShort())
.matchIPProtocol(IPv4.PROTOCOL_UDP)
.matchUdpDst((short) 1812)
.matchUdpSrc((short) 1812)
.build();
packetService.requestPackets(radSelector, CONTROL, appId);
}
/**
......@@ -241,6 +249,14 @@ public class AAA {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort());
packetService.cancelPackets(selector.build(), CONTROL, appId);
TrafficSelector radSelector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.IPV4.ethType().toShort())
.matchIPProtocol(IPv4.PROTOCOL_UDP)
.matchUdpDst((short) 1812)
.matchUdpSrc((short) 1812)
.build();
packetService.cancelPackets(radSelector, CONTROL, appId);
}
/**
......
......@@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IPv4;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
......@@ -124,6 +125,16 @@ public class CordFabricManager implements FabricService {
.matchInPort(PortNumber.portNumber(1))
.build();
TrafficSelector oltMgmtUp = DefaultTrafficSelector.builder()
.matchEthSrc(MacAddress.valueOf("00:0c:d5:00:01:01"))
.matchInPort(PortNumber.portNumber(2))
.build();
TrafficSelector oltMgmtDown = DefaultTrafficSelector.builder()
.matchEthDst(MacAddress.valueOf("00:0c:d5:00:01:01"))
.matchInPort(PortNumber.portNumber(9))
.build();
TrafficTreatment up = DefaultTrafficTreatment.builder()
.setOutput(PortNumber.portNumber(1))
.build();
......@@ -150,6 +161,9 @@ public class CordFabricManager implements FabricService {
.setOutput(PortNumber.portNumber(2))
.build();
TrafficTreatment toVolt = DefaultTrafficTreatment.builder()
.setOutput(PortNumber.portNumber(9))
.build();
TrafficTreatment sentToRadius = DefaultTrafficTreatment.builder()
.setOutput(PortNumber.portNumber(5))
......@@ -193,12 +207,31 @@ public class CordFabricManager implements FabricService {
.withTreatment(down)
.add();
ForwardingObjective upOltMgmt = DefaultForwardingObjective.builder()
.fromApp(appId)
.makePermanent()
.withFlag(ForwardingObjective.Flag.VERSATILE)
.withPriority(PRIORITY)
.withSelector(oltMgmtUp)
.withTreatment(toVolt)
.add();
ForwardingObjective downOltMgmt = DefaultForwardingObjective.builder()
.fromApp(appId)
.makePermanent()
.withFlag(ForwardingObjective.Flag.VERSATILE)
.withPriority(PRIORITY)
.withSelector(oltMgmtDown)
.withTreatment(toOlt)
.add();
flowObjectiveService.forward(fabricDeviceId, upCtrl);
flowObjectiveService.forward(fabricDeviceId, downCtrl);
flowObjectiveService.forward(fabricDeviceId, radiusToServer);
flowObjectiveService.forward(fabricDeviceId, serverToRadius);
flowObjectiveService.forward(fabricDeviceId, upOltMgmt);
flowObjectiveService.forward(fabricDeviceId, downOltMgmt);
}
@Override
......
......@@ -57,7 +57,9 @@ import java.util.stream.IntStream;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.net.MediaType.JSON_UTF_8;
import static java.net.HttpURLConnection.*;
import static java.net.HttpURLConnection.HTTP_CREATED;
import static java.net.HttpURLConnection.HTTP_NO_CONTENT;
import static java.net.HttpURLConnection.HTTP_OK;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -87,6 +89,9 @@ public class OnosXOSIntegrationManager implements VoltTenantService {
private static final int FABRIC_SERVER_PORT = 8181;
private static final String FABRIC_BASE_URI = "/onos/cordfabric/vlans/add";
private static final DeviceId OLT_DEVICE_ID = DeviceId.deviceId("of:90e2ba82f97791e9");
private static final int OLT_UPLINK_PORT = 129;
private static final ConnectPoint FABRIC_PORT = new ConnectPoint(
DeviceId.deviceId("of:000090e2ba82f974"),
PortNumber.portNumber(2));
......@@ -154,11 +159,11 @@ public class OnosXOSIntegrationManager implements VoltTenantService {
PortNumber.portNumber(3)));
portToVlan = Maps.newHashMap();
portToVlan.putIfAbsent(2L, (short) 201);
portToVlan.putIfAbsent(1L, (short) 201);
portToVlan.putIfAbsent(6L, (short) 401);
portToSsid = Maps.newHashMap();
portToSsid.put(new ConnectPoint(FABRIC_DEVICE_ID, PortNumber.portNumber(2)), "0");
portToSsid.put(new ConnectPoint(OLT_DEVICE_ID, PortNumber.portNumber(1)), "0");
portToSsid.put(new ConnectPoint(FABRIC_DEVICE_ID, PortNumber.portNumber(6)), "1");
}
......@@ -333,19 +338,25 @@ public class OnosXOSIntegrationManager implements VoltTenantService {
if (providerServiceId == -1) {
providerServiceId = xosProviderService;
}
PortNumber onuPort = newTenant.port().port();
VlanId subscriberVlan = VlanId.vlanId(portToVlan.get(onuPort.toLong()));
VoltTenant tenantToCreate = VoltTenant.builder()
.withProviderService(providerServiceId)
.withServiceSpecificId(portToSsid.get(newTenant.port()))
.withVlanId(newTenant.vlanId())
.withVlanId(String.valueOf(subscriberVlan.toShort()))
.withPort(newTenant.port())
.build();
String json = tenantToJson(tenantToCreate);
provisionVlanOnPort(OLT_DEVICE_ID, OLT_UPLINK_PORT, onuPort, subscriberVlan.toShort());
//provisionDataPlane(tenantToCreate);
String retJson = postRest(json);
fetchCPELocation(newTenant, retJson);
fetchCPELocation(tenantToCreate, retJson);
return newTenant;
}
......@@ -355,10 +366,11 @@ public class OnosXOSIntegrationManager implements VoltTenantService {
if (json.get("computeNodeName") != null) {
ConnectPoint point = nodeToPort.get(json.get("computeNodeName").asString());
ConnectPoint fromPoint = newTenant.port();
//ConnectPoint fromPoint = newTenant.port();
ConnectPoint oltPort = new ConnectPoint(FABRIC_DEVICE_ID, FABRIC_OLT_CONNECT_POINT);
provisionFabric(VlanId.vlanId(Short.parseShort(newTenant.vlanId())),
point, fromPoint);
point, oltPort);
}
}
......@@ -374,6 +386,50 @@ public class OnosXOSIntegrationManager implements VoltTenantService {
}
}
private void provisionVlanOnPort(DeviceId deviceId, int uplinkPort, PortNumber p, short vlanId) {
TrafficSelector upstream = DefaultTrafficSelector.builder()
.matchVlanId(VlanId.vlanId(vlanId))
.matchInPort(p)
.build();
TrafficSelector downstream = DefaultTrafficSelector.builder()
.matchVlanId(VlanId.vlanId(vlanId))
.matchInPort(PortNumber.portNumber(uplinkPort))
.build();
TrafficTreatment upstreamTreatment = DefaultTrafficTreatment.builder()
.setOutput(PortNumber.portNumber(uplinkPort))
.build();
TrafficTreatment downstreamTreatment = DefaultTrafficTreatment.builder()
.setOutput(p)
.build();
ForwardingObjective upFwd = DefaultForwardingObjective.builder()
.withFlag(ForwardingObjective.Flag.VERSATILE)
.withPriority(1000)
.makePermanent()
.withSelector(upstream)
.fromApp(appId)
.withTreatment(upstreamTreatment)
.add();
ForwardingObjective downFwd = DefaultForwardingObjective.builder()
.withFlag(ForwardingObjective.Flag.VERSATILE)
.withPriority(1000)
.makePermanent()
.withSelector(downstream)
.fromApp(appId)
.withTreatment(downstreamTreatment)
.add();
flowObjectiveService.forward(deviceId, upFwd);
flowObjectiveService.forward(deviceId, downFwd);
}
private void provisionDataPlane(VoltTenant tenant) {
VlanId vlan = VlanId.vlanId(Short.parseShort(tenant.vlanId()));
......@@ -420,15 +476,8 @@ public class OnosXOSIntegrationManager implements VoltTenantService {
}
private void provisionFabric(VlanId vlanId, ConnectPoint point, ConnectPoint fromPoint) {
//String json = "{\"vlan\":" + vlanId + ",\"ports\":[";
//json += "{\"device\":\"" + FABRIC_DEVICE_ID.toString() + "\",\"port\":\""
// + FABRIC_OLT_CONNECT_POINT.toString() + "\"},";
//json += "{\"device\":\"" + FABRIC_DEVICE_ID.toString() + "\",\"port\":\""
// + FABRIC_VCPE_CONNECT_POINT.toString() + "\"}";
//json += "]}";
long vlan = portToVlan.get(fromPoint.port().toLong());
long vlan = vlanId.toShort();
JsonObject node = new JsonObject();
node.add("vlan", vlan);
......
......@@ -56,7 +56,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Simple single table pipeline abstraction.
* Pipeliner for OLT device.
*/
public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner {
......@@ -101,10 +101,6 @@ public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner {
.matchEthType(EthType.EtherType.EAPOL.ethType().toShort())
.build();
TrafficSelector arpSelector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.ARP.ethType().toShort())
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.punt()
.build();
......@@ -113,11 +109,7 @@ public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner {
PacketPriority.CONTROL.priorityValue(),
appId, 0, true, null);
FlowRule arpRule = new DefaultFlowRule(deviceId, arpSelector, treatment,
PacketPriority.CONTROL.priorityValue(),
appId, 0, true, null);
flowRuleService.applyFlowRules(flowRule, arpRule);
flowRuleService.applyFlowRules(flowRule);
}
@Override
......