From patchwork Thu Feb 14 13:16:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 158381 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1357038jaa; Thu, 14 Feb 2019 05:16:18 -0800 (PST) X-Google-Smtp-Source: AHgI3IaA7Ld0+ZUd07V4Y8eE4qY2X9SIiAe1WlLtcI4rZnY6nY2NDvMzjCrD4ml4OZ5zEwK9HxFc X-Received: by 2002:a63:200e:: with SMTP id g14mr3754287pgg.235.1550150178219; Thu, 14 Feb 2019 05:16:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550150178; cv=none; d=google.com; s=arc-20160816; b=qBA0l+5W8wDBdz+HxUx478fz1d5M+1fll1U3iPZqKaVovGIzURilTBt2ZngtAUC/n/ NdurtSsZTYt/t74WM4OrtK4qNQGqDVAl7fsHbB7Y66DjxXisnE3TmePbAh2hAge3WnhC JAkBzMsUTxDjrEg1AEoxJYCh19x/pljJL4fqyXmx1WDxbXfgwXSFt1utF57GEimWUZoI syBwLuXdPRCKTDDNq9HWiy39iJrBZWgNkzVmtjv2B5rV72iFEQgz0LHqmpSbHWWpjm9h l64Zlk3Laii5CNIjH1lOB1MA74nswnnIlB5WUTc1MEsi/9j42O+fQ+nLPKo+FW/ln/bF /IvA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ZutH7ifJiZ/RPF+ibS28QIyG2IwMd4T54yOAkvN78uU=; b=wcx+VIp7rAEE+lyxBPf/tB8x940DONdbbpWMYaBYKpmnUH5GrBHEyRVcVuUmG9eWEo TEadkTimKuJBH9wKg+hSoP67eKYY+5q0b8aYQg7/FZcnBglJKnKJj4b+ObpnrALWVN1a zWRmul/pNqt2wqSWQi/dNyDvSkn5g9LoA9q87l6Bp3cYGPx5VUgU8nl1YCtComO7KGUN qny5msQUcKZHRBYeHn0jd2KbDg3QEkuL145N7NcJ1Nwhye93/lkIpYkULYv7/7YQkOop 4gL1qJm9Jof10LmwgsLWZC+xQpxx6JGk5+YEaV6plEwjStK6UeaEmFhqGTV/F9+rX68j 4lFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SJaVQqHq; 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 f124si2588160pfa.1.2019.02.14.05.16.17; Thu, 14 Feb 2019 05:16:18 -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=SJaVQqHq; 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 S2438845AbfBNNQR (ORCPT + 15 others); Thu, 14 Feb 2019 08:16:17 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35566 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729596AbfBNNQR (ORCPT ); Thu, 14 Feb 2019 08:16:17 -0500 Received: by mail-lf1-f67.google.com with SMTP id v7so4528594lfd.2 for ; Thu, 14 Feb 2019 05:16:15 -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:mime-version :content-transfer-encoding; bh=ZutH7ifJiZ/RPF+ibS28QIyG2IwMd4T54yOAkvN78uU=; b=SJaVQqHqGgZ/GQPa/hh9aD8+PnSFn2hEUid9aVNCJKjRFp3RxbsyAiduXAvgBSxNnj 989HdO4Mw7d78wHmgFXZgQAWJcz//KN9cJ2lwasVSwrb4GAhkKY6aDNkSw9X2UuAekd2 bMtuSBWZrgtfpp1CeNF7tW4oVk+lOBlrWM4YqWDop6e7EYoXKhm67/MBNZUYIATSYtL+ k3+sTt74r+xBvW3SxXwB18YIpsKqIZiWbiVXdc3kdDCwHcSuK3uVJmRmXyq3z5O1RlvC tJ6eKLeY3UxYE4X6EeuqQMfqXkxxvu3jb/HozlO8H89zdx/e4UZvWf3gZRMzvtf5lKjx ThiA== 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:mime-version :content-transfer-encoding; bh=ZutH7ifJiZ/RPF+ibS28QIyG2IwMd4T54yOAkvN78uU=; b=TSTl6e5WoOl2vZlpvSuSp3DU0IYpxo2J17FRqGH0B1giTq8B23fjDKB8fw4pSGhrUh YNuYeUUftgP2+YhNa+XjBMSz4uxljox9HBx6gV48cJU0vKPHIcY4KPiwj23B6haJeLHW zSySP+6r7+JIxP+mpExQlgXOvdkA+PNQnA+86Wx2myiTRzZ9K6CiGdwyveVgVTHwoYJ8 1qiUuWKIyg/n/07SwG1qKYCsBiDNnxdkClR8DLwxJHYpAe8n6k103NdxcPyEqctgpvf/ s+zt0fXI+ZPGrx+vs+q4lteKPGeXrIdgFKOF0toIRAJh6OYsVonXI0/pR/01gMHCH7AS qjOA== X-Gm-Message-State: AHQUAubArw3eVxBLI9jT9nIV5XMY16Q6Aw46v1Ma56EyX9W3uJ7jc48p +1+yV9hq2bPvH8qU4oGRebjEtg== X-Received: by 2002:a19:d250:: with SMTP id j77mr2299949lfg.21.1550150174667; Thu, 14 Feb 2019 05:16:14 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id z88sm440258ljb.10.2019.02.14.05.16.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 05:16:13 -0800 (PST) From: Linus Walleij To: Greg Kroah-Hartman , stable@vger.kernel.org, openwrt-devel@lists.openwrt.org Cc: "David S . Miller" , Dave Taht , Linus Walleij Subject: [PATCH v2] net: Allow class-e address assignment via ifconfig ioctl Date: Thu, 14 Feb 2019 14:16:04 +0100 Message-Id: <20190214131604.8107-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dave Taht commit 65cab850f0eeaa9180bd2e10a231964f33743edf upstream. 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 Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Add SoB-line - This commit is upstream in v4.20 - This should ve applied for stable v4.19.y, v4.14.y and v4.9.y --- 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 48e8a225b985..f6052e70bf40 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 ea4bd8a52422..e38042933a27 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -941,17 +941,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);