From patchwork Mon Dec 17 10:27:16 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: 1014391 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="LZtDWDid"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=darbyshire-bryant.me.uk header.i=@darbyshire-bryant.me.uk header.b="ERFrhw+g"; 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 43JHR33N6Rz9sBh for ; Mon, 17 Dec 2018 21:27:43 +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=LHZonqBx2jw+SiIlDACod85caQGk7piwUS541MZj9XA=; b=LZtDWDid+h5gFw xZJBNILN3GlbKbXixCYUvr0tHWZryKbeD6ac7Y4+YxA3L6T5Pa/TLEpy0QxEsihT25qQSWBaPMRiD MSCfNwBq0PxrYrdy2JFtcjnhXSAymI86fyYtmkN55m3/RmOY//4QHDwCFJWwLI9jiKqf3G85fan08 W0PNbLiNH9ezKBqYtGLU/Fhq24LSARC5cQsUtIYlTkqHs7UkQM0D3Tqa98lIzQ//zyqe/pZANKYOM X+mCkyjXyBw5JLEf68EbJPSIM9zhDIB4ZW/YHaf0Mv7QBbiTgNO2iQ5UOLW3zh8h/1AvrwPhYpq/F 7MPMbTbI+X+qFVG55tvQ==; 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 1gYq7b-00074H-Vi; Mon, 17 Dec 2018 10:27:35 +0000 Received: from mail-he1eur01on0631.outbound.protection.outlook.com ([2a01:111:f400:fe1e::631] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gYq7Y-00073e-F8 for openwrt-devel@lists.openwrt.org; Mon, 17 Dec 2018 10:27:35 +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=ih6k8hQvbYuF8hhDxK8ygwR+Sy+Dds/dobSt5RAYujg=; b=ERFrhw+gkpWxqBCkr7LIbzXQDtOOWRlNlGp7zu4MRdS98Zg/uqZsxgR0+vZhaJqMQslFAbfGuWpCWDWI3CxIKRBKfReLK65eDLiy+g4TzR/iejMQDGIkhksseWagaVnWJN50CI2WQjrSM4mZ9FDOVrL2W3Z9IlLl2kIej6vdokY= Received: from VI1PR0302MB2750.eurprd03.prod.outlook.com (10.171.105.143) by VI1PR0302MB3470.eurprd03.prod.outlook.com (52.134.14.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.18; Mon, 17 Dec 2018 10:27:16 +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:27:16 +0000 From: Kevin 'ldir' Darbyshire-Bryant To: "openwrt-devel@lists.openwrt.org" Thread-Topic: [PATCH v2] kernel: backport ifconfig ioctl support for class e addresses Thread-Index: AQHUlfMVzHEoSogKc0qe//BlRqQ/TA== Date: Mon, 17 Dec 2018 10:27:16 +0000 Message-ID: <20181217102706.76737-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: CWLP123CA0085.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:5b::25) 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; VI1PR0302MB3470; 6:VVDGtMJPJ6aWpIUG5dWXdtTqs7qlOwo/UBjGSUGwd+2/dFAwJe+cL00FTZTW+rWlr0KfcV4KSe51BVoDFTGsHRaIQEqM8XoMuwdM2HUwkE/RqFszRTq3WBjnL5CEdH2YVoH7rMGnunkjjBofD8/KQYWwRHe6+wu6OVj6ZUFL3DaAfTr8tYAGrt4oC8XXzlR3xw/DU+TZDjKbOH70pE+weZa1zi3oxm+D/MvHc1LbyHmHeGYZUFDl5gD9QJGxu/qHZ5M2y8riUwQbuZTfXHM5fBspsBeC5NRn3TQlkC40/zWRGyT+F/VkfsR6IiBHwXeiqARxrb+bz/CE+CUhhA0AVRJsnt6kpM6zv4wUS5vtsZvgCGyUcTe2jexBlvhYdL32duVIro/4yHx3VnkpnRCRb+C4927nDt+MnH6KWr8kvjP8zddv0rbgLXoaUlwk+fBUmHWtIoXPL6wS1rorJpRCyA==; 5:42AA0jLxr9lmYUdiTVYgUcyGSR4oEXoiRVi9i7qMdx2iI5tkp6j+Z46mX/RQUuK7Kf+kXgRB5xBYfis4+x35Bh80DMteBZp6Opj9uDfasCCYPq6fn/RJ514Je5c3ZExECcNEImmB3AWYY5DDZZuIOqXLskoObl+R417ZCeibuf0=; 7:7gcBrfuYCXD4WdMK+93IjcijZYvKMo7Jp7qzLawT253ySewBy2MwgT45fzZJhFOEtEymndSJcJBkSgOvpmvly0yaEIEqMg7OOrm+YKJt/RiqIRWuYO4XQzLAR+16THVcy6aVhpLqEsMUe2pNEocSvw== x-ms-office365-filtering-correlation-id: 146ef003-60fe-4fc2-8ca1-08d6640a378e 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:VI1PR0302MB3470; x-ms-traffictypediagnostic: VI1PR0302MB3470: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(3230021)(999002)(6040522)(2401047)(5005006)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(2016111802025)(20161123564045)(20161123558120)(6043046)(201708071742011)(7699051)(76991095); SRVR:VI1PR0302MB3470; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0302MB3470; x-forefront-prvs: 08897B549D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(346002)(39830400003)(396003)(366004)(136003)(189003)(199004)(53936002)(4326008)(6512007)(486006)(6116002)(74482002)(6436002)(6486002)(1076002)(6916009)(106356001)(966005)(305945005)(107886003)(5640700003)(6306002)(97736004)(36756003)(575784001)(86362001)(2906002)(508600001)(4744004)(6506007)(71200400001)(71190400001)(7736002)(2501003)(386003)(81156014)(102836004)(68736007)(81166006)(186003)(46003)(8676002)(256004)(476003)(105586002)(316002)(2616005)(2351001)(14454004)(25786009)(8936002)(99286004)(5660300001)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0302MB3470; H:VI1PR0302MB2750.eurprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: darbyshire-bryant.me.uk does not designate permitted sender hosts) x-microsoft-antispam-message-info: GTkUPc1hw+t2t1xiSEewNE0wrW+O7g/2yrNsJiBh/cK6p4+vIrOB9hQhVgC3ExzxMxoBEngOPeNch1dH4me0fg+48/PGSnyfPRfUrHddygUmmItXbUckB3fxrDthePDZi9Y8bz4Uhoy8RPCn9M9vuf6USnc1H7j+ITGabnMe4avWhOnH2h39+kkPWmrtTabhuOqpSHRfxnEQLZy4BOQzmiHW8MhW+Nk6PPu8bSnmC8fAUjF6d9Wn07mqRphTYdDDXJbFVoTIwiFGxUHdpbYhN9grfsgkCsfa+5oaqgnWow69dKemn5ET4sF+t+K8G4kx spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: darbyshire-bryant.me.uk X-MS-Exchange-CrossTenant-Network-Message-Id: 146ef003-60fe-4fc2-8ca1-08d6640a378e X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2018 10:27:16.6855 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9151708b-c553-406f-8e56-694f435154a4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0302MB3470 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181217_022732_819983_A7E0D1C0 X-CRM114-Status: GOOD ( 15.39 ) 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:fe1e:0:0:0:631 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 v2] 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 --- v2 - change patch number ...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/095-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch create mode 100644 target/linux/generic/backport-4.19/095-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch create mode 100644 target/linux/generic/backport-4.9/095-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch diff --git a/target/linux/generic/backport-4.14/095-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch b/target/linux/generic/backport-4.14/095-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/095-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/095-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch b/target/linux/generic/backport-4.19/095-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/095-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/095-Allow-class-e-address-assignment-via-ifconfig-ioctl.patch b/target/linux/generic/backport-4.9/095-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/095-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);