From patchwork Tue Jun 30 01:06:20 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: 192037 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp3369487ilg; Mon, 29 Jun 2020 18:06:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL6uWBWLAHWcJiMzVk3w93gIk2Sx7IfxSQvERoPsHiCX9Qdn1RJX2jvB9LWmVrWY4CfN4x X-Received: by 2002:a50:b065:: with SMTP id i92mr21664451edd.112.1593479207963; Mon, 29 Jun 2020 18:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593479207; cv=none; d=google.com; s=arc-20160816; b=Ku5/jAPs/UWJuMWdymmHQu84Y0WHflNHX7tj/3D+6vJe5X+H1aLPm0toXfSwNhQHS8 c9ROj329s+4sutbMuYO2fJ+Cjnu9MyleA9OkdMQkPKw77FKjwVuMmmLV+KNeWLXVpbt5 hr1yi5Cq13jaKA/QNT5QdfSpR01G0ZoTQ9YRDlXPMhdWYMG+Yu3IT3+DF1OzmY+3+J56 Xm3YMvgL3Fo2HbHC1lPq2Uh78ZQNsVRCFiO4hLvdRazZqS2mYwekxJbup+jpUy7LkZPq rB7rTizFCL7L/WvooUtRpVfUwlRxu/F277tesGs+Isw7WjzbtpiocqL2lsvC9drQwt0k 2Dig== 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=kvbxJPl5WzAkWHv1uFWyfOz1qwHCJvWnkUfU7Txylpk=; b=q5uLu9q/M74YcP4Stt3qJWw10AeuRcgRj2LfR7JruLjGb4NCyrixWzOpCXc6B6dSZM ZHnhFjsLf1/0P/wa+VB9EbPwFdEIspuNLkAAQffe7VdYd/u6Tw/MP3CSfWljPbK8rALo 0UpN5fjeqiCsNJz3J6xoN57VejrgI7PlKO9LqK3YPrdbjXkB6AjOjuX4vuW89cjNLakH xbI72hzrqZ0K0fQLpom3WB3UEzHW8MspAGJpJaqG+3SQIYLGj6CVxufOOnMighar7Ly+ BBL6kCNQg78ERPCqZ8XZrnAfQoaUQbOzrUG4ctFF1oKIAxnuhbdFlRfeJ4VEsKhhMyEU XgWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=nwPcNe37; 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.47; Mon, 29 Jun 2020 18:06:47 -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=nwPcNe37; 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 S1727863AbgF3BGr (ORCPT + 9 others); 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 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(+) -- 2.27.0 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;