Linux C IPv6原始套接字 - 告诉套接字不要分配流标签

时间:2018-01-17 21:12:49

标签: c linux sockets ipv6

我试图使用IPv6原始套接字发送内容。出于某种原因,我需要IPv6流标签为空。 Linux似乎在未由用户设置时分配随机流标签。

我找到的是IPV6_FLOWLABEL_MGRIPV6_FLOWINFO_SEND。通过将IPV6_FLOWLABEL_MGR设置为true,我可以使用in6_flowlabel_reqIPV6_FLOWINFO_SEND自行分配标签。

但是,我找不到禁用自动分配行为的选项。我尝试手动将标签设置为0 - 但是当用户将标签设置为0时,Linux为其分配了一个新标签。

我错过了什么吗?

1 个答案:

答案 0 :(得分:4)

请参阅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