[EXT] [PATCH] ipsec: fix NAT-T length calculation

Radu Nicolau radu.nicolau at intel.com
Fri Jul 7 15:26:53 CEST 2023


On 07-Jul-23 1:51 PM, Xiao Liang wrote:
>> 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?

I will defer to Konstantin for a definite answer, that is if sa->hdr_len 
is supposed to include l2 length / offset or not. If it does, then the 
change that triggered this discussion is correct and we don't need to 
account for hdr_l3_off there.



More information about the dev mailing list