Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6575734rwp; Tue, 18 Jul 2023 02:34:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlF479RFmKbMBmkKOe2mwT4kA/M9w42IS/vzDdEvl8Be8HcFKxYSv83tINIS+rXygHiTpNdP X-Received: by 2002:a17:906:c28f:b0:978:7262:d125 with SMTP id r15-20020a170906c28f00b009787262d125mr12524353ejz.76.1689672869936; Tue, 18 Jul 2023 02:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689672869; cv=none; d=google.com; s=arc-20160816; b=ykRzJDguvC05zQdNpxtzc/dVtp4smTTz8tPCPjKa/tLHbpYcQ7IRMFCYok4wbwbICB Wl+ObcNgQm3wQ3y8b134KZccjvUJZRlZBopxl1VRQtkF1CdOCCJ3p/l3V6iFqK2BFSdL SICwKcOeo87HVwE47ymehXtbJntU9Vqg/nPdil2IiZQyMPg6ff5ZyhQXxldJeRQ5/KaL bXSUzyxTgv3XBfee/krm9r5/yze8IzIET0KES65vdIhK6skylQ1yGQm9ywS6TU+vzajQ K0f0scTpwVRS1CZ2SWZQV3dK14ZXeKLHFt+3TiNrgLx1BpuXBW7IISzOOQYx/fMOznIK zKUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=NMmvKRp+3I4Z/9KweExjsB6OX8zNLrt8ehA9B7eaT5E=; fh=o2ieaTKSCmgMb3tcMpOyNlhllYLO0fUPNRSw0x3fd0w=; b=ggo8Aal0m5fr35HNR3C05XvwCcTl5I6BtH5i7yA8/vA4aXtZHL067bFGemjOQeVb2h gVwN2ySqoWgEryFqsZTnLUG6JZL99STILo9SSKxJEX5QL+PtMDguUpEsVuKKnQn9SDY/ uD+dX1/U+4DuglJ3ekTnMgxOhw4oMAu53XHHVcHHK5AkWDGoS3n0uEA9ki6MtmnVtNho tmdOrxOJlm4/ltOPYaVvEJlgj31KTckbCBqS/4G9sARaiggUjogB/6SEij2HgAHWo80t GPYCP3AHFMDqv7lbDkBPK7oZDPWdoQ5MKjTvah9Gmpu9Yu7FkV9hGmqq9wW+XoTAVav2 6fmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a1709063c0400b00993032b5db1si882038ejg.726.2023.07.18.02.34.05; Tue, 18 Jul 2023 02:34:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231462AbjGRJYO (ORCPT + 99 others); Tue, 18 Jul 2023 05:24:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231558AbjGRJYN (ORCPT ); Tue, 18 Jul 2023 05:24:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF3C4E4F for ; Tue, 18 Jul 2023 02:24:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 54FB0614E9 for ; Tue, 18 Jul 2023 09:24:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10489C433C8; Tue, 18 Jul 2023 09:24:07 +0000 (UTC) From: Ilia Lin To: steffen.klassert@secunet.com, herbert@gondor.apana.org.au, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, leonro@nvidia.com, Ilia Lin Subject: [PATCH] xfrm: Allow ESP over UDP in packet offload mode Date: Tue, 18 Jul 2023 12:24:05 +0300 Message-Id: <20230718092405.4124345-1-quic_ilial@quicinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ESP encapsulation is not supported only in crypto mode. In packet offload mode, the RX is bypassing the XFRM, so we can enable the encapsulation. Signed-off-by: Ilia Lin --- net/xfrm/xfrm_device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c index 4aff76c6f12e0..3018468d97662 100644 --- a/net/xfrm/xfrm_device.c +++ b/net/xfrm/xfrm_device.c @@ -246,8 +246,10 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, return -EINVAL; } - /* We don't yet support UDP encapsulation and TFC padding. */ - if (x->encap || x->tfcpad) { + is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET; + + /* We don't yet support UDP encapsulation except full mode and TFC padding. */ + if ((!is_packet_offload && x->encap) || x->tfcpad) { NL_SET_ERR_MSG(extack, "Encapsulation and TFC padding can't be offloaded"); return -EINVAL; } @@ -258,7 +260,6 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, return -EINVAL; } - is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET; dev = dev_get_by_index(net, xuo->ifindex); if (!dev) { if (!(xuo->flags & XFRM_OFFLOAD_INBOUND)) { --