From patchwork Thu Feb 14 10:24:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 158340 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1172989jaa; Thu, 14 Feb 2019 02:25:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IYzJKhDUzXlucphkYLhfSH+FapcehMa4v7GBJkwZDuoIEDFwkoURpccBkIVleB/zXCHHWK+ X-Received: by 2002:a65:6215:: with SMTP id d21mr3029711pgv.289.1550139944893; Thu, 14 Feb 2019 02:25:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550139944; cv=none; d=google.com; s=arc-20160816; b=tuWYPzEZvUII/J85r44bv/NTVQtHCZto0au86FkEVOklWauEAL0IPDzrNTcdjxAl/0 lZ/abMRQKN/4a8XpSIFyMBqsNu7BifGNdvAqPy2dvE41REUUXdg5iGs/XoEGA1S3yyNg wQWjFcc+lrbtIBgO4Eb5zLPPbwHIPl01Qw89PEnzCY8lOhkz1M++kNlebNHIcIE1unn8 o5qd3SV0lzRgSFiOW//HDQo6regbfXK3bzkE1Lg6cyHN5+JvsZ0Nbg2G53By8HHAm+jg U7qwcYNQWRCJ2nyHlUnPTUGHsSM30uE+Mebf9LcbirvSn2PkUS4SGgyVEh65zptD+yHL eclg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Dz6xtFHT/2/4X/iK6IHqnPMEHnCcKqJxd8+wIE+5pc4=; b=hjRRJrcVQ6UO3pRCaJ91Ve7lv5KqDVfiYOMNZTqcjLrh/nBdGrCu7GE/4tTkaHns+O rkhfp62HsPoc3/xIHkTk8mUWSI+9jePhO1khFxzBiT+xHtk9Z8YcxIALEtWmf1RmTV4e rkiY5GUBe4La2ucuNYsZ3qNDN0YfUNpZmTve+zKj8ygxNrLCi6LLZIl4A1Ttxw+Lr9UK BraZHsrneNiBLyVXODW0jknfcYiKud+1wnk8Nfs52uuUz1C2nir6XIFRI5gWONtTgqpc wPb9IOpYSWupTjjdWsv+rJyCmJTnMyYNZz5AcZN3BarFmrAXD81nthYPI1op0JxaeF33 +gyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="b9Ymec/7"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si2132062plv.258.2019.02.14.02.25.44; Thu, 14 Feb 2019 02:25:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="b9Ymec/7"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391286AbfBNKZo (ORCPT + 15 others); Thu, 14 Feb 2019 05:25:44 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:37076 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389001AbfBNKZn (ORCPT ); Thu, 14 Feb 2019 05:25:43 -0500 Received: by mail-lj1-f194.google.com with SMTP id r10-v6so4751695ljj.4 for ; Thu, 14 Feb 2019 02:25:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dz6xtFHT/2/4X/iK6IHqnPMEHnCcKqJxd8+wIE+5pc4=; b=b9Ymec/7Kpo82XIGwRLY9+SsG7TTapb/VKHeG9NvWtEugpPoPrZWY4Rsi3CYvk6QLS tWJKpkeknTAeHWz2XygxdZhhB268cepnKPdM9knpOJYlp0Rmcj4dq9N5tfKYhzk60u5O K0o3uAG1PxSKuW8ZxhKe8cuR3uJeXbKw6TVj6aSGaNYdEBYdwssyuGT416reWOzhWZJz RaQtPQyvxIsnxL6N3wyOIjd/uYFEEA1w74fuIuaEsw+U3Ct7G8TTQz7fktS9hV7OKqx9 YW7NmqyRC2CxQPiAUfl3RZVx68SlQ6TyPAqBB0scmzhg+2VlZ4URfRUDj/aAyqex+QIC tuhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dz6xtFHT/2/4X/iK6IHqnPMEHnCcKqJxd8+wIE+5pc4=; b=S1gTTzhH6UiTzizFAzr/oLhK7eoQpjZDheKJyIC0Q2doYn4Pwr7qsxmSjXzgAEWd2z AlKK/yjbddcS6QXpePLqq9NB5wLBW28DdT6fMtWEvjKh3t0HcuOIHU0vWBt4gA2o69Yq tiIbzsjnDsqIf7DP57vjlcOexTCjSifi5hFhoNgWYYkpRiArPjoOSqDDnP2+Dvbqn3lg 9LgHsUS31UMyL7kdSBa9cZrGjr1oNno843tAXasZDwHIZ44EEaN+gVGRur4oa+uGCTWM GnY2aq/U+TOSPOaS7s/9Y2mX45Rt7T5sDpukj7q/vTIIAb4KynPp4AoNSJOtWUSwPK7V BwVA== X-Gm-Message-State: AHQUAuZ4/c8kSuFCqRMx69Es4km/5aZcpunuGbzTKJ/vQHNeYRy8+Efx Mph5lwUE1IvEmpRIV7fj0wi5+Q== X-Received: by 2002:a2e:9e0a:: with SMTP id e10-v6mr1780921ljk.157.1550139941409; Thu, 14 Feb 2019 02:25:41 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n189sm380392lfn.82.2019.02.14.02.25.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 02:25:40 -0800 (PST) From: Linus Walleij To: Greg Kroah-Hartman , stable@vger.kernel.org, openwrt-devel@lists.openwrt.org Cc: "David S . Miller" , Eric Dumazet , Hauke Mehrtens , Dave Taht , Liping Zhang , John Youn , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , James Hughes , Felix Fietkau Subject: [PATCH 09/10] net: Allow class-e address assignment via ifconfig ioctl Date: Thu, 14 Feb 2019 11:24:35 +0100 Message-Id: <20190214102436.5092-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190214102436.5092-1-linus.walleij@linaro.org> References: <20190214102436.5092-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: 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 Signed-off-by: David S. Miller --- include/uapi/linux/in.h | 10 +++++++--- net/ipv4/devinet.c | 5 +++-- net/ipv4/ipconfig.c | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h index eaf94919291a..550b234be4a1 100644 --- a/include/uapi/linux/in.h +++ b/include/uapi/linux/in.h @@ -264,10 +264,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 f08f984ebc56..32335ed0e9fe 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -898,17 +898,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 d278b06459ac..ecf19f7ab5fd 100644 --- 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);