From patchwork Thu Feb 14 12:22:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 158354 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1295089jaa; Thu, 14 Feb 2019 04:22:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IY9425qNYyGbwRq7Dz9ddIcASyg+04OOVvObfOvHjBELtrQUOkwSchxTPR4xV1M9vFScN3c X-Received: by 2002:a17:902:7c83:: with SMTP id y3mr3867876pll.260.1550146976005; Thu, 14 Feb 2019 04:22:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550146976; cv=none; d=google.com; s=arc-20160816; b=EuFywF3OH7hoiAtyEWRUV5j6rNatVUHp0cH9yVZQ4th4jAaq1wrb+DiObOqP5BMhYn xo8Hli5O6A6mwoGePOlFqb93fswKVyiVg1hK4As1jwwvr5u9Xr1wq4hd3BDl600lt/EB ejOV0dKyzy/wTULjVJfJ5ewdaIzXje2Y2Ijuji3Aubqdp+6qZrNZCFop4U4jtwjym9ks yRr4j/jm6BrFp3LFSdEXlGzy+oaTBdBoie4Rb7eMWraO9960zmu01JVC3M8AGMJsuu+F y4Q4BkrYYpU9iTpFVIK6Kse71g4aSoyB9yymb+ni66RJEz4RvnC2rK09/2ikFbOhcXMH 8pQA== 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=kHy3Ud5DGgiT0eM0ywA3z+f2qEn/yFfoWLPgpiEbbOk=; b=akYxyWblizH7HtiQISKIcn7PsMRIvTJO4PcYF4QAiPV96abG6fenWe3DXY25x8CN15 ZKOgRaCsN9t4G0fTZEiQU8bKDxsg9Agj8DLeLs+D5PmqMXGGUe0oHwP2Sdao+d2eGe8H YceDIqgxUg0Wz4gJpJsWJyeHq2Qt9pPYGv54efpaSCLEwkOwLwWPr96aI79tabeg0C4P UjstlrAGaSDA4yoXfADtOq387vMwDz4qJ9RsnbgESZ63Zh/WKz2mDxeDFDBCCuuzWX+W vmRxbWaDFZOxat2i7IQZzyBnWxKL0sqMjaL3sdAuzBdONnyOslgorByHXocns+Fy1Lf7 p5SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xMUTLvO7; 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 k123si2328152pgc.280.2019.02.14.04.22.55; Thu, 14 Feb 2019 04:22:55 -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=xMUTLvO7; 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 S2390049AbfBNMWz (ORCPT + 15 others); Thu, 14 Feb 2019 07:22:55 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:38633 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726485AbfBNMWy (ORCPT ); Thu, 14 Feb 2019 07:22:54 -0500 Received: by mail-lf1-f65.google.com with SMTP id n15so4393038lfe.5 for ; Thu, 14 Feb 2019 04:22:53 -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=kHy3Ud5DGgiT0eM0ywA3z+f2qEn/yFfoWLPgpiEbbOk=; b=xMUTLvO7yiWyyfgr2RXu8JQ0IMnPhlxgnhOdULroPPpU8hGp9mKozcFhvLHoaSL9rc ttondtc7VPlXtv+hbdwH/BvBtb0iyTrwPXHkvt/5yqx1IxEHm/z1Di80kLEuXANuBB03 kRGFkatFV48JGPsJaQ0NyY9qDrcfuYHy3r2TTvbzH1Ij+SHR6e5AsfKD+rsUFjUgRA0a PXpIYz+WGHCIV4Ky39kufqcZlbE+Kdufl/S8+dtMq3YIcZ57OzOPQipsBhqCQu6yaTPd ybTJKyudhmCnzf2CJ/RQ4nns57ACmAnqBE95iOzJa68k3YNG2L/IvJwx+jP0bEfBy5sp ++nA== 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=kHy3Ud5DGgiT0eM0ywA3z+f2qEn/yFfoWLPgpiEbbOk=; b=EtwyLlR0EF89oNaZ3HfkJV87l9zTEcfAORxfX96Pyoyb4HS9L/Rn2/Ii4EJFIcXEup dRcwMQ1AyUsWs/NdXo4Ivd6672xOgTLusBx4+3FyJaQRkzEgv0G9LBbe71rEyUjyuAFp 6kP8kI/63GAgMWURmAjhLmY4B3IDIXMvfwyL8qVo0R5cXai4SOrUXPPBMf1KgfxPtNal lcy0OyhaQ6IMD6DuCbviUQNh9P8mXjvynvo1z/M0KXSnw7i+FMpiiKczEKMZFRupklj/ +d9sh5HYNrUYnsiVr2uIxcefrLVz/qNlCyeXCSbLk2o1zf0yKM7+QxEorJAw+DJBnWO+ jqsw== X-Gm-Message-State: AHQUAuZC/4UHXurLCqru6wHSaGuoaFGSRqsveEsZCKnk4zpL6Rt1acGk nzr+KkA8nT38PES/wCN1qYTKxw== X-Received: by 2002:a19:5504:: with SMTP id n4mr2246533lfe.43.1550146972865; Thu, 14 Feb 2019 04:22:52 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e9-v6sm401705ljk.92.2019.02.14.04.22.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 04:22:51 -0800 (PST) From: Linus Walleij To: Greg Kroah-Hartman , stable@vger.kernel.org, openwrt-devel@lists.openwrt.org Cc: "David S . Miller" , Dave Taht Subject: [PATCH] net: Allow class-e address assignment via ifconfig ioctl Date: Thu, 14 Feb 2019 13:22:44 +0100 Message-Id: <20190214122244.25796-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 --- - 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);