Suppress IPv6 flows when the device is not configured with IPv6

- Do not punt link local address if the device is not configured with ipv6Loopback
- Do not punt NDP and block DAD if the device is not configured with ipv6Loopback

Change-Id: Iaf36bcf9bf3c11bc199c271f1a03eb6ae448cfab
This commit is contained in:
Charles Chan 2018-08-29 14:55:53 -07:00
parent 3330195a19
commit f27ef096a8

View File

@ -1177,9 +1177,9 @@ public class RoutingRulePopulator {
} }
Set<IpAddress> allIps = new HashSet<>(config.getPortIPs(deviceId)); Set<IpAddress> allIps = new HashSet<>(config.getPortIPs(deviceId));
allIps.add(routerIpv4); allIps.add(routerIpv4);
allIps.add(routerLinkLocalIpv6);
if (routerIpv6 != null) { if (routerIpv6 != null) {
allIps.add(routerIpv6); allIps.add(routerIpv6);
allIps.add(routerLinkLocalIpv6);
} }
if (pairRouterIpv4 != null) { if (pairRouterIpv4 != null) {
allIps.add(pairRouterIpv4); allIps.add(pairRouterIpv4);
@ -1284,6 +1284,7 @@ public class RoutingRulePopulator {
}); });
srManager.flowObjectiveService.forward(deviceId, fwdObj); srManager.flowObjectiveService.forward(deviceId, fwdObj);
if (isIpv6Configured(deviceId)) {
// We punt all NDP packets towards the controller. // We punt all NDP packets towards the controller.
ndpFwdObjective(null, true, ARP_NDP_PRIORITY).forEach(builder -> { ndpFwdObjective(null, true, ARP_NDP_PRIORITY).forEach(builder -> {
ForwardingObjective obj = builder.add(new ObjectiveContext() { ForwardingObjective obj = builder.add(new ObjectiveContext() {
@ -1295,6 +1296,7 @@ public class RoutingRulePopulator {
}); });
srManager.flowObjectiveService.forward(deviceId, obj); srManager.flowObjectiveService.forward(deviceId, obj);
}); });
}
srManager.getPairLocalPort(deviceId).ifPresent(port -> { srManager.getPairLocalPort(deviceId).ifPresent(port -> {
ForwardingObjective pairFwdObj; ForwardingObjective pairFwdObj;
@ -1309,6 +1311,7 @@ public class RoutingRulePopulator {
}); });
srManager.flowObjectiveService.forward(deviceId, pairFwdObj); srManager.flowObjectiveService.forward(deviceId, pairFwdObj);
if (isIpv6Configured(deviceId)) {
// Do not punt NDP packets from pair port // Do not punt NDP packets from pair port
ndpFwdObjective(port, false, PacketPriority.CONTROL.priorityValue() + 1).forEach(builder -> { ndpFwdObjective(port, false, PacketPriority.CONTROL.priorityValue() + 1).forEach(builder -> {
ForwardingObjective obj = builder.add(new ObjectiveContext() { ForwardingObjective obj = builder.add(new ObjectiveContext() {
@ -1331,6 +1334,7 @@ public class RoutingRulePopulator {
} }
}); });
srManager.flowObjectiveService.forward(deviceId, pairFwdObj); srManager.flowObjectiveService.forward(deviceId, pairFwdObj);
}
}); });
} }
@ -1781,4 +1785,13 @@ public class RoutingRulePopulator {
} }
} }
private boolean isIpv6Configured(DeviceId deviceId) {
boolean isIpv6Configured;
try {
isIpv6Configured = (config.getRouterIpv6(deviceId) != null);
} catch (DeviceConfigNotFoundException e) {
isIpv6Configured = false;
}
return isIpv6Configured;
}
} }