From 7018901bccdf38d7245feac729e674b433168d65 Mon Sep 17 00:00:00 2001 From: Asad Ahmed Date: Tue, 5 Nov 2013 11:37:40 -0800 Subject: [PATCH] Added an extra validation check so that the gateway mask cannot be 0 or 32 Change-Id: I78a4174c7800fcca7bdd95d03a520db5db01983d Signed-off-by: Asad Ahmed --- .../opendaylight/controller/switchmanager/SubnetConfig.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java index b0d586152c..577c039530 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java @@ -104,6 +104,9 @@ public class SubnetConfig implements Cloneable, Serializable { if (!NetUtils.isIPAddressValid(subnet)) { return new Status(StatusCode.BADREQUEST, String.format("Invalid Subnet configuration: Invalid address: %s", subnet)); } + if((this.getIPMaskLen() == 0) || (this.getIPMaskLen() == 32)) { + return new Status(StatusCode.BADREQUEST, String.format("Invalid Subnet configuration: Invalid mask: /%s", this.getIPMaskLen())); + } byte[] bytePrefix = NetUtils.getSubnetPrefix(this.getIPAddress(), this.getIPMaskLen()).getAddress(); long prefix = BitBufferHelper.getLong(bytePrefix); if (prefix == 0) { -- 2.36.6