sangho
Committed by Gerrit Code Review

Fix the logic of deleting FIB entries in CorsaPipeline

Change-Id: I9fe3545fe29225d82a5c3e6b5ffc295565218ecb
......@@ -27,11 +27,8 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.Ethernet;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onosproject.config.NetworkConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
......@@ -66,13 +63,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import static org.onlab.util.Tools.delay;
/**
* BgpRouter component.
*/
......@@ -226,7 +220,7 @@ public class BgpRouter {
for (FibUpdate update : withdraws) {
FibEntry entry = update.entry();
Integer nextId = nextHops.get(entry.nextHopIp());
//Integer nextId = nextHops.get(entry.nextHopIp());
/* Group group = deleteNextHop(entry.prefix());
if (group == null) {
......@@ -235,7 +229,7 @@ public class BgpRouter {
}*/
flowObjectiveService.forward(deviceId,
generateRibForwardingObj(entry.prefix(), nextId).remove());
generateRibForwardingObj(entry.prefix(), null).remove());
}
......@@ -253,11 +247,15 @@ public class BgpRouter {
ForwardingObjective.Builder fwdBuilder = DefaultForwardingObjective.builder()
.fromApp(appId)
.makePermanent()
.nextStep(nextId)
.withSelector(selector)
.withPriority(priority)
.withFlag(ForwardingObjective.Flag.SPECIFIC);
if (nextId == null) {
fwdBuilder.withTreatment(DefaultTrafficTreatment.builder().build());
} else {
fwdBuilder.nextStep(nextId);
}
return fwdBuilder;
}
......@@ -384,13 +382,14 @@ public class BgpRouter {
if (event.subject().id().equals(deviceId)) {
processIntfFilters(true, configService.getInterfaces());
/* For test only - will be removed before Cardinal release */
/* For test only - will be removed before Cardinal release
delay(1000);
FibEntry fibEntry = new FibEntry(Ip4Prefix.valueOf("10.1.0.0/16"),
Ip4Address.valueOf("192.168.10.1"),
MacAddress.valueOf("DE:AD:BE:EF:FE:ED"));
FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, fibEntry);
updateFibEntry(Collections.singletonList(fibUpdate));
*/
}
if (event.subject().id().equals(ctrlDeviceId)) {
......
......@@ -317,28 +317,26 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli
selector.getCriterion(Criterion.Type.IPV4_DST)).ip())
.build();
NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
GroupKey key = appKryo.deserialize(next.data());
Group group = groupService.getGroup(deviceId, key);
if (group == null) {
log.warn("The group left!");
fail(fwd, ObjectiveError.GROUPMISSING);
return Collections.emptySet();
TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
if (fwd.nextId() != null) {
NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
GroupKey key = appKryo.deserialize(next.data());
Group group = groupService.getGroup(deviceId, key);
if (group == null) {
log.warn("The group left!");
fail(fwd, ObjectiveError.GROUPMISSING);
return Collections.emptySet();
}
tb.group(group.id());
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.group(group.id())
.build();
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
.fromApp(fwd.appId())
.withPriority(fwd.priority())
.forDevice(deviceId)
.withSelector(filteredSelector)
.withTreatment(treatment);
.withTreatment(tb.build());
if (fwd.permanent()) {
ruleBuilder.makePermanent();
......