From patchwork Tue Jun 30 01:06:22 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: 192040 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp3369552ilg; Mon, 29 Jun 2020 18:06:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBL0Vg49RR5mznxnWM0zG3NFHn0TFofkCPWt/SbL79s9zSAxeEzt9dkKkCzy97JSyYWuWs X-Received: by 2002:a50:d8c2:: with SMTP id y2mr12593103edj.114.1593479213505; Mon, 29 Jun 2020 18:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593479213; cv=none; d=google.com; s=arc-20160816; b=pDqYOn2Kp9mkxo0i0xA8k3IO9dDNyNbtcAswTdlMmXYi+vK9zkQeNcizU/6VJwJc3m 6ot5wjcxteiq5oJ+5YAbOHoVgLC6//ebB1cm6TJgq9lpvUj0kQBU1gCSFxBEFpJFAcuk XCNUBGJWfswLkKRMlrhINYvWXKRpgKol6awcUrKFj+5yzzLjQYJg7m7u7sXAZi+KBQQh npMuHN+/mkwid7mghOqx9Gp3SXatTaPgphatbTYSPgKiYACTDnFVrOk11/49P5TOR+jw Vz+WSWK9UwKpaQGeYSVTcG+MEIkPmMB80eJS69IqcjqiJMHpE54BbRwU5ZiFSEoUiQNC IgWg== 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=XNzFU6OpMmBp5T3OWFxdbUiH/Dc9ZhwhGOCp6vmelFRRuYbnkwIO5P0U1F0cuc+bAQ 8KGnJWoZfkML0KNNRW21VI6P6yR50cNcVSfCC/OoG6xou0GjCeUxQbXkIQzl3S9TyA+I OPqJMpwXWvljFFRm9vkUNMBGrQlJA+uEuQYFZtDokpQPAKfuQUewuVBQO79aU0xJcwqU /QwvlkQnA2VckgY+grrWAQRjI5mamkWvnYA7DDsuurJxXcHMEzlJz8NlsKhi8uyRM7qK ZAmYl8uQH2ULWnEnrn+oJfCTIoh3ccZu7vc2m6y7CDnerw8y4OIRIBFaV+LgYOR+7Zno 1vDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=TLrlpmwa; 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 d17si849269edu.223.2020.06.29.18.06.53; Mon, 29 Jun 2020 18:06:53 -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=TLrlpmwa; 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 S1728142AbgF3BGw (ORCPT + 9 others); Mon, 29 Jun 2020 21:06:52 -0400 Received: from mail.zx2c4.com ([192.95.5.64]:60171 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728024AbgF3BGp (ORCPT ); Mon, 29 Jun 2020 21:06:45 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id e00a5875; Tue, 30 Jun 2020 00:47:01 +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=TLrlpmwaTRb9+gAnZoo7lj3ktt+WOh3dfJLrxQ0tZCHikMcQktsTZKL4D VwXy59ZAnPCXP+xnvTrBnwtwfRW3M80+KMwO2Y1prKw0kq2sJmw6jeTI/26XUKBJ GUlvrzwlww9JJKrcoBeGDfo6CObNpqtaCQA82jVbXvb4131zHxWXtXv0VICDWPXh I1/zRq/X4imqDTz0DTic3IvMfqSr6dkluYAME0EZpPgY2hqfKic+UqeVzffBTaYz qdVHIwE3D1XS2GY/V43wEYLrPe3NJnnalYyzl5sne07OY+/0uEhRLnJ/VFg1fajE t7rFoFZYjz3/J6IfgrpUHfAJvIqng== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 35fbf544 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 30 Jun 2020 00:47:00 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, davem@davemloft.net Cc: "Jason A. Donenfeld" , Hans Wippel Subject: [PATCH net v2 5/8] tun: implement header_ops->parse_protocol for AF_PACKET Date: Mon, 29 Jun 2020 19:06:22 -0600 Message-Id: <20200630010625.469202-6-Jason@zx2c4.com> In-Reply-To: <20200630010625.469202-1-Jason@zx2c4.com> References: <20200630010625.469202-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;