Received: by 10.213.65.68 with SMTP id h4csp2119057imn; Sun, 8 Apr 2018 20:10:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SUa9/BxrjAHdWM1Qy9X11m0I9y9lN5LzZFUNuhkysNcJwz2NWAb4xEML9znnbMGqDbvZ8 X-Received: by 2002:a17:902:a589:: with SMTP id az9-v6mr36625277plb.283.1523243345107; Sun, 08 Apr 2018 20:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243345; cv=none; d=google.com; s=arc-20160816; b=NdAvbKSwYCE+kcP5dVV09YiUR5JwWJTi1KSLQVBLENrz2oZ5GpWuF6Iz/9ZGWAdVWb 8ES0QqxBsGLEIBUx6XDql6qnWToi30paWsCcX6oxUlC/D/ll1YNzO1bjpV1I4xk3/WxW PfGHYxDSkBvMnj+85par/NUBBGA0caYUty95GhQwr0gMsXeiqfO9R4wQyhegzH0s3vtS 9DQQiSRuJUlqacHrI4jI+V8etzgZ00JR388uqVN9Wg0UoXin7DVIB31+7tGzSqrkrHsN pE0Wa1mOn8q+0WbK0vbnN0Qiqa3pEG6fSHOHg/bczZzYp7FupiRImDZxje63uoKoPGi0 oOcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Vv/H6jq921iehr5zdOvywnHgpU3bFrSrMHhkwbXCab8=; b=w+G1Yymm6dFjioE/PrlrRDx3MdURXO9t8OIyIH8pPrSm0/4OBmh8I8hpSQ+4IbhLLG SXitJbXFwEgGZWQInBPUBtuIb117uQznHyIzxQ3F6+2a7iaS0gipBrdcr5kSNUDeXDtF TC5Vscm7slGh0n3dg8TamULlAXj7uueUfIGo4jki2iD2uWndChrn/HFsIQHJTa6Y8qcY anomm3D3IzB/yfDsLevsfOFS5AVN9w8LcgTzE+uBKb5pQ80rjUkUdK/Y5Slx2aUYjH9K J9e+TjbLMCbVtfqK8AQnUBodUedAS6Li2yJuCU3WEZhn8xSn0ne/5iI0NUDjSZ8NK54q wT0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=cEEZVX6X; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i196si794661pgc.625.2018.04.08.20.08.28; Sun, 08 Apr 2018 20:09:05 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=cEEZVX6X; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932619AbeDICTz (ORCPT + 99 others); Sun, 8 Apr 2018 22:19:55 -0400 Received: from mail-sn1nam02on0125.outbound.protection.outlook.com ([104.47.36.125]:10314 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755136AbeDIAaS (ORCPT ); Sun, 8 Apr 2018 20:30:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Vv/H6jq921iehr5zdOvywnHgpU3bFrSrMHhkwbXCab8=; b=cEEZVX6X2/28Ul4OmOGr3a9eKIA7WeudjZvpCkWvbxEqeFJQGT8a61i6GL91JeHMdth080ihe9DfdA8vu0bKtjGiuYV0VH2O6qCozLDEWlZL8Zg3af/OCx1Oo+qCw8Vr6EUlkri5vB3bY0BUbZhC9ykkouz6/ZOmTtHLZke2IGg= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:30:15 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:30:15 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Serhey Popovych , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 123/293] veth: Be more robust on network device creation when no attributes Thread-Topic: [PATCH AUTOSEL for 4.9 123/293] veth: Be more robust on network device creation when no attributes Thread-Index: AQHTz5kfDTIZKlAdIEy5UvVCo2fFjg== Date: Mon, 9 Apr 2018 00:24:28 +0000 Message-ID: <20180409002239.163177-123-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1032;7:xKoX0BU1wgQToa6edmZHa8XdN0UtkyuZj7FzSttEAzgc/vw4hwnz/QLRIGUvveucZMxNuTFYgLfxrJO9o2Bu/prPt4bHHA93pD7q5TFb0/jdD2sL7Z0b0x8LlgvSkDqkraKuPTPhYHGpR0RQBBLxUVDIarjfEuwtyWTxL21ZMql5VQkNTVUcLTDlNtA46GdhJHgm2/UufIf9XtKbv258AUpOA/GU05ZNyNDYBareiZwm/2lV9jCLQ98qDaKy8N6a;20:yJY6ATbsSyfa+DZNyhKXKu+3Uo25NLgMFbrvkSLuTTTgenNp/hYTNE2QPLUkdxu1bSrAhHtqWLnL/Hu4g7yLI7ip94XCDhcpm+djOnqCBkoGif9Se3nFZ2/VxK0kxlHBgfCF/iTUzt6VVGI/CuUsbTKyGWvoGSP+esuugKgJt+4= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: c834a844-5456-45d3-f4e2-08d59db1103d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1032; x-ms-traffictypediagnostic: DM5PR2101MB1032: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231221)(944501327)(52105095)(10201501046)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB1032;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1032; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(396003)(39860400002)(376002)(366004)(189003)(199004)(5660300001)(76176011)(99286004)(10090500001)(2900100001)(105586002)(305945005)(7736002)(107886003)(2501003)(5250100002)(14454004)(53936002)(4326008)(8936002)(68736007)(25786009)(86612001)(3846002)(66066001)(1076002)(486006)(316002)(72206003)(22452003)(106356001)(186003)(97736004)(6436002)(6116002)(476003)(2616005)(39060400002)(478600001)(6486002)(10290500003)(2906002)(110136005)(54906003)(6512007)(81156014)(81166006)(8676002)(36756003)(11346002)(3660700001)(446003)(6666003)(86362001)(26005)(102836004)(3280700002)(6506007)(22906009)(217873001)(357404004);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1032;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: oRrMrEk9ry+fUtqlC8PSzjgXD4Zx6Z0Shx/jb/GWAk8xQm+jw+W09/akrZ0HNTePfKRzbfptG5EkqXpoqPnqodfwGOmdOP4I98RtTPI6QyUs/TWQ+RH28rBlaKG1SQ1DhQS+czp3LfAxsTHtOPUQOoIFbwzsOnn8OufsWW7kdF+SIaItVUUwthko2sx/AOp36CbBIMhXDRlUgcTHis2r3zYTgW/pIQK19DCRDIR/CfK7GqsxX3zLl2Jmo7KlP8pEvNn6RDVjh9+tYs+jEd6NWpqzPwxFhcTnwc03m7KIP4LrwQMZslbcPbX1GuoOPqwVdRUDCjGUMTTOqhQoBWFQWPXlSEx5nLPd4+D3xn6XtwyZGmhtr+G+wM646sMBSv3xJWphz/uuwTCwoXjOdhAmnPu/iuoH9giNt1OFKZ/iQ0Y= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: c834a844-5456-45d3-f4e2-08d59db1103d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:28.7688 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1032 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Serhey Popovych [ Upstream commit 191cdb3822e5df6b3c8b9f8cb8c4bf93f6cc90c7 ] There are number of problems with configuration peer network device in absence of IFLA_VETH_PEER attributes where attributes for main network device shared with peer. First it is not feasible to configure both network devices with same MAC address since this makes communication in such configuration problematic. This case can be reproduced with following sequence: # ip link add address 02:11:22:33:44:55 type veth # ip li sh ... 26: veth0@veth1: mtu 1500 qdisc \ noop state DOWN mode DEFAULT qlen 1000 link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff 27: veth1@veth0: mtu 1500 qdisc \ noop state DOWN mode DEFAULT qlen 1000 link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff Second it is not possible to register both main and peer network devices with same name, that happens when name for main interface is given with IFLA_IFNAME and same attribute reused for peer. This case can be reproduced with following sequence: # ip link add dev veth1a type veth RTNETLINK answers: File exists To fix both of the cases check if corresponding netlink attributes are taken from peer_tb when valid or name based on rtnl ops kind and random address is used. Signed-off-by: Serhey Popovych Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/veth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index ee7460ee3d05..06b2b1484bbc 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -400,7 +400,7 @@ static int veth_newlink(struct net *src_net, struct net= _device *dev, tbp =3D tb; } =20 - if (tbp[IFLA_IFNAME]) { + if (ifmp && tbp[IFLA_IFNAME]) { nla_strlcpy(ifname, tbp[IFLA_IFNAME], IFNAMSIZ); name_assign_type =3D NET_NAME_USER; } else { @@ -419,7 +419,7 @@ static int veth_newlink(struct net *src_net, struct net= _device *dev, return PTR_ERR(peer); } =20 - if (tbp[IFLA_ADDRESS] =3D=3D NULL) + if (!ifmp || !tbp[IFLA_ADDRESS]) eth_hw_addr_random(peer); =20 if (ifmp && (dev->ifindex !=3D 0)) --=20 2.15.1