From patchwork Fri Jun 25 13:33:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 467772 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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS 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 EA175C2B9F4 for ; Fri, 25 Jun 2021 13:33:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0AA061983 for ; Fri, 25 Jun 2021 13:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231557AbhFYNf3 (ORCPT ); Fri, 25 Jun 2021 09:35:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55157 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbhFYNf2 (ORCPT ); Fri, 25 Jun 2021 09:35:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624627987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BG5/tC6RNX9gL3Dxu0UwfHRG1H2K8zRjKTUW+uiKmBs=; b=MH+3r2pjHT7jerFUCuXO3CB2IGxhEJ0xb3XbIWUZNfkme4+ddAnJlqycMvje8EY27kQtR7 upkL3t4+/IYm+FmUxFGxuNh1co9Hesb7P1/ZS+nT/2uqcsM8uGCmDRlEw24EpUWDsCB4V2 ek0gvm4v5RtFn4Ri3G7s/X94y6RjDOg= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-CZpZ_mj8MMusExK_m1RauA-1; Fri, 25 Jun 2021 09:33:06 -0400 X-MC-Unique: CZpZ_mj8MMusExK_m1RauA-1 Received: by mail-wr1-f72.google.com with SMTP id l6-20020a0560000226b029011a80413b4fso3484293wrz.23 for ; Fri, 25 Jun 2021 06:33:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BG5/tC6RNX9gL3Dxu0UwfHRG1H2K8zRjKTUW+uiKmBs=; b=NTpZWxEwtLxcd8Lvxcu5jOpEUwtblqJO6Qp87Hrqpq528wHKiQRdrK2upuj2HxAelO cfiCFecfsVaZfWxp6bqeqb1wv2PjO5meYGW82lbTGuw4PP7CBwhiGns7slqn1MP87web 1utcd5vsH5qVFC8xxamUOVbPAvS488aR46WNNoSNhntFJSpPWuhkeTn6nBfmFJN9E0Nc 0YRQgReRQd3gmT4rOXGk8rfQVN7n/q8mmhn3CarfL+mX9n5uYRY9fV2H81M0msD4c76W rICEAeyrbRP1DVTiKtAetHtFB8CcnHeYJzgC+og6PEMr+E2QY9wLetDO5xgJRYKvYzhl sgyA== X-Gm-Message-State: AOAM5305+wtXNnc4FqKutL2Hat/J1ZylVpsrtiVYRO9uT+DMcjv/tYZq Ey6/fTdAtbONVmQ5Gr7P1VTRNqt/vWvidJqcHTt+by/i9tkT41gv4Ow6gpXC2o0tuVJVoFDgPTM xg29cEjwiE6wHahVq X-Received: by 2002:adf:f711:: with SMTP id r17mr6611990wrp.136.1624627985099; Fri, 25 Jun 2021 06:33:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMrbIzVtrzLn06xRbHzTIzAuoiwmLHluMUh9tdNBxa8JBTmBJEkqhQLTqlhtlPtNLNg0sa6A== X-Received: by 2002:adf:f711:: with SMTP id r17mr6611969wrp.136.1624627984948; Fri, 25 Jun 2021 06:33:04 -0700 (PDT) Received: from pc-32.home (2a01cb058918ce00dd1a5a4f9908f2d5.ipv6.abo.wanadoo.fr. [2a01:cb05:8918:ce00:dd1a:5a4f:9908:f2d5]) by smtp.gmail.com with ESMTPSA id b5sm5416298wmj.7.2021.06.25.06.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 06:33:03 -0700 (PDT) Date: Fri, 25 Jun 2021 15:33:01 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, Martin Varghese , Eli Cohen Subject: [PATCH net-next 1/6] bareudp: allow redirecting bareudp packets to eth devices Message-ID: <0aafb805b5a6a845375b5332f07c96c0d43b08e3.1624572003.git.gnault@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Even though bareudp transports L3 data (typically IP or MPLS), it needs to reset the mac_header pointer, so that other parts of the stack don't mistakenly access the outer header after the packet has been decapsulated. This allows to push an Ethernet header to bareudp packets and redirect them to an Ethernet device: $ tc filter add dev bareudp0 ingress matchall \ action vlan push_eth dst_mac 00:00:5e:00:53:01 \ src_mac 00:00:5e:00:53:00 \ action mirred egress redirect dev eth0 Without this patch, push_eth refuses to add an ethernet header because the skb appears to already have a MAC header. Signed-off-by: Guillaume Nault --- drivers/net/bareudp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index edfad93e7b68..a7ee0af1af90 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -133,6 +133,7 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) skb->dev = bareudp->dev; oiph = skb_network_header(skb); skb_reset_network_header(skb); + skb_reset_mac_header(skb); if (!IS_ENABLED(CONFIG_IPV6) || family == AF_INET) err = IP_ECN_decapsulate(oiph, skb); From patchwork Fri Jun 25 13:33:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 467308 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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS 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 B3E03C2B9F4 for ; Fri, 25 Jun 2021 13:33:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A0DA6197F for ; Fri, 25 Jun 2021 13:33:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231680AbhFYNfc (ORCPT ); Fri, 25 Jun 2021 09:35:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58446 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbhFYNfa (ORCPT ); Fri, 25 Jun 2021 09:35:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624627989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wcBFLIEnFRlhUYdUFMk5RzbFnCLcUMnL7WWScaTtUEs=; b=F6D+pRxps01Px6UFsLaVfgG8Aj/Tx3BhLX6eIs8rcwVV9Ko8omw3GdxCQNU0sMXs8tLo7y xgw4kRP7/ta0+hW4IgK2NK63c3dQRbDqU2L+jrew3uUsjkdBgk9eqU4vwN8fEo/px9q4NL uSiWw6yDaYQIIH3QJbvq4/NEZcTSvOA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-MV_gSHQwMMG-5vo04EwhOA-1; Fri, 25 Jun 2021 09:33:08 -0400 X-MC-Unique: MV_gSHQwMMG-5vo04EwhOA-1 Received: by mail-wm1-f71.google.com with SMTP id j6-20020a05600c1906b029019e9c982271so4224039wmq.0 for ; Fri, 25 Jun 2021 06:33:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wcBFLIEnFRlhUYdUFMk5RzbFnCLcUMnL7WWScaTtUEs=; b=JrRU0vidZK+R4PWk7vCEVbUq5zNQF2zXASpX99gqXgOwo40elGcxmbYawJzDxzMxjw kIm3g56LTLcfMevhqntD3nb+iboJfPz1Bdf6Zx6y+ftsdBzOfqB9pyunCLF9R5murW/D NPYdnTT1cl52ZMUeWzCywZt0TQOSAYXVkmcMYh1VEnL6oXRx4KrcG1dwmwz3wjfdR4Lm 9C/kJThUWJL/fQ7M8byGPeO0nGSKH9jlZk9i5VP0+arXtHEUgxwTcQkfJ3bVg5LiQWkM lToPxJc1RxjeyubxtMOGHdlN0x38SN25KX94y/CVTpPyalt7u7TPk5oBMgt8D53/zlJM imjw== X-Gm-Message-State: AOAM530bfS1l6V8hY03TQW111ATjrtqW8z7CC/mnAiuIFmMpkgyNroHM lVknqUprYr+Xz8oCFKdeGJYFd/XT5JgzcF/6m4b8zOFQEPA1JKYUSQCNAW2o315KRqx2ZnMrtc+ hT2swDAyolrIpSqiD X-Received: by 2002:a05:600c:3791:: with SMTP id o17mr10943886wmr.187.1624627987085; Fri, 25 Jun 2021 06:33:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYHRhgr2JZcHzYrT6lYYqjt4DOLy1JOo/IQgoAZ/fi92SsagIuYPb8hj64/xRrsr05pU7sqg== X-Received: by 2002:a05:600c:3791:: with SMTP id o17mr10943862wmr.187.1624627986928; Fri, 25 Jun 2021 06:33:06 -0700 (PDT) Received: from pc-32.home (2a01cb058918ce00dd1a5a4f9908f2d5.ipv6.abo.wanadoo.fr. [2a01:cb05:8918:ce00:dd1a:5a4f:9908:f2d5]) by smtp.gmail.com with ESMTPSA id b18sm7252874wrx.45.2021.06.25.06.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 06:33:06 -0700 (PDT) Date: Fri, 25 Jun 2021 15:33:04 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, Hideaki YOSHIFUJI , David Ahern , Simon Horman Subject: [PATCH net-next 2/6] ipip: allow redirecting ipip and mplsip packets to eth devices Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Even though ipip transports IPv4 or MPLS packets, it needs to reset the mac_header pointer, so that other parts of the stack don't mistakenly access the outer header after the packet has been decapsulated. This allows to push an Ethernet header to ipip or mplsip packets and redirect them to an Ethernet device: $ tc filter add dev ipip0 ingress matchall \ action vlan push_eth dst_mac 00:00:5e:00:53:01 \ src_mac 00:00:5e:00:53:00 \ action mirred egress redirect dev eth0 Without this patch, push_eth refuses to add an ethernet header because the skb appears to already have a MAC header. Signed-off-by: Guillaume Nault --- net/ipv4/ipip.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index d5bfa087c23a..266c65577ba6 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -242,6 +242,8 @@ static int ipip_tunnel_rcv(struct sk_buff *skb, u8 ipproto) if (!tun_dst) return 0; } + skb_reset_mac_header(skb); + return ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error); } From patchwork Fri Jun 25 13:33:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 467771 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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS 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 89C25C2B9F4 for ; Fri, 25 Jun 2021 13:33:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 725336197C for ; Fri, 25 Jun 2021 13:33:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231621AbhFYNfj (ORCPT ); Fri, 25 Jun 2021 09:35:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24265 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbhFYNfi (ORCPT ); Fri, 25 Jun 2021 09:35:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624627997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=07gaNdDU4jdLTbiLg4I5HGLFZA2UUTXHidiT8HumwPs=; b=AJhVdEtDtBi4gNlv0MLdaNpDtmDFnbW/R4d+X2FGgW0CoqKusLy3VdF7u1z2jZiL4UqcPN s7s8egG+HAvEeWJGA7emmKQK8uAS1ph7dK8dfHjQhGwjA3EYnZ7+fi62Xx/K+S0JfIbkCT +Na8O4NGyjoMfrpopFK3bGfvPS5raKo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-EIkJcjNIOHCBiQ5jxTl7Cw-1; Fri, 25 Jun 2021 09:33:12 -0400 X-MC-Unique: EIkJcjNIOHCBiQ5jxTl7Cw-1 Received: by mail-wm1-f71.google.com with SMTP id j38-20020a05600c1c26b02901dbf7d18ff8so4197327wms.8 for ; Fri, 25 Jun 2021 06:33:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=07gaNdDU4jdLTbiLg4I5HGLFZA2UUTXHidiT8HumwPs=; b=Ew03tIch6OGImCQXmNqAeZKAliwB+7oOSWDXd8ScQ7F1aoklvI/UL3HgIY5sUNSGaK vgmGTIQjR4JLfQAUlgIZvC4H9FIbK2Sss4jAQ7F+qA6xDKYplRwOEQ2TzpN09HzQJJV9 wOyGav2jOiW7ULni6px9JJ1RjPcr8wAFbBr2azlUkl+aGrRpOtwoqEo8um8g0j6aCSQA ilLlWdOxcXBQRXnaaYutoady6TxoaK7awbL/Uy33L9dWzvZIsQlSCG1wUpxJ6xEWrOMj 51XtTxfJ/LTswsAArxaj/PaZIlINgJSOAdaFmXrTM+CemLwr3jUzOxVmRtD5i79kH5dV hBrg== X-Gm-Message-State: AOAM532PRvEs2RnjIifLRkZ/xNr4V+lL9fP3W0V/DNuRrFpp4id/0I3S d99LlrQ/BhYjPBT9MHSd4Pq9LN0HkQ4TcQqXJ1GZZGuRqOZh/oIY/bUmi5ZCsYRUppbDZAh/gx5 4OzHjqoevMbDy0mSm X-Received: by 2002:a05:6000:188b:: with SMTP id a11mr10478231wri.274.1624627991118; Fri, 25 Jun 2021 06:33:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyE2dcs4be8AiIZkOa1cCLwPtVzHUUl+nen+50HMmf+fIx4jzwt3pwZiKkzjfqy91lKaRK8lQ== X-Received: by 2002:a05:6000:188b:: with SMTP id a11mr10478218wri.274.1624627990948; Fri, 25 Jun 2021 06:33:10 -0700 (PDT) Received: from pc-32.home (2a01cb058918ce00dd1a5a4f9908f2d5.ipv6.abo.wanadoo.fr. [2a01:cb05:8918:ce00:dd1a:5a4f:9908:f2d5]) by smtp.gmail.com with ESMTPSA id r10sm5996504wrq.17.2021.06.25.06.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 06:33:10 -0700 (PDT) Date: Fri, 25 Jun 2021 15:33:08 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, Hideaki YOSHIFUJI , David Ahern , Simon Horman Subject: [PATCH net-next 3/6] sit: allow redirecting ip6ip, ipip and mplsip packets to eth devices Message-ID: <741ee403015d9241d8005978fc71309930d921ce.1624572003.git.gnault@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Even though sit transports L3 data (IPv6, IPv4 or MPLS) packets, it needs to reset the mac_header pointer, so that other parts of the stack don't mistakenly access the outer header after the packet has been decapsulated. There are two rx handlers to modify: ipip6_rcv() for the ip6ip mode and sit_tunnel_rcv() which is used to re-implement the ipip and mplsip modes of ipip.ko. This allows to push an Ethernet header to sit packets and redirect them to an Ethernet device: $ tc filter add dev sit0 ingress matchall \ action vlan push_eth dst_mac 00:00:5e:00:53:01 \ src_mac 00:00:5e:00:53:00 \ action mirred egress redirect dev eth0 Without this patch, push_eth refuses to add an ethernet header because the skb appears to already have a MAC header. Signed-off-by: Guillaume Nault --- net/ipv6/sit.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index e0a39b0bb4c1..df5bea818410 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -710,6 +710,8 @@ static int ipip6_rcv(struct sk_buff *skb) * old iph is no longer valid */ iph = (const struct iphdr *)skb_mac_header(skb); + skb_reset_mac_header(skb); + err = IP_ECN_decapsulate(iph, skb); if (unlikely(err)) { if (log_ecn_error) @@ -780,6 +782,8 @@ static int sit_tunnel_rcv(struct sk_buff *skb, u8 ipproto) tpi = &ipip_tpi; if (iptunnel_pull_header(skb, 0, tpi->proto, false)) goto drop; + skb_reset_mac_header(skb); + return ip_tunnel_rcv(tunnel, skb, tpi, NULL, log_ecn_error); } From patchwork Fri Jun 25 13:33:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 467307 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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS 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 6F95FC49EA7 for ; Fri, 25 Jun 2021 13:33:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 559EA6197B for ; Fri, 25 Jun 2021 13:33:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229498AbhFYNfk (ORCPT ); Fri, 25 Jun 2021 09:35:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36327 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbhFYNfj (ORCPT ); Fri, 25 Jun 2021 09:35:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624627998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ISp2QePUMvDjiKjeNxC9ivL80ybCZ6sPLL0br4GSbTI=; b=D0uTopDMjxkDuEe3uSDbIUJYuHsjILBkxk6gp5BF7fTEcHs5+gXbTIton9AgJEnshRqNew JK5icizP90hMa1+/3pCW95w8DG67pltcIYomh/WGAM32PGJDknGruF5YsfrMOvaTYEnVlR IMJn0X1mzyRTvUeJQnbiP12XXQbb+IY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-ZpILfLAANiyCmcdac3od5g-1; Fri, 25 Jun 2021 09:33:16 -0400 X-MC-Unique: ZpILfLAANiyCmcdac3od5g-1 Received: by mail-wm1-f69.google.com with SMTP id k16-20020a7bc3100000b02901d849b41038so4195320wmj.7 for ; Fri, 25 Jun 2021 06:33:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ISp2QePUMvDjiKjeNxC9ivL80ybCZ6sPLL0br4GSbTI=; b=BZdnnNFaaQGLZXivUHK+BxHBPVDx8IZW2BQHcG7PapuiAQC+hDh8Hvms0IEAbo9caK pzfT7dg9f+evPStBkQmMg5aXm6ARHaAq4a2u24I7YIlZ17fCs5932h9UqKB/TBw6jkZS 2xSq0yvzPMp1fP2WOXQvDnZGpa4xJTugo+05eFY6jOteAJGXRjUPUbQpIZ53zfQUKCI1 DtTkzP+ZTEqE4wq5tRHmgJUIIECdmrakmtNSsYuwv0DfRcK5WFv8bN5hpEONA9SXYgIM jaBFbiQIRHG7Pt82B29QFP8Aa7AiuSkKCnFSzPICamz7pJekE62cyLjCplm7c06To/Jx BQLw== X-Gm-Message-State: AOAM530dLtsbpunZWTCW+GTkUy/XqD/Tpa5dsloK8I0yti1sHNB9HItQ nyQwbdTEsRFzqDcqfCEozt3iM2GRI6r2A+ggDa3nT1xk8Npv4wySPmzcxVtHwJoBL/OdwGN0w67 fTT0cXzXz87hfCjpK X-Received: by 2002:a7b:cb8a:: with SMTP id m10mr10724296wmi.176.1624627995607; Fri, 25 Jun 2021 06:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO5sxM3bN9PYZyaDWB/CUmKkQtaOD1UnFzzhL/0MV01Qosya0yuZViIUjq2/c9gfwG5RubJQ== X-Received: by 2002:a7b:cb8a:: with SMTP id m10mr10724280wmi.176.1624627995490; Fri, 25 Jun 2021 06:33:15 -0700 (PDT) Received: from pc-32.home (2a01cb058918ce00dd1a5a4f9908f2d5.ipv6.abo.wanadoo.fr. [2a01:cb05:8918:ce00:dd1a:5a4f:9908:f2d5]) by smtp.gmail.com with ESMTPSA id z3sm11127185wmi.29.2021.06.25.06.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 06:33:15 -0700 (PDT) Date: Fri, 25 Jun 2021 15:33:13 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, Hideaki YOSHIFUJI , David Ahern , Jiri Benc Subject: [PATCH net-next 4/6] gre: let mac_header point to outer header only when necessary Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit e271c7b4420d ("gre: do not keep the GRE header around in collect medata mode") did reset the mac_header for the collect_md case. Let's extend this behaviour to classical gre devices as well. ipgre_header_parse() seems to be the only case that requires mac_header to point to the outer header. We can detect this case accurately by checking ->header_ops. For all other cases, we can reset mac_header. This allows to push an Ethernet header to ipgre packets and redirect them to an Ethernet device: $ tc filter add dev gre0 ingress matchall \ action vlan push_eth dst_mac 00:00:5e:00:53:01 \ src_mac 00:00:5e:00:53:00 \ action mirred egress redirect dev eth0 Before this patch, this worked only for collect_md gre devices. Now this works for regular gre devices as well. Only the special case of gre devices that use ipgre_header_ops isn't supported. Signed-off-by: Guillaume Nault --- net/ipv4/ip_gre.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index a68bf4c6fe9b..12dca0c85f3c 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -107,6 +107,8 @@ module_param(log_ecn_error, bool, 0644); MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN"); static struct rtnl_link_ops ipgre_link_ops __read_mostly; +static const struct header_ops ipgre_header_ops; + static int ipgre_tunnel_init(struct net_device *dev); static void erspan_build_header(struct sk_buff *skb, u32 id, u32 index, @@ -364,7 +366,10 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi, raw_proto, false) < 0) goto drop; - if (tunnel->dev->type != ARPHRD_NONE) + /* Special case for ipgre_header_parse(), which expects the + * mac_header to point to the outer IP header. + */ + if (tunnel->dev->header_ops == &ipgre_header_ops) skb_pop_mac_header(skb); else skb_reset_mac_header(skb); From patchwork Fri Jun 25 13:33:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 467770 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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS 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 D8A6DC2B9F4 for ; Fri, 25 Jun 2021 13:33:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C32336197C for ; Fri, 25 Jun 2021 13:33:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231719AbhFYNfq (ORCPT ); Fri, 25 Jun 2021 09:35:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58864 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231710AbhFYNfn (ORCPT ); Fri, 25 Jun 2021 09:35:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624628002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Nv53atI+/3xq82pcVecJPgLExtd+IzeYGeaDiAVjnpY=; b=B0dTb2PtWVcFC42XpaqtKSwtEM7yoMNjQAsvooZ+DTs+kVYQY+zENy9ut4ktY6K6A3zAAe MPolh4bvLkLhMbr0NJ2Q4lcrPSyJZ6VfN3/f5ceC2gXSkVZUDV6zb2gYcNhjHnepibH4IN u0mnz4c2aY3CWsqUiKjgxFQfI0KtQQ4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-126-wFVvX7hiOfOExMJ7yf3EfA-1; Fri, 25 Jun 2021 09:33:21 -0400 X-MC-Unique: wFVvX7hiOfOExMJ7yf3EfA-1 Received: by mail-wr1-f70.google.com with SMTP id l6-20020a0560000226b029011a80413b4fso3484500wrz.23 for ; Fri, 25 Jun 2021 06:33:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Nv53atI+/3xq82pcVecJPgLExtd+IzeYGeaDiAVjnpY=; b=pFyebMhanPaeegds+ViMu1B1JtlMmhu8HQPpNb2pRTqdzWkASaiXxt/9cVsyPBMvgM jPbcXTgXrAQtV94S7KIW3obm4An5Kx/FXl3AERr7VBXDEZ9g4r53THzlo1vPeiGC8kqL plLkvH4NIZO+By3F9m4pXAQ/hU1B6XenhETYccjDpNJIEJEt0GLPznmQ3FyfMBbgNda/ /9EH6tXT8Yfhfe1s4s27KtKs0ynKSDof/2Z353xYXCXQqQnm6XuSPYOAovrgLx+nqta/ dMZAuEYzrD0IhsmklT9ZxZjOYdKMSz3Wfhb30NWbwvyrMKTtIZhTt+8oyB7xpIRW3/xO DaiA== X-Gm-Message-State: AOAM531MYADoo4Wg1RlcCuac19GUVi5sFnpfepiGnw7qeuyaUCFUklet QCOGliqXSf+hhW48Ws3tO9JrBQ07jVCFSgwfrNSPl6r3tDro7Q6YQ7eo+3riuHqdlBcHmi58C6H QvRb4sd8vZbYDgvne X-Received: by 2002:a05:6000:1245:: with SMTP id j5mr10967358wrx.371.1624628000216; Fri, 25 Jun 2021 06:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymH3WMVfjoPhIqwGJfKuPDEEh38Z+WK7RGQyNJFzedbPufv2FEYPEwbiYNkhvVxPhQI2VA2Q== X-Received: by 2002:a05:6000:1245:: with SMTP id j5mr10967345wrx.371.1624628000103; Fri, 25 Jun 2021 06:33:20 -0700 (PDT) Received: from pc-32.home (2a01cb058918ce00dd1a5a4f9908f2d5.ipv6.abo.wanadoo.fr. [2a01:cb05:8918:ce00:dd1a:5a4f:9908:f2d5]) by smtp.gmail.com with ESMTPSA id y66sm5769906wmy.39.2021.06.25.06.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 06:33:19 -0700 (PDT) Date: Fri, 25 Jun 2021 15:33:17 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, Hideaki YOSHIFUJI , David Ahern , Tom Herbert Subject: [PATCH net-next 5/6] ip6_tunnel: allow redirecting ip6gre and ipxip6 packets to eth devices Message-ID: <0d7669824973cb3825c00553ca912997e4a1f2be.1624572003.git.gnault@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Reset the mac_header pointer even when the tunnel transports only L3 data (in the ARPHRD_ETHER case, this is already done by eth_type_trans). This prevents other parts of the stack from mistakenly accessing the outer header after the packet has been decapsulated. In practice, this allows to push an Ethernet header to ipip6, ip6ip6, mplsip6 or ip6gre packets and redirect them to an Ethernet device: $ tc filter add dev ip6tnl0 ingress matchall \ action vlan push_eth dst_mac 00:00:5e:00:53:01 \ src_mac 00:00:5e:00:53:00 \ action mirred egress redirect dev eth0 Without this patch, push_eth refuses to add an ethernet header because the skb appears to already have a MAC header. Signed-off-by: Guillaume Nault --- net/ipv6/ip6_tunnel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 288bafded998..0b8a38687ce4 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -837,6 +837,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb, skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); } else { skb->dev = tunnel->dev; + skb_reset_mac_header(skb); } skb_reset_network_header(skb); From patchwork Fri Jun 25 13:33:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 467306 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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS 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 763F3C2B9F4 for ; Fri, 25 Jun 2021 13:33:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E9926197C for ; Fri, 25 Jun 2021 13:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231713AbhFYNf4 (ORCPT ); Fri, 25 Jun 2021 09:35:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26080 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbhFYNft (ORCPT ); Fri, 25 Jun 2021 09:35:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624628007; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hKk8ehhPwsaZmv01FKLGHWWpwSjV54lb50ZYmD/4jjE=; b=NWm2JQXIFxlZs9jGCvBDlC8BrRnwbeYBegCxiLgtcHKo7cv9tEVqzJD8d9wckvtMeTB4IH WNFiXDdcy/3yLrDjr8W132u51VE/EAkmxtIhOfva6oZm4+i1OPYWB+bxcNBIpC7Tsav3rn 5FxZBNDcc8QjuwBz1ZQRhRH20GmqGkI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99-TCao6h9WOWWxjsFBFCZ-Jw-1; Fri, 25 Jun 2021 09:33:26 -0400 X-MC-Unique: TCao6h9WOWWxjsFBFCZ-Jw-1 Received: by mail-wr1-f71.google.com with SMTP id b3-20020a05600018a3b029011a84f85e1cso3508866wri.10 for ; Fri, 25 Jun 2021 06:33:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hKk8ehhPwsaZmv01FKLGHWWpwSjV54lb50ZYmD/4jjE=; b=EJHlOGAwaN2+frsNILIvDgaHC6BV/FO6iFyT7SquHHppZ9Ic5sOU9RoNB31CSHd4/p 5eonyNCmgn8vByKd/8nc4QCk9WSmmM2iqa/3jy1a/WbwFufs1zdp72moKdNF6W5J0RlF 4IxnKSon7zBG4SHEGDT5bq9icm9yjn1q0uy04QPTL5IQSOw1DuWttmxTcDuPM0NiGY4h gt7bOda6GMo3cD0XeXKNIdrSJCIUvgxx3m0ai1nqPcLyIPGr+0fZfVDg32WjAeMuwnEL lXz++32fKBIk6oIbZerB3J1bSpmVKeBogx7aKOKFLlRXMZEXA52oKVGFsvZfqxqPXIn+ r3og== X-Gm-Message-State: AOAM532AqaSKgC6+oOGyWVnMaZKiRfBePrfacYna24HlcvxT1uavr39A J+St30gic6aATeaLKLR45rMtTPB7cgCF3uvJbATzo2Q5hde5n75515HFrcQXq3FESjRjDp9TcdS N5OZZXXrfkR0EhN7h X-Received: by 2002:a05:6000:1367:: with SMTP id q7mr11177908wrz.306.1624628005319; Fri, 25 Jun 2021 06:33:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0/UMU51nxm/oAWHLm16J4e4QO9vcW9LsS6LpQ2bpb79Y+DM5sQxDiNSnoEECUX0I6t9AhyA== X-Received: by 2002:a05:6000:1367:: with SMTP id q7mr11177893wrz.306.1624628005212; Fri, 25 Jun 2021 06:33:25 -0700 (PDT) Received: from pc-32.home (2a01cb058918ce00dd1a5a4f9908f2d5.ipv6.abo.wanadoo.fr. [2a01:cb05:8918:ce00:dd1a:5a4f:9908:f2d5]) by smtp.gmail.com with ESMTPSA id c12sm7104288wrr.90.2021.06.25.06.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 06:33:24 -0700 (PDT) Date: Fri, 25 Jun 2021 15:33:23 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, Pablo Neira Ayuso , Harald Welte , Andreas Schultz , Jonas Bonn Subject: [PATCH net-next 6/6] gtp: reset mac_header after decap Message-ID: <0afd995463a3a2b4811b0b15f55deccbe0eaf5a1.1624572003.git.gnault@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For consistency with other L3 tunnel devices, reset the mac_header pointer after decapsulation. This makes the mac_header 0 bytes long, thus making it clear that this skb has no mac_header. Compile tested only. Signed-off-by: Guillaume Nault --- drivers/net/gtp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 1c9023d47e00..30e0a10595a1 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -201,6 +201,7 @@ static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff *skb, * calculate the transport header. */ skb_reset_network_header(skb); + skb_reset_mac_header(skb); skb->dev = pctx->dev;