Re: [IPsec] Discussion of draft-pwouters-ipsecme-multi-sa-performance

Valery Smyslov <smyslov.ietf@gmail.com> Fri, 21 October 2022 14:06 UTC

Return-Path: <smyslov.ietf@gmail.com>
X-Original-To: ipsec@ietfa.amsl.com
Delivered-To: ipsec@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 3E29AC14F74F for <ipsec@ietfa.amsl.com>; Fri, 21 Oct 2022 07:06:53 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 2.892
X-Spam-Level: **
X-Spam-Status: No, score=2.892 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, GB_SUMOF=5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id shGA2cRPRXdl for <ipsec@ietfa.amsl.com>; Fri, 21 Oct 2022 07:06:49 -0700 (PDT)
Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id F2B01C14CF1B for <ipsec@ietf.org>; Fri, 21 Oct 2022 07:06:48 -0700 (PDT)
Received: by mail-lf1-x131.google.com with SMTP id b1so5287167lfs.7 for <ipsec@ietf.org>; Fri, 21 Oct 2022 07:06:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-language:thread-index:content-transfer-encoding :mime-version:message-id:date:subject:in-reply-to:references:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=A0glX3rT3XZcLY405Q1kBRF04f1C99RtJYmEBVU7klQ=; b=SbXFvxCN1QueD+FkcFKGLfZCEL4u3cpOc0Rol9LvzrKoPGv9T4h4DWxI6UBOJzj8dw gFSwzGHSdqUiTQHzQl/dJo2+AbJ0MK3dcC/DTNkXu3tbOKUrGEse8e8EQvLYnESelCn9 V/4px5NsvC8W/rsbhTx6q8f5ateVDVYzyuzV/JkQSEA99F1ihq4LxX/8XTI4hkldM5TM Ww0LLdzjOlDQnPfax1PRe027+c1dQYw9noeRANIhilq6g2scoZSm32GJaqOtUWI2x6m8 a7QOk0gX5c1AtQEfGMcBZ8oe4fgy7/NX0lZb7Nzs7g9JhN1wEKIAX9BzkKBWf97rWMxz CjIw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-language:thread-index:content-transfer-encoding :mime-version:message-id:date:subject:in-reply-to:references:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=A0glX3rT3XZcLY405Q1kBRF04f1C99RtJYmEBVU7klQ=; b=mjchkUBXtez29nm3pZJULNnfz3cU+dMS6bJeVCbAlXicaYeDsmS8vQAmxw/uBdplzw 3f5XxZlA933e/5z1w99S4gamvefrOQWCw5jgqcR9Go++QZJx/afUO04wBrWkL9aDaZRL BX+67SbPxRpe+T7kIHXpgDVaSyZVtW3ysUoaJIRYARByWWmPU0NLvLh4BIsVm56smV1k mFeeLuxWzoDFRph7La0zojnlXrzPnCJpf1BvfCJwR0JS4WGpD9H0mZFE7u2ipgUaNelA hoSrdCZbPTIcvUB68vydCnlxER3JmVWSQJVxybdnEVg2c2Wi7pti8QIVjXEht8Lf9rVJ 1fTQ==
X-Gm-Message-State: ACrzQf3A2hbDoiZlmxId1BUPRbNlcuOze+ElF1xoZcjJMqpv+slXsETK 3NE6WtnYrDoHJs3cqPAQgohpFmWmX6w=
X-Google-Smtp-Source: AMsMyM75dXwGvPkEAImfqQc0wKFTSB6IUVByvPVT0KqkL2Abx6K3cckYWyGuRAtKmo1hH/hVo+b/jA==
X-Received: by 2002:a05:6512:3f29:b0:4a1:c920:ebad with SMTP id y41-20020a0565123f2900b004a1c920ebadmr7068551lfa.574.1666361206649; Fri, 21 Oct 2022 07:06:46 -0700 (PDT)
Received: from buildpc ([93.188.44.204]) by smtp.gmail.com with ESMTPSA id n5-20020a195505000000b004a27bb1ad62sm3167723lfe.205.2022.10.21.07.06.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Oct 2022 07:06:46 -0700 (PDT)
From: Valery Smyslov <smyslov.ietf@gmail.com>
To: 'Steffen Klassert' <steffen.klassert@secunet.com>
Cc: 'Michael Richardson' <mcr+ietf@sandelman.ca>, 'IPsecME WG' <ipsec@ietf.org>
References: <15eb01d8dd7e$fdf158e0$f9d40aa0$@gmail.com> <10861.1665504183@localhost> <161701d8dd8c$8d042a50$a70c7ef0$@gmail.com> <20221014101504.GI2602992@gauss3.secunet.de> <03c901d8e232$3850ef20$a8f2cd60$@gmail.com> <20221021073714.GP3294086@gauss3.secunet.de>
In-Reply-To: <20221021073714.GP3294086@gauss3.secunet.de>
Date: Fri, 21 Oct 2022 17:06:44 +0300
Message-ID: <087401d8e556$5a41cec0$0ec56c40$@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 14.0
Thread-Index: AQJS+NHZSxlPMvP0ZarIorjX6+t7ygGkEVyDAbA4wY4BcMyZqQIz4SzuAtW+A6Cs1iBSsA==
Content-Language: ru
Archived-At: <https://mailarchive.ietf.org/arch/msg/ipsec/8pVXHoF2JoDUlDdTHna4MMmLQwk>
Subject: Re: [IPsec] Discussion of draft-pwouters-ipsecme-multi-sa-performance
X-BeenThere: ipsec@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: Discussion of IPsec protocols <ipsec.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/ipsec>, <mailto:ipsec-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/ipsec/>
List-Post: <mailto:ipsec@ietf.org>
List-Help: <mailto:ipsec-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/ipsec>, <mailto:ipsec-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 21 Oct 2022 14:06:53 -0000

Hi Steffen,

> Hi Valery,
> 
> > Then my next question is - how the sending side decides
> > whether to one of use per-CPU SAs or the fallback SA?
> > My guess that the packet is handled by some kernel thread
> > (i.e. by some CPU), so once this CPU figures out that
> > it doesn't have an SA - I assume it uses the fallback SA then.
> > Is it right?
> 
> Right.
> 
> > If so, then why it cannot hand over the packet
> > to the CPU that for sure has the needed SA (this CPU can
> > be indicated in the stub SA entry)?
> 
> Moving in flight packets to a different cpu is always a pain.

I understand.

> From an implementation point of view, that should be avoided
> whenever possible. Aside from the overhead it creates, we
> also have to care about corener cases. For example, how
> do you make sure that the SA on this remote cpu is still
> there when the packet arrives on it?

Then it should be re-steered to yet another CPU.
Fortunately this should happen infrequently.

> Also, where would that stub SA entry be located, in a percpu
> or in a global SAD? If it is an a percpu SAD, then remote
> cpus must update all stub SA entries when a percpu SA
> comes up or goes down. So we would need to lock the
> percpu SADs. If it is in a global SAD, then why not just
> negotiate keymat and use it (as a fallback)?

In a per-CPU SAD. Updating is costly, I agree, but should happen 
relatively infrequently. There may also be some optimization.
For example, when new per-CPU SA appears, you don't have
to update all remote stubs (let them continue to point to another existing SA), 
you only need to do it if a per-CPU SA is deleted.

> Instead of having a stub SA entry, I could think of encoding
> the information which cpu has a valid SA to the policy. The
> policy is global anyway. But then we still need to re-steer
> the packets, what I really dislike.

How much costly is re-steering comparing to a locking 
needed for a global fallback SA?

> Is it just that you don't like that the fallback SA MUST (or
> maybe SHOULD) be always up, or is it that you don't want to
> negotiate this additional SA at all?

The former. I'd like to avoid SAs that need special treatment,
whenever possible.

> Another possibility would be to use the same keymat on all
> percpu SAs, as it was proposed at the discussion we had
> at our 'IPsec coffee hour' last time. In that case you
> have a valid SA on all cpus with a single negotiation.
> But hat would require a change to ESP what this proposal
> don't need.

This would bring other difficulties. For example, if 
the amount of data that can be safely processed with
a single key is limited (as it should be), then you
need to count the sum of the traffic on all such SAs,
that would require some kind of locking.
Or you should use significantly smaller value
to be sure that traffic never reaches the threshold.

> > In both cases some
> > locking is required - does the latter case require much more locking?
> 
> The percpu SAs don't need locking as long as you can make sure that
> it is never ever accessed by a remote cpu. To guarantee this, something
> that does the 'dirt work' is needed. In our case that would be the
> fallback SA.

Then how per-SAs are installed? Doesn't it require some locking?

Regards,
Valery.

> Steffen