From patchwork Sat Jun 27 08:07:10 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: 191944 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1178228ilg; Sat, 27 Jun 2020 01:07:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRt+gtDn57DwNoesXNakWxy2QESSmmgsjuf8aLXclv9CTyuPdqFrEZUsRDFtrK9tpEhRGe X-Received: by 2002:a17:906:1386:: with SMTP id f6mr5896401ejc.66.1593245252967; Sat, 27 Jun 2020 01:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593245252; cv=none; d=google.com; s=arc-20160816; b=e8XdHWanXFWLP2DVhxpiWRwkrXTFQfMt7S3bF/slmZqxJlnuc9wp3Rq/9r9AUSwJXQ Dvc/PEUY6JhjahK29sxBvPftoPOutCbTr/oSpznxDImskL8464c0nPpuqfjUSqj38yKs LnOJiNGirkW5xsxrTNvxYO05shJY3j4ZRKXyqvwm+t9prDi5iPmz+ls/Ze8JsFvTjFYw bUcStSRAtsazsI77E6LLp5kj+Eb0PX+7qUi2VWeOw6FSxTz+KfRVJk7nL8ZchShFvQmT 15xY55bRfefdJmBzdtsPzCvcc7bDC05HYqyVmXkFI88byiANh3JqzGIARHYkB7495h0E 3TXA== 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=vWBrPP9l+QKDIyH9arTmX+HFWS9FqfcSiC36xjoMF34=; b=AR52XQs6e6wWRzSua3qlgmyK4fXe60KJPL0+EdbBBErw5wLU2FxK4/wmwQkrOaJZUZ gX1Cbmf6H6KYi/i8JVR8wb5Dfxg0En5Wrm3Bt+XvoW4ziW+skkoaetnAmZ/yNlyxQbXw 7fKRaWbrBcuz1VX5QpYLVhz2SPfQ86PJfOL3BMY/OR/WjIfTJhfXJrtJGp9oW9e25Y04 9im2nQaHI01Y6oUAacNB5hupTqUWVYs/1knBohVoJTDZZknbpXOUW6sH7+mxSuUxGiAv zhQYsZ6FoTdkoyRk58iZPBfDe2geZsDuXm2qej2Le9IIybo0QpLrUFExiT6pfvrvPw1u 1sEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=3gFJ1lXv; 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.32; Sat, 27 Jun 2020 01:07:32 -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=3gFJ1lXv; 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 S1726356AbgF0IHb (ORCPT + 9 others); Sat, 27 Jun 2020 04:07:31 -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 S1726139AbgF0IH2 (ORCPT ); Sat, 27 Jun 2020 04:07:28 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 98160d3d; Sat, 27 Jun 2020 07:48:04 +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=xKPsjje8Yh5NeiPGcodksFIMq EM=; b=3gFJ1lXvw/h4T7b8GfonTIDVGdvaOawzoQSF+NPaHH2t0JtbP0XHud99H A1Cd+j9fJXscQ/paZ57y5v09fIiGI/SfwMVCx3p+AqYXm3rIe9XK0D1Z7i6xF/ny +sn2DhtI/GSde4ZpCH5rsZB4FtsDzj925sYH5PgtQf443DqUpV8Gszv6wtsN300R X/70kCgBLyS21b9m1ltn0l1zIz0X/a3uo9sP4dR6LF0JiQn9fPvbUH9oqYHRdwfq F2FuMt39/iw4lrJl6MHjtnwZlpmarK0lZaPr3znLly3ReShhYSjqD+ssP2os/fnF csnYPimDxdYsJiF/dkLTSFIIYzcrQ== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 4f8fbdf5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 27 Jun 2020 07:48:03 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, davem@davemloft.net Cc: "Jason A. Donenfeld" Subject: [PATCH net 2/5] net: ipip: implement header_ops->parse_protocol for AF_PACKET Date: Sat, 27 Jun 2020 02:07:10 -0600 Message-Id: <20200627080713.179883-3-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 Ipip uses skb->protocol to determine packet type, and bails out if it's not set. 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 ipip rejects the skb. So, this wires up the ip_tunnel handler for layer 3 packets for that case. Signed-off-by: Jason A. Donenfeld --- net/ipv4/ipip.c | 1 + net/ipv6/ip6_tunnel.c | 1 + 2 files changed, 2 insertions(+) -- 2.27.0 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 40fea52c8277..75d35e76bec2 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -361,6 +361,7 @@ static const struct net_device_ops ipip_netdev_ops = { static void ipip_tunnel_setup(struct net_device *dev) { dev->netdev_ops = &ipip_netdev_ops; + dev->header_ops = &ip_tunnel_header_ops; dev->type = ARPHRD_TUNNEL; dev->flags = IFF_NOARP; diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 821d96c720b9..a18c378ca5f4 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -1846,6 +1846,7 @@ static const struct net_device_ops ip6_tnl_netdev_ops = { static void ip6_tnl_dev_setup(struct net_device *dev) { dev->netdev_ops = &ip6_tnl_netdev_ops; + dev->header_ops = &ip_tunnel_header_ops; dev->needs_free_netdev = true; dev->priv_destructor = ip6_dev_free;