From patchwork Thu Mar 26 09:02:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 221808 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT 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 755EBC43331 for ; Thu, 26 Mar 2020 09:02:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 446532070A for ; Thu, 26 Mar 2020 09:02:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GDtb20Ke" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727742AbgCZJCu (ORCPT ); Thu, 26 Mar 2020 05:02:50 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:41382 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbgCZJCu (ORCPT ); Thu, 26 Mar 2020 05:02:50 -0400 Received: by mail-pl1-f195.google.com with SMTP id t16so1883704plr.8 for ; Thu, 26 Mar 2020 02:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=G6Gn9p3Ec01xE6utZqG5eed8oBFLxDsG8Rbe5vC1mWU=; b=GDtb20Ke2iMzLrgvoHp01kAO9Hvkv+hbdeHnzgttQDbt2BqP5XbQ5jCHf8Avq8T9RN Zi8yrGLbjUIm9sHtf8TayvawB8JxEnNlq8SP33xHy91U5Wte9uh/2jQbrzU34H0s770+ e8KPrJJjfpz9fZyjkSaoxLo9dJrm7SALOEOWT4Kj2QpVnWW/UlUkwusCAxXjCgZDhxB/ /qDINdvKa0qH0ou6nlFsK5uYvYDJmpF4qaFUua68GHzvcuV/sQ0rd/vbNY6xsOKJArjN 4poTUm3A1xLMkTMV46cgGjBgctNpNptLUWtF+1lJrSTkLkEKN0sfLcbK2g6MQdazjy0E UP+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=G6Gn9p3Ec01xE6utZqG5eed8oBFLxDsG8Rbe5vC1mWU=; b=ILxlOAoNysO4z8X1mBAPpVGlXojyXAm2ohzvt9xXbDjreEWJ20Ew73uT9RXRURYR4t JqT6P2AB6r5IaycuHpdE7IAUTMXVNR60ra2ThlNVIiP9TQx5pJkm7K+OUc4l+LuEj5sR /XvxZI6wsD8dRGgyhHQm9lBWdiK/GRwVhCN1GnaN9ZmhhQnAPBJza6EZkkgvU4nUe3Fg A72Da75X4DrmUx8VGW83bhnbyqZQlRIk4Yp1c/4n721VTetEG1jTWerIv20bgLKKKnFH WvX884L6dFGfjNgLnJlbxWG60NOSOC/FRMige/AzZpLvu7zASCPU3qx3A7tJgX3T1Lat vPMQ== X-Gm-Message-State: ANhLgQ0C//AQyfzRVLB4INd6X84SAVoFDn+Kbx8vW0yLJhax7FhQyTwR 5Wzj46RN2qtGcobQu+IrFD1GNgbs X-Google-Smtp-Source: ADFU+vvU7jK58JYB9AoI6c18k32PwFYKhUDUaeMMOqJTrCJnCoocZ03M/SdrJpJeWRhws/VGlafQ+Q== X-Received: by 2002:a17:90a:315:: with SMTP id 21mr1878126pje.96.1585213368349; Thu, 26 Mar 2020 02:02:48 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id d3sm1194413pfq.126.2020.03.26.02.02.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Mar 2020 02:02:47 -0700 (PDT) From: Xin Long To: netdev@vger.kernel.org Cc: Steffen Klassert , Herbert Xu , "David S. Miller" , Florian Westphal , Sabrina Dubroca Subject: [PATCH ipsec-next 1/3] esp4: add gso_segment for esp4 beet mode Date: Thu, 26 Mar 2020 17:02:29 +0800 Message-Id: <0baafba3ed70c5e04d437faf83f2c40f57f52540.1585213292.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Similar to xfrm4_tunnel/transport_gso_segment(), _gso_segment() is added to do gso_segment for esp4 beet mode. Before calling inet_offloads[proto]->callbacks.gso_segment, it needs to do: - Get the upper proto from ph header to get its gso_segment when xo->proto is IPPROTO_BEETPH. - Add SKB_GSO_TCPV4 to gso_type if x->sel.family == AF_INET6 and the proto == IPPROTO_TCP, so that the current tcp ipv4 packet can be segmented. - Calculate a right value for skb->transport_header and move skb->data to the transport header position. Signed-off-by: Xin Long --- net/ipv4/esp4_offload.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c index e2e219c..731022c 100644 --- a/net/ipv4/esp4_offload.c +++ b/net/ipv4/esp4_offload.c @@ -132,6 +132,36 @@ static struct sk_buff *xfrm4_transport_gso_segment(struct xfrm_state *x, return segs; } +static struct sk_buff *xfrm4_beet_gso_segment(struct xfrm_state *x, + struct sk_buff *skb, + netdev_features_t features) +{ + struct xfrm_offload *xo = xfrm_offload(skb); + struct sk_buff *segs = ERR_PTR(-EINVAL); + const struct net_offload *ops; + int proto = xo->proto; + + skb->transport_header += x->props.header_len; + + if (proto == IPPROTO_BEETPH) { + struct ip_beet_phdr *ph = (struct ip_beet_phdr *)skb->data; + + skb->transport_header += ph->hdrlen * 8; + proto = ph->nexthdr; + } else if (x->sel.family != AF_INET6) { + skb->transport_header -= IPV4_BEET_PHMAXLEN; + } else if (proto == IPPROTO_TCP) { + skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV4; + } + + __skb_pull(skb, skb_transport_offset(skb)); + ops = rcu_dereference(inet_offloads[proto]); + if (likely(ops && ops->callbacks.gso_segment)) + segs = ops->callbacks.gso_segment(skb, features); + + return segs; +} + static struct sk_buff *xfrm4_outer_mode_gso_segment(struct xfrm_state *x, struct sk_buff *skb, netdev_features_t features) @@ -141,6 +171,8 @@ static struct sk_buff *xfrm4_outer_mode_gso_segment(struct xfrm_state *x, return xfrm4_tunnel_gso_segment(x, skb, features); case XFRM_MODE_TRANSPORT: return xfrm4_transport_gso_segment(x, skb, features); + case XFRM_MODE_BEET: + return xfrm4_beet_gso_segment(x, skb, features); } return ERR_PTR(-EOPNOTSUPP); From patchwork Thu Mar 26 09:02:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 221807 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT 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 4E28EC43331 for ; Thu, 26 Mar 2020 09:03:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FD2F2070A for ; Thu, 26 Mar 2020 09:03:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ud33KFWW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727768AbgCZJC7 (ORCPT ); Thu, 26 Mar 2020 05:02:59 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37835 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbgCZJC6 (ORCPT ); Thu, 26 Mar 2020 05:02:58 -0400 Received: by mail-pl1-f193.google.com with SMTP id x1so1891072plm.4 for ; Thu, 26 Mar 2020 02:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=qKM544i7sMxs7sN6CF+56+EfYgSDyC7c3U6yG2tQvdU=; b=Ud33KFWWAaGjrFsILnPjoIBSpeFTCdwroQwP1f4+51BQaopzInefIjpqiArU4EJsak UCnOWocFiw/CmPzetmQx7DCEq8/DT7VLIq1/2YBRynwl4R8KcSKIUHxhdXue7aufi12T jKng38wnQWeijVM1vAaLlpaDiLUJFwryWJdeuTJKSRTYi3zvB2QvVYTtxnuHAVj1MjUN 6myB1j1TDJ+7JgvcERi27IEPDvVJavvIOmBwNQpTm5OtzzGZ4llqxhxOUNDjewxjd8kS ixkbtNgWAYDwJYTNa8VVaj1lLyEGgZXkzo1rroUEh1VI+1AHB7qCcUvDt4slu3uyww98 dxaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=qKM544i7sMxs7sN6CF+56+EfYgSDyC7c3U6yG2tQvdU=; b=IyiJ4Y3HVPecwKAHrDniv58fijaf37Tg8tS9JDusePqHT117iH/UXG9VMuyfa7mI3W L9GBbKPwWibPCfikA6MCKx3TeqXd6oAD4IBI6mgLyiRw0168SbcDVTPChx+1Lo3G4NLq 4PcZeSfTMQEyud+onCSwTwB2kjHQiYM7OfJMn2s5oe1+WzxgyK1EHGJDvtndM7T2713g ncluq8DTl/uQg2hrgOKUV04D2FX5FUKELlps8VfE9VfnCkWcD40CFYF8DaY3skST981R uPjCJxHUmvm+9eoweLslTD5GRIe97HLbWPdBOxuiiwyh1OtFp7PkOwKjYRKYiUEBp2Nw P/4Q== X-Gm-Message-State: ANhLgQ3a0U8JIx4oUn+SKHcjgbn1yysH7jK8zYzF6IPW+rWBNKmRRroq AyJ1XfIbl+3dCrKXVm5Z66ZxQvAO X-Google-Smtp-Source: ADFU+vvZ9Q1d2fYNImYGpQedR8Kt/8juTiMrqS4Uif5+kold/2OgL3rkbTydVQqADKUa//fQSWOYxw== X-Received: by 2002:a17:90a:5888:: with SMTP id j8mr2034701pji.61.1585213377534; Thu, 26 Mar 2020 02:02:57 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id y18sm1152753pfe.19.2020.03.26.02.02.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Mar 2020 02:02:56 -0700 (PDT) From: Xin Long To: netdev@vger.kernel.org Cc: Steffen Klassert , Herbert Xu , "David S. Miller" , Florian Westphal , Sabrina Dubroca Subject: [PATCH ipsec-next 2/3] esp6: add gso_segment for esp6 beet mode Date: Thu, 26 Mar 2020 17:02:30 +0800 Message-Id: X-Mailer: git-send-email 2.1.0 In-Reply-To: <0baafba3ed70c5e04d437faf83f2c40f57f52540.1585213292.git.lucien.xin@gmail.com> References: <0baafba3ed70c5e04d437faf83f2c40f57f52540.1585213292.git.lucien.xin@gmail.com> In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Similar to xfrm6_tunnel/transport_gso_segment(), _gso_segment() is added to do gso_segment for esp6 beet mode. Before calling inet6_offloads[proto]->callbacks.gso_segment, it needs to do: - Get the upper proto from ph header to get its gso_segment when xo->proto is IPPROTO_BEETPH. - Add SKB_GSO_TCPV6 to gso_type if x->sel.family != AF_INET6 and the proto == IPPROTO_TCP, so that the current tcp ipv6 packet can be segmented. - Calculate a right value for skb->transport_header and move skb->data to the transport header position. Signed-off-by: Xin Long --- net/ipv6/esp6_offload.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c index fd53505..8eab2c8 100644 --- a/net/ipv6/esp6_offload.c +++ b/net/ipv6/esp6_offload.c @@ -159,6 +159,40 @@ static struct sk_buff *xfrm6_transport_gso_segment(struct xfrm_state *x, return segs; } +static struct sk_buff *xfrm6_beet_gso_segment(struct xfrm_state *x, + struct sk_buff *skb, + netdev_features_t features) +{ + struct xfrm_offload *xo = xfrm_offload(skb); + struct sk_buff *segs = ERR_PTR(-EINVAL); + const struct net_offload *ops; + int proto = xo->proto; + + skb->transport_header += x->props.header_len; + + if (proto == IPPROTO_BEETPH) { + struct ip_beet_phdr *ph = (struct ip_beet_phdr *)skb->data; + + skb->transport_header += ph->hdrlen * 8; + proto = ph->nexthdr; + } + + if (x->sel.family != AF_INET6) { + skb->transport_header -= + (sizeof(struct ipv6hdr) - sizeof(struct iphdr)); + + if (proto == IPPROTO_TCP) + skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6; + } + + __skb_pull(skb, skb_transport_offset(skb)); + ops = rcu_dereference(inet6_offloads[proto]); + if (likely(ops && ops->callbacks.gso_segment)) + segs = ops->callbacks.gso_segment(skb, features); + + return segs; +} + static struct sk_buff *xfrm6_outer_mode_gso_segment(struct xfrm_state *x, struct sk_buff *skb, netdev_features_t features) @@ -168,6 +202,8 @@ static struct sk_buff *xfrm6_outer_mode_gso_segment(struct xfrm_state *x, return xfrm6_tunnel_gso_segment(x, skb, features); case XFRM_MODE_TRANSPORT: return xfrm6_transport_gso_segment(x, skb, features); + case XFRM_MODE_BEET: + return xfrm6_beet_gso_segment(x, skb, features); } return ERR_PTR(-EOPNOTSUPP);