next up previous contents
Next: Note about IPv6 options Up: Sending/receiving flow information. Previous: Discussion.   Contents

Implementation.

By default Linux IPv6 does not read sin6_flowinfo field assuming that common applications are not obliged to initialize it and are permitted to consider it as pure alignment padding. In order to tell kernel that application is aware of this field, it is necessary to set socket option IPV6_FLOWINFO_SEND.

  int on = 1;
  setsockopt(sock, SOL_IPV6, IPV6_FLOWINFO_SEND,
             (void*)&on, sizeof(on));

Linux kernel never fills sin6_flowinfo field, when passing message to user space, though the kernels which support flow labels initialize it to zero. If user wants to get received flowinfo, he will set option IPV6_FLOWINFO and after this he will receive flowinfo as ancillary data object of type IPV6_FLOWINFO (cf. RFC2292).

  int on = 1;
  setsockopt(sock, SOL_IPV6, IPV6_FLOWINFO, (void*)&on, sizeof(on));

Flowinfo received and latched by a connected TCP socket also may be fetched with getsockopt() IPV6_PKTOPTIONS together with another optional information.

Besides that, in the spirit of RFC2292 the option IPV6_FLOWINFO may be used as alternative way to send flowinfo with sendmsg() or to latch it with IPV6_PKTOPTIONS.