From patchwork Mon Dec 17 10:02:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin 'ldir' Darbyshire-Bryant X-Patchwork-Id: 1014373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=darbyshire-bryant.me.uk Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="X2UE4IYX"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=darbyshire-bryant.me.uk header.i=@darbyshire-bryant.me.uk header.b="f9sUOOoS"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43JGtJ2zlLz9sMr for ; Mon, 17 Dec 2018 21:02:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-ID:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=6u2DFwqS/1Wcn2qsJ4wHfkvfWYocXSA+kIZAPpL3uQI=; b=X2UE4IYXUfVsTx l0ssatQ7WKq3QsBF1QT//p+wwDY3oy1lSiry4/Dsan7ZVz4WPbfyjs/nC/0RpmXssTqzCgjuF2HSj FKluP0QE8FrcESv5o3NV50zTFkRt15emm9r8JRbZwMJnQEWXMc4a+0iXTlaVFMmyBGIHLyQNijkZP EeF3EkJbhxwf9OLZcfjNO29ZOrquiTlLhj33awopXgSLh51I2rmdE1XkdMz0t6vLPmdiYAdnmkeQr /tXCIZ9ZyzRtfQJbIUZBm/dYd2gqLLSjAiaFIa5DDO7nTLrFDP7P8YDb9hekQXSPMnAYAuHdAWgIb GYaxYytV32YyIebGzo4g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gYpjW-0005V3-OD; Mon, 17 Dec 2018 10:02:42 +0000 Received: from mail-am5eur02on0604.outbound.protection.outlook.com ([2a01:111:f400:fe07::604] helo=EUR02-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gYpjO-0005UO-78 for openwrt-devel@lists.openwrt.org; Mon, 17 Dec 2018 10:02:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=darbyshire-bryant.me.uk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MMup2hnlgChQQd220jjhwRMIpzB5JweM1Yey0iLm1i4=; b=f9sUOOoSJVNvgZci9G4tdQ3+2kGgWFXhJE8N9k8tFlKPKz12VqtpKZdL3eHu/crc/y5VivcvWClbyP/8nyS6tPacN7NveBV8Z+rwnpm68DI2BQeCyWAz985HzVwh+OyzmKEgxM/bRA1ew1GIWm5S8Cj4pLY7Gv3FA7KShHnLWNc= Received: from VI1PR0302MB2750.eurprd03.prod.outlook.com (10.171.105.143) by VI1PR0302MB3293.eurprd03.prod.outlook.com (52.134.12.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Mon, 17 Dec 2018 10:02:18 +0000 Received: from VI1PR0302MB2750.eurprd03.prod.outlook.com ([fe80::d77:d217:1660:c5d4]) by VI1PR0302MB2750.eurprd03.prod.outlook.com ([fe80::d77:d217:1660:c5d4%2]) with mapi id 15.20.1425.021; Mon, 17 Dec 2018 10:02:18 +0000 From: Kevin 'ldir' Darbyshire-Bryant To: "openwrt-devel@lists.openwrt.org" Thread-Topic: [PATCH] kernel: backport ifconfig ioctl support for class e addresses Thread-Index: AQHUle+YKSPDFhruxkekPkVhfRWI/w== Date: Mon, 17 Dec 2018 10:02:18 +0000 Message-ID: <20181217100154.76332-1-ldir@darbyshire-bryant.me.uk> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP123CA0095.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:5b::35) To VI1PR0302MB2750.eurprd03.prod.outlook.com (2603:10a6:800:e2::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ldir@darbyshire-bryant.me.uk; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2a02:c7f:1240:ee00::dc83] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0302MB3293; 6:54ZCdjxVI8a/sbVLcRlyOu0LrP9ZJq1nEKBYL2yIDZxPQjv5LvJSnSFAk5ID7ILsTfVYXgJjPF0MMBwBakBUKOkUtkZ3b6BnHX9Y18ZP+uKFfvmB8HqttP7aMFNlUCItS8lnWUtPqvs/PiyRvgamDaKcKD9EYHJX2re6MatjwBdgzS4SRQIzkTc2rqiT5jPCP9ro+O6fPLMewADOUxR5e1mWPnKbvLJpkxmtwhYOgyE/5h9bHNDKi7r0FO8eLGATq5rukv9dnywL9dx5cv7+k5u5BH1IJiGVoib2tctyM90IkRF1HEjmrOYFWH64jS9rhl59k+Q4wWlpuvZqztKbHESCV92LG4qmrJNlp2osjCdRMx1HFBiW7QPzfW/Km+qSBolFwC/JqJgC5ltl2zD8qGL7f7VSeLbtnMF8akfKR24aseEMiHPWq5rSUBCGdwZlgfbYlSVSJw8dbg8NutUL5g==; 5:L50A+dtRvbLCN6VLfW3g8EMxdt0T5KXKbkJNnrO024oFBjwFqAyofJni7EyXdB9+jQpnw7LCCH9LGOZn0nIGFX4CqXBpsPJj0A8veBQPsPeGrLonXOfp3+QXKneq1sC2TsG5TowKvbzOzmG2C5YiyQPfEE7m6yydXePtnMeQt2Y=; 7:AXr//dTFXV27txFibSzZS702DJcw7HZYObMDa6UOFULE6w4s1WQrPjJ8aqK9uPaK9mIq0+we42hR0kBF7MNwg7lkXs1PzbSq3sMZLDQzGzI+CMYTFH9rKIcxGykN6yShBkZ6gmklRld619kFnsfJKw== x-ms-office365-filtering-correlation-id: d05111ed-7cc4-451b-4727-08d66406ba5a x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR0302MB3293; x-ms-traffictypediagnostic: VI1PR0302MB3293: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3231475)(944501520)(52105112)(3002001)(10201501046)(93006095)(93001095)(148016)(149066)(150057)(6041310)(20161123562045)(2016111802025)(20161123560045)(20161123564045)(20161123558120)(6043046)(201708071742011)(7699051)(76991095); SRVR:VI1PR0302MB3293; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0302MB3293; x-forefront-prvs: 08897B549D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(39830400003)(376002)(136003)(396003)(366004)(199004)(189003)(4326008)(106356001)(1076002)(966005)(4744004)(508600001)(5660300001)(74482002)(2906002)(6116002)(6486002)(6512007)(7736002)(2351001)(46003)(6916009)(5640700003)(14454004)(36756003)(107886003)(6306002)(71200400001)(102836004)(6436002)(186003)(256004)(25786009)(305945005)(53936002)(71190400001)(68736007)(486006)(2616005)(386003)(6506007)(8676002)(2501003)(81166006)(81156014)(476003)(97736004)(8936002)(52116002)(99286004)(575784001)(105586002)(316002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0302MB3293; H:VI1PR0302MB2750.eurprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: darbyshire-bryant.me.uk does not designate permitted sender hosts) x-microsoft-antispam-message-info: lmE8a+bo/ozivPc2gBEx7XEzKOsWLpWa3+cGc/eJU9FBnC3aQpStYoqfXe5XznyeU/T6iV8IOYxN3uCsyDGW0HWP3eoiPcOybuP/RCTdmZaO1UIzH4oCpDEnhk7atNZY3qoolD7LLrIR3OgGw+8D3oB0wkMivqCIfwikxnATVua4NAQ0hXjVsyO5VU09p5qoGKKLkzbyXUcgu+3moO4vv7SeDAy9+vGu4/R/RFCQT6YBapcZtP0U2f0pXBEhkafO2Nl6I1fdC3g+BjRnB0wFw9mpKrll618xaIEnhSUuv6xk4tKD66E2xwEMKGxrB3IJ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: darbyshire-bryant.me.uk X-MS-Exchange-CrossTenant-Network-Message-Id: d05111ed-7cc4-451b-4727-08d66406ba5a X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2018 10:02:18.2782 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9151708b-c553-406f-8e56-694f435154a4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0302MB3293 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181217_020234_602960_37F84339 X-CRM114-Status: GOOD ( 15.31 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a01:111:f400:fe07:0:0:0:604 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain Subject: [OpenWrt-Devel] [PATCH] kernel: backport ifconfig ioctl support for class e addresses X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin 'ldir' Darbyshire-Bryant Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Backport 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. https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=65cab850f0eeaa9180bd2e10a231964f33743edf Signed-off-by: Kevin Darbyshire-Bryant --- ...ddress-assignment-via-ifconfig-ioctl.patch | 79 +++++++++++++++++++ ...ddress-assignment-via-ifconfig-ioctl.patch | 79 +++++++++++++++++++ ...ddress-assignment-via-ifconfig-ioctl.patch | 79 +++++++++++++++++++ 3 files changed, 237 insertions(+) create mode 100644 target/linux/generic/backport-4.14/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch create mode 100644 target/linux/generic/backport-4.19/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch create mode 100644 target/linux/generic/backport-4.9/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch diff --git a/target/linux/generic/backport-4.14/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch b/target/linux/generic/backport-4.14/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch new file mode 100644 index 0000000000..fec083dadb --- /dev/null +++ b/target/linux/generic/backport-4.14/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch @@ -0,0 +1,79 @@ +From 46bf067870156abd61fe24d14c2486d15b8b502c Mon Sep 17 00:00:00 2001 +From: Dave Taht +Date: Fri, 14 Dec 2018 18:38:40 +0000 +Subject: [PATCH 1/1] Allow class-e address assignment in ifconfig and early + boot + +While the linux kernel became mostly "class-e clean" a decade ago, +and 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. + +With this patch, also, a boot command line on these addresses is feasible: +(ip=248.0.1.2::248.0.1.1:255.255.255.0). + +While CIDR has been obsolete for 2 decades, and a survey of all the +userspace open source code in the world shows most IN_whatever macros +are also obsolete... rather than obsolete CIDR from this ioctl entirely, +this patch merely enables class-e assignment, sanely. + +H/T to Vince Fuller and his original patch here: + https://lkml.org/lkml/2008/1/7/370 + +Signed-off-by: Dave Taht +Reviewed-by: John Gilmore +--- + include/uapi/linux/in.h | 8 ++++++-- + net/ipv4/devinet.c | 4 +++- + net/ipv4/ipconfig.c | 2 ++ + 3 files changed, 11 insertions(+), 3 deletions(-) + +--- a/include/uapi/linux/in.h ++++ b/include/uapi/linux/in.h +@@ -268,8 +268,12 @@ struct sockaddr_in { + #define IN_MULTICAST(a) IN_CLASSD(a) + #define IN_MULTICAST_NET 0xF0000000 + +-#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) +--- a/net/ipv4/devinet.c ++++ b/net/ipv4/devinet.c +@@ -921,7 +921,7 @@ 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); +@@ -932,6 +932,8 @@ static int inet_abc_len(__be32 addr) + rc = 16; + else if (IN_CLASSC(haddr)) + rc = 24; ++ else if (IN_CLASSE(haddr)) ++ rc = 32; + } + + return rc; +--- a/net/ipv4/ipconfig.c ++++ b/net/ipv4/ipconfig.c +@@ -457,6 +457,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); diff --git a/target/linux/generic/backport-4.19/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch b/target/linux/generic/backport-4.19/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch new file mode 100644 index 0000000000..861e1061e0 --- /dev/null +++ b/target/linux/generic/backport-4.19/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch @@ -0,0 +1,79 @@ +From 46bf067870156abd61fe24d14c2486d15b8b502c Mon Sep 17 00:00:00 2001 +From: Dave Taht +Date: Fri, 14 Dec 2018 18:38:40 +0000 +Subject: [PATCH 1/1] Allow class-e address assignment in ifconfig and early + boot + +While the linux kernel became mostly "class-e clean" a decade ago, +and 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. + +With this patch, also, a boot command line on these addresses is feasible: +(ip=248.0.1.2::248.0.1.1:255.255.255.0). + +While CIDR has been obsolete for 2 decades, and a survey of all the +userspace open source code in the world shows most IN_whatever macros +are also obsolete... rather than obsolete CIDR from this ioctl entirely, +this patch merely enables class-e assignment, sanely. + +H/T to Vince Fuller and his original patch here: + https://lkml.org/lkml/2008/1/7/370 + +Signed-off-by: Dave Taht +Reviewed-by: John Gilmore +--- + include/uapi/linux/in.h | 8 ++++++-- + net/ipv4/devinet.c | 4 +++- + net/ipv4/ipconfig.c | 2 ++ + 3 files changed, 11 insertions(+), 3 deletions(-) + +--- a/include/uapi/linux/in.h ++++ b/include/uapi/linux/in.h +@@ -268,8 +268,12 @@ struct sockaddr_in { + #define IN_MULTICAST(a) IN_CLASSD(a) + #define IN_MULTICAST_NET 0xF0000000 + +-#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) +--- a/net/ipv4/devinet.c ++++ b/net/ipv4/devinet.c +@@ -941,7 +941,7 @@ 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); +@@ -952,6 +952,8 @@ static int inet_abc_len(__be32 addr) + rc = 16; + else if (IN_CLASSC(haddr)) + rc = 24; ++ else if (IN_CLASSE(haddr)) ++ rc = 32; + } + + return rc; +--- 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); diff --git a/target/linux/generic/backport-4.9/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch b/target/linux/generic/backport-4.9/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch new file mode 100644 index 0000000000..fd804888ff --- /dev/null +++ b/target/linux/generic/backport-4.9/700-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch @@ -0,0 +1,79 @@ +From 46bf067870156abd61fe24d14c2486d15b8b502c Mon Sep 17 00:00:00 2001 +From: Dave Taht +Date: Fri, 14 Dec 2018 18:38:40 +0000 +Subject: [PATCH 1/1] Allow class-e address assignment in ifconfig and early + boot + +While the linux kernel became mostly "class-e clean" a decade ago, +and 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. + +With this patch, also, a boot command line on these addresses is feasible: +(ip=248.0.1.2::248.0.1.1:255.255.255.0). + +While CIDR has been obsolete for 2 decades, and a survey of all the +userspace open source code in the world shows most IN_whatever macros +are also obsolete... rather than obsolete CIDR from this ioctl entirely, +this patch merely enables class-e assignment, sanely. + +H/T to Vince Fuller and his original patch here: + https://lkml.org/lkml/2008/1/7/370 + +Signed-off-by: Dave Taht +Reviewed-by: John Gilmore +--- + include/uapi/linux/in.h | 8 ++++++-- + net/ipv4/devinet.c | 4 +++- + net/ipv4/ipconfig.c | 2 ++ + 3 files changed, 11 insertions(+), 3 deletions(-) + +--- a/include/uapi/linux/in.h ++++ b/include/uapi/linux/in.h +@@ -266,8 +266,12 @@ struct sockaddr_in { + #define IN_MULTICAST(a) IN_CLASSD(a) + #define IN_MULTICAST_NET 0xF0000000 + +-#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) +--- a/net/ipv4/devinet.c ++++ b/net/ipv4/devinet.c +@@ -898,7 +898,7 @@ 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); +@@ -909,6 +909,8 @@ static int inet_abc_len(__be32 addr) + rc = 16; + else if (IN_CLASSC(haddr)) + rc = 24; ++ else if (IN_CLASSE(haddr)) ++ rc = 32; + } + + return rc; +--- a/net/ipv4/ipconfig.c ++++ b/net/ipv4/ipconfig.c +@@ -455,6 +455,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);