Re: [PATCH bpf-next] selftests/bpf: Avoid subtraction after htons() in ipip tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Asbjørn Sloth Tønnesen <ast@xxxxxxxxxxx> writes:

> On little-endian systems, doing subtraction after htons()
> leads to interesting results:
>
> Given:
>   MAGIC_BYTES = 123 = 0x007B aka. in big endian: 0x7B00 = 31488
>   sizeof(struct iphdr) = 20
>
> Before this patch:
> __bpf_constant_htons(MAGIC_BYTES) - sizeof(struct iphdr) = 0x7AEC
> 0x7AEC = htons(0xEC7A) = htons(60538)
>
> So these were outer IP packets with a total length of 123 bytes,
> containing an inner IP packet with a total length of 60538 bytes.

It's just using bag of holding technology!

> After this patch:
> __bpf_constant_htons(MAGIC_BYTES - sizeof(struct iphdr)) = htons(103)
>
> Now these packets are outer IP packets with a total length of 123 bytes,
> containing an inner IP packet with a total length of 103 bytes.
>
> Signed-off-by: Asbjørn Sloth Tønnesen <ast@xxxxxxxxxxx>

Reviewed-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux