From: Alessandro Boch Date: Sun, 27 Apr 2014 17:08:03 +0000 (-0700) Subject: Allow to disable default gw feature X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~165^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=b10374443562bed1960c06bb85767d8c270436dd Allow to disable default gw feature - Default gateway is a good feature for having host discovery, and consequently hosts' pings, work out of the box. But in real scenarios a controlled network node may be connected to a legacy switch's trunk port which exposes thousand of hosts which ARP packets would easily stress controller functionality. Even though today this can be prevented by configuring a more specific subnet gateway, the issue is very much possible at first controller boot, and can always re-occur during subnet config manipulation if at any point of time we have no user configured subnet gateways. - This patch provides a way to disable he default gw feature by mean of a property in config.ini. Property addition is not included, current behavior is unchanged. Change-Id: I15b63233e3ed46a8a9fb57bb0988a0d4a2984b11 Signed-off-by: Alessandro Boch --- diff --git a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java index 07252b06f7..e95ab8095d 100644 --- a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java +++ b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java @@ -115,6 +115,9 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa * only subnet returned. As soon as a user-configured subnet is created this one will * vanish. */ + private static final String DISABLE_DEFAULT_SUBNET_PROP = "switchmanager.disableDefaultSubnetGateway"; + private static final String DISABLE_DEFAULT_SUBNET_PROP_VAL = System.getProperty(DISABLE_DEFAULT_SUBNET_PROP); + private static final boolean USE_DEFAULT_SUBNET_GW = !Boolean.valueOf(DISABLE_DEFAULT_SUBNET_PROP_VAL); protected static final SubnetConfig DEFAULT_SUBNETCONFIG; protected static final Subnet DEFAULT_SUBNET; protected static final String DEFAULT_SUBNET_NAME = "default (cannot be modifed)"; @@ -288,9 +291,9 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa @Override public List getSubnetsConfigList() { // if there are no subnets, return the default subnet - if(subnetsConfigList.size() == 0){ + if (USE_DEFAULT_SUBNET_GW && subnetsConfigList.isEmpty()) { return Collections.singletonList(DEFAULT_SUBNETCONFIG); - }else{ + } else { return new ArrayList(subnetsConfigList.values()); } } @@ -298,9 +301,9 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa @Override public SubnetConfig getSubnetConfig(String subnet) { // if there are no subnets, return the default subnet - if(subnetsConfigList.isEmpty() && subnet.equalsIgnoreCase(DEFAULT_SUBNET_NAME)){ + if (USE_DEFAULT_SUBNET_GW && subnetsConfigList.isEmpty() && subnet.equalsIgnoreCase(DEFAULT_SUBNET_NAME)) { return DEFAULT_SUBNETCONFIG; - }else{ + } else { return subnetsConfigList.get(subnet); } }