【问题标题】:Linux C IPv6 raw socket - tell socket NOT to assign a flow labelLinux C IPv6 原始套接字 - 告诉套接字不要分配流标签
【发布时间】:2018-01-17 21:12:48
【问题描述】:

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

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

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

我错过了什么吗?

【问题讨论】:

  • “空”流标签是指所有位为 0 的流标签吗?
  • 当你说“用户未设置”时,你的意思是“用户指定为零”吗?
  • @john-bollinger 未由用户设置意味着用户没有指定任何内容,是的,空我的意思是所有位都是 0。
  • 据我所知,当用户connect()bind() 时,用户不能失败在 IPv6 套接字上设置流标签。它是struct sockaddr_in6(成员sin6_flowinfo)的一部分,必须为这两个接口提供一个实例。您的问题可能是您没有初始化此成员吗?或者我应该如何解释“没有指定任何东西”?
  • "我需要 IPv6 流标签为空。"为什么?

标签: c linux sockets ipv6


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-22
    • 1970-01-01
    • 1970-01-01
    • 2017-10-28
    • 2020-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多