Enhancement Request: Support setting packet mark via socket (SO_MARK)
- Dominant language
- C
- Stars
- 8.8k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
I would like to propose the addition of a new feature to control the packet mark from an iperf instance.
In Linux, packet marks are commonly used by the networking framework to enforce packet filtering (iptables) or policy routing (tc) among other.
Setting the packet mark is a feature already supported by ping and very handy to debug networking issues. From the man pages:
```
-m mark
use mark to tag the packets going out. This is useful for variety of reasons within the kernel such as using policy routing to select specific outbound processing.
```
This can be added to iperf (Linux) via the SO_MARK socket option. From the man pages:
```
SO_MARK (since Linux 2.6.25)
Set the mark for each packet sent through this socket (similar
to the netfilter MARK target but socket-based). Changing the
mark can be used for mark-based routing without netfilter or
for packet filtering. Setting this option requires the
CAP_NET_ADMIN capability.
```
I haven't looked at the source code structure, since IP_TOS is already used, it shouldn't be too much hassle.
The new feature would allow us to further stress test more complex networking environments without having to resort to specific packet marking via iptables.
Note: I don't know if this feature can be ported to the rest of the supported OS.
Contributor guide
Assessment
This issue has not been assessed yet.