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,17 +1284,19 @@ public class RoutingRulePopulator {
}); });
srManager.flowObjectiveService.forward(deviceId, fwdObj); srManager.flowObjectiveService.forward(deviceId, fwdObj);
// We punt all NDP packets towards the controller. if (isIpv6Configured(deviceId)) {
ndpFwdObjective(null, true, ARP_NDP_PRIORITY).forEach(builder -> { // We punt all NDP packets towards the controller.
ForwardingObjective obj = builder.add(new ObjectiveContext() { ndpFwdObjective(null, true, ARP_NDP_PRIORITY).forEach(builder -> {
@Override ForwardingObjective obj = builder.add(new ObjectiveContext() {
public void onError(Objective objective, ObjectiveError error) { @Override
log.warn("Failed to install forwarding objective to punt NDP to {}: {}", public void onError(Objective objective, ObjectiveError error) {
deviceId, error); log.warn("Failed to install forwarding objective to punt NDP to {}: {}",
} deviceId, error);
}
});
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,28 +1311,30 @@ public class RoutingRulePopulator {
}); });
srManager.flowObjectiveService.forward(deviceId, pairFwdObj); srManager.flowObjectiveService.forward(deviceId, pairFwdObj);
// Do not punt NDP packets from pair port if (isIpv6Configured(deviceId)) {
ndpFwdObjective(port, false, PacketPriority.CONTROL.priorityValue() + 1).forEach(builder -> { // Do not punt NDP packets from pair port
ForwardingObjective obj = builder.add(new ObjectiveContext() { ndpFwdObjective(port, false, PacketPriority.CONTROL.priorityValue() + 1).forEach(builder -> {
@Override ForwardingObjective obj = builder.add(new ObjectiveContext() {
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install forwarding objective to ignore ARP to {}: {}",
deviceId, error);
}
});
srManager.flowObjectiveService.forward(deviceId, obj);
});
// Do not forward DAD packets from pair port
pairFwdObj = dad6FwdObjective(port, PacketPriority.CONTROL.priorityValue() + 2)
.add(new ObjectiveContext() {
@Override @Override
public void onError(Objective objective, ObjectiveError error) { public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install forwarding objective to drop DAD to {}: {}", log.warn("Failed to install forwarding objective to ignore ARP to {}: {}",
deviceId, error); deviceId, error);
} }
}); });
srManager.flowObjectiveService.forward(deviceId, pairFwdObj); srManager.flowObjectiveService.forward(deviceId, obj);
});
// Do not forward DAD packets from pair port
pairFwdObj = dad6FwdObjective(port, PacketPriority.CONTROL.priorityValue() + 2)
.add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install forwarding objective to drop DAD to {}: {}",
deviceId, error);
}
});
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;
}
} }