NetworkManager/shared/n-dhcp4/src
Beniamino Galvani 3c6b14fa0d
n-dhcp4: fix BPF filter endianness issue
The BPF filter takes the byte containing IP Flags and performs a
bitwise AND with "ntohs(IP_MF | IP_OFFMASK)".

On little-endian architectures the IP_MF flag (0x20) is ANDed with
0xFF3F and so the presence of the flag is correctly detected ignoring
other flags as IP_DF (0x40) or IP_RF (0x80).

On big-endian, "ntohs(IP_MF | IP_OFFMASK)" is 0x3FFF and so the filter
wrongly checks the presence of *any* flags. Therefore, a packet with
the DF flag set is dropped.

Instead, take the two bytes containing flags and offset:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Version|  IHL  |Type of Service|          Total Length         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |         Identification        |Flags|      Fragment Offset    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

and verify that IP_MF and the offset are zero.

Fixes: e43b1791a3 ('Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4'')

https://bugzilla.redhat.com/show_bug.cgi?id=1861488
https://github.com/nettools/n-dhcp4/pull/19
(cherry picked from commit 03d38e83e558802a82cb0e4847cb1f1ef75ccd16)
(cherry picked from commit 0024cef238)
(cherry picked from commit 80835f8f89)
(cherry picked from commit 4588e2e817)
(cherry picked from commit 7208f594f6)
2020-09-08 14:57:59 +02:00
..
util n-dhcp4: avoid {net,linux}/if.h clashes on old distros 2019-07-05 11:04:32 +02:00
libndhcp4.sym n-dhcp4/lease: expose the server IP address 2019-11-18 13:44:06 +01:00
meson.build Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
n-dhcp4-c-connection.c n-dhcp4: fix initialization of the 'secs' DHCP header field 2020-04-20 08:06:49 +02:00
n-dhcp4-c-lease.c n-dhcp4/lease: expose the server IP address 2019-11-18 13:44:06 +01:00
n-dhcp4-c-probe.c n-dhcp4: arm timers in bound state 2019-09-18 09:38:52 +02:00
n-dhcp4-client.c shared/n-dhcp4: avoid c_min() macro to work with old GCC 2019-07-05 11:04:32 +02:00
n-dhcp4-incoming.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
n-dhcp4-outgoing.c n-dhcp4: fix initialization of the 'secs' DHCP header field 2020-04-20 08:06:49 +02:00
n-dhcp4-private.h n-dhcp4: fix initialization of the 'secs' DHCP header field 2020-04-20 08:06:49 +02:00
n-dhcp4-s-connection.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
n-dhcp4-s-lease.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
n-dhcp4-server.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
n-dhcp4-socket.c n-dhcp4: fix BPF filter endianness issue 2020-09-08 14:57:59 +02:00
n-dhcp4.h n-dhcp4/lease: expose the server IP address 2019-11-18 13:44:06 +01:00
test-api.c n-dhcp4/lease: expose the server IP address 2019-11-18 13:44:06 +01:00
test-connection.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
test-message.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
test-run-client.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
test-socket.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
test.h Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00