Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4675177ybg; Mon, 8 Jun 2020 14:03:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzST7AxQ9Ioj42/3lp+qhecPhSxNTVaMhK8aOgpmTeDGwyRWSuzHOrcB4PqhHg+I59NDsxT X-Received: by 2002:a17:906:2b48:: with SMTP id b8mr23864837ejg.332.1591650214437; Mon, 08 Jun 2020 14:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591650214; cv=none; d=google.com; s=arc-20160816; b=CH9UBmG3K3gvzePPRzmZLhE4FynWQCwVOBiqJt6K9qHFKJ2Ek4gY6SkajSACptWU9N pKcavX7o63FyVtn9m5M+yM8cmFJ6RriyxooC0z9P5f4ZTH+86iIvirMqBKmW353n+FJz D3kD+bLsmG9qctv++YDYpI/XtKnCFNHPI+fGiBEjD3b45tDf2JrnBtZb5O7RBgR2UyIQ U97VfHLM2j4pRV8tuoQltcu48SbjfJlGDXwE4a1eVzohUIGqPyW9SqniSyr5RAqgWhmT SRlU9dMQtl8Yg8qCgXMqoNXj2rYKgkbT65qwE6sW1dJO0tRLgCSuIvWoiz+M6HWhzNeC v+2g== 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=mZRjN4QhW5X6YfR7Z2yjjbULaODEXfUST0bMuVtU8r4=; b=lWM6qs+crHDjwkGh6dkucoLqTSHrT2ZmcmayuYXC4Phx2dzcWTdMbSNCT5dn5iLL0g 5p78ipZC8wLALaweMSX//PC96EEri4Xy4nHY03oxrNBf7IWsAFm1YtVFVgbkdjc90BHg Enr8h+ULbF2mzq1rlI6fC0YNDIBCY8oW4l4wF+lpJa93h5re6jbAe5HlBJk09AmQBK+w O5wicjDRFAq+ohEeGDrfBD26sARuvS6gauNSQBPzy6pM2L1ZDDV8OEppA+IQpoX+qeIW SKckuxwtLZT98MvLnJjZi9qgBhAEjeCCOwqMS/F6iQRoxEB48wLq2P8yJhLIz5FznBQj z6dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TVq4UqEp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i16si9059014ejh.449.2020.06.08.14.03.12; Mon, 08 Jun 2020 14:03:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@redhat.com header.s=mimecast20190719 header.b=TVq4UqEp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbgFHVBT (ORCPT + 99 others); Mon, 8 Jun 2020 17:01:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:40542 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726776AbgFHVBQ (ORCPT ); Mon, 8 Jun 2020 17:01:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591650075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mZRjN4QhW5X6YfR7Z2yjjbULaODEXfUST0bMuVtU8r4=; b=TVq4UqEpH6AzOPmz2u6Bgb7NTJYGje/XKnsbvG1tpExn+Q4km03fRIbArVCniSnuvYC2wt 2STGGESwY2zyDneh0ZGE98UGbn+vWJdzxIJiEwbECNrBJX4l6+tD1VwzhKjmnzKdO9A7uN 52JrWhmCE/ZhwuCBKUASnpw3/hH5878= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-No3wbXOUNVKMTEBnZFNWjw-1; Mon, 08 Jun 2020 17:01:10 -0400 X-MC-Unique: No3wbXOUNVKMTEBnZFNWjw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 925A31883612; Mon, 8 Jun 2020 21:01:08 +0000 (UTC) Received: from hp-dl360pgen8-07.khw2.lab.eng.bos.redhat.com (hp-dl360pgen8-07.khw2.lab.eng.bos.redhat.com [10.16.210.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2B7D61169; Mon, 8 Jun 2020 21:01:06 +0000 (UTC) From: Jarod Wilson To: linux-kernel@vger.kernel.org Cc: Jarod Wilson , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jeff Kirsher , Jakub Kicinski , Steffen Klassert , Herbert Xu , netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org Subject: [PATCH net-next 1/4] xfrm: bail early on slave pass over skb Date: Mon, 8 Jun 2020 17:00:55 -0400 Message-Id: <20200608210058.37352-2-jarod@redhat.com> In-Reply-To: <20200608210058.37352-1-jarod@redhat.com> References: <20200608210058.37352-1-jarod@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is prep work for initial support of bonding hardware encryption pass-through support. The bonding driver will fill in the slave_dev pointer, and we use that to know not to skb_push() again on a given skb that was already processed on the bond device. CC: Jay Vosburgh CC: Veaceslav Falico CC: Andy Gospodarek CC: "David S. Miller" CC: Jeff Kirsher CC: Jakub Kicinski CC: Steffen Klassert CC: Herbert Xu CC: netdev@vger.kernel.org CC: intel-wired-lan@lists.osuosl.org Signed-off-by: Jarod Wilson --- include/net/xfrm.h | 1 + net/xfrm/xfrm_device.c | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 094fe682f5d7..e20b2b27ec48 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -127,6 +127,7 @@ struct xfrm_state_walk { struct xfrm_state_offload { struct net_device *dev; + struct net_device *slave_dev; unsigned long offload_handle; unsigned int num_exthdrs; u8 flags; diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c index f50d1f97cf8e..b8918fc5248b 100644 --- a/net/xfrm/xfrm_device.c +++ b/net/xfrm/xfrm_device.c @@ -106,6 +106,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur struct sk_buff *skb2, *nskb, *pskb = NULL; netdev_features_t esp_features = features; struct xfrm_offload *xo = xfrm_offload(skb); + struct net_device *dev = skb->dev; struct sec_path *sp; if (!xo) @@ -119,6 +120,10 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur if (xo->flags & XFRM_GRO || x->xso.flags & XFRM_OFFLOAD_INBOUND) return skb; + /* This skb was already validated on the master dev */ + if ((x->xso.dev != dev) && (x->xso.slave_dev == dev)) + return skb; + local_irq_save(flags); sd = this_cpu_ptr(&softnet_data); err = !skb_queue_empty(&sd->xfrm_backlog); @@ -129,25 +134,20 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur return skb; } - if (skb_is_gso(skb)) { - struct net_device *dev = skb->dev; - - if (unlikely(x->xso.dev != dev)) { - struct sk_buff *segs; + if (skb_is_gso(skb) && unlikely(x->xso.dev != dev)) { + struct sk_buff *segs; - /* Packet got rerouted, fixup features and segment it. */ - esp_features = esp_features & ~(NETIF_F_HW_ESP - | NETIF_F_GSO_ESP); + /* Packet got rerouted, fixup features and segment it. */ + esp_features = esp_features & ~(NETIF_F_HW_ESP | NETIF_F_GSO_ESP); - segs = skb_gso_segment(skb, esp_features); - if (IS_ERR(segs)) { - kfree_skb(skb); - atomic_long_inc(&dev->tx_dropped); - return NULL; - } else { - consume_skb(skb); - skb = segs; - } + segs = skb_gso_segment(skb, esp_features); + if (IS_ERR(segs)) { + kfree_skb(skb); + atomic_long_inc(&dev->tx_dropped); + return NULL; + } else { + consume_skb(skb); + skb = segs; } } -- 2.20.1