Committed by
Gerrit Code Review
Move AAA app to OLT
Change-Id: Ie1e41353177c8755f25bca1476b41df1f2826288
Showing
4 changed files
with
115 additions
and
25 deletions
| ... | @@ -232,6 +232,14 @@ public class AAA { | ... | @@ -232,6 +232,14 @@ public class AAA { |
| 232 | selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort()); | 232 | selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort()); |
| 233 | packetService.requestPackets(selector.build(), | 233 | packetService.requestPackets(selector.build(), |
| 234 | CONTROL, appId); | 234 | CONTROL, appId); |
| 235 | + | ||
| 236 | + TrafficSelector radSelector = DefaultTrafficSelector.builder() | ||
| 237 | + .matchEthType(EthType.EtherType.IPV4.ethType().toShort()) | ||
| 238 | + .matchIPProtocol(IPv4.PROTOCOL_UDP) | ||
| 239 | + .matchUdpDst((short) 1812) | ||
| 240 | + .matchUdpSrc((short) 1812) | ||
| 241 | + .build(); | ||
| 242 | + packetService.requestPackets(radSelector, CONTROL, appId); | ||
| 235 | } | 243 | } |
| 236 | 244 | ||
| 237 | /** | 245 | /** |
| ... | @@ -241,6 +249,14 @@ public class AAA { | ... | @@ -241,6 +249,14 @@ public class AAA { |
| 241 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 249 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 242 | selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort()); | 250 | selector.matchEthType(EthType.EtherType.EAPOL.ethType().toShort()); |
| 243 | packetService.cancelPackets(selector.build(), CONTROL, appId); | 251 | packetService.cancelPackets(selector.build(), CONTROL, appId); |
| 252 | + | ||
| 253 | + TrafficSelector radSelector = DefaultTrafficSelector.builder() | ||
| 254 | + .matchEthType(EthType.EtherType.IPV4.ethType().toShort()) | ||
| 255 | + .matchIPProtocol(IPv4.PROTOCOL_UDP) | ||
| 256 | + .matchUdpDst((short) 1812) | ||
| 257 | + .matchUdpSrc((short) 1812) | ||
| 258 | + .build(); | ||
| 259 | + packetService.cancelPackets(radSelector, CONTROL, appId); | ||
| 244 | } | 260 | } |
| 245 | 261 | ||
| 246 | /** | 262 | /** | ... | ... |
| ... | @@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; | ... | @@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 26 | import org.apache.felix.scr.annotations.Service; | 26 | import org.apache.felix.scr.annotations.Service; |
| 27 | import org.onlab.packet.Ethernet; | 27 | import org.onlab.packet.Ethernet; |
| 28 | import org.onlab.packet.IPv4; | 28 | import org.onlab.packet.IPv4; |
| 29 | +import org.onlab.packet.MacAddress; | ||
| 29 | import org.onlab.packet.VlanId; | 30 | import org.onlab.packet.VlanId; |
| 30 | import org.onosproject.core.ApplicationId; | 31 | import org.onosproject.core.ApplicationId; |
| 31 | import org.onosproject.core.CoreService; | 32 | import org.onosproject.core.CoreService; |
| ... | @@ -124,6 +125,16 @@ public class CordFabricManager implements FabricService { | ... | @@ -124,6 +125,16 @@ public class CordFabricManager implements FabricService { |
| 124 | .matchInPort(PortNumber.portNumber(1)) | 125 | .matchInPort(PortNumber.portNumber(1)) |
| 125 | .build(); | 126 | .build(); |
| 126 | 127 | ||
| 128 | + TrafficSelector oltMgmtUp = DefaultTrafficSelector.builder() | ||
| 129 | + .matchEthSrc(MacAddress.valueOf("00:0c:d5:00:01:01")) | ||
| 130 | + .matchInPort(PortNumber.portNumber(2)) | ||
| 131 | + .build(); | ||
| 132 | + | ||
| 133 | + TrafficSelector oltMgmtDown = DefaultTrafficSelector.builder() | ||
| 134 | + .matchEthDst(MacAddress.valueOf("00:0c:d5:00:01:01")) | ||
| 135 | + .matchInPort(PortNumber.portNumber(9)) | ||
| 136 | + .build(); | ||
| 137 | + | ||
| 127 | TrafficTreatment up = DefaultTrafficTreatment.builder() | 138 | TrafficTreatment up = DefaultTrafficTreatment.builder() |
| 128 | .setOutput(PortNumber.portNumber(1)) | 139 | .setOutput(PortNumber.portNumber(1)) |
| 129 | .build(); | 140 | .build(); |
| ... | @@ -150,6 +161,9 @@ public class CordFabricManager implements FabricService { | ... | @@ -150,6 +161,9 @@ public class CordFabricManager implements FabricService { |
| 150 | .setOutput(PortNumber.portNumber(2)) | 161 | .setOutput(PortNumber.portNumber(2)) |
| 151 | .build(); | 162 | .build(); |
| 152 | 163 | ||
| 164 | + TrafficTreatment toVolt = DefaultTrafficTreatment.builder() | ||
| 165 | + .setOutput(PortNumber.portNumber(9)) | ||
| 166 | + .build(); | ||
| 153 | 167 | ||
| 154 | TrafficTreatment sentToRadius = DefaultTrafficTreatment.builder() | 168 | TrafficTreatment sentToRadius = DefaultTrafficTreatment.builder() |
| 155 | .setOutput(PortNumber.portNumber(5)) | 169 | .setOutput(PortNumber.portNumber(5)) |
| ... | @@ -193,12 +207,31 @@ public class CordFabricManager implements FabricService { | ... | @@ -193,12 +207,31 @@ public class CordFabricManager implements FabricService { |
| 193 | .withTreatment(down) | 207 | .withTreatment(down) |
| 194 | .add(); | 208 | .add(); |
| 195 | 209 | ||
| 210 | + ForwardingObjective upOltMgmt = DefaultForwardingObjective.builder() | ||
| 211 | + .fromApp(appId) | ||
| 212 | + .makePermanent() | ||
| 213 | + .withFlag(ForwardingObjective.Flag.VERSATILE) | ||
| 214 | + .withPriority(PRIORITY) | ||
| 215 | + .withSelector(oltMgmtUp) | ||
| 216 | + .withTreatment(toVolt) | ||
| 217 | + .add(); | ||
| 218 | + | ||
| 219 | + ForwardingObjective downOltMgmt = DefaultForwardingObjective.builder() | ||
| 220 | + .fromApp(appId) | ||
| 221 | + .makePermanent() | ||
| 222 | + .withFlag(ForwardingObjective.Flag.VERSATILE) | ||
| 223 | + .withPriority(PRIORITY) | ||
| 224 | + .withSelector(oltMgmtDown) | ||
| 225 | + .withTreatment(toOlt) | ||
| 226 | + .add(); | ||
| 196 | 227 | ||
| 197 | 228 | ||
| 198 | flowObjectiveService.forward(fabricDeviceId, upCtrl); | 229 | flowObjectiveService.forward(fabricDeviceId, upCtrl); |
| 199 | flowObjectiveService.forward(fabricDeviceId, downCtrl); | 230 | flowObjectiveService.forward(fabricDeviceId, downCtrl); |
| 200 | flowObjectiveService.forward(fabricDeviceId, radiusToServer); | 231 | flowObjectiveService.forward(fabricDeviceId, radiusToServer); |
| 201 | flowObjectiveService.forward(fabricDeviceId, serverToRadius); | 232 | flowObjectiveService.forward(fabricDeviceId, serverToRadius); |
| 233 | + flowObjectiveService.forward(fabricDeviceId, upOltMgmt); | ||
| 234 | + flowObjectiveService.forward(fabricDeviceId, downOltMgmt); | ||
| 202 | } | 235 | } |
| 203 | 236 | ||
| 204 | @Override | 237 | @Override | ... | ... |
| ... | @@ -57,7 +57,9 @@ import java.util.stream.IntStream; | ... | @@ -57,7 +57,9 @@ import java.util.stream.IntStream; |
| 57 | 57 | ||
| 58 | import static com.google.common.base.Strings.isNullOrEmpty; | 58 | import static com.google.common.base.Strings.isNullOrEmpty; |
| 59 | import static com.google.common.net.MediaType.JSON_UTF_8; | 59 | import static com.google.common.net.MediaType.JSON_UTF_8; |
| 60 | -import static java.net.HttpURLConnection.*; | 60 | +import static java.net.HttpURLConnection.HTTP_CREATED; |
| 61 | +import static java.net.HttpURLConnection.HTTP_NO_CONTENT; | ||
| 62 | +import static java.net.HttpURLConnection.HTTP_OK; | ||
| 61 | import static org.slf4j.LoggerFactory.getLogger; | 63 | import static org.slf4j.LoggerFactory.getLogger; |
| 62 | 64 | ||
| 63 | 65 | ||
| ... | @@ -87,6 +89,9 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -87,6 +89,9 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
| 87 | private static final int FABRIC_SERVER_PORT = 8181; | 89 | private static final int FABRIC_SERVER_PORT = 8181; |
| 88 | private static final String FABRIC_BASE_URI = "/onos/cordfabric/vlans/add"; | 90 | private static final String FABRIC_BASE_URI = "/onos/cordfabric/vlans/add"; |
| 89 | 91 | ||
| 92 | + private static final DeviceId OLT_DEVICE_ID = DeviceId.deviceId("of:90e2ba82f97791e9"); | ||
| 93 | + private static final int OLT_UPLINK_PORT = 129; | ||
| 94 | + | ||
| 90 | private static final ConnectPoint FABRIC_PORT = new ConnectPoint( | 95 | private static final ConnectPoint FABRIC_PORT = new ConnectPoint( |
| 91 | DeviceId.deviceId("of:000090e2ba82f974"), | 96 | DeviceId.deviceId("of:000090e2ba82f974"), |
| 92 | PortNumber.portNumber(2)); | 97 | PortNumber.portNumber(2)); |
| ... | @@ -154,11 +159,11 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -154,11 +159,11 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
| 154 | PortNumber.portNumber(3))); | 159 | PortNumber.portNumber(3))); |
| 155 | 160 | ||
| 156 | portToVlan = Maps.newHashMap(); | 161 | portToVlan = Maps.newHashMap(); |
| 157 | - portToVlan.putIfAbsent(2L, (short) 201); | 162 | + portToVlan.putIfAbsent(1L, (short) 201); |
| 158 | portToVlan.putIfAbsent(6L, (short) 401); | 163 | portToVlan.putIfAbsent(6L, (short) 401); |
| 159 | 164 | ||
| 160 | portToSsid = Maps.newHashMap(); | 165 | portToSsid = Maps.newHashMap(); |
| 161 | - portToSsid.put(new ConnectPoint(FABRIC_DEVICE_ID, PortNumber.portNumber(2)), "0"); | 166 | + portToSsid.put(new ConnectPoint(OLT_DEVICE_ID, PortNumber.portNumber(1)), "0"); |
| 162 | portToSsid.put(new ConnectPoint(FABRIC_DEVICE_ID, PortNumber.portNumber(6)), "1"); | 167 | portToSsid.put(new ConnectPoint(FABRIC_DEVICE_ID, PortNumber.portNumber(6)), "1"); |
| 163 | } | 168 | } |
| 164 | 169 | ||
| ... | @@ -333,19 +338,25 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -333,19 +338,25 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
| 333 | if (providerServiceId == -1) { | 338 | if (providerServiceId == -1) { |
| 334 | providerServiceId = xosProviderService; | 339 | providerServiceId = xosProviderService; |
| 335 | } | 340 | } |
| 341 | + | ||
| 342 | + PortNumber onuPort = newTenant.port().port(); | ||
| 343 | + VlanId subscriberVlan = VlanId.vlanId(portToVlan.get(onuPort.toLong())); | ||
| 344 | + | ||
| 336 | VoltTenant tenantToCreate = VoltTenant.builder() | 345 | VoltTenant tenantToCreate = VoltTenant.builder() |
| 337 | .withProviderService(providerServiceId) | 346 | .withProviderService(providerServiceId) |
| 338 | .withServiceSpecificId(portToSsid.get(newTenant.port())) | 347 | .withServiceSpecificId(portToSsid.get(newTenant.port())) |
| 339 | - .withVlanId(newTenant.vlanId()) | 348 | + .withVlanId(String.valueOf(subscriberVlan.toShort())) |
| 340 | .withPort(newTenant.port()) | 349 | .withPort(newTenant.port()) |
| 341 | .build(); | 350 | .build(); |
| 342 | String json = tenantToJson(tenantToCreate); | 351 | String json = tenantToJson(tenantToCreate); |
| 343 | 352 | ||
| 353 | + | ||
| 354 | + provisionVlanOnPort(OLT_DEVICE_ID, OLT_UPLINK_PORT, onuPort, subscriberVlan.toShort()); | ||
| 344 | //provisionDataPlane(tenantToCreate); | 355 | //provisionDataPlane(tenantToCreate); |
| 345 | 356 | ||
| 346 | String retJson = postRest(json); | 357 | String retJson = postRest(json); |
| 347 | 358 | ||
| 348 | - fetchCPELocation(newTenant, retJson); | 359 | + fetchCPELocation(tenantToCreate, retJson); |
| 349 | 360 | ||
| 350 | return newTenant; | 361 | return newTenant; |
| 351 | } | 362 | } |
| ... | @@ -355,10 +366,11 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -355,10 +366,11 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
| 355 | 366 | ||
| 356 | if (json.get("computeNodeName") != null) { | 367 | if (json.get("computeNodeName") != null) { |
| 357 | ConnectPoint point = nodeToPort.get(json.get("computeNodeName").asString()); | 368 | ConnectPoint point = nodeToPort.get(json.get("computeNodeName").asString()); |
| 358 | - ConnectPoint fromPoint = newTenant.port(); | 369 | + //ConnectPoint fromPoint = newTenant.port(); |
| 370 | + ConnectPoint oltPort = new ConnectPoint(FABRIC_DEVICE_ID, FABRIC_OLT_CONNECT_POINT); | ||
| 359 | 371 | ||
| 360 | provisionFabric(VlanId.vlanId(Short.parseShort(newTenant.vlanId())), | 372 | provisionFabric(VlanId.vlanId(Short.parseShort(newTenant.vlanId())), |
| 361 | - point, fromPoint); | 373 | + point, oltPort); |
| 362 | } | 374 | } |
| 363 | 375 | ||
| 364 | } | 376 | } |
| ... | @@ -374,6 +386,50 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -374,6 +386,50 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
| 374 | } | 386 | } |
| 375 | } | 387 | } |
| 376 | 388 | ||
| 389 | + private void provisionVlanOnPort(DeviceId deviceId, int uplinkPort, PortNumber p, short vlanId) { | ||
| 390 | + | ||
| 391 | + TrafficSelector upstream = DefaultTrafficSelector.builder() | ||
| 392 | + .matchVlanId(VlanId.vlanId(vlanId)) | ||
| 393 | + .matchInPort(p) | ||
| 394 | + .build(); | ||
| 395 | + | ||
| 396 | + TrafficSelector downstream = DefaultTrafficSelector.builder() | ||
| 397 | + .matchVlanId(VlanId.vlanId(vlanId)) | ||
| 398 | + .matchInPort(PortNumber.portNumber(uplinkPort)) | ||
| 399 | + .build(); | ||
| 400 | + | ||
| 401 | + TrafficTreatment upstreamTreatment = DefaultTrafficTreatment.builder() | ||
| 402 | + .setOutput(PortNumber.portNumber(uplinkPort)) | ||
| 403 | + .build(); | ||
| 404 | + | ||
| 405 | + TrafficTreatment downstreamTreatment = DefaultTrafficTreatment.builder() | ||
| 406 | + .setOutput(p) | ||
| 407 | + .build(); | ||
| 408 | + | ||
| 409 | + | ||
| 410 | + ForwardingObjective upFwd = DefaultForwardingObjective.builder() | ||
| 411 | + .withFlag(ForwardingObjective.Flag.VERSATILE) | ||
| 412 | + .withPriority(1000) | ||
| 413 | + .makePermanent() | ||
| 414 | + .withSelector(upstream) | ||
| 415 | + .fromApp(appId) | ||
| 416 | + .withTreatment(upstreamTreatment) | ||
| 417 | + .add(); | ||
| 418 | + | ||
| 419 | + ForwardingObjective downFwd = DefaultForwardingObjective.builder() | ||
| 420 | + .withFlag(ForwardingObjective.Flag.VERSATILE) | ||
| 421 | + .withPriority(1000) | ||
| 422 | + .makePermanent() | ||
| 423 | + .withSelector(downstream) | ||
| 424 | + .fromApp(appId) | ||
| 425 | + .withTreatment(downstreamTreatment) | ||
| 426 | + .add(); | ||
| 427 | + | ||
| 428 | + flowObjectiveService.forward(deviceId, upFwd); | ||
| 429 | + flowObjectiveService.forward(deviceId, downFwd); | ||
| 430 | + | ||
| 431 | + } | ||
| 432 | + | ||
| 377 | private void provisionDataPlane(VoltTenant tenant) { | 433 | private void provisionDataPlane(VoltTenant tenant) { |
| 378 | VlanId vlan = VlanId.vlanId(Short.parseShort(tenant.vlanId())); | 434 | VlanId vlan = VlanId.vlanId(Short.parseShort(tenant.vlanId())); |
| 379 | 435 | ||
| ... | @@ -420,15 +476,8 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -420,15 +476,8 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
| 420 | } | 476 | } |
| 421 | 477 | ||
| 422 | private void provisionFabric(VlanId vlanId, ConnectPoint point, ConnectPoint fromPoint) { | 478 | private void provisionFabric(VlanId vlanId, ConnectPoint point, ConnectPoint fromPoint) { |
| 423 | - //String json = "{\"vlan\":" + vlanId + ",\"ports\":["; | ||
| 424 | - //json += "{\"device\":\"" + FABRIC_DEVICE_ID.toString() + "\",\"port\":\"" | ||
| 425 | - // + FABRIC_OLT_CONNECT_POINT.toString() + "\"},"; | ||
| 426 | - //json += "{\"device\":\"" + FABRIC_DEVICE_ID.toString() + "\",\"port\":\"" | ||
| 427 | - // + FABRIC_VCPE_CONNECT_POINT.toString() + "\"}"; | ||
| 428 | - //json += "]}"; | ||
| 429 | - | ||
| 430 | - long vlan = portToVlan.get(fromPoint.port().toLong()); | ||
| 431 | 479 | ||
| 480 | + long vlan = vlanId.toShort(); | ||
| 432 | 481 | ||
| 433 | JsonObject node = new JsonObject(); | 482 | JsonObject node = new JsonObject(); |
| 434 | node.add("vlan", vlan); | 483 | node.add("vlan", vlan); | ... | ... |
| ... | @@ -56,7 +56,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -56,7 +56,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 56 | import static org.slf4j.LoggerFactory.getLogger; | 56 | import static org.slf4j.LoggerFactory.getLogger; |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | - * Simple single table pipeline abstraction. | 59 | + * Pipeliner for OLT device. |
| 60 | */ | 60 | */ |
| 61 | public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner { | 61 | public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner { |
| 62 | 62 | ||
| ... | @@ -101,10 +101,6 @@ public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner { | ... | @@ -101,10 +101,6 @@ public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner { |
| 101 | .matchEthType(EthType.EtherType.EAPOL.ethType().toShort()) | 101 | .matchEthType(EthType.EtherType.EAPOL.ethType().toShort()) |
| 102 | .build(); | 102 | .build(); |
| 103 | 103 | ||
| 104 | - TrafficSelector arpSelector = DefaultTrafficSelector.builder() | ||
| 105 | - .matchEthType(EthType.EtherType.ARP.ethType().toShort()) | ||
| 106 | - .build(); | ||
| 107 | - | ||
| 108 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() | 104 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() |
| 109 | .punt() | 105 | .punt() |
| 110 | .build(); | 106 | .build(); |
| ... | @@ -113,11 +109,7 @@ public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner { | ... | @@ -113,11 +109,7 @@ public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner { |
| 113 | PacketPriority.CONTROL.priorityValue(), | 109 | PacketPriority.CONTROL.priorityValue(), |
| 114 | appId, 0, true, null); | 110 | appId, 0, true, null); |
| 115 | 111 | ||
| 116 | - FlowRule arpRule = new DefaultFlowRule(deviceId, arpSelector, treatment, | 112 | + flowRuleService.applyFlowRules(flowRule); |
| 117 | - PacketPriority.CONTROL.priorityValue(), | ||
| 118 | - appId, 0, true, null); | ||
| 119 | - | ||
| 120 | - flowRuleService.applyFlowRules(flowRule, arpRule); | ||
| 121 | } | 113 | } |
| 122 | 114 | ||
| 123 | @Override | 115 | @Override | ... | ... |
-
Please register or login to post a comment