* [PATCH] Allow class-e address assignment via ifconfig ioctl
@ 2018-12-11 23:30 Dave Taht
2018-12-14 23:39 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Dave Taht @ 2018-12-11 23:30 UTC (permalink / raw)
To: netdev; +Cc: Dave Taht
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>
---
include/uapi/linux/in.h | 10 +++++++---
net/ipv4/devinet.c | 5 +++--
net/ipv4/ipconfig.c | 2 ++
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
index 48e8a225b985..eba44371231f 100644
--- a/include/uapi/linux/in.h
+++ b/include/uapi/linux/in.h
@@ -266,10 +266,14 @@ struct sockaddr_in {
#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
#define IN_MULTICAST(a) IN_CLASSD(a)
-#define IN_MULTICAST_NET 0xF0000000
+#define IN_MULTICAST_NET 0xe0000000
-#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
-#define IN_BADCLASS(a) IN_EXPERIMENTAL((a))
+#define IN_BADCLASS(a) ((((long int) (a) ) == 0xffffffff)
+#define IN_EXPERIMENTAL(a) IN_BADCLASS((a))
+
+#define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
+#define IN_CLASSE_NET 0xffffffff
+#define IN_CLASSE_NSHIFT 0
/* Address to accept any incoming messages. */
#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)
{
int rc = -1; /* Something else, probably a multicast. */
- if (ipv4_is_zeronet(addr))
+ if (ipv4_is_zeronet(addr) || ipv4_is_lbcast(addr))
rc = 0;
else {
__u32 haddr = ntohl(addr);
-
if (IN_CLASSA(haddr))
rc = 8;
else if (IN_CLASSB(haddr))
rc = 16;
else if (IN_CLASSC(haddr))
rc = 24;
+ else if (IN_CLASSE(haddr))
+ rc = 32;
}
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)
ic_netmask = htonl(IN_CLASSB_NET);
else if (IN_CLASSC(ntohl(ic_myaddr)))
ic_netmask = htonl(IN_CLASSC_NET);
+ else if (IN_CLASSE(ntohl(ic_myaddr)))
+ ic_netmask = htonl(IN_CLASSE_NET);
else {
pr_err("IP-Config: Unable to guess netmask for address %pI4\n",
&ic_myaddr);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow class-e address assignment via ifconfig ioctl
2018-12-11 23:30 [PATCH] Allow class-e address assignment via ifconfig ioctl Dave Taht
@ 2018-12-14 23:39 ` David Miller
2018-12-16 1:22 ` Dave Taht
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2018-12-14 23:39 UTC (permalink / raw)
To: dave.taht; +Cc: netdev
From: Dave Taht <dave.taht@gmail.com>
Date: Tue, 11 Dec 2018 15:30:34 -0800
> 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>
Applied, thanks Dave.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow class-e address assignment via ifconfig ioctl
2018-12-14 23:39 ` David Miller
@ 2018-12-16 1:22 ` Dave Taht
2018-12-16 2:25 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Dave Taht @ 2018-12-16 1:22 UTC (permalink / raw)
To: David Miller, netdev; +Cc: dave.taht
David Miller <davem@davemloft.net> writes:
> From: Dave Taht <dave.taht@gmail.com>
> Date: Tue, 11 Dec 2018 15:30:34 -0800
>
>> 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>
>
> Applied, thanks Dave.
Thanks, but...
Into what tree did you pull it? it's not in net-next as I speak.
I reworked it a bit, giving a hat tip to Vince Fuller and his original
patch here: https://lkml.org/lkml/2008/1/7/370
http://www.taht.net/classe/0001-linux-kernel-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch
and was minutes away from submitting that version when you took this.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow class-e address assignment via ifconfig ioctl
2018-12-16 1:22 ` Dave Taht
@ 2018-12-16 2:25 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-12-16 2:25 UTC (permalink / raw)
To: dave; +Cc: netdev, dave.taht
From: Dave Taht <dave@taht.net>
Date: Sat, 15 Dec 2018 17:22:52 -0800
> Into what tree did you pull it? it's not in net-next as I speak.
It's in the 'net' tree.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-16 2:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-11 23:30 [PATCH] Allow class-e address assignment via ifconfig ioctl Dave Taht
2018-12-14 23:39 ` David Miller
2018-12-16 1:22 ` Dave Taht
2018-12-16 2:25 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.