Received: by 10.213.65.68 with SMTP id h4csp2114616imn; Sun, 8 Apr 2018 20:04:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx494zlAtwbB33ECH3yWeaa3fT9i6acKwVWg/54bTyhNKr4E+tYGQFlTvWrZiQwhicjpxmQfS X-Received: by 10.98.93.141 with SMTP id n13mr27776576pfj.10.1523243096562; Sun, 08 Apr 2018 20:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243096; cv=none; d=google.com; s=arc-20160816; b=bndXiNHGUe6Tyfx4PgZWCehw/M6juuaVGbT4XUaU9H6i8L7xC1v+q7ZtTVxxaAtb1i i/AKbFokgz6RooNd8are44B5pVAodNY3ZObgj9mlzPaUcQq6Fyvww2hNooq/I7peJmXU GYtpxzWcUNR68eXoUqyHaYCimKEpkXKUzFoH/WjvbbWDCREy83GgeAO1a5MRYPKUkmu/ VFwY2egSZJDl6quCXgXxXbIq8Wsj8vkN2bq12eMBH3ccChHGs48ltfpZKeh7Zxu/yY1K FJ/56O+I4OQ7Df1stl6uAwnSZ0SZquwthqBoZuQd9MCkwR4ATzzj3DuXhQ2kT9Ti1ZjM 1vuA== 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=y+UZXJhKbGCcwoKYTE185RMmkw611rJJv8vg2a4iDPc=; b=O2yKUEKCRL8o4G0VHlJNtxdBJpseFqk6m1OokTLfovAV7YV4tgry/EuXr7Sq83MjxH ip0/S9cimgm0vKk/NFsiZ/A781/rCeoS1Y6ZvZdsW2DMcHhwZAM06IaV/ooEhj7TgCca lkn9HqNUwZWTGQ2xlHNugvssevciDR54+5SSJUY7Uq6WdvNbDArFy49ZNr3E+1UjtUwM WSsGDGqJBrieWDq1ls5g5YppQO7Ti2ZuR+Y8OkuNXtmY7FeZ0w2pdspKK4ytmojUez4Y bO+41QTxQA2aNoci2bg15WPu23592eXnz/9wfmyc8mAu1H65I9lS8ok1I/mExavEwFMd xK5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=TlQpO3v5; 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 k3-v6si13581261pld.221.2018.04.08.20.04.19; Sun, 08 Apr 2018 20:04:56 -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=TlQpO3v5; 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 S932701AbeDIAgz (ORCPT + 99 others); Sun, 8 Apr 2018 20:36:55 -0400 Received: from mail-sn1nam02on0127.outbound.protection.outlook.com ([104.47.36.127]:39469 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932682AbeDIAgw (ORCPT ); Sun, 8 Apr 2018 20:36:52 -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=y+UZXJhKbGCcwoKYTE185RMmkw611rJJv8vg2a4iDPc=; b=TlQpO3v5VjE570Tswk4/YJRHv11DyqUxu/F8d4uThT4tw/MlXh6bdzGAc458XgHKpQA9U6ZXBp96RML6EJLahXg8M5uzlfGbyrYJOLORdgL7OjuDDuKdwCnovHV8IjMWv8XtD2ExNJQkcu2ZcNhr9SNYHKw+8aDe3owl4EkA9Ro= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0885.namprd21.prod.outlook.com (52.132.132.154) 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:36:47 +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:36:47 +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.4 066/162] veth: Be more robust on network device creation when no attributes Thread-Topic: [PATCH AUTOSEL for 4.4 066/162] veth: Be more robust on network device creation when no attributes Thread-Index: AQHTz5mvC+PefVibSka45X1PzmkMSg== Date: Mon, 9 Apr 2018 00:28:30 +0000 Message-ID: <20180409002738.163941-66-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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;DM5PR2101MB0885;7:LVyXIENzVmICuIAKw8sHjptYO3A69k7iqLrFYFTQml2OQnfC8l3ipcjS6JtPaFnEBdwUJd92aJk46+6VYA3jsxa00lJZGUKyPPQ0srj2wnamq/oedyp/rtDq4skxhWF1NS10gZM0DsO48dGTWtTHb29I4nvXB/RgjAPasrHi98Tj6vi0t7ljZmwOVYXBZoZu+01BzymYFpLPpQil6wP6FK+VK2+tr2YK6ZoSvJ4NMqlbvNbagRFNF41ftRYJZo0O;20:nj8Fy8oWE/rpYwC2clXj+zSyCp5ynNDiMnwKcKLFOAbGoiefa2Z3bgtB5y42NrOO0VjAnaweELIQLhaweS8M6TnhAmbr5eN3eiyRkMFLkoMCWhvNZQlNu9/7qI2wuopEmVGNZO9342xiJg473J/6mk3MxZYwofdSaAqv7Nt9c/4= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 442e2629-7264-4bb1-7326-08d59db1fa26 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0885; x-ms-traffictypediagnostic: DM5PR2101MB0885: 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)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0885;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0885; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(396003)(376002)(39860400002)(366004)(346002)(199004)(189003)(66066001)(39060400002)(3846002)(6116002)(86362001)(305945005)(10290500003)(6436002)(5250100002)(3280700002)(10090500001)(3660700001)(6506007)(2501003)(107886003)(446003)(53936002)(11346002)(2616005)(26005)(76176011)(7736002)(478600001)(476003)(81156014)(25786009)(8676002)(81166006)(186003)(8936002)(4326008)(97736004)(102836004)(99286004)(14454004)(36756003)(6512007)(316002)(2906002)(22452003)(68736007)(54906003)(110136005)(486006)(6486002)(6666003)(5660300001)(2900100001)(1076002)(72206003)(86612001)(105586002)(106356001)(22906009)(217873001)(357404004);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0885;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: cJRySXonMoXjuMp5OsgtSkE5UrJAxb8Cl1jdblCqN0+jqioRFA5ee8aXG1lCuK4ZO0BhgEZ5a+1QLvIPjU+EeklR46kww/PBo374UP886ChhZurOdkGvcGvYUFoecflmeZmwDqztL8wfgnH3BtIpe/Ghv4ng6H0gygKtSYh5eXMAgxAPdOtGKDlGzo1A7L1x134oSlihwgzB2yxeLBE6dtn1Eg+VW1l6UiT/wEmG1bl7ZrRAIhuwYd3ArX98h+oP8UIRAR73rSWnKYVwV0n+1I1tE/UMHLU7n6rOwKl9kJDOP9mQaCQ8Y+bGq4jwKAC/QVxs/4M8xDEyGiir7tM1/suCP1IP75f1gD7BTWlP9kspwUqFNpR3IcnfLGvLwmSfxWqH4w0nGD5Xx5Q3vbD8/2RD3T76o6ush3HpHiINm3Y= 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: 442e2629-7264-4bb1-7326-08d59db1fa26 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:28:30.6770 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0885 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 6b4cc1c2e6b4..5446a1b6480c 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -374,7 +374,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 { @@ -393,7 +393,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