sangho
Committed by Gerrit Code Review

Pushes flow rules to the control switch when the switch is connected and available.

Change-Id: I7cc03a44e21b9dd67d40139ceea7a9b44201d7a8
......@@ -381,15 +381,21 @@ public class BgpRouter {
case DEVICE_AVAILABILITY_CHANGED:
if (deviceService.isAvailable(event.subject().id())) {
log.info("Device connected {}", event.subject().id());
processIntfFilters(true, configService.getInterfaces());
/* 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(deviceId)) {
processIntfFilters(true, configService.getInterfaces());
/* 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)) {
connectivityManager.notifySwitchAvailable();
}
}
break;
......
......@@ -81,6 +81,23 @@ public class TunnellingConnectivityManager {
this.bgpSpeaker = bgpSpeaker;
}
public void start() {
packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 3);
}
public void stop() {
packetService.removeProcessor(processor);
// Should revoke packet requests in the future
}
/**
* Pushes the flow rules for forwarding BGP TCP packets to controller.
* It is called when switches are connected and available.
*/
public void notifySwitchAvailable() {
// control plane OVS is available, push default flows
TrafficSelector selectorDst = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
.matchIPProtocol(IPv4.PROTOCOL_TCP)
......@@ -105,7 +122,7 @@ public class TunnellingConnectivityManager {
.withFlag(ForwardingObjective.Flag.VERSATILE)
.add();
flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(),
puntSrc);
puntSrc);
ForwardingObjective puntDst = DefaultForwardingObjective.builder()
.fromApp(appId)
......@@ -115,18 +132,8 @@ public class TunnellingConnectivityManager {
.withFlag(ForwardingObjective.Flag.VERSATILE)
.add();
flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(),
puntDst);
puntDst);
log.info("Sent punt forwarding objective to {}", bgpSpeaker.connectPoint().deviceId());
}
public void start() {
packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 3);
}
public void stop() {
packetService.removeProcessor(processor);
// Should revoke packet requests in the future
}
/**
......