[EXT] [PATCH] ipsec: fix NAT-T length calculation
Xiao Liang
shaw.leon at gmail.com
Fri Jul 7 14:51:05 CEST 2023
> sa->hdr_len and prm->tun.hdr_len don't include L2 length so both should
> start in the diagram at the end of the ETH header.
>
> So the right way to compute datagram length is
>
> dgram_len = mb->pkt_len - sqh_len - sa->hdr_l3_off - sa->hdr_len +
> sizeof(struct rte_udp_hdr)
>
|<- mb->pkt_len - sqh_len ->|
|<- sa->hdr_l3_off ->|<- sa->hdr_len ->|
|<- udph->dgram_len ->|
+--------------------+------------+-----+-----+---------+-----+
| ETH | IP | UDP | ESP | payload | sqh |
+--------------------+------------+-----+-----+---------+-----+
|<- sa->hdr_l3_off ->|<- l3_len ->|
|<- sa->hdr_len ->|
If hdr_len doesn't include L2 length, I would agree that
dgram_len = mb->pkt_len - sqh_len - sa->hdr_l3_off - sa->hdr_len +
sizeof(struct rte_udp_hdr)
But then what's the point of
sa->hdr_len - sa->hdr_l3_off
in lib/ipsec/sa.c?
More information about the dev
mailing list