Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp747969rwb; Thu, 12 Jan 2023 11:46:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXs9nQ4NhH2PC2ho4C2PgUB9B2VzNiail4peoM7EinnjBQalFQilLmVnQFHrec6zsNIxrkpd X-Received: by 2002:aa7:947b:0:b0:575:2337:17bf with SMTP id t27-20020aa7947b000000b00575233717bfmr8010353pfq.12.1673552811468; Thu, 12 Jan 2023 11:46:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673552811; cv=none; d=google.com; s=arc-20160816; b=rWTYco9idl8ICHiHp1V14EiIBs78oUcfaMbPMUA1rmdpgsE9C9anNNva7feqseFQub 7XqHXo5WukQcMW10vc55C6ApVkYGsGSE76f5OtilxjHuTei2JoKHouRVfpn5e9WovWPH 4vG5iiR4R8FEtXf5TntWWgt5XHXcHK9AUFKty+UYwjUcQycIafjT5aKB4aXN1wTWf4TQ 4YmsJoYVO7LwB27fdjb8BcGLhEhuWmB9HNos2VsYpMa07xxY2ngy8kw6E72h5Qx5YQ6X wuiqNu3UTMAQ0mj+VtTxwGLty6HwYH8SA+A4LqNXpyQaBLs2ooqfEAWzIC0r5bRQY6kI jkBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=23TuRY8Uscw3wYyB7HeYKYN6bJDj1xjIuPRk/WYsq5Y=; b=bYECVamtJ1pkxzV136eGe5uCFYkruL+AsQ8K2vMEPlB40/M/2yMXGvyJC/kCG80mRc Qu5sziALYWfj+ZPbrV3LAnnq5xbzS8NqO6pGL4LA6uBd96IIvctNaL7w0Dck/uxaUTWf aR4QghUfdAvGuil/KBzDp2czMXv0dWHnRQMVdzXOQ7rmLVBKxUZTm5/WX3dreTZcFuse hyFBJm/T2gwLldrQfESVeAOyGAF85S+fWh4JQoGN0T0gO2XfhEQPcd0N3I6ZhsBYw40R /Cp9o6Z2D5JLepAY4nd/mUDvw5IreAohQcA0g3ste/o+EFB3UOhZaTi3chekmhs5Ewr0 qRFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="rSPdjg/k"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 11-20020a62170b000000b00589c467f33fsi8996108pfx.55.2023.01.12.11.46.45; Thu, 12 Jan 2023 11:46:51 -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=@google.com header.s=20210112 header.b="rSPdjg/k"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238181AbjALTBF (ORCPT + 50 others); Thu, 12 Jan 2023 14:01:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233223AbjALTAc (ORCPT ); Thu, 12 Jan 2023 14:00:32 -0500 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28ADB10FC9 for ; Thu, 12 Jan 2023 10:39:25 -0800 (PST) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-4d13cb4bbffso132293207b3.3 for ; Thu, 12 Jan 2023 10:39:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=23TuRY8Uscw3wYyB7HeYKYN6bJDj1xjIuPRk/WYsq5Y=; b=rSPdjg/k+MG5Py1mmE+l0sWVZS9lWS6Drj3ExXuwUj1jrvcPmnQHsfRuQs5qeNeHph BXpeaG8wE/qpkQSdfawEcV6b0cIGkZdCApVqSMNsOu9OR7QifCslPTGM6D1fA1GPDbpk i+CobIn3bskR9ge37OBxDiDt9RJI3Trq1zh8pZqEYgUC790FY04YaWwIBA1EjZ90eMTO MrY4nS4usT4B3Fk2P4ta7T5P9boZG3euou6QOwFcJre88JezvxaZ3BmIMlUNYI/yYDuh QVGIq/Y1f4+gPNVojgDyCOv/iAsI3nCZW06GY86caS8F11J4MkYw3MniCb0s+jPoqTXI 1LZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=23TuRY8Uscw3wYyB7HeYKYN6bJDj1xjIuPRk/WYsq5Y=; b=tK87qE6yjGTq7ACETReJQMxKyguNagZ6aQ8xSHiD6jrjxoRURqdBViyvxCiubhjka7 qFXnl6tbfpKr/9yh5EC+KzTYsr2NweSEw4mOvAwSK1Y1lgudFBdBtNZOp3oJqfA4HteL 9+HrFvqGvQcem+MwckIlr6ODNyQIwdwDCcgyDfBKAJbWLSEwAwMV8R5R3qPwQVaCa6gH p7jJbfIY2pcvQfWEH3xrgcMRRYYeWMiNtmDJiqxHsj7OFS+ENvixe//plImQfRdilWfU ga6CseGcopl6RPa+osizOrQj6Xi7yu4dVg61vsRZj0hDLDMR9b84uHhA6wZZrPjYokzE N6eQ== X-Gm-Message-State: AFqh2krc6L0C6cnmO9K+co+t4ckq3cye9DYgh+ZpcBgn6xBd25/uqfjD q123mQxm2Vb7JKM7c4IOXDH/KqRttUI9sdPvv9wpxQ== X-Received: by 2002:a05:690c:a99:b0:4cf:c11b:f132 with SMTP id ci25-20020a05690c0a9900b004cfc11bf132mr1472653ywb.287.1673548764297; Thu, 12 Jan 2023 10:39:24 -0800 (PST) MIME-Version: 1.0 References: <20230110191725.22675-1-admin@netgeek.ovh> <20230110191725.22675-2-admin@netgeek.ovh> <47d9b00c664dbaabd8921a47257ffc3b7c5a1325.camel@redhat.com> In-Reply-To: From: Willem de Bruijn Date: Thu, 12 Jan 2023 13:38:46 -0500 Message-ID: Subject: Re: [PATCH net 2/2] net/af_packet: fix tx skb network header on SOCK_RAW sockets over VLAN device To: =?UTF-8?Q?Herv=C3=A9_Boisse?= Cc: Paolo Abeni , "David S. Miller" , Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Thu, Jan 12, 2023 at 11:25 AM Herv=C3=A9 Boisse wrot= e: > > On Thu, Jan 12, 2023 at 04:47:38PM +0100, Paolo Abeni wrote: > > I understand, thanks. Still is not clear why the user-space application > > would attach to dummy0.832 instead of dummy0. > > > > With your patch the filter will match, but the dhcp packet will reach > > the wire untagged, so the app will behave exactly as it would do > > if/when attached to dummy0. > > > > To me it looks like the dhcp client has a bad configuration (wrong > > interface) and these patches address the issue in the wrong place > > (inside the kernel). > > No, the packet will actually reach the wire as a properly tagged 802.1Q f= rame. > For devices that do not support VLAN offloading (such as dummy but also t= he network card I am using), the kernel adds the tag itself in software bef= ore transmitting the packet to the real device. > > You can verify this with a capture using tcpdump/wireshark on dummy0 vers= us dummy0.832. > That's why dhclient has to send its packets over dummy0.832 and not dummy= 0. > > The same will happen on a real device. I checked on real hardware, with t= wo boxes and their network cards connected through a cable. > If dhclient is started directly on the first box real device (eth0), the = frame is received untagged by the second box, as intended. > But, if dhclient is started on top of the VLAN device (eth0.832), the sec= ond box receives a properly tagged frame. SOCK_DGRAM writing the tag and SOCK_RAW not writing it is inconsistent. The driver clearly anticipates SOCK_RAW writers that write only Ethernet, and fixes up the difference in its ndo_start_xmit: /* Handle non-VLAN frames if they are sent to us, for example by DHCP. That workaround only comes too late for code between dev_queue_xmit and ndo_start_xmit: tc filters. Strictly, dhclient is just not writing the right link layer, as advertised by this device in dev->hard_header_len and vlan_dev_hard_header. But being pedantic won't make the application work (I assume it never has). Perhaps the device can have an optional mode where it does present as a pure Ethernet device, and handles all the VLAN insertion purely in the driver code in ndo_start_xmit?