NetworkManager/shared/n-dhcp4/src
Beniamino Galvani 0024cef238 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)
2020-08-04 16:10:02 +02:00
..
util all: fix minor typos 2020-07-07 11:33:46 +02:00
libndhcp4.sym n-dhcp4/lease: expose the server IP address 2019-11-18 13:34:09 +01:00
meson.build nettools: reimport nettools' n-dhcp4 and rework logging 2020-06-03 22:34:22 +02:00
n-dhcp4-c-connection.c all: fix minor typos 2020-07-07 11:33:46 +02:00
n-dhcp4-c-lease.c all: fix minor typos 2020-07-07 11:33:46 +02:00
n-dhcp4-c-probe.c all: fix minor typos 2020-07-07 11:33:46 +02:00
n-dhcp4-client.c all: fix minor typos 2020-07-07 11:33:46 +02:00
n-dhcp4-incoming.c n-dhcp4: accept options that are longer than requested 2020-01-25 11:31:58 +01:00
n-dhcp4-outgoing.c n-dhcp4: fix initialization of the 'secs' DHCP header field 2020-02-10 16:36:25 +01:00
n-dhcp4-private.h nettools: reimport nettools' n-dhcp4 2020-07-07 11:15:26 +02:00
n-dhcp4-s-connection.c all: fix minor typos 2020-07-07 11:33:46 +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-08-04 16:10:02 +02:00
n-dhcp4.h nettools: reimport nettools' n-dhcp4 and rework logging 2020-06-03 22:34:22 +02:00
test-api.c n-dhcp4/lease: expose the server IP address 2019-11-18 13:34:09 +01:00
test-connection.c nettools: reimport nettools' n-dhcp4 and rework logging 2020-06-03 22:34:22 +02:00
test-message.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
test-run-client.c all: fix minor typos 2020-07-07 11:33:46 +02:00
test-socket.c Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4' 2019-05-25 02:02:04 +02:00
test.h all: fix minor typos 2020-07-07 11:33:46 +02:00