Skip to content

Commit

Permalink
Merge pull request #14 from opennetworkinglab/app-fix2
Browse files Browse the repository at this point in the history
Remove srv6-related parts from app
  • Loading branch information
ccascone authored Sep 6, 2019
2 parents c6ba958 + 5ed1a5d commit f15da53
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 598 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ app/src/main/resources/bmv2.json
ptf/bmv2.log
ptf/ptf.log
ptf/ptf.pcap
**/*.iml
**/*.pyc
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ app-install:
$(info *** Installing and activating app in ONOS...)
${onos_curl} -X POST -HContent-Type:application/octet-stream \
'${onos_url}/v1/applications?activate=true' \
--data-binary @app/target/srv6-tutorial-1.0-SNAPSHOT.oar
--data-binary @app/target/ngsdn-tutorial-1.0-SNAPSHOT.oar
@echo

app-uninstall:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.onosproject.ngsdn.tutorial.common.Srv6DeviceConfig;
import org.onosproject.ngsdn.tutorial.common.FabricDeviceConfig;
import org.onosproject.ngsdn.tutorial.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -571,11 +571,6 @@ private void setUpSpineRoutes(DeviceId spineId) {
final MacAddress leafMac = getMyStationMac(leafId);
final Set<Ip6Prefix> subnetsToRoute = getInterfaceIpv6Prefixes(leafId);

// Since we're here, we also add a route for SRv6, to forward
// packets with IPv6 dst the SID of a leaf switch.
final Ip6Address leafSid = getDeviceSid(leafId);
subnetsToRoute.add(Ip6Prefix.valueOf(leafSid, 128));

// Create a group with only one member.
int groupId = macToGroupId(leafMac);

Expand Down Expand Up @@ -628,24 +623,6 @@ private void setUpLeafRoutes(DeviceId leafId) {
.collect(Collectors.toList());

insertInOrder(ecmpGroup, flowRules);

// Since we're here, we also add a route for SRv6, to forward
// packets with IPv6 dst the SID of a spine switch, in this case using a
// single-member group.
stream(deviceService.getDevices())
.map(Device::id)
.filter(this::isSpine)
.forEach(spineId -> {
MacAddress spineMac = getMyStationMac(spineId);
Ip6Address spineSid = getDeviceSid(spineId);
int spineGroupId = macToGroupId(spineMac);
GroupDescription group = createNextHopGroup(
spineGroupId, Collections.singleton(spineMac), leafId);
FlowRule routingRule = createRoutingRule(
leafId, Ip6Prefix.valueOf(spineSid, 128),
spineGroupId);
insertInOrder(group, Collections.singleton(routingRule));
});
}

//--------------------------------------------------------------------------
Expand All @@ -660,7 +637,7 @@ private void setUpLeafRoutes(DeviceId leafId) {
* @return true if the device is a spine, false otherwise
*/
private boolean isSpine(DeviceId deviceId) {
return getDeviceConfig(deviceId).map(Srv6DeviceConfig::isSpine)
return getDeviceConfig(deviceId).map(FabricDeviceConfig::isSpine)
.orElseThrow(() -> new ItemNotFoundException(
"Missing isSpine config for " + deviceId));
}
Expand All @@ -684,20 +661,20 @@ private boolean isLeaf(DeviceId deviceId) {
*/
private MacAddress getMyStationMac(DeviceId deviceId) {
return getDeviceConfig(deviceId)
.map(Srv6DeviceConfig::myStationMac)
.map(FabricDeviceConfig::myStationMac)
.orElseThrow(() -> new ItemNotFoundException(
"Missing myStationMac config for " + deviceId));
}

/**
* Returns the Srv6 config object for the given device.
* Returns the fabric config object for the given device.
*
* @param deviceId the device ID
* @return Srv6 device config
* @return fabric device config
*/
private Optional<Srv6DeviceConfig> getDeviceConfig(DeviceId deviceId) {
Srv6DeviceConfig config = networkConfigService.getConfig(
deviceId, Srv6DeviceConfig.class);
private Optional<FabricDeviceConfig> getDeviceConfig(DeviceId deviceId) {
FabricDeviceConfig config = networkConfigService.getConfig(
deviceId, FabricDeviceConfig.class);
return Optional.ofNullable(config);
}

Expand Down Expand Up @@ -749,19 +726,6 @@ private void insertInOrder(GroupDescription group, Collection<FlowRule> flowRule
}
}

/**
* Gets Srv6 SID for the given device.
*
* @param deviceId the device ID
* @return SID for the device
*/
private Ip6Address getDeviceSid(DeviceId deviceId) {
return getDeviceConfig(deviceId)
.map(Srv6DeviceConfig::mySid)
.orElseThrow(() -> new ItemNotFoundException(
"Missing mySid config for " + deviceId));
}

/**
* Sets up IPv6 routing on all devices known by ONOS and for which this ONOS
* node instance is currently master.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.onosproject.ngsdn.tutorial.common.Srv6DeviceConfig;
import org.onosproject.ngsdn.tutorial.common.FabricDeviceConfig;
import org.onosproject.ngsdn.tutorial.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -423,15 +423,15 @@ private boolean isSpine(DeviceId deviceId) {
// "devices": {
// "device:spine1": {
// ...
// "srv6DeviceConfig": {
// "fabricDeviceConfig": {
// "myStationMac": "...",
// "mySid": "...",
// "isSpine": true
// }
// },
// ...
final Srv6DeviceConfig cfg = configService.getConfig(
deviceId, Srv6DeviceConfig.class);
final FabricDeviceConfig cfg = configService.getConfig(
deviceId, FabricDeviceConfig.class);
return cfg != null && cfg.isSpine();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.onosproject.ngsdn.tutorial.common.Srv6DeviceConfig;
import org.onosproject.ngsdn.tutorial.common.FabricDeviceConfig;
import org.onosproject.ngsdn.tutorial.pipeconf.PipeconfLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -36,7 +36,7 @@
import static org.onosproject.ngsdn.tutorial.common.Utils.sleep;

/**
* A component which among other things registers the Srv6DeviceConfig to the
* A component which among other things registers the fabricDeviceConfig to the
* netcfg subsystem.
*/
@Component(immediate = true, service = MainComponent.class)
Expand Down Expand Up @@ -68,12 +68,12 @@ public class MainComponent {
@Reference(cardinality = ReferenceCardinality.MANDATORY)
private ComponentConfigService compCfgService;

private final ConfigFactory<DeviceId, Srv6DeviceConfig> srv6ConfigFactory =
new ConfigFactory<DeviceId, Srv6DeviceConfig>(
SubjectFactories.DEVICE_SUBJECT_FACTORY, Srv6DeviceConfig.class, Srv6DeviceConfig.CONFIG_KEY) {
private final ConfigFactory<DeviceId, FabricDeviceConfig> fabricConfigFactory =
new ConfigFactory<DeviceId, FabricDeviceConfig>(
SubjectFactories.DEVICE_SUBJECT_FACTORY, FabricDeviceConfig.class, FabricDeviceConfig.CONFIG_KEY) {
@Override
public Srv6DeviceConfig createConfig() {
return new Srv6DeviceConfig();
public FabricDeviceConfig createConfig() {
return new FabricDeviceConfig();
}
};

Expand All @@ -97,13 +97,13 @@ protected void activate() {
compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider",
"requestIpv6ND", "true", false);

configRegistry.registerConfigFactory(srv6ConfigFactory);
configRegistry.registerConfigFactory(fabricConfigFactory);
log.info("Started");
}

@Deactivate
protected void deactivate() {
configRegistry.unregisterConfigFactory(srv6ConfigFactory);
configRegistry.unregisterConfigFactory(fabricConfigFactory);

cleanUp();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.onosproject.ngsdn.tutorial.common.Srv6DeviceConfig;
import org.onosproject.ngsdn.tutorial.common.FabricDeviceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -122,10 +122,10 @@ private void setUpAllDevices() {
}

private void setUpDevice(DeviceId deviceId) {
Srv6DeviceConfig config = configService.getConfig(deviceId, Srv6DeviceConfig.class);
FabricDeviceConfig config = configService.getConfig(deviceId, FabricDeviceConfig.class);
if (config == null) {
// Config not available yet
throw new ItemNotFoundException("Missing Srv6Config for " + deviceId);
throw new ItemNotFoundException("Missing FabricDeviceConfig for " + deviceId);
}

final MacAddress deviceMac = config.myStationMac();
Expand Down
Loading

0 comments on commit f15da53

Please sign in to comment.