Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2951047rwb; Mon, 16 Jan 2023 01:28:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9EMjQXH7BhcDd6vBKVMuoJLgAJdJ/ewKQlHS8EFY8mabVrSR9L/USGlTu5Ux68d3yZ8y0 X-Received: by 2002:a17:902:9b97:b0:193:b58:2b0c with SMTP id y23-20020a1709029b9700b001930b582b0cmr30093883plp.23.1673861289837; Mon, 16 Jan 2023 01:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673861289; cv=none; d=google.com; s=arc-20160816; b=JVLOAE9wJHWwP5AkZ9TBdEsBAVMeMYn5yiu7gLNq90fAfVzbI+zaHQS+rDVuO5Qctt DLzokHWcX53GtyQHM0svgau87UMiTqVpfkkTsehtZWWGs/wFMbTAcyxNFGAYs8a79cg1 pxzCPImambEYD5ZMGld34UEfXbBDmBlapyJTUNZ6iu8ZOQycrqsfsowQvbm4pC6eRwGS uSDdO8uGy2/qg8ya+vURc4+EU62PQCXiE+RGaMFnM/u4Y9Ts3C8wEDp0bcWgDqbzG0O7 5jfDNvlzb9Dp4gkPR6n4p0c1HVlU9i9Jf8XV62M8rue0n/iaiB/ZcRGr94PQwW0VeTlY D+HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id :dkim-signature; bh=EJMjpZ2ePdq4QsXq5r/GaTYNTcCjHGHNdiTm8AbaYvU=; b=h0SyOHZAfVAqv1Eb39qZudvEXwKcqE6MysxwKmjCmi/Y5jpXmBfpTQl+B7oD8O0qWb fbgPRrvA62YoKyDyykZbGf634R/EZKMzya2C6xgIaRK5ra7qzzm66IynwaYCI149ZCpH 1D0ZIi+ZaI546w2K/8jsIFakjCpJg6iRwv2i/jGBTF/50TPWI2DP1aTsM+Sq77x+1+OP 5FXcZlPpj7tBdNltYkc15d0uoEJ+n3cXCc5+yXNLuNbjNG8xe+2pd3LqIC2Sg7zVUK3I Qr4nQQR7ij62XbTqj+E4o5mkn+ukjeApMmGk592J8X6VLqP6k5CBp/5LZF0gLlK5JRrs 8r6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@norrbonn-se.20210112.gappssmtp.com header.s=20210112 header.b=kh7H1sgT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k13-20020a170902c40d00b001949c680b60si941015plk.231.2023.01.16.01.28.04; Mon, 16 Jan 2023 01:28:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@norrbonn-se.20210112.gappssmtp.com header.s=20210112 header.b=kh7H1sgT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232499AbjAPJB7 (ORCPT + 51 others); Mon, 16 Jan 2023 04:01:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232428AbjAPJAA (ORCPT ); Mon, 16 Jan 2023 04:00:00 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D352813528 for ; Mon, 16 Jan 2023 00:59:30 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id b3so41755941lfv.2 for ; Mon, 16 Jan 2023 00:59:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=EJMjpZ2ePdq4QsXq5r/GaTYNTcCjHGHNdiTm8AbaYvU=; b=kh7H1sgTfLjtAfLKGvuuIC2auIxf2jpKBvP9Arr+XfC1JiASpqc2JmoF+QPbMei0Pm 1AbmIJ3nqcIS+Nq2BKmL43CxyrSoHCvcRh5y2vJggefT4qCBTK9M2XnrD0bl+wEi3Pbw zRxBC6aZu8JaRCRktw8JySXLWPXQwFCVDQKaXDYHpIb8fkBmnxWU4blqHtONg606TIFa mGP42tP1dVfJ5FIx3366qAqkuuhcq3pTCujsQ6aejAYopq6+VIqyWLR3Ih+nHY3tJotw q6txA5vycRRzLI78EvgXw0dGtHVbZLRQAba/ox+h/dH41u2M8dKdlOznFavpHIEmDPBC e8kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=EJMjpZ2ePdq4QsXq5r/GaTYNTcCjHGHNdiTm8AbaYvU=; b=GoxBRjb1Dtyqj+iseWetXSL91/+5xBoUaAoHUqr2aEvWhWzHGmuNfucIak8i6QBFm2 HY5gU08WKBVlR3ZaBrl5pW72ygAVq5PJfJ6FrcG7ik0yrWt1ZZCcyAsO9YtXH9jNZy2z TwO76ztp0QUpqVIgtlksZx+dmlQOb4ZLZ2ruGqbZmFiAzLWPu+On9/WE4BxBWsAY1X++ LstC1edRYQQGs2Wb+TQAtbaP6AaP6rcbeJ0G3OOpxNRZSJFjUfzX3SpD6HqGYsoyHsPU 1qaduhvy9LvuETrdh/0fykHwzWq5vRdXKfZDW5DElRZEH9jzugJ3moJSKwPwLhTXnB2R XE+A== X-Gm-Message-State: AFqh2kojByj/pokwhDHZ9046/NmgDyuACFeMw1bN10F5j1bIHav9i+yP 5UEsHkzfpRhs1kzH/MHONKklmOTTLv2G9IpS X-Received: by 2002:a05:6512:2308:b0:4b5:6b87:a5ce with SMTP id o8-20020a056512230800b004b56b87a5cemr30341753lfu.46.1673859569205; Mon, 16 Jan 2023 00:59:29 -0800 (PST) Received: from [192.168.1.213] (h-155-4-88-185.A159.priv.bahnhof.se. [155.4.88.185]) by smtp.gmail.com with ESMTPSA id s10-20020a2e98ca000000b0028837c7a7b7sm2211724ljj.128.2023.01.16.00.59.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Jan 2023 00:59:28 -0800 (PST) Message-ID: <75a2cb16-9e39-4123-de8e-b846c9b482f0@norrbonn.se> Date: Mon, 16 Jan 2023 09:59:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US To: "Michael S. Tsirkin" , Jason Wang Cc: LKML From: Jonas Bonn Subject: vhost-net Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I have a question about using vhost-net with an IFF_TUN device. I'm uncertain about the behaviour I'm seeing which is: i) on RX, the descriptor contains no Ethernet header, which is what I was expecting ii) on TX, the first 14 bytes of the transmitted _IP_ packet are lost; if I prepend an extra 14 bytes (zeroes) before the IP packet and extend the packet length accordingly, then things appear to work as expected. In vhost_net_build_xdp() it appears that the userspace packet data is copied verbatim to an XDP packet structure that assumes the presence of an ethernet header; as such, the IP header is copied into the ethernet header area. I think this accounts for losing the first 14 bytes of the IP header... If I set SO_SNDBUF to something less than INT_MAX, then the XDP path is bypassed and transmission of IP packets works. This means that knowing the value of SO_SNDBUF becomes important in the userspace application in order to know whether an extra 14 bytes needs to be prepended to the IP packet... which is awkward, at best. For an IFF_TUN device, should vhost-net not be adding an implicit ethernet header in _build_xdp()? Can this be done without backward compatibility implications? Thanks, Jonas