summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Taht <dave.taht@gmail.com>2018-12-11 18:30:34 -0500
committerDavid S. Miller <davem@davemloft.net>2018-12-14 18:39:31 -0500
commit65cab850f0eeaa9180bd2e10a231964f33743edf (patch)
tree4961b7fab35dd56eed20a01ee338e3cfd1bed7a4
parent69d2c86766da2ded2b70281f1bf242cb0d58a778 (diff)
net: Allow class-e address assignment via ifconfig ioctl
While most distributions long ago switched to the iproute2 suite of utilities, which allow class-e (240.0.0.0/4) address assignment, distributions relying on busybox, toybox and other forms of ifconfig cannot assign class-e addresses without this kernel patch. While CIDR has been obsolete for 2 decades, and a survey of all the open source code in the world shows the IN_whatever macros are also obsolete... rather than obsolete CIDR from this ioctl entirely, this patch merely enables class-e assignment, sanely. Signed-off-by: Dave Taht <dave.taht@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/uapi/linux/in.h10
-rw-r--r--net/ipv4/devinet.c5
-rw-r--r--net/ipv4/ipconfig.c2
3 files changed, 12 insertions, 5 deletions
diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
index 48e8a225b985..f6052e70bf40 100644
--- a/include/uapi/linux/in.h
+++ b/include/uapi/linux/in.h
@@ -266,10 +266,14 @@ struct sockaddr_in {
266 266
267#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) 267#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
268#define IN_MULTICAST(a) IN_CLASSD(a) 268#define IN_MULTICAST(a) IN_CLASSD(a)
269#define IN_MULTICAST_NET 0xF0000000 269#define IN_MULTICAST_NET 0xe0000000
270 270
271#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) 271#define IN_BADCLASS(a) ((((long int) (a) ) == 0xffffffff)
272#define IN_BADCLASS(a) IN_EXPERIMENTAL((a)) 272#define IN_EXPERIMENTAL(a) IN_BADCLASS((a))
273
274#define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
275#define IN_CLASSE_NET 0xffffffff
276#define IN_CLASSE_NSHIFT 0
273 277
274/* Address to accept any incoming messages. */ 278/* Address to accept any incoming messages. */
275#define INADDR_ANY ((unsigned long int) 0x00000000) 279#define INADDR_ANY ((unsigned long int) 0x00000000)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index a34602ae27de..608a6f4223fb 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -952,17 +952,18 @@ static int inet_abc_len(__be32 addr)
952{ 952{
953 int rc = -1; /* Something else, probably a multicast. */ 953 int rc = -1; /* Something else, probably a multicast. */
954 954
955 if (ipv4_is_zeronet(addr)) 955 if (ipv4_is_zeronet(addr) || ipv4_is_lbcast(addr))
956 rc = 0; 956 rc = 0;
957 else { 957 else {
958 __u32 haddr = ntohl(addr); 958 __u32 haddr = ntohl(addr);
959
960 if (IN_CLASSA(haddr)) 959 if (IN_CLASSA(haddr))
961 rc = 8; 960 rc = 8;
962 else if (IN_CLASSB(haddr)) 961 else if (IN_CLASSB(haddr))
963 rc = 16; 962 rc = 16;
964 else if (IN_CLASSC(haddr)) 963 else if (IN_CLASSC(haddr))
965 rc = 24; 964 rc = 24;
965 else if (IN_CLASSE(haddr))
966 rc = 32;
966 } 967 }
967 968
968 return rc; 969 return rc;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 88212615bf4c..2393e5c106bf 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -429,6 +429,8 @@ static int __init ic_defaults(void)
429 ic_netmask = htonl(IN_CLASSB_NET); 429 ic_netmask = htonl(IN_CLASSB_NET);
430 else if (IN_CLASSC(ntohl(ic_myaddr))) 430 else if (IN_CLASSC(ntohl(ic_myaddr)))
431 ic_netmask = htonl(IN_CLASSC_NET); 431 ic_netmask = htonl(IN_CLASSC_NET);
432 else if (IN_CLASSE(ntohl(ic_myaddr)))
433 ic_netmask = htonl(IN_CLASSE_NET);
432 else { 434 else {
433 pr_err("IP-Config: Unable to guess netmask for address %pI4\n", 435 pr_err("IP-Config: Unable to guess netmask for address %pI4\n",
434 &ic_myaddr); 436 &ic_myaddr);