Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753531AbdIFDPE (ORCPT ); Tue, 5 Sep 2017 23:15:04 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:53361 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750880AbdIFDO6 (ORCPT ); Tue, 5 Sep 2017 23:14:58 -0400 Subject: Re: [PATCH v3 2/2] ip6_tunnel: fix ip6 tunnel lookup in collect_md mode To: Haishuang Yan , "David S. Miller" References: <1504514174-14958-1-git-send-email-yanhaishuang@cmss.chinamobile.com> <1504514174-14958-2-git-send-email-yanhaishuang@cmss.chinamobile.com> CC: , From: Alexei Starovoitov Message-ID: Date: Tue, 5 Sep 2017 20:14:30 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1504514174-14958-2-git-send-email-yanhaishuang@cmss.chinamobile.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [2620:10d:c090:180::1:ca20] X-ClientProxiedBy: DM5PR17CA0066.namprd17.prod.outlook.com (2603:10b6:3:13f::28) To DM3PR15MB0970.namprd15.prod.outlook.com (2603:10b6:0:10::24) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e9ce7ae4-e9ea-4896-d3ec-08d4f4d565ef X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DM3PR15MB0970; X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB0970;3:nYIUn7vxFbjICxLvzo+jR1Ibpekk0EG1zTq0qggAe6iFlPBBip1SDvZ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lmIYgbiJ/rCWioiVMdsZef0jbgRqNFsnp4kkSahc5WeVjVXer2KPTMZlJLDANWZRWETO2c7vSkcR39zBGJMiVOvemrcWOYUI4ggkXjdIrvHnhXxH7OhXuSx3Rw7lsCvrqAF0YqD3khRD2swBfUKBoqQv1kEbkWMwqvNTRG9D/tJWnsQu2EwLB3gDLlAPVDR9pl/pXZBfJZq1YNJj1B6W/2Hq95Ic0fflhATcJ+CwbfnVIXPOenKWyBxiCzhlK9y85yTEIJEA4rwJHtb5J27PJivknmxm2ujt1DNCcqxPP5;4:3SKx273ieDKp/y1KoMqNgzwVAJfeY+HqQccLANzq2xSTk0g+gYiBjV5KMEDPZJgdGk3nLLyh/2Yweyl4C1w+7YP5OHn7DWxz5gnQeZd6Qu6soG9Ggm3H3i4t8Fcsx/Fp1w9uO8QJi+Bi3qfwcOyaUVp04wkikryS6HgdZprmlpm96MLclUOOGtgVyox+09gAiaOUNO7iLHZ86ED9+rYbKjsfXRR2GwlF1Pw+n6FeS/LTdm+L/YSe1Qs5m3lBrotnBCDF6Hyn84rwOpiGPf8Y596+ip4kvnfXgrWmMhN1di4= X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(6041248)(20161123558100)(20161123562025)(20161123555025)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM3PR15MB0970;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM3PR15MB0970; X-Forefront-PRVS: 0422860ED4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(199003)(189002)(24454002)(377454003)(6246003)(65956001)(4001350100001)(42186005)(65806001)(47776003)(6486002)(6116002)(189998001)(53546010)(31686004)(53936002)(36756003)(64126003)(68736007)(86362001)(83506001)(97736004)(230700001)(1706002)(25786009)(229853002)(8936002)(478600001)(31696002)(81166006)(81156014)(8676002)(105586002)(50466002)(305945005)(7736002)(54356999)(23746002)(33646002)(4326008)(2950100002)(106356001)(76176999)(101416001)(2906002)(50986999)(5660300001)(65826007)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM3PR15MB0970;H:[IPv6:2620:10d:c081:1130::1001];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;DM3PR15MB0970;23:UG+X3lwYHQlDO/N9CqayXpr/vqfKUivHFeiDB?= =?Windows-1252?Q?68P0OhN31k4wUTJMYTy7dnI6iOHgj8NbK+C8JiUT1C2GjL1NB5vsp0Ez?= =?Windows-1252?Q?bkWMHTuy1IDRMbWGMN6vMUTHEdnK0I3yb3eTT1j9kMv0HsX4PooX0WCk?= =?Windows-1252?Q?XxPCD/V9zoAo6906NJNfhso+oe/LF/GDPR2KDG7bKzCesuII9aRicg2D?= =?Windows-1252?Q?ZUHj1pVPw2vkOXxRrjxeShApPXv4aYJdayQYHIfshs21xtgwPEmEIC4i?= =?Windows-1252?Q?bf0uFT8Lys7K3sK/MAfD4B5t6xdnHQG8C6A9oGTbMpqs50XGDcbELpdu?= =?Windows-1252?Q?/12LG2ev6NBjOV0TCgn8OckZwTfy9B/j+1pHyKwEid9HC73vYB3qHgB7?= =?Windows-1252?Q?3Z6ymaJwdNYjOPxIMkqPtKr1eGdfNwFQfk3TIa4LX0nr9zt39hP4ik+M?= =?Windows-1252?Q?33a3o74X9A2+EhNZkdPc3JAjRO449y1CHvty5HEuWxo4Ayjdf5XiEr7p?= =?Windows-1252?Q?DJ5/dPyISy1dgScETEVNEaNS5viuSRyTg/ynWyhAAG71DBISz6THsIGD?= =?Windows-1252?Q?/VWoJA5ANcyLmGjf8OlLGFHd+3NGx+2vVmEO9lf1nn4QuHVrUYTbmQ2f?= =?Windows-1252?Q?XZtbfTyDBJJxUWLaE4fLcocQEtZptX1DAyolT2ZLshKpTPBe7G8LWj9q?= =?Windows-1252?Q?9EzitSbP7eLpVMqJpNo+pihH2KamKqCMTIdpFreKbFb7B9OrdC26L+NC?= =?Windows-1252?Q?FICAPX80g3PtZ3J7X6ZNTxr4iykiRM3tkjDWZJ7ocy504CCDa3X948Nr?= =?Windows-1252?Q?LRmKXReYwOdb92tYJIhknLx8ed0QMklNQX93U7okugwPOKydZ5wI57+d?= =?Windows-1252?Q?RqBYiuwZ5ap3DFRZkAUOK+wyy40JckvPN9zm+sPQ2DspJZ3Hfd9ToIIw?= =?Windows-1252?Q?pY810lEgXlTvxSSQKP5rEDRYMMIiIiFGwwbbeNBEs46+TKrOxSAeh+oM?= =?Windows-1252?Q?uNPL0S0SEriy816XyBGqz9t8qa+Vw0mDD4KB9YjNXF9t9NbeeZ08hcXD?= =?Windows-1252?Q?lJHVpXWEzr4ZO826rE//j2MiTkRw2PY/g3pDIZjzix5WmqbAZ/WSBC/R?= =?Windows-1252?Q?z+gFff4iiDalNJDoGPtsRDvU0SREYWV4z2VXIlXLGb5JG/iZWcw5bcMI?= =?Windows-1252?Q?gAvPGDsSFK5FzOH8LgeA4PHo0q+MpRlCncKDv6G6dWzWaF898+2vlWam?= =?Windows-1252?Q?ymFHG+c1YHfrUPRErEwbA8sZx1wY73wQx+ctB9XTR/mbs1swa+PSJdO2?= =?Windows-1252?Q?WJN?= X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB0970;6:rRIVirddkHPW+u3USqEs3HOlTvpf1S/8hyjDXeAU1wQ9RctjaYnpSPgAfTSjfMYxktEgmJ2+RZTzGbQ5Sf2FDDfTkF3TMeNXZYuSZsur+oTd8Q8K3df5tONM3uXOcl6fzYah6H/igzdTFaxBYnpRle1E7bHBrCLSBWzx3J5DjHduHmV2pk1KqTIaCY1pjKzYr3Hm6HIQ2I4jZMcgreGTY5leo+/IsORr28kvpEXmTLBHZzbkcER5gv40vBmU6/Jy8nPjR+PNWggxBeycTvgKXbD3N1NxeQUaQ/vOX0Tw/F9iSfi2NgC0rFRjT4dpgLFlzQPAutaxAUym0nGeNsgDgw==;5:zP6U2XmHFaw/OvIZs8aHT9c78Bj33OAUwpQ2Jo29PSo8Y/qxTzWPYru79Ef9St7N9uztcWxvIEtWXGAq1RUGwLdX0AWk0t3m8zBDyFRKdeCRtc1Kq8hzssukazj8xymRgi8nKx836H7zePzDKhdt7g==;24:lSTiQCM951zB/X+Es3LGLOTntFql5U5ZH/ctFaI8j7wGCpH0DfKGXdq+IatOvYGeNjMafM/72/uDrKiGUghbIXcHQ3TNBreUmDXBtzwR5JE=;7:7evb6K1GHTI+Rl2u8YI2zFxfr00Gp4xjq1+iuoqoPlSpZ8r7gqMpq0CaBObsuhKWTfeRzUHAP0rKS4CEcEoAcISHBnrtxg8X/A20Vr9hufch5NkqFV4HNGoczLQTMqWwdQK08bJ7BXTH2ZA3yx5j4khLGUS28ksAq3rsdksYzBPzrB1mU1V4ntgDnj3cGUzifFjWAudPRqapp/Bx84MOc2z2gcE8HYMnKiwFRBwroeA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB0970;20:bd3nudDNKqX4376DZ0sPClYgJ4t63Adykhz8o/w9zT/2dFqEYZ2TL8zyDERTND4+46tmSNkqtWE+UsuxkcEf/ZnShRf/LiQQ5Por/8rGcZdgXELhUh+AkHDlGU0ay66DupYgsRP8NDdf8B2gBnxs+ru4PcY/cjIEE8c09b1ePRk= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2017 03:14:33.5884 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR15MB0970 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-06_01:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1383 Lines: 41 On 9/4/17 1:36 AM, Haishuang Yan wrote: > In collect_md mode, if the tun dev is down, it still can call > __ip6_tnl_rcv to receive on packets, and the rx statistics increase > improperly. > > Fixes: 8d79266bc48c ("ip6_tunnel: add collect_md mode to IPv6 tunnels") > Cc: Alexei Starovoitov > Signed-off-by: Haishuang Yan > > --- > Change since v3: > * Increment rx_dropped if tunnel device is not up, suggested by > Pravin B Shelar > * Fix wrong recipient address > --- > net/ipv6/ip6_tunnel.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c > index 10a693a..e91d3b6 100644 > --- a/net/ipv6/ip6_tunnel.c > +++ b/net/ipv6/ip6_tunnel.c > @@ -171,8 +171,11 @@ static struct net_device_stats *ip6_get_stats(struct net_device *dev) > } > > t = rcu_dereference(ip6n->collect_md_tun); > - if (t) > - return t; > + if (t) { > + if (t->dev->flags & IFF_UP) > + return t; > + t->dev->stats.rx_dropped++; > + } Why increment the stats only for this drop case? There are plenty of other conditions where packet will be dropped in ip6 tunnel. I think it's important to present consistent behavior to the users, so I'd increment drop stats either for all drop cases or for none. And today it's none. The ! IFF_UP case should probably be return NULL too.