
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)
n-dhcp4
Dynamic Host Configuration Protocol for IPv4
The n-dhcp4 project implements the IPv4 Dynamic Host Configuration Protocol as defined in RFC-2132+.
Project
- Website: https://nettools.github.io/n-dhcp4
- Bug Tracker: https://github.com/nettools/n-dhcp4/issues
- Mailing-List: https://groups.google.com/forum/#!forum/nettools-devel
Requirements
The requirements for this project are:
Linux kernel >= 3.19
libc
(e.g.,glibc >= 2.16
)
At build-time, the following software is required:
meson >= 0.41
pkg-config >= 0.29
Build
The meson build-system is used for this project. Contact upstream documentation for detailed help. In most situations the following commands are sufficient to build and install from source:
mkdir build
cd build
meson setup ..
ninja
meson test
ninja install
No custom configuration options are available.
Repository:
- web: https://github.com/nettools/n-dhcp4
- https:
https://github.com/nettools/n-dhcp4.git
- ssh:
git@github.com:nettools/n-dhcp4.git
License:
- Apache-2.0 OR LGPL-2.1-or-later
- See AUTHORS file for details.