Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC876C433E0 for ; Tue, 30 Jun 2020 01:06:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B89E320722 for ; Tue, 30 Jun 2020 01:06:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="nwPcNe37" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727863AbgF3BGr (ORCPT ); Mon, 29 Jun 2020 21:06:47 -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 S1727780AbgF3BGn (ORCPT ); Mon, 29 Jun 2020 21:06:43 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 4290374f; Tue, 30 Jun 2020 00:46:58 +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=uwnjUE31tMKRKEKYq4haAys8j Ew=; b=nwPcNe37L5CN62lr+nhaWqiTbDSySqUdWEqRGfqa7qfLiEoj+2iNc25uH 4G2lHP9P8wtVYvDIqcF41KEh6HvjdqHDfF52zsaWlBpITLFTKeN1V5qsmJK8Qul2 b75dR6w1XC+bbGHbze8x/otYgPEg+adx0tudhYYDeQ5Sd9biHhNe+MF776FzVB0/ T6+E7VVJVTK87eRteL9cogaw93KkM9U1buDKSd3OIhP3j9dWfMdMiWQ/e0QNGOrz RHqjFA/OclAmuW5KIzFTu1g6YyhWSg8M2xqQwC3cYc/7sbclr3r2D6t8GIWewnxT yt5XwnW890pUouVD3thFDARN5GuBA== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 89153989 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 30 Jun 2020 00:46:57 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, davem@davemloft.net Cc: "Jason A. Donenfeld" , Hans Wippel Subject: [PATCH net v2 3/8] wireguard: implement header_ops->parse_protocol for AF_PACKET Date: Mon, 29 Jun 2020 19:06:20 -0600 Message-Id: <20200630010625.469202-4-Jason@zx2c4.com> In-Reply-To: <20200630010625.469202-1-Jason@zx2c4.com> References: <20200630010625.469202-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org WireGuard uses skb->protocol to determine packet type, and bails out if it's not set or set to something it's not expecting. 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 wireguard then rejects the skb. So, this wires up the ip_tunnel handler for layer 3 packets for that case. Reported-by: Hans Wippel Signed-off-by: Jason A. Donenfeld --- drivers/net/wireguard/device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c index a8f151b1b5fa..c9f65e96ccb0 100644 --- a/drivers/net/wireguard/device.c +++ b/drivers/net/wireguard/device.c @@ -262,6 +262,7 @@ static void wg_setup(struct net_device *dev) max(sizeof(struct ipv6hdr), sizeof(struct iphdr)); dev->netdev_ops = &netdev_ops; + dev->header_ops = &ip_tunnel_header_ops; dev->hard_header_len = 0; dev->addr_len = 0; dev->needed_headroom = DATA_PACKET_HEAD_ROOM; -- 2.27.0