From patchwork Wed Feb 13 19:31:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1041550 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="czo5gSy5"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4408lx04nYz9sMr for ; Thu, 14 Feb 2019 06:31:41 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394415AbfBMTbj (ORCPT ); Wed, 13 Feb 2019 14:31:39 -0500 Received: from mail-eopbgr10057.outbound.protection.outlook.com ([40.107.1.57]:4089 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2394402AbfBMTbi (ORCPT ); Wed, 13 Feb 2019 14:31:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AV0jpIlpxmBtqTuG5P/HrvuT/2tsC/6yogD8Dc+IZ/U=; b=czo5gSy51VFNVIkSSV3ApaxMkj9epgwKvGONianSaMFZ01UtgGCFMNJJ1H4Xvuue4OhtnySj23nVth88wkRmjd65o0DCae4d3BJcLddlLgHXDDvO0IWOyoCgQd/VGn88pZgsG84xNLaPuOER7049lkrGecJ+wHMDBJiYDw1bnuY= Received: from VI1PR05MB3247.eurprd05.prod.outlook.com (10.170.238.16) by VI1PR05MB6061.eurprd05.prod.outlook.com (20.178.204.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.21; Wed, 13 Feb 2019 19:31:32 +0000 Received: from VI1PR05MB3247.eurprd05.prod.outlook.com ([fe80::210b:6763:af21:4f43]) by VI1PR05MB3247.eurprd05.prod.outlook.com ([fe80::210b:6763:af21:4f43%6]) with mapi id 15.20.1601.023; Wed, 13 Feb 2019 19:31:32 +0000 From: Petr Machata To: "netdev@vger.kernel.org" CC: Petr Machata , "davem@davemloft.net" , "kuznet@ms2.inr.ac.ru" , "yoshfuji@linux-ipv6.org" , Lorenzo Bianconi Subject: [PATCH net-next] net: ip6_gre: Give ERSPAN a fill_info link op of its own Thread-Topic: [PATCH net-next] net: ip6_gre: Give ERSPAN a fill_info link op of its own Thread-Index: AQHUw9K5dpstWc49J0qciAUnagKJgA== Date: Wed, 13 Feb 2019 19:31:32 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.4.11 x-clientproxiedby: LO2P265CA0280.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a1::28) To VI1PR05MB3247.eurprd05.prod.outlook.com (2603:10a6:802:1c::16) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c0ef7752-0f8a-49e5-d2ed-08d691e9dbd6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB6061; x-ms-traffictypediagnostic: VI1PR05MB6061: x-microsoft-exchange-diagnostics: =?i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25QA0jUrv7F9qbrAT3o?= =?iso-8859-1?q?5t4dPMHKQX5T9jJzGuKNyfAnGBUXrw1UNyBY/RsRmoSIOg/JtB5?= =?iso-8859-1?q?X41sy2BtH84xh1XT15LzR7U+9U1B8dYkbksAdr52NWGGDJhHk9E?= =?iso-8859-1?q?f+BJq/ebxkcqvSXFJ1DvAetLyOoiEu3yMw1G0BGLYRS65zct+rC?= =?iso-8859-1?q?VilS4cWlHXTczf+wiDnO+sKOuU+EKmIT1o3opPJUyaChUWiflsw?= =?iso-8859-1?q?lqUov38jC26r7T9ldnnr0E76YWgfbt/ttppA0bHYI4uE/msy1XF?= =?iso-8859-1?q?2TH9I8WDDJsvmPERPRA5k7hhVnfypGqDmrj+gk1E5D8Yl59Pvj6?= =?iso-8859-1?q?pAjrij7Thi1va1mTuzabNGL3hjhVqhgiOCCEk/UFmn1/7ZQLaea?= =?iso-8859-1?q?m2IhxuNYu8tMcstW8OuG4+8JdHl49tA03pjgm+6c7f+6jBixRwf?= =?iso-8859-1?q?wXNGqDzwQ0gnTu2dw=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 094700CA91 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(366004)(346002)(376002)(39860400002)(199004)(189003)(25786009)(5640700003)(50226002)(6916009)(6486002)(99286004)(7736002)(52116002)(186003)(386003)(6346003)(97736004)(26005)(53936002)(4326008)(3846002)(6116002)(102836004)(54906003)(6512007)(6506007)(6436002)(2501003)(316002)(2351001)(36756003)(71200400001)(68736007)(105586002)(86362001)(476003)(2616005)(106356001)(2906002)(71190400001)(305945005)(256004)(8676002)(8936002)(14454004)(478600001)(486006)(1730700003)(118296001)(81156014)(81166006)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB6061; H:VI1PR05MB3247.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 72N0/l8vbJc0UyMcwfqp5Aey9GOEm9Rqy4UByfcHEZ13gATgv3FClYTTGvqwRX+bSbvj++ytFelwn5yopbVeCaDIxbTk1zO7uuLvh00Mz6OO5m49KmWpzMx05m1fJI7v3xw0x4X8kMiuEUPTd5R5kURZfShQ16VDAOgJKqqZuf4PXlc6r0MBMhlotO3JuiydUUQDccLSgXBgTbw/Y7pD2sAyL0Q/jp5YuOGlqdsyrZY5sGR5Z3K7l5DAjOFX6Y3ROa4f3U3hHPDR0wqovU4suUB3axtdG1yQnHl+xAFmO4TWPmcZmVkR63wirl+YhFtL1AO1s33DRLGoMJ8HtVtYMjrD7xYVxgCRK9/c9JYcus2lMTamkxzexhjdRa2lBoRyJTj8HVxukcxTMTehL/Sbbh4vKFwojmeVdjFdH+/Uxhw= MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0ef7752-0f8a-49e5-d2ed-08d691e9dbd6 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2019 19:31:31.4145 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB6061 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In commit c706863bc890 ("net: ip6_gre: always reports o_key to userspace"), ip6gre and ip6gretap tunnels started reporting a TUNNEL_KEY output flag even if one was not configured at the device. When an okey-less ip6gre or ip6gretap netdevice is created, it initially encapsulates the packets without okey. But any configuration change (even a non-change such as setting TOS to an already-configured value) then causes the okey flag from the reported configuration to be circulated back to actual configuration. From that point on, the device encapsulates packets with output key of 0. The intention was to implement this behavior for ERSPAN devices, not for all ip6gre devices. The ERSPAN netdevice should really have its own fill_info callback. Add one. Fixes: c706863bc890 ("net: ip6_gre: always reports o_key to userspace") CC: Lorenzo Bianconi Signed-off-by: Petr Machata --- net/ipv6/ip6_gre.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 65a4f96dc462..0a6087cffe54 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -2094,15 +2094,13 @@ static size_t ip6gre_get_size(const struct net_device *dev) 0; } -static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev) +static int __ip6gre_fill_info(struct sk_buff *skb, + const struct net_device *dev, + __be16 base_o_flags) { struct ip6_tnl *t = netdev_priv(dev); struct __ip6_tnl_parm *p = &t->parms; - __be16 o_flags = p->o_flags; - - if ((p->erspan_ver == 1 || p->erspan_ver == 2) && - !p->collect_md) - o_flags |= TUNNEL_KEY; + __be16 o_flags = p->o_flags | base_o_flags; if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) || nla_put_be16(skb, IFLA_GRE_IFLAGS, @@ -2155,6 +2153,11 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev) return -EMSGSIZE; } +static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev) +{ + return __ip6gre_fill_info(skb, dev, 0); +} + static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = { [IFLA_GRE_LINK] = { .type = NLA_U32 }, [IFLA_GRE_IFLAGS] = { .type = NLA_U16 }, @@ -2256,6 +2259,20 @@ static int ip6erspan_changelink(struct net_device *dev, struct nlattr *tb[], return 0; } +static int ip6erspan_fill_info(struct sk_buff *skb, + const struct net_device *dev) +{ + struct ip6_tnl *t = netdev_priv(dev); + struct __ip6_tnl_parm *p = &t->parms; + __be16 base_o_flags = 0; + + if ((p->erspan_ver == 1 || p->erspan_ver == 2) && + !p->collect_md) + base_o_flags |= TUNNEL_KEY; + + return __ip6gre_fill_info(skb, dev, base_o_flags); +} + static struct rtnl_link_ops ip6gre_link_ops __read_mostly = { .kind = "ip6gre", .maxtype = IFLA_GRE_MAX, @@ -2295,7 +2312,7 @@ static struct rtnl_link_ops ip6erspan_tap_ops __read_mostly = { .newlink = ip6erspan_newlink, .changelink = ip6erspan_changelink, .get_size = ip6gre_get_size, - .fill_info = ip6gre_fill_info, + .fill_info = ip6erspan_fill_info, .get_link_net = ip6_tnl_get_link_net, };