Committed by
Gerrit Code Review
Pushes flow rules to the control switch when the switch is connected and available.
Change-Id: I7cc03a44e21b9dd67d40139ceea7a9b44201d7a8
Showing
2 changed files
with
34 additions
and
21 deletions
... | @@ -381,15 +381,21 @@ public class BgpRouter { | ... | @@ -381,15 +381,21 @@ public class BgpRouter { |
381 | case DEVICE_AVAILABILITY_CHANGED: | 381 | case DEVICE_AVAILABILITY_CHANGED: |
382 | if (deviceService.isAvailable(event.subject().id())) { | 382 | if (deviceService.isAvailable(event.subject().id())) { |
383 | log.info("Device connected {}", event.subject().id()); | 383 | log.info("Device connected {}", event.subject().id()); |
384 | - processIntfFilters(true, configService.getInterfaces()); | 384 | + if (event.subject().id().equals(deviceId)) { |
385 | - | 385 | + processIntfFilters(true, configService.getInterfaces()); |
386 | - /* For test only - will be removed before Cardinal release */ | 386 | + |
387 | - delay(1000); | 387 | + /* For test only - will be removed before Cardinal release */ |
388 | - FibEntry fibEntry = new FibEntry(Ip4Prefix.valueOf("10.1.0.0/16"), | 388 | + delay(1000); |
389 | - Ip4Address.valueOf("192.168.10.1"), | 389 | + FibEntry fibEntry = new FibEntry(Ip4Prefix.valueOf("10.1.0.0/16"), |
390 | - MacAddress.valueOf("DE:AD:BE:EF:FE:ED")); | 390 | + Ip4Address.valueOf("192.168.10.1"), |
391 | - FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, fibEntry); | 391 | + MacAddress.valueOf("DE:AD:BE:EF:FE:ED")); |
392 | - updateFibEntry(Collections.singletonList(fibUpdate)); | 392 | + FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, fibEntry); |
393 | + updateFibEntry(Collections.singletonList(fibUpdate)); | ||
394 | + } | ||
395 | + | ||
396 | + if (event.subject().id().equals(ctrlDeviceId)) { | ||
397 | + connectivityManager.notifySwitchAvailable(); | ||
398 | + } | ||
393 | } | 399 | } |
394 | break; | 400 | break; |
395 | 401 | ... | ... |
... | @@ -81,6 +81,23 @@ public class TunnellingConnectivityManager { | ... | @@ -81,6 +81,23 @@ public class TunnellingConnectivityManager { |
81 | 81 | ||
82 | this.bgpSpeaker = bgpSpeaker; | 82 | this.bgpSpeaker = bgpSpeaker; |
83 | 83 | ||
84 | + } | ||
85 | + | ||
86 | + public void start() { | ||
87 | + packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 3); | ||
88 | + } | ||
89 | + | ||
90 | + public void stop() { | ||
91 | + packetService.removeProcessor(processor); | ||
92 | + // Should revoke packet requests in the future | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Pushes the flow rules for forwarding BGP TCP packets to controller. | ||
97 | + * It is called when switches are connected and available. | ||
98 | + */ | ||
99 | + public void notifySwitchAvailable() { | ||
100 | + // control plane OVS is available, push default flows | ||
84 | TrafficSelector selectorDst = DefaultTrafficSelector.builder() | 101 | TrafficSelector selectorDst = DefaultTrafficSelector.builder() |
85 | .matchEthType(Ethernet.TYPE_IPV4) | 102 | .matchEthType(Ethernet.TYPE_IPV4) |
86 | .matchIPProtocol(IPv4.PROTOCOL_TCP) | 103 | .matchIPProtocol(IPv4.PROTOCOL_TCP) |
... | @@ -105,7 +122,7 @@ public class TunnellingConnectivityManager { | ... | @@ -105,7 +122,7 @@ public class TunnellingConnectivityManager { |
105 | .withFlag(ForwardingObjective.Flag.VERSATILE) | 122 | .withFlag(ForwardingObjective.Flag.VERSATILE) |
106 | .add(); | 123 | .add(); |
107 | flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(), | 124 | flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(), |
108 | - puntSrc); | 125 | + puntSrc); |
109 | 126 | ||
110 | ForwardingObjective puntDst = DefaultForwardingObjective.builder() | 127 | ForwardingObjective puntDst = DefaultForwardingObjective.builder() |
111 | .fromApp(appId) | 128 | .fromApp(appId) |
... | @@ -115,18 +132,8 @@ public class TunnellingConnectivityManager { | ... | @@ -115,18 +132,8 @@ public class TunnellingConnectivityManager { |
115 | .withFlag(ForwardingObjective.Flag.VERSATILE) | 132 | .withFlag(ForwardingObjective.Flag.VERSATILE) |
116 | .add(); | 133 | .add(); |
117 | flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(), | 134 | flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(), |
118 | - puntDst); | 135 | + puntDst); |
119 | log.info("Sent punt forwarding objective to {}", bgpSpeaker.connectPoint().deviceId()); | 136 | log.info("Sent punt forwarding objective to {}", bgpSpeaker.connectPoint().deviceId()); |
120 | - | ||
121 | - } | ||
122 | - | ||
123 | - public void start() { | ||
124 | - packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 3); | ||
125 | - } | ||
126 | - | ||
127 | - public void stop() { | ||
128 | - packetService.removeProcessor(processor); | ||
129 | - // Should revoke packet requests in the future | ||
130 | } | 137 | } |
131 | 138 | ||
132 | /** | 139 | /** | ... | ... |
-
Please register or login to post a comment