Commit Graph

12 Commits

Author SHA1 Message Date
Vincent Bernat
49b42f6055 inlet/flow: avoid repeating common socket options for Linux and others
Some checks failed
CI / 🤖 Check dependabot status (push) Has been cancelled
CI / 🐧 Test on Linux (${{ github.ref_type == 'tag' }}, misc) (push) Has been cancelled
CI / 🐧 Test on Linux (coverage) (push) Has been cancelled
CI / 🐧 Test on Linux (regular) (push) Has been cancelled
CI / ❄️ Build on Nix (push) Has been cancelled
CI / 🍏 Build and test on macOS (push) Has been cancelled
CI / 🧪 End-to-end testing (push) Has been cancelled
CI / 🔍 Upload code coverage (push) Has been cancelled
CI / 🔬 Test only Go (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 20) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 22) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 24) (push) Has been cancelled
CI / ⚖️ Check licenses (push) Has been cancelled
CI / 🐋 Build Docker images (push) Has been cancelled
CI / 🐋 Tag Docker images (push) Has been cancelled
CI / 🚀 Publish release (push) Has been cancelled
Update Nix dependency hashes / Update dependency hashes (push) Has been cancelled
Update Go toolchain / Update Go toolchain (push) Has been cancelled
Update Nix flake.lock / Update Nix lockfile (asn2org) (push) Has been cancelled
Update Nix flake.lock / Update Nix lockfile (iana-assignments) (push) Has been cancelled
Update Nix flake.lock / Update Nix lockfile (nixpkgs) (push) Has been cancelled
Also, fix the description for `SO_REUSEADDR`.
2025-11-02 15:16:18 +01:00
Vincent Bernat
9f594ef66c inlet/flow: make some of the socket options not fatal
If the kernel is too old for timestamping, it should not be fatal. I
prefer to not accept SO_TIMESTAMP_OLD as the size of the timestamp is
arch-dependent.

Fix #1978
2025-09-22 21:33:21 +02:00
Vincent Bernat
fc167f052c inlet/flow: use unsafe to cast data from the kernel
We don't need to use NativeEndian, we can just cast. The alignment is
ensured by CMSG_DATA macro, so it's safe even on archs not allowing
unaligned data access.

This way of doing things was one of the main reason Go took so much time
to get binary.NativeEndian.
2025-09-07 11:21:28 +02:00
Vincent Bernat
9aa267f1bc inlet/flow: ensure we request 64-bit timestamps from the kernel
This requires Linux 5.0+. Below, we would just get no timestamp. This is
more correct this way, even if most people would run that on 64-bit
Linux and already get 64-bit timestamp.

We also don't use the nanosecond part as it is "long long" and should be
virtually 64-bit on all archs, this is not totally correct.
2025-09-07 11:14:12 +02:00
Vincent Bernat
93ae69ad9e inlet/flow: switch to binary.NativeEndian to get native endianness
This is available since Go 1.21 and it is better than enumerating
architectures. We were not up-to-date. See for example:

https://cs.opensource.google/go/go/+/refs/tags/go1.25.1:src/encoding/binary/native_endian_big.go
2025-09-07 10:18:26 +02:00
Vincent Bernat
51404d5d11 inlet/flow: do not ask for hardware timestamps for UDP input
This is useless as this also needs to be enabled with the SIOCSHWTSTAMP
ioctl. This requires CAP_NET_ADMIN and we would need to guess the
physical interface. Too much trouble.
2024-06-04 14:08:43 +02:00
Vincent Bernat
70d59b2925 Revert "inlet/udp: use SO_RCVBUFFORCE to increase socket memory on Linux"
This reverts commit 57e725108e. This is
mostly useless as it does not work inside an unprivileged container and
outside of it, people should just increase rmem_max on their system.
Less code is better.
2023-05-20 12:11:12 +02:00
Vincent Bernat
57e725108e inlet/udp: use SO_RCVBUFFORCE to increase socket memory on Linux 2023-05-18 01:26:38 +02:00
Vincent Bernat
254fb15bcf inlet/udp: explain a bit more the various socket options 2022-07-18 22:46:55 +02:00
Vincent Bernat
56e42539e9 inlet/udp: drop extraneous call to fmt.Println 2022-07-18 22:44:29 +02:00
Vincent Bernat
50112ded57 inlet/udp: ask the kernel to timestamp incoming packets
With very large receive buffer, we may process many packets in burst
and not account for the real receive time. The kernel is able to
provide us with a timestamp, use it. We ask for hardware timestamps if
possible.
2022-07-18 22:43:01 +02:00
Vincent Bernat
13e8c65bfb inlet/flow: make it compile on MacOS 2022-07-16 21:15:17 +02:00