我试图使用 IPv6 原始套接字发送一些内容。由于某种原因,我需要 IPv6 流标签为空。当用户未设置时,Linux 似乎会分配随机流标签。
我发现的是IPV6_FLOWLABEL_MGR
和IPV6_FLOWINFO_SEND
。通过将 IPV6_FLOWINFO_SEND
设置为 true,我可以使用 IPV6_FLOWLABEL_MGR
和 in6_flowlabel_req
自行分配标签。
但是,我找不到禁用自动分配行为的选项。我尝试手动将标签设置为 0 - 但当用户将标签设置为 0 时,Linux 为其分配了一个新标签。
我错过了什么吗?
最佳答案
请参阅sysctl :
/proc/sys/net/ipv6/auto_flowlabels - INTEGER
Automatically generate flow labels based on a flow hash of the
packet. This allows intermediate devices, such as routers, to
identify packet flows for mechanisms like Equal Cost Multipath
Routing (see RFC 6438).
0: automatic flow labels are completely disabled
1: automatic flow labels are enabled by default, they can be
disabled on a per socket basis using the IPV6_AUTOFLOWLABEL
socket option
2: automatic flow labels are allowed, they may be enabled on a
per socket basis using the IPV6_AUTOFLOWLABEL socket option
3: automatic flow labels are enabled and enforced, they cannot
be disabled by the socket option
Default: 1
关于c - Linux C IPv6 原始套接字 - 告诉套接字不要分配流标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48310068/