SONA: OpenstackSwitching - remove flows
- Remove the corresponding flows when VMs are removed. - Remove the IP mapping of the VM removed from the DHCP service (even when doNotPushFlows is true) - Updated the network config json file to reflect the change of cordvtn Change-Id: I4c359d456422ece37b93e6366f2fd4daaf081a37
Showing
6 changed files
with
75 additions
and
12 deletions
| ... | @@ -35,13 +35,14 @@ public interface OpenstackSwitchingService { | ... | @@ -35,13 +35,14 @@ public interface OpenstackSwitchingService { |
| 35 | * Removes flow rules corresponding to the port removed by Openstack. | 35 | * Removes flow rules corresponding to the port removed by Openstack. |
| 36 | * | 36 | * |
| 37 | */ | 37 | */ |
| 38 | - void deletePorts(); | 38 | + void deletePort(String uuid); |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
| 41 | * Updates flow rules corresponding to the port information updated by Openstack. | 41 | * Updates flow rules corresponding to the port information updated by Openstack. |
| 42 | * | 42 | * |
| 43 | + * @param openstackPort | ||
| 43 | */ | 44 | */ |
| 44 | - void updatePorts(); | 45 | + void updatePort(OpenstackPort openstackPort); |
| 45 | 46 | ||
| 46 | /** | 47 | /** |
| 47 | * Stores the network information created by openstack. | 48 | * Stores the network information created by openstack. | ... | ... |
| ... | @@ -40,6 +40,9 @@ | ... | @@ -40,6 +40,9 @@ |
| 40 | </api.description> | 40 | </api.description> |
| 41 | <api.package>org.onosproject.openstackswitching.web</api.package> | 41 | <api.package>org.onosproject.openstackswitching.web</api.package> |
| 42 | <onos.app.origin>SKT, Inc.</onos.app.origin> | 42 | <onos.app.origin>SKT, Inc.</onos.app.origin> |
| 43 | + <onos.app.requires> | ||
| 44 | + org.onosproject.dhcp | ||
| 45 | + </onos.app.requires> | ||
| 43 | </properties> | 46 | </properties> |
| 44 | 47 | ||
| 45 | 48 | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -131,6 +131,21 @@ public class OpenstackSwitchingRulePopulator { | ... | @@ -131,6 +131,21 @@ public class OpenstackSwitchingRulePopulator { |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | /** | 133 | /** |
| 134 | + * Remove flows rules for the VM removed. | ||
| 135 | + * | ||
| 136 | + * @param deviceId device to remove rules | ||
| 137 | + * @param vmIp IP address of the VM removed | ||
| 138 | + */ | ||
| 139 | + public void removeSwitchingRules(DeviceId deviceId, Ip4Address vmIp) { | ||
| 140 | + removeFlowRuleForVMsInSameCnode(deviceId, vmIp); | ||
| 141 | + deviceService.getAvailableDevices().forEach(device -> { | ||
| 142 | + if (!device.id().equals(deviceId)) { | ||
| 143 | + removeVxLanFlowRule(device.id(), vmIp); | ||
| 144 | + } | ||
| 145 | + }); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + /** | ||
| 134 | * Populates the flow rules for traffic to VMs in the same Cnode as the sender. | 149 | * Populates the flow rules for traffic to VMs in the same Cnode as the sender. |
| 135 | * | 150 | * |
| 136 | * @param device device to put the rules | 151 | * @param device device to put the rules |
| ... | @@ -170,9 +185,10 @@ public class OpenstackSwitchingRulePopulator { | ... | @@ -170,9 +185,10 @@ public class OpenstackSwitchingRulePopulator { |
| 170 | Ip4Address hostIpx = Ip4Address.valueOf(cidx.split(":")[0]); | 185 | Ip4Address hostIpx = Ip4Address.valueOf(cidx.split(":")[0]); |
| 171 | MacAddress vmMacx = getVmMacAddressForPort(pName); | 186 | MacAddress vmMacx = getVmMacAddressForPort(pName); |
| 172 | Ip4Address fixedIpx = getFixedIpAddressForPort(pName); | 187 | Ip4Address fixedIpx = getFixedIpAddressForPort(pName); |
| 173 | - | 188 | + if (port.isEnabled()) { |
| 174 | - setVxLanFlowRule(vni, device.id(), hostIpx, fixedIpx, vmMacx); | 189 | + setVxLanFlowRule(vni, device.id(), hostIpx, fixedIpx, vmMacx); |
| 175 | - setVxLanFlowRule(vni, d.id(), hostIpAddress, fixedIp, vmMac); | 190 | + setVxLanFlowRule(vni, d.id(), hostIpAddress, fixedIp, vmMac); |
| 191 | + } | ||
| 176 | } | 192 | } |
| 177 | }); | 193 | }); |
| 178 | } | 194 | } |
| ... | @@ -246,7 +262,7 @@ public class OpenstackSwitchingRulePopulator { | ... | @@ -246,7 +262,7 @@ public class OpenstackSwitchingRulePopulator { |
| 246 | .findFirst().orElse(null); | 262 | .findFirst().orElse(null); |
| 247 | 263 | ||
| 248 | if (port == null) { | 264 | if (port == null) { |
| 249 | - log.error("There is port information for port name {}", portName); | 265 | + log.error("There is no port information for port name {}", portName); |
| 250 | return null; | 266 | return null; |
| 251 | } | 267 | } |
| 252 | 268 | ||
| ... | @@ -341,6 +357,40 @@ public class OpenstackSwitchingRulePopulator { | ... | @@ -341,6 +357,40 @@ public class OpenstackSwitchingRulePopulator { |
| 341 | flowObjectiveService.forward(id, fo); | 357 | flowObjectiveService.forward(id, fo); |
| 342 | } | 358 | } |
| 343 | 359 | ||
| 360 | + private void removeFlowRuleForVMsInSameCnode(DeviceId id, Ip4Address vmIp) { | ||
| 361 | + TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); | ||
| 362 | + | ||
| 363 | + sBuilder.matchEthType(Ethernet.TYPE_IPV4) | ||
| 364 | + .matchIPDst(vmIp.toIpPrefix()); | ||
| 365 | + | ||
| 366 | + ForwardingObjective fo = DefaultForwardingObjective.builder() | ||
| 367 | + .withSelector(sBuilder.build()) | ||
| 368 | + .withTreatment(DefaultTrafficTreatment.builder().build()) | ||
| 369 | + .withFlag(ForwardingObjective.Flag.VERSATILE) | ||
| 370 | + .withPriority(SWITCHING_RULE_PRIORITY) | ||
| 371 | + .fromApp(appId) | ||
| 372 | + .remove(); | ||
| 373 | + | ||
| 374 | + flowObjectiveService.forward(id, fo); | ||
| 375 | + } | ||
| 376 | + | ||
| 377 | + private void removeVxLanFlowRule(DeviceId id, Ip4Address vmIp) { | ||
| 378 | + TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); | ||
| 379 | + // XXX: Later, more matches will be added when multiple table is implemented. | ||
| 380 | + sBuilder.matchEthType(Ethernet.TYPE_IPV4) | ||
| 381 | + .matchIPDst(vmIp.toIpPrefix()); | ||
| 382 | + | ||
| 383 | + ForwardingObjective fo = DefaultForwardingObjective.builder() | ||
| 384 | + .withSelector(sBuilder.build()) | ||
| 385 | + .withTreatment(DefaultTrafficTreatment.builder().build()) | ||
| 386 | + .withFlag(ForwardingObjective.Flag.VERSATILE) | ||
| 387 | + .withPriority(SWITCHING_RULE_PRIORITY) | ||
| 388 | + .fromApp(appId) | ||
| 389 | + .remove(); | ||
| 390 | + | ||
| 391 | + flowObjectiveService.forward(id, fo); | ||
| 392 | + } | ||
| 393 | + | ||
| 344 | private ExtensionTreatment buildNiciraExtenstion(DeviceId id, Ip4Address hostIp) { | 394 | private ExtensionTreatment buildNiciraExtenstion(DeviceId id, Ip4Address hostIp) { |
| 345 | Driver driver = driverService.getDriver(id); | 395 | Driver driver = driverService.getDriver(id); |
| 346 | DriverHandler driverHandler = new DefaultDriverHandler(new DefaultDriverData(driver, id)); | 396 | DriverHandler driverHandler = new DefaultDriverHandler(new DefaultDriverData(driver, id)); | ... | ... |
| ... | @@ -28,6 +28,7 @@ import javax.ws.rs.DELETE; | ... | @@ -28,6 +28,7 @@ import javax.ws.rs.DELETE; |
| 28 | import javax.ws.rs.POST; | 28 | import javax.ws.rs.POST; |
| 29 | import javax.ws.rs.PUT; | 29 | import javax.ws.rs.PUT; |
| 30 | import javax.ws.rs.Path; | 30 | import javax.ws.rs.Path; |
| 31 | +import javax.ws.rs.PathParam; | ||
| 31 | import javax.ws.rs.Produces; | 32 | import javax.ws.rs.Produces; |
| 32 | import javax.ws.rs.core.MediaType; | 33 | import javax.ws.rs.core.MediaType; |
| 33 | import javax.ws.rs.core.Response; | 34 | import javax.ws.rs.core.Response; |
| ... | @@ -68,12 +69,9 @@ public class OpenstackPortWebResource extends AbstractWebResource { | ... | @@ -68,12 +69,9 @@ public class OpenstackPortWebResource extends AbstractWebResource { |
| 68 | } | 69 | } |
| 69 | } | 70 | } |
| 70 | 71 | ||
| 72 | + @Path("{portUUID}") | ||
| 71 | @DELETE | 73 | @DELETE |
| 72 | - @Path("{id}") | 74 | + public Response deletePorts(@PathParam("portUUID") String id) { |
| 73 | - @Consumes(MediaType.APPLICATION_JSON) | ||
| 74 | - @Produces(MediaType.APPLICATION_JSON) | ||
| 75 | - public Response deletesPorts(InputStream input) { | ||
| 76 | - log.debug("REST API ports is called with {}", input.toString()); | ||
| 77 | return Response.status(Response.Status.OK).build(); | 75 | return Response.status(Response.Status.OK).build(); |
| 78 | } | 76 | } |
| 79 | 77 | ||
| ... | @@ -82,7 +80,6 @@ public class OpenstackPortWebResource extends AbstractWebResource { | ... | @@ -82,7 +80,6 @@ public class OpenstackPortWebResource extends AbstractWebResource { |
| 82 | @Consumes(MediaType.APPLICATION_JSON) | 80 | @Consumes(MediaType.APPLICATION_JSON) |
| 83 | @Produces(MediaType.APPLICATION_JSON) | 81 | @Produces(MediaType.APPLICATION_JSON) |
| 84 | public Response updatePorts(InputStream input) { | 82 | public Response updatePorts(InputStream input) { |
| 85 | - log.info("REST API ports is called with {}", input.toString()); | ||
| 86 | return Response.status(Response.Status.OK).build(); | 83 | return Response.status(Response.Status.OK).build(); |
| 87 | } | 84 | } |
| 88 | } | 85 | } | ... | ... |
| ... | @@ -32,19 +32,31 @@ | ... | @@ -32,19 +32,31 @@ |
| 32 | "nodes" : [ | 32 | "nodes" : [ |
| 33 | { | 33 | { |
| 34 | "hostname" : "compute-01", | 34 | "hostname" : "compute-01", |
| 35 | +<<<<<<< HEAD | ||
| 35 | "ovsdbIp" : "10.40.101.208", | 36 | "ovsdbIp" : "10.40.101.208", |
| 37 | +======= | ||
| 38 | + "ovsdbIp" : "127.0.0.1", | ||
| 39 | +>>>>>>> 6a78e2e... SONA: OpenstackSwitching - remove flows | ||
| 36 | "ovsdbPort" : "6640", | 40 | "ovsdbPort" : "6640", |
| 37 | "bridgeId" : "of:0000000000000001" | 41 | "bridgeId" : "of:0000000000000001" |
| 38 | }, | 42 | }, |
| 39 | { | 43 | { |
| 40 | "hostname" : "compute-02", | 44 | "hostname" : "compute-02", |
| 45 | +<<<<<<< HEAD | ||
| 41 | "ovsdbIp" : "10.40.101.227", | 46 | "ovsdbIp" : "10.40.101.227", |
| 47 | +======= | ||
| 48 | + "ovsdbIp" : "127.0.0.1", | ||
| 49 | +>>>>>>> 6a78e2e... SONA: OpenstackSwitching - remove flows | ||
| 42 | "ovsdbPort" : "6640", | 50 | "ovsdbPort" : "6640", |
| 43 | "bridgeId" : "of:0000000000000002" | 51 | "bridgeId" : "of:0000000000000002" |
| 44 | }, | 52 | }, |
| 45 | { | 53 | { |
| 46 | "hostname" : "network", | 54 | "hostname" : "network", |
| 55 | +<<<<<<< HEAD | ||
| 47 | "ovsdbIp" : "10.40.101.209", | 56 | "ovsdbIp" : "10.40.101.209", |
| 57 | +======= | ||
| 58 | + "ovsdbIp" : "127.0.0.1", | ||
| 59 | +>>>>>>> 6a78e2e... SONA: OpenstackSwitching - remove flows | ||
| 48 | "ovsdbPort" : "6640", | 60 | "ovsdbPort" : "6640", |
| 49 | "bridgeId" : "of:0000000000000003" | 61 | "bridgeId" : "of:0000000000000003" |
| 50 | } | 62 | } | ... | ... |
-
Please register or login to post a comment