From patchwork Sat Jun 27 08:07:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 191947 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1178299ilg; Sat, 27 Jun 2020 01:07:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi1AXMgcF7lzW+dOyuQRLQ6XyQaUkeGxQYKAUeoG99/ShrkQfcmns6HIqj5b/dkMnB55Xa X-Received: by 2002:a50:a661:: with SMTP id d88mr7483539edc.34.1593245260447; Sat, 27 Jun 2020 01:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593245260; cv=none; d=google.com; s=arc-20160816; b=hJsiIXfQnb0FPpT2+EZmH+aKdPoMiCxEDur/MKC4QaiBBNpInknCqxf6nsHnOy9bLY HG5xn3s02v6pag8vF5/kI1+a75LUnDLQEe3VD+pPLPwf91g7CUgxZ+dATo+otvFuMKKL MigZ8CMOiunfXjvjqFSpD00EGMkCht+/QudmmXnyZJ+0USI188WEtlDStZxr7wGd6HT9 HB4S1BAFbHKu5erLHLbUTVio68y0ffyp6LFmdhVQ9wL5adweoFFclGpOhIFRb4/x8eg/ ZnHwX/2DJtcYaqZ2D3SaYoPenMx94MveiTnykDpI/uX3FxNVNv95s8MwsbbZhtgQii9m 4vHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nfPFmkx6WYOblu+B7unOiOab2bOyqhxJcYoQTa7pYmg=; b=U9s9uXycS1ZgfeGv8nXSUENc3Rvdzmiz+iuBaMhyLaxFDEaTYmOW2F9pzyAuWJorxy S9mfjdmcehVE5uVgsOhQcOVFfgmPWn/HJBS8yImDs+WBctX5SSjaA8gcNjxKm9JXfkjT bx7UvZAHDfcAngM2uxe11ilLiTeTuR288KHcM12EuzQxYhE/pPrdN6D2ldbnFaHA6m4t tSoAsGWyvqrtQj7VXYfaTxh2BdGDONpbCC3zXQnlGcvSSP6JoH6QwwA1hySjhpwoGsM2 FZsdxR8qL2VFp0prJMKnDIzxG4KgO0DAZkygMHYiJjgDrecSEO7o1j49oasvpiMtyFVo ckRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=R7+RFpp8; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c25si9181037edv.335.2020.06.27.01.07.40; Sat, 27 Jun 2020 01:07:40 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=R7+RFpp8; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726402AbgF0IHj (ORCPT + 9 others); Sat, 27 Jun 2020 04:07:39 -0400 Received: from mail.zx2c4.com ([192.95.5.64]:48179 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbgF0IHe (ORCPT ); Sat, 27 Jun 2020 04:07:34 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 78266130; Sat, 27 Jun 2020 07:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=yhbQ52i5catljqOFAhcNxV2L/ vc=; b=R7+RFpp8dDhJmSShOsBe9mvuS5x03Im8dQF82SqUIIGebE4T3bGKnALNf zuWYdftbtjfqjlt/ZkMoBkJFR5TBl2SOlB+qH8rJT5Frmh+NbxuXCoR004fV3++I UCZlKhNYHkP9ArBcwTFM7c1O6oTPUXiqtQGp/7fcTRXpjmMD4Y8NrHc3etF9FvB/ rvRCkhR0MWonBxbSBZk3NP7q505jkFjrd1Bej14Mps067lNBqJ/tlU+GYMYAu8Od 1PyTgqM+O8EIvnu7fDm71/8ouRh+mWrss9cHS1aiR7exUuZNG29hk1oesdV4SwNZ e+sBFWuzlISD4MDQBNZc9yV80D6tg== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id b41ae87a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 27 Jun 2020 07:48:07 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, davem@davemloft.net Cc: "Jason A. Donenfeld" Subject: [PATCH net 5/5] tun: implement header_ops->parse_protocol for AF_PACKET Date: Sat, 27 Jun 2020 02:07:13 -0600 Message-Id: <20200627080713.179883-6-Jason@zx2c4.com> In-Reply-To: <20200627080713.179883-1-Jason@zx2c4.com> References: <20200627080713.179883-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The tun driver passes up skb->protocol to userspace in the form of PI headers. For AF_PACKET injection, we need to support its call chain of: packet_sendmsg -> packet_snd -> packet_parse_headers -> dev_parse_header_protocol -> parse_protocol Without a valid parse_protocol, this returns zero, and the tun driver then gives userspace bogus values that it can't deal with. Note that this isn't the case with tap, because tap already benefits from the shared infrastructure for ethernet headers. But with tun, there's nothing. Signed-off-by: Jason A. Donenfeld --- drivers/net/tun.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.27.0 diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 858b012074bd..7adeb91bd368 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -1351,6 +1352,7 @@ static void tun_net_init(struct net_device *dev) switch (tun->flags & TUN_TYPE_MASK) { case IFF_TUN: dev->netdev_ops = &tun_netdev_ops; + dev->header_ops = &ip_tunnel_header_ops; /* Point-to-Point TUN Device */ dev->hard_header_len = 0;