Committed by
Gerrit Code Review
olt installs default flows when ports appear and/or when config is uploaded.
Change-Id: Ia91f7315dac1d3a53e2b9fbf978da77a362354c6
Showing
1 changed file
with
32 additions
and
8 deletions
| ... | @@ -60,6 +60,7 @@ import org.onosproject.olt.AccessDeviceListener; | ... | @@ -60,6 +60,7 @@ import org.onosproject.olt.AccessDeviceListener; |
| 60 | import org.onosproject.olt.AccessDeviceService; | 60 | import org.onosproject.olt.AccessDeviceService; |
| 61 | import org.slf4j.Logger; | 61 | import org.slf4j.Logger; |
| 62 | 62 | ||
| 63 | +import java.util.List; | ||
| 63 | import java.util.Map; | 64 | import java.util.Map; |
| 64 | import java.util.Optional; | 65 | import java.util.Optional; |
| 65 | import java.util.Set; | 66 | import java.util.Set; |
| ... | @@ -149,7 +150,7 @@ public class Olt | ... | @@ -149,7 +150,7 @@ public class Olt |
| 149 | .flatMap(did -> deviceService.getPorts(did).stream()) | 150 | .flatMap(did -> deviceService.getPorts(did).stream()) |
| 150 | .filter(p -> oltData.get(p.element().id()).uplink() != p.number()) | 151 | .filter(p -> oltData.get(p.element().id()).uplink() != p.number()) |
| 151 | .filter(p -> p.isEnabled()) | 152 | .filter(p -> p.isEnabled()) |
| 152 | - .forEach(p -> installFilteringObjectives((DeviceId) p.element().id(), p)); | 153 | + .forEach(p -> processFilteringObjectives((DeviceId) p.element().id(), p, true)); |
| 153 | 154 | ||
| 154 | deviceService.addListener(deviceListener); | 155 | deviceService.addListener(deviceListener); |
| 155 | 156 | ||
| ... | @@ -344,9 +345,10 @@ public class Olt | ... | @@ -344,9 +345,10 @@ public class Olt |
| 344 | 345 | ||
| 345 | } | 346 | } |
| 346 | 347 | ||
| 347 | - private void installFilteringObjectives(DeviceId devId, Port port) { | 348 | + private void processFilteringObjectives(DeviceId devId, Port port, boolean install) { |
| 348 | - FilteringObjective eapol = DefaultFilteringObjective.builder() | 349 | + DefaultFilteringObjective.Builder builder = DefaultFilteringObjective.builder(); |
| 349 | - .permit() | 350 | + |
| 351 | + FilteringObjective eapol = (install ? builder.permit() : builder.deny()) | ||
| 350 | .withKey(Criteria.matchInPort(port.number())) | 352 | .withKey(Criteria.matchInPort(port.number())) |
| 351 | .addCondition(Criteria.matchEthType(EthType.EtherType.EAPOL.ethType())) | 353 | .addCondition(Criteria.matchEthType(EthType.EtherType.EAPOL.ethType())) |
| 352 | .withMeta(DefaultTrafficTreatment.builder() | 354 | .withMeta(DefaultTrafficTreatment.builder() |
| ... | @@ -383,9 +385,9 @@ public class Olt | ... | @@ -383,9 +385,9 @@ public class Olt |
| 383 | //TODO: Port handling and bookkeeping should be inproved once | 385 | //TODO: Port handling and bookkeeping should be inproved once |
| 384 | // olt firmware handles correct behaviour. | 386 | // olt firmware handles correct behaviour. |
| 385 | case PORT_ADDED: | 387 | case PORT_ADDED: |
| 386 | - if (oltData.get(devId).uplink() != event.port().number() && | 388 | + if (!oltData.get(devId).uplink().equals(event.port().number()) && |
| 387 | - event.port().isEnabled()) { | 389 | + event.port().isEnabled()) { |
| 388 | - installFilteringObjectives(devId, event.port()); | 390 | + processFilteringObjectives(devId, event.port(), true); |
| 389 | } | 391 | } |
| 390 | break; | 392 | break; |
| 391 | case PORT_REMOVED: | 393 | case PORT_REMOVED: |
| ... | @@ -393,8 +395,20 @@ public class Olt | ... | @@ -393,8 +395,20 @@ public class Olt |
| 393 | unprovisionSubscriber(devId, olt.uplink(), | 395 | unprovisionSubscriber(devId, olt.uplink(), |
| 394 | event.port().number(), | 396 | event.port().number(), |
| 395 | olt.vlan()); | 397 | olt.vlan()); |
| 398 | + if (!oltData.get(devId).uplink().equals(event.port().number()) && | ||
| 399 | + event.port().isEnabled()) { | ||
| 400 | + processFilteringObjectives(devId, event.port(), false); | ||
| 401 | + } | ||
| 396 | break; | 402 | break; |
| 397 | case PORT_UPDATED: | 403 | case PORT_UPDATED: |
| 404 | + if (oltData.get(devId).uplink().equals(event.port().number())) { | ||
| 405 | + break; | ||
| 406 | + } | ||
| 407 | + if (event.port().isEnabled()) { | ||
| 408 | + processFilteringObjectives(devId, event.port(), true); | ||
| 409 | + } else { | ||
| 410 | + processFilteringObjectives(devId, event.port(), false); | ||
| 411 | + } | ||
| 398 | break; | 412 | break; |
| 399 | case DEVICE_ADDED: | 413 | case DEVICE_ADDED: |
| 400 | post(new AccessDeviceEvent( | 414 | post(new AccessDeviceEvent( |
| ... | @@ -419,7 +433,6 @@ public class Olt | ... | @@ -419,7 +433,6 @@ public class Olt |
| 419 | break; | 433 | break; |
| 420 | case DEVICE_UPDATED: | 434 | case DEVICE_UPDATED: |
| 421 | case DEVICE_SUSPENDED: | 435 | case DEVICE_SUSPENDED: |
| 422 | - | ||
| 423 | case PORT_STATS_UPDATED: | 436 | case PORT_STATS_UPDATED: |
| 424 | default: | 437 | default: |
| 425 | return; | 438 | return; |
| ... | @@ -439,6 +452,7 @@ public class Olt | ... | @@ -439,6 +452,7 @@ public class Olt |
| 439 | networkConfig.getConfig((DeviceId) event.subject(), CONFIG_CLASS); | 452 | networkConfig.getConfig((DeviceId) event.subject(), CONFIG_CLASS); |
| 440 | if (config != null) { | 453 | if (config != null) { |
| 441 | oltData.put(config.getOlt().deviceId(), config.getOlt()); | 454 | oltData.put(config.getOlt().deviceId(), config.getOlt()); |
| 455 | + provisionDefaultFlows((DeviceId) event.subject()); | ||
| 442 | } | 456 | } |
| 443 | } | 457 | } |
| 444 | break; | 458 | break; |
| ... | @@ -450,4 +464,14 @@ public class Olt | ... | @@ -450,4 +464,14 @@ public class Olt |
| 450 | } | 464 | } |
| 451 | } | 465 | } |
| 452 | 466 | ||
| 467 | + private void provisionDefaultFlows(DeviceId deviceId) { | ||
| 468 | + List<Port> ports = deviceService.getPorts(deviceId); | ||
| 469 | + | ||
| 470 | + ports.stream() | ||
| 471 | + .filter(p -> !oltData.get(p.element().id()).uplink().equals(p.number())) | ||
| 472 | + .filter(p -> p.isEnabled()) | ||
| 473 | + .forEach(p -> processFilteringObjectives((DeviceId) p.element().id(), p, true)); | ||
| 474 | + | ||
| 475 | + } | ||
| 476 | + | ||
| 453 | } | 477 | } | ... | ... |
-
Please register or login to post a comment