Allow class-e address assignment via ifconfig ioctl
Subsystems (3)
PATCH 1/1 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.
--- include/uapi/linux/in.h | 10 +++++++--- net/ipv4/devinet.c | 5 +++-- net/ipv4/ipconfig.c | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-)
include/uapi/linux/in.h +7 -3
@@ -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)
net/ipv4/devinet.c +3 -2
@@ -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;
net/ipv4/ipconfig.c +2 -0
@@ -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);
Signature · 1 line
2.17.1
From: Dave Taht <[email protected]>
Date: Tue, 11 Dec 2018 15:30:34 -0800
Quoted 11 lines
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_whatevermacros are also obsolete... rather than obsolete CIDR from this ioctl entirely, this patch merely enables class-e assignment, sanely.Signed-off-by Dave Taht <[email protected]>
Applied, thanks Dave.
Quoted 8 lines · David Miller
From: Dave Taht <[email protected]>
Date: Tue, 11 Dec 2018 15:30:34 -0800Quoted 5 lines
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.
Quoted 8 lines
Quoted 6 lines
While CIDR has been obsolete for 2 decades, and a survey of all the open source code in the world shows the
IN_whatevermacros are also obsolete... rather than obsolete CIDR from this ioctl entirely, this patch merely enables class-e assignment, sanely.Signed-off-by Dave Taht <[email protected]>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
and was minutes away from submitting that version when you took this.
David Miller
maintainerFrom: Dave Taht <[email protected]>
Date: Sat, 15 Dec 2018 17:22:52 -0800
Quoted 1 line
Into what tree did you pull it? it's not in net-next as I speak.
It's in the 'net' tree.