From owner-svn-src-all@freebsd.org Thu Mar 9 03:14:49 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E14DCCD40D8 for ; Thu, 9 Mar 2017 03:14:49 +0000 (UTC) (envelope-from royger@gmail.com) Received: from mail-pg0-x22b.google.com (mail-pg0-x22b.google.com [IPv6:2607:f8b0:400e:c05::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AE65BB36 for ; Thu, 9 Mar 2017 03:14:49 +0000 (UTC) (envelope-from royger@gmail.com) Received: by mail-pg0-x22b.google.com with SMTP id g2so3353960pge.3 for ; Wed, 08 Mar 2017 19:14:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=W/FJ3zyRj7/pwF1YMbf6zTptcCrRrbjrylYLnUgpmcQ=; b=ffbzb1O536dlHoKmLEXkl7T/mj+ERiYuGYpM9vmtAV0Hm1m+bEg8dnRbMAOLdmBzrW CJg/jZWE55cPdy786/JjoYK3QUw9n0qHUy8meRvFDsjbZN7Vcbsjbp1e0OpVsmdwlN0e 0ZDMAAKd5Ek327PkUi0rN/5w2Y6pArmk7dAh+8DTn+6c3MsodY59Db8fdAWTbCrfSmaM jNdmAF5FfNAY6mxAOaPEq3KPTjf0YlyyzMJ/Gs3pBznnIKn8naBbFxwdfuq4jSbY+1/r fgkMgXoawWrR6fBOxc/VoYQylNM+9hA78PTpzxChl7S4HCG+l8upKulqt7Wr40d8fcDL 5jEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=W/FJ3zyRj7/pwF1YMbf6zTptcCrRrbjrylYLnUgpmcQ=; b=UKDZeIM9KTy8xwl9It++ILhXYzVhvEAxKdRi/qqoAK0OPz2/8ryGH0dyBzRZQ62wIv sysMqLNSsR3ANGHOyM6FaD0PUf9rUxigUzyoh8G2L9DjkkWXLbWMh3e9Z1n1bMKijlw8 YanIPGRlJj6MNmWXCE6wijIVNXu6li1y2agPvV8g/quTZ6xRCQuUwhSBTd9oFq1u7SCm hwMi35djXpSigyYfx6ys9xgWAFsgP0VbLRP2usRFTn7Mu16q/Vb9KAmo7sS9zYlH0L2q 12Pymr7hY5/E63Zq42pRMON2manaFWg0bl0+abe034oJz7g0DembJ7Kk7loHEXdQ3xwt GXaA== X-Gm-Message-State: AMke39kFmiXbkUEQKXKSXFvKRUhsVwMc62wdNTTUDqE9WuMyMR6l5YHMtw/FHGBRR4Dvyw== X-Received: by 10.99.36.7 with SMTP id k7mr10908119pgk.201.1489029289212; Wed, 08 Mar 2017 19:14:49 -0800 (PST) Received: from localhost ([153.150.77.170]) by smtp.gmail.com with ESMTPSA id 80sm8635844pfy.67.2017.03.08.19.14.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Mar 2017 19:14:48 -0800 (PST) Sender: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Date: Thu, 9 Mar 2017 12:14:40 +0900 From: Roger Pau =?utf-8?B?TW9ubuyxlQ==?= To: YongHyeon PYUN , svn-src-all@freebsd.org Subject: Re: svn commit: r314842 - head/sys/dev/xen/netfront Message-ID: <20170309031440.5dbloz5z6g6thg4c@MacBook-Pro-de-Roger.local> References: <201703070918.v279Iq8Y061870@repo.freebsd.org> <20170307125231.GA1149@michelle.fasterthan.co.kr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170307125231.GA1149@michelle.fasterthan.co.kr> User-Agent: NeoMutt/20170306 (1.8.0) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Mar 2017 03:14:50 -0000 On Tue, Mar 07, 2017 at 09:52:31PM +0900, YongHyeon PYUN wrote: > On Tue, Mar 07, 2017 at 09:18:52AM +0000, Roger Pau Monn?? wrote: > > Author: royger > > Date: Tue Mar 7 09:18:52 2017 > > New Revision: 314842 > > URL: https://svnweb.freebsd.org/changeset/base/314842 > > > > Log: > > xen/netfront: fix inbound packet flags for checksum offload > > > > Currently netfront is setting the flags of inbound packets with the checksum > > not present (offloaded) to (CSUM_IP_CHECKED | CSUM_IP_VALID | CSUM_DATA_VALID | > > CSUM_PSEUDO_HDR). According to the mbuf(9) man page this is not the correct > > combination of flags, it should instead be (CSUM_DATA_VALID | > > CSUM_PSEUDO_HDR). > > > > [...] > > > @@ -1192,15 +1192,17 @@ xn_rxeof(struct netfront_rxq *rxq) > > > > m->m_pkthdr.rcvif = ifp; > > if ( rx->flags & NETRXF_data_validated ) { > > - /* Tell the stack the checksums are okay */ > > /* > > - * XXX this isn't necessarily the case - need to add > > - * check > > + * According to mbuf(9) the correct way to tell > > + * the stack that the checksum of an inbound > > + * packet is correct, without it actually being > > + * present (because the underlying interface > > + * doesn't provide it), is to set the > > + * CSUM_DATA_VALID and CSUM_PSEUDO_HDR flags, > > + * and the csum_data field to 0xffff. > > */ > > - > > - m->m_pkthdr.csum_flags |= > > - (CSUM_IP_CHECKED | CSUM_IP_VALID | CSUM_DATA_VALID > > - | CSUM_PSEUDO_HDR); > > + m->m_pkthdr.csum_flags |= (CSUM_DATA_VALID > > + | CSUM_PSEUDO_HDR); > > m->m_pkthdr.csum_data = 0xffff; > > } > > if ((rx->flags & NETRXF_extra_info) != 0 && > > > > By chance, is there an easy way to know whether received packet is > IPv4/IP6? If we know received packet is IPv4, we can skip IPv4 > checksum computation too. One of side effect of setting > CSUM_DATA_VALID makes SCTP checksum valid for the received packet. > I'm not sure whether this is intentional one though. Not really, NETRXF_data_validated [0] AFAICT can be used for both IPv4 and IPv6 checksum offload. In any case, the mbuf(9) man page doesn't contain any information about this, are there some kind of hidden flags in order to pass this up to the stack? > I guess if we know address family(IPv4 or IPv6), protocol (TCP, UDP > or SCTP) and VLAN information of received packet, we can easily > mimic all the nice offloading features of real H/W NIC. Hm, I'm not a network expert, so I'm not familiar with all this stuff. It seems like the netif protocol [1] has been expanded to include hash functions, and that differentiates between IPv4/6. Sadly none of this has been integrated on FreeBSD netfront/netback. Roger. [0] http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/include/public/io/netif.h;h=ca0061410dad2797f590c5fcaf080ab5c86404b3;hb=HEAD#l902 [1] http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/include/public/io/netif.h;h=ca0061410dad2797f590c5fcaf080ab5c86404b3;hb=HEAD#l193