Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3435036img; Mon, 25 Mar 2019 10:12:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjvvwCLQNE9m5G53h+QylxCRj0VaAMlhWATjEzq93sQX6bP9eqBB2PV57avJkZ3dddGOzV X-Received: by 2002:a17:902:8692:: with SMTP id g18mr25614694plo.149.1553533959209; Mon, 25 Mar 2019 10:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553533959; cv=none; d=google.com; s=arc-20160816; b=TEtJKFpNgrCWRvKu7j6FtZxpStW2hjVUndlvd7bVdDTQzPqX+9fAWcTfcYXwVTtDvs +0rD/fBXOQkF7p+qEue6jRSXXbRY3m4yznbEZsomyWgqQKUrpQkOAOj7xStjUD70CESF aF1qWn50xa/khQCc+X8koCl14OptTspX/J1zm2a8Bip1oBHp7qPT0CZrlXYKDDp+kbKY Fdmt74pP7EoCfNGdY0dqDaM/5Wx6IxZm0bNwRF6DJVslxXoxpXNLXxH7B2mA8tWBIB+j z9SmufT7bDy8pbd8DYfkgekfj3DRJRPvT29/oOuaK30XF3AVNR6LA8BGYcp59s5GYfya W2KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=xCHitjIY7+ISql4D0IvViO6wlYYJC4JvEJtESj1fiPA=; b=Hovz+wrZEaSfQ8xY4fMoyFnSul9CHqwFobn1Tz9hVkOQuQ9SSXki6Cf7wltj/Ra0PM tDZzgbjQDJBVwR6snkMC44eIjgLc5K69XYCB8Pzi1cHlCP2hCReisYCBAVlIJauCLoou 2WopVZTrrbxfJS/4ax0eHMaAUByklLPVM11j4EKxT9rwZgZ7iz4CoBsO1fhH+9qslp9I cvIdl5mJOENO3AJ39+EhJC54EDfWlSdmXHBuSV/SSLq+2JOvhq6sHYDYYUFBRC8qNooF gXX8MvisqVCAl/sSUnfrYI3nsUfmz/J0IZC5ki/xfC3WqGvZ/L2fZ/vtTXZhSns2VyN4 Bqxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si13734492pgq.392.2019.03.25.10.12.23; Mon, 25 Mar 2019 10:12:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729899AbfCYRH7 (ORCPT + 99 others); Mon, 25 Mar 2019 13:07:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:50798 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729414AbfCYRH7 (ORCPT ); Mon, 25 Mar 2019 13:07:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EE0B6AFB8; Mon, 25 Mar 2019 17:07:57 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 8CB01E1404; Mon, 25 Mar 2019 18:07:57 +0100 (CET) Message-Id: <16ffb1fbfa8f54de587ac52f4ff95e5034c590b4.1553532199.git.mkubecek@suse.cz> In-Reply-To: References: From: Michal Kubecek Subject: [PATCH net-next v5 01/22] rtnetlink: provide permanent hardware address in RTM_NEWLINK To: David Miller , netdev@vger.kernel.org Cc: Jakub Kicinski , Jiri Pirko , Andrew Lunn , Florian Fainelli , John Linville , Stephen Hemminger , linux-kernel@vger.kernel.org Date: Mon, 25 Mar 2019 18:07:57 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Permanent hardware address of a network device was traditionally provided via ethtool ioctl interface but as Jiri Pirko pointed out in a review of ethtool netlink interface, rtnetlink is much more suitable for it so let's add it to the RTM_NEWLINK message. As permanent address is not modifiable, reject userspace requests containing IFLA_PERM_ADDRESS attribute. Note: we already provide permanent hardware address for bond slaves; unfortunately we cannot drop that attribute for backward compatibility reasons. Signed-off-by: Michal Kubecek --- include/uapi/linux/if_link.h | 1 + net/core/rtnetlink.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 5b225ff63b48..351ef746b8b0 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -167,6 +167,7 @@ enum { IFLA_NEW_IFINDEX, IFLA_MIN_MTU, IFLA_MAX_MTU, + IFLA_PERM_ADDRESS, __IFLA_MAX }; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index a51cab95ba64..a72e8f4d777b 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1026,6 +1026,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, + nla_total_size(4) /* IFLA_CARRIER_DOWN_COUNT */ + nla_total_size(4) /* IFLA_MIN_MTU */ + nla_total_size(4) /* IFLA_MAX_MTU */ + + nla_total_size(MAX_ADDR_LEN) /* IFLA_PERM_ADDRESS */ + 0; } @@ -1683,6 +1684,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, nla_put_s32(skb, IFLA_NEW_IFINDEX, new_ifindex) < 0) goto nla_put_failure; + if (nla_put(skb, IFLA_PERM_ADDRESS, dev->addr_len, dev->perm_addr)) + goto nla_put_failure; rcu_read_lock(); if (rtnl_fill_link_af(skb, dev, ext_filter_mask)) @@ -1742,6 +1745,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_CARRIER_DOWN_COUNT] = { .type = NLA_U32 }, [IFLA_MIN_MTU] = { .type = NLA_U32 }, [IFLA_MAX_MTU] = { .type = NLA_U32 }, + [IFLA_PERM_ADDRESS] = { .type = NLA_REJECT }, }; static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { -- 2.21.0