From: Xiao Liang <shaw.leon@gmail.com>
To: Radu Nicolau <radu.nicolau@intel.com>
Cc: Konstantin Ananyev <konstantin.ananyev@huawei.com>,
Akhil Goyal <gakhil@marvell.com>,
Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [EXT] [PATCH] ipsec: fix NAT-T length calculation
Date: Fri, 7 Jul 2023 10:06:48 +0800 [thread overview]
Message-ID: <CABAhCOR+Smz2R=Tn+sCHOESFQYfh-5sBe=igrK_kL-x9syjnHw@mail.gmail.com> (raw)
In-Reply-To: <05b87294-0b96-804c-f4e7-0fc3b3ccbbf4@intel.com>
Well, let me explain.
> >>> diff --git a/lib/ipsec/esp_outb.c b/lib/ipsec/esp_outb.c
> >>> index 9cbd9202f6..ec87b1dce2 100644
> >>> --- a/lib/ipsec/esp_outb.c
> >>> +++ b/lib/ipsec/esp_outb.c
> >>> @@ -198,7 +198,7 @@ outb_tun_pkt_prepare(struct rte_ipsec_sa *sa,
> >>> rte_be64_t sqc,
> >>> struct rte_udp_hdr *udph = (struct rte_udp_hdr *)
> >>> (ph + sa->hdr_len - sizeof(struct rte_udp_hdr));
> >>> udph->dgram_len = rte_cpu_to_be_16(mb->pkt_len - sqh_len -
> >>> - sa->hdr_l3_off - sa->hdr_len);
> >>> + sa->hdr_len + sizeof(struct rte_udp_hdr));
> > To be honest, it is not clear to me why we shouldn't take into account sa->hdr_l3_off
> > any more.
> > Probably the author can explain.
> > Also would like author of NAT-T support to chime in.
> > Radu, any comments on that patch?
> I agree, hdr_l3_off should not be ignored. Also sa->hdr_len already
> includes the size of UDP header, see line 366 in esp_outb_tun_init in
> sa.c (or the line above this change, where the udph pointer is computed
> assuming this)
A few lines above, there is:
ph = rte_pktmbuf_prepend(mb, hlen - l2len);
The L2 header is already pulled from the packet, then the packet
length has nothing to do with hdr_l3_off from this point, so use encap
header length instead.
You are right sa->hdr_len already includes the size of UDP header, and
that's why it should be added back here.
> >>> }
> >>>
> >>> /* update original and new ip header fields */
> >>> diff --git a/lib/ipsec/sa.c b/lib/ipsec/sa.c
> >>> index 59a547637d..2297bd6d72 100644
> >>> --- a/lib/ipsec/sa.c
> >>> +++ b/lib/ipsec/sa.c
> >>> @@ -371,7 +371,7 @@ esp_outb_tun_init(struct rte_ipsec_sa *sa, const struct
> >>> rte_ipsec_sa_prm *prm)
> >>>
> >>> /* update l2_len and l3_len fields for outbound mbuf */
> >>> sa->tx_offload.val = rte_mbuf_tx_offload(sa->hdr_l3_off,
> >>> - sa->hdr_len - sa->hdr_l3_off, 0, 0, 0, 0, 0);
> >>> + prm->tun.hdr_len - sa->hdr_l3_off, 0, 0, 0, 0, 0);
> >>>
> >>> esp_outb_init(sa, sa->hdr_len, prm->ipsec_xform.esn.value);
> >>> }
Again sa->hdr_len includes UDP header, which is not part of L3, so use
the original prm->tun.hdr_len.
Thanks,
Xiao Liang
next prev parent reply other threads:[~2023-07-07 2:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 8:46 Xiao Liang
2023-07-05 13:49 ` [EXT] " Akhil Goyal
2023-07-06 9:08 ` Konstantin Ananyev
2023-07-06 10:20 ` Radu Nicolau
2023-07-07 2:06 ` Xiao Liang [this message]
2023-07-07 3:12 ` Xiao Liang
2023-07-07 8:59 ` Radu Nicolau
2023-07-07 12:51 ` Xiao Liang
2023-07-07 13:17 ` Xiao Liang
2023-07-07 13:26 ` Radu Nicolau
2023-07-10 9:24 ` Konstantin Ananyev
2023-07-10 9:38 ` Radu Nicolau
2023-07-10 9:20 ` Konstantin Ananyev
2023-07-11 2:13 ` [PATCH v2] ipsec: fix NAT-T header " Xiao Liang
2023-07-11 2:18 ` Xiao Liang
2023-07-11 8:48 ` [EXT] " Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CABAhCOR+Smz2R=Tn+sCHOESFQYfh-5sBe=igrK_kL-x9syjnHw@mail.gmail.com' \
--to=shaw.leon@gmail.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=konstantin.ananyev@huawei.com \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=radu.nicolau@intel.com \
--cc=vladimir.medvedkin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).