Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp448678rwb; Thu, 12 Jan 2023 08:05:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXvXxuQXxwbqsl8cHq9UyBIP0daLxia7odT+eP9setX8AT7XSmd34xmTBCDx3tyluVy4Nn2C X-Received: by 2002:a05:6a21:6d82:b0:ac:f68:d0f8 with SMTP id wl2-20020a056a216d8200b000ac0f68d0f8mr118012251pzb.23.1673539555151; Thu, 12 Jan 2023 08:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673539555; cv=none; d=google.com; s=arc-20160816; b=WzaXyYc9thmxy6aHH6VoP+ds6hT3PqYc3BYGA9bPFjDXR3tHorW+Z5fdZzvBPvPYil Z4n/EhXJpUwef8qdJXiRzuSHXzKT0gwa46PVYlHdYqOeYyBWfMqah5uxDd4Hh+ANm8YK 74GfTldyHx4NmBp0lc9RgjJjRDRTryHFm89BUuSQKy0j9FEku1ujmHJWCaC4Rmtt8wSO MJkXTuw7qBgAtsbHOregyW9dgn5xfg05H8EZGbBc2RAdt+cUeXwVWujr7AMkcn2q1gBQ knHR2oqgyFYlQxHbot7OuoRis9zPWQLWOFk0sYcq0UK4xyvHoxC/MdqsA6QJa8TdLIEw Nxlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=KRE5893iX04jrGywKNs0iqtC9XhdTqoDhy9dIOaS4B0=; b=ENIYx8acJYQQjUyRNYHmRDzvaQAEZGueto5nBxWTyxfBQRq7KZIqJQycGj8oegkEkO AYlv0/LlVy6QPGPkkcEV4Hn7C+y7OlKTgDqX703hFGdWvyFgC2GzBcX7Sm1EvAw1L/Ge KoCBN5CEtwN6IseR4Xwyoo+QgshDZGTKMIAO0ZlERd1eaU1Pvr4kxE8gNsW/QdnbE0n8 ZpRh3V7GEpnFketWKNic6zTYMihT98gkoZ5zIVOBGkTVNazFHu9NK1SVlw4rZgDhm0fx CcdB1818SlHuC8rJYUvd3UPea6Yag3Qot7bKYqp6vWqegwpm6cv/XmuoCNV+jwCTSl4l B+IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="dgbRe/WY"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g4-20020a636b04000000b00476cb3a08fcsi17586457pgc.338.2023.01.12.08.05.48; Thu, 12 Jan 2023 08:05:55 -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=@redhat.com header.s=mimecast20190719 header.b="dgbRe/WY"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240520AbjALP6H (ORCPT + 50 others); Thu, 12 Jan 2023 10:58:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240641AbjALP5m (ORCPT ); Thu, 12 Jan 2023 10:57:42 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 934FE6342 for ; Thu, 12 Jan 2023 07:47:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673538463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KRE5893iX04jrGywKNs0iqtC9XhdTqoDhy9dIOaS4B0=; b=dgbRe/WYQHoa+UbXC9xT/9QsDvkn6b7pnrDmorcPxJ6Puh1V8fMFFwdYkQqer4oo1YdBNw PGxSq2ceNaCLsA8GsQRm5Jq3Tu014wwfKKWB3GAUoE42n2scwt3Y5w93JmFkMcdo/Var6F juD4VouaXoHU+JSZfNzp3VTcBrutIII= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-528-aloRACgrPhSx_WFVLXyaSQ-1; Thu, 12 Jan 2023 10:47:42 -0500 X-MC-Unique: aloRACgrPhSx_WFVLXyaSQ-1 Received: by mail-wm1-f69.google.com with SMTP id q19-20020a1cf313000000b003d96c95e2f9so4409460wmq.2 for ; Thu, 12 Jan 2023 07:47:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=KRE5893iX04jrGywKNs0iqtC9XhdTqoDhy9dIOaS4B0=; b=JykFssFBGevozPQL5aifiPFiS6kerg6P3SjcBWhdUz2T6LWGGZLaG1rBdVWoRDPab3 wazCNzhAjjnYa9HFbaTHu5soV2AJuDdLm1RTaIhqon7LffFCVw0MH24n7zemSWMb5TGS sGVEVc1Nb6g2bY+RqiwMSwdcguZefGOKPZPAkU3lqRt7W8nrgMzIsOuUaW5WpDTlwqbP sC4neI25pm17rZpHAR+x43eSt0ujYs9t380TdR/6qAd8droLBddX52QSUnyzs125RTvt RA1X9Bj273zvtR8q6hTawJLSKDtxKPJEbOMtUw2BgKDnqFR6y6UArUtnQLoHtYc+Pxdq kjzQ== X-Gm-Message-State: AFqh2kr141Eg2Gdz1uHxMlb6egskUNLiGsqGZZXv5GuN+r/Ira0UvISi 2bAXSwnLKG3Fdb6ex7E80zKAtoYCDEnA0wBkm+bbkC+Nag2nUyWfkAXq+Nf0aYxbiMH4X7nJcqG HgL4DwL4gZzg2O25u7eV2EjGG X-Received: by 2002:a05:600c:354c:b0:3da:10e6:b79c with SMTP id i12-20020a05600c354c00b003da10e6b79cmr3055892wmq.24.1673538460984; Thu, 12 Jan 2023 07:47:40 -0800 (PST) X-Received: by 2002:a05:600c:354c:b0:3da:10e6:b79c with SMTP id i12-20020a05600c354c00b003da10e6b79cmr3055879wmq.24.1673538460719; Thu, 12 Jan 2023 07:47:40 -0800 (PST) Received: from gerbillo.redhat.com (146-241-113-183.dyn.eolo.it. [146.241.113.183]) by smtp.gmail.com with ESMTPSA id hg11-20020a05600c538b00b003cf6a55d8e8sm21422831wmb.7.2023.01.12.07.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 07:47:39 -0800 (PST) Message-ID: <47d9b00c664dbaabd8921a47257ffc3b7c5a1325.camel@redhat.com> Subject: Re: [PATCH net 2/2] net/af_packet: fix tx skb network header on SOCK_RAW sockets over VLAN device From: Paolo Abeni To: =?ISO-8859-1?Q?Herv=E9?= Boisse Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 12 Jan 2023 16:47:38 +0100 In-Reply-To: References: <20230110191725.22675-1-admin@netgeek.ovh> <20230110191725.22675-2-admin@netgeek.ovh> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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, 2023-01-12 at 16:27 +0100, Hervé Boisse wrote: > On Thu, Jan 12, 2023 at 01:48:51PM +0100, Paolo Abeni wrote: > > I'm unsure I read correctly the use case: teh user-space application is > > providing an L2 header and is expecting the Linux stack to add a vlan > > tag? Or the linux application is sending packets on top of a vlan > > device and desire no tag on the egress packet? or something else? > > The userland app does not care about the device being a VLAN one or not. Just a regular Ethernet device on which to send raw frames. > This means the app provides a standard 14 byte Ethernet header on the socket and does not matter about any VLAN tag. > > Then, the goal is to be able to alter those packets at the qdisc level with tc filters. > But, when such packets are sent on top of a VLAN device whose real device does not support VLAN tx offloading, the bad position of the skb network header makes this task impossible. > > To give a concrete example, here are few commands to show the problem easily: > > # modprobe dummy > # ip link add link dummy0 dummy0.832 type vlan id 832 > # tc qdisc replace dev dummy0.832 root handle 1: prio > # tc filter del dev dummy0.832 > # tc filter add dev dummy0.832 parent 1: prio 1 protocol ip u32 match u8 0 0 action pedit pedit munge ip tos set 0xc0 > # ip link set dummy0 up > # ip link set dummy0.832 up > > Then start an application that uses AF_PACKET+SOCK_RAW sockets over the VLAN device: > > # dhclient -v dummy0.832 > > If you look at the emitted packets on dummy0, you will see that the 0xc0 byte of the IPv4 TOS/DSCP field is not set. > Instead, the 0xc0 tos byte is written 4 bytes too far, in the last byte of the IPv4 Identification field. 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). Cheers, Paolo