Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp800704ybg; Wed, 10 Jun 2020 14:12:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw63f5qlZzPLtHrZpFAkVtULbvPQvwi37dSu4UHj0dfGanQ4xr/2YrijmmvcVTCf8QFn5oS X-Received: by 2002:a17:906:7751:: with SMTP id o17mr5466521ejn.111.1591823533960; Wed, 10 Jun 2020 14:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591823533; cv=none; d=google.com; s=arc-20160816; b=ZoxDGHDnlF7l6Oa2SBlRyzHIBnhFbSYdhha8a8sVMlVji5tbb5HJfmE293UbhiClBl GarN/BACY/wcizGjkwHL6mKRCe9ZbIZXCp07DU1FlaEtxeMj6LANKAio+0OGkBeC2fH+ 56iSR4EUrsSqxk5Ah6WAYDOTo/6sDQWAHsH0uyLgTARacurY7X9pAwm7F2N0ahCeQAIP XkYSZJU0diRsPcQMblKw1uJlEHRkQooYWIvgmYIvSHh8CN0iRjC/byJBsx3I8o8Ol0cE tBFt3+3pvtrxfjyKwscPCrjlkSQZJPBS++SgBDcifq9RpG99GkavDyfAvnwI1IVKUmtY vlvw== 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=YVEyyFJvpb/MDPvJV+GhQyShpvWb2NY3XyrK1WQulXUzZm2fqYhoT3DXLooZ1kvt70 /3TNPJisDm4b6LAvprbRGxuB/vnhG9qz+zGZRrEyYRWTcoljYQ+TG6Vs4anH6QWQRO4d kmW8LGp1AorZcfmDDfQzFjNXOYys2LV1YCPKsiOqSmgxeD6PWzQNZQpWoMHCG6bdjM57 Qsuxc5AC7cV9bOZv6PTWf25zfHoaneSk0N51Y152UesEF78XWTrvhLu8pvF5WHG2LxSX V1JVJxfiFNT+hqGppFUIb+q4/en3bLH+FjeLeabN/jAonrSWCtT6tBXSMpRDmy+nIN2A pTew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UFUghsm0; 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 o10si744041ejr.656.2020.06.10.14.11.51; Wed, 10 Jun 2020 14:12:13 -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=UFUghsm0; 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 S1730083AbgFJS7l (ORCPT + 99 others); Wed, 10 Jun 2020 14:59:41 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:57650 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728043AbgFJS7j (ORCPT ); Wed, 10 Jun 2020 14:59:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591815577; 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=UFUghsm0jX2BF5xUdySKmJzxyqKHACG7Ioxa0PJLA84auxhPx8xj5glFev3bM70WLiIHmd O/eybnKQ7Ip53QPaJ6ftbopvfLCz8k6GIzASysoVG+WHuGztCK6GfCG8lOBptwylRJPn+C OVHs1lb6JSKydSmQnfx2uNm2Q5roIRs= 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-160-bS6LqGuBPL-24bCqkFVOQA-1; Wed, 10 Jun 2020 14:59:34 -0400 X-MC-Unique: bS6LqGuBPL-24bCqkFVOQA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75A13EC1A1; Wed, 10 Jun 2020 18:59:31 +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 34ED710013D0; Wed, 10 Jun 2020 18:59:29 +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 v2 1/4] xfrm: bail early on slave pass over skb Date: Wed, 10 Jun 2020 14:59:07 -0400 Message-Id: <20200610185910.48668-2-jarod@redhat.com> In-Reply-To: <20200610185910.48668-1-jarod@redhat.com> References: <20200608210058.37352-1-jarod@redhat.com> <20200610185910.48668-1-jarod@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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