From patchwork Sat Jun 27 08:07:11 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: 191945 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1178258ilg; Sat, 27 Jun 2020 01:07:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfLe/AGoiWOIik/W/62LRUQF9zrlLAU508kkiv4q59afGWXLFtkU66+r4y1X2bx4HLPMTr X-Received: by 2002:a05:6402:202a:: with SMTP id ay10mr7731928edb.0.1593245256422; Sat, 27 Jun 2020 01:07:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593245256; cv=none; d=google.com; s=arc-20160816; b=udJFBYyt9LKNlqRL5m9M/Y6UTOtqY969ErR5i9uRgBxNlLH30t5QRtFMyKRvj/59Uv lyDKJyvKGUsx3r7angPg5TX2iB4FeJZIE8HmkmHw+Xe3WGnbZQ5Z7QL2dOIjiaSDq3ix mpwER6jNv1m5V1nsV9d22VYNE6hvUTzrKUFANR4jEjV0WFcnIvB1Q+GJqF1i0reQTWPr c6cbC2pBttmmfW4+RNp+9tUahOxSDL/5nuOA19+OA82c8UkSWFk+9eJzNLT1bjv90i5j ZUVnKNkGKr5sppOl5zGw032znVRT17aL1vm5Biky4fuXeMDhYV5OnOxGLc0RFMNGTND9 0Bpg== 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=jJT6CrcooyU1YJlWbmvkDJQL5CqkFB4lk70N9J+tB8ER9mlXhm3Zx4viCgbRPHoF76 S423KkNm2pydEu/m5wgL9xjNfH9VO5AqwFDdq19Z6cE3TAIuayIsYO37445CkwdOQdDU u6PfQ9v18OqGDzlkGxRhob4A2YeLluQ6z6TvttW6BQYTDP/w/lrwJ22fHwmEAS6Db1V8 SvRTVPBa1icgRVWPffL5Sx6pNW2OA8kFeSCZwqTAUCqQ8FBac4pvHTTrJO1aThbktOt/ Sv/hOmeqT2lQKxLX80wm/JYyI1O5sfpLUzsGNPitufOBSm4JpTwRIJA3+WD+uKchOBll koog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=mk6W3tZ3; 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.36; Sat, 27 Jun 2020 01:07:36 -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=mk6W3tZ3; 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 S1726394AbgF0IHf (ORCPT + 9 others); Sat, 27 Jun 2020 04:07:35 -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 S1726317AbgF0IHa (ORCPT ); Sat, 27 Jun 2020 04:07:30 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id f278eb5f; Sat, 27 Jun 2020 07:48:05 +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=mk6W3tZ3kchWeSUuHXnTUxI+s3lBoTrQUEaypnA9g8qkKrjmeFSB6B9ma WKn3EHHuWOhYnXVLTGHCcWaqTUwrPQDBFNS/mYSyvvUXCp2IvFFbQkpEy+e//iIu XaVVXdzxVWTUz0CpcbBBhioSK12ytg4u0bvksKpdUye4CeUdLYElq73kJmwvyahN zyTGRLBbSFpm0nyh0JQ+7RKGvk6HdSMI5UAAa8dwGIFbhTC/I8xGRwTHqaOFH5Qy MJ+HJ4NJfVtye6eXDi0AFy5j6SpWra8xLnpmyut+T9VtUP7d0beIL56YQGBU0ehS m+l+1YcigHYYQLnQ+nEP8u7LEQhsQ== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 89c47963 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 27 Jun 2020 07:48:05 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, davem@davemloft.net Cc: "Jason A. Donenfeld" , Hans Wippel Subject: [PATCH net 3/5] wireguard: implement header_ops->parse_protocol for AF_PACKET Date: Sat, 27 Jun 2020 02:07:11 -0600 Message-Id: <20200627080713.179883-4-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 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;