From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH][net-next] net: slightly optimize eth_type_trans Date: Sat, 17 Nov 2018 17:19:34 -0800 Message-ID: <4c39a882-2d58-f258-9bd2-df0b2540be41@gmail.com> References: <1542072871-21208-1-git-send-email-lirongqing@baidu.com> <20181115.151131.596213640354724307.davem@davemloft.net> <20181117.165138.801331179496411533.davem@davemloft.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: lirongqing@baidu.com, netdev@vger.kernel.org To: David Miller , eric.dumazet@gmail.com Return-path: Received: from mail-pg1-f173.google.com ([209.85.215.173]:45443 "EHLO mail-pg1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725734AbeKRLiM (ORCPT ); Sun, 18 Nov 2018 06:38:12 -0500 Received: by mail-pg1-f173.google.com with SMTP id y4so12225240pgc.12 for ; Sat, 17 Nov 2018 17:19:37 -0800 (PST) In-Reply-To: <20181117.165138.801331179496411533.davem@davemloft.net> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 11/17/2018 04:51 PM, David Miller wrote: > From: Eric Dumazet > Date: Sat, 17 Nov 2018 14:37:12 -0800 > >> >> >> On 11/15/2018 03:11 PM, David Miller wrote: >> >>> >>> Applied. >>> >> >> While reviewing this stuff, I found we have a bug. >> >> If napi_reuse_skb() is called, we might inherit from prior skb->pkt_type value. >> >> It seems that GRO could aggregate packets with pkt_type != PACKET_HOST, right ? >> >> David, any objection if I submit the following fix ? > > Oh weird, so we do GRO frags accumulation using SKB which never goes through > eth_type_trans()? > > I don't understand how we can, in this circumstance, assume PACKET_HOST? > > Because that is what your suggested patch does. > > Frame could be UDP multicast, and we could legitimately GRO accumulate it. > In that situations setting PACKET_HOST doesn't seem correct. > I might have been not very clear. Issue is that with macvlan and GRO-friend traffic we can receive the following packets : P1-P2 with PACKET_OTHERHOST because eth_type_trans() detected the dst MAC is not the eth0 device mac address. P2 has been aggregated to P1, so the sk_buff has been put to napi->skb via napi_reuse_skb() Then we receive on same NAPI packet P3, for this host, reusing napi->skb that was saved (old P2 sk_buff). skb->pkt_type is PACKET_OTHERHOST. eth_type_trans() does not change skb->pkt_type because ethernet dst mac address is our ethernet mac address. -> We feed the upper stack with P3, with incorrect pkt_type. -> packet is dropped because pkt_type != PACKET_HOST, for example in tcp_v4_rcv()