From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2973FC54EBE for ; Thu, 12 Jan 2023 19:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231951AbjALTBK (ORCPT ); Thu, 12 Jan 2023 14:01:10 -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-Google-Smtp-Source: AMrXdXsFuJy/CPoXuGhRI0DtDH8DiK0WOzxYNRnH1nP6q6jXuZpqRyShxPF7ezkVDhU9xEE6oNyzTGlah0UZ3z+JPVo= 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 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?