1aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\documentstyle[12pt,twoside]{article}
2aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\def\TITLE{IPv6 Flow Labels}
3aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\input preamble
4aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{center}
5aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\Large\bf IPv6 Flow Labels in Linux-2.2.
6aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{center}
7aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
8aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
9aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{center}
10aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger{ \large Alexey~N.~Kuznetsov } \\
11aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\em Institute for Nuclear Research, Moscow \\
12aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\verb|kuznet@ms2.inr.ac.ru| \\
13aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\rm April 11, 1999
14aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{center}
15aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
16aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\vspace{5mm}
17aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
18aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\tableofcontents
19aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
20aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\section{Introduction.}
21aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
22aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerEvery IPv6 packet carries 28 bits of flow information. RFC2460 splits
23aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerthese bits to two fields: 8 bits of traffic class (or DS field, if you
24aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerprefer this term) and 20 bits of flow label. Currently there exist
25aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerno well-defined API to manage IPv6 flow information. In this document
26aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerI describe an attempt to design the API for Linux-2.2 IPv6 stack.
27aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
28aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\vskip 1mm
29aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
30aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerThe API must solve the following tasks:
31aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
32aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{enumerate}
33aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
34aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item To allow user to set traffic class bits.
35aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
36aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item To allow user to read traffic class bits of received packets.
37aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerThis feature is not so useful as the first one, however it will be
38aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingernecessary f.e.\ to implement ECN [RFC2481] for datagram oriented services
39aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeror to implement receiver side of SRP or another end-to-end protocol
40aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerusing traffic class bits.
41aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
42aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item To assign flow labels to packets sent by user.
43aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
44aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item To get flow labels of received packets. I do not know
45aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerany applications of this feature, but it is possible that receiver will
46aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerwant to use flow labels to distinguish sub-flows.
47aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
48aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item To allocate flow labels in the way, compliant to RFC2460. Namely:
49aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
50aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{itemize}
51aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item
52aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerFlow labels must be uniformly distributed (pseudo-)random numbers,
53aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerso that any subset of 20 bits can be used as hash key.
54aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
55aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item
56aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerFlows with coinciding source address and flow label must have identical
57aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerdestination address and not-fragmentable extensions headers (i.e.\ 
58aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerhop by hop options and all the headers up to and including routing header,
59aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerif it is present.)
60aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
61aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{NB}
62aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerThere is a hole in specs: some hop-by-hop options can be
63aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerdefined only on per-packet base (f.e.\  jumbo payload option).
64aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerEssentially, it means that such options cannot present in packets
65aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerwith flow labels.
66aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{NB}
67aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{NB}
68aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerNB notes here and below reflect only my personal opinion,
69aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerthey should be read with smile or should not be read at all :-).
70aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{NB}
71aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
72aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
73aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item
74aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerFlow labels have finite lifetime and source is not allowed to reuse
75aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerflow label for another flow within the maximal lifetime has expired,
76aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerso that intermediate nodes will be able to invalidate flow state before
77aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerthe label is taken over by another flow.
78aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerFlow state, including lifetime, is propagated along datagram path
79aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerby some application specific methods
80aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger(f.e.\ in RSVP PATH messages or in some hop-by-hop option).
81aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
82aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
83aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{itemize}
84aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
85aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{enumerate}
86aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
87aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\section{Sending/receiving flow information.}
88aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
89aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\paragraph{Discussion.}
90aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\addcontentsline{toc}{subsection}{Discussion}
91aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerIt was proposed (Where? I do not remember any explicit statement)
92aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerto solve the first four tasks using
93aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\verb|sin6_flowinfo| field added to \verb|struct| \verb|sockaddr_in6|
94aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger(see RFC2553).
95aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
96aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{NB}
97aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	This method is difficult to consider as reasonable, because it
98aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	puts additional overhead to all the services, despite of only
99aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	very small subset of them (none, to be more exact) really use it.
100aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	It contradicts both to IETF spirit and the letter. Before RFC2553
101aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	one justification existed, IPv6 address alignment left 4 byte
102aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	hole in \verb|sockaddr_in6| in any case. Now it has no justification.
103aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{NB}
104aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
105aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerWe have two problems with this method. The first one is common for all OSes:
106aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerif \verb|recvmsg()| initializes \verb|sin6_flowinfo| to flow info
107aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerof received packet, we loose one very important property of BSD socket API,
108aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingernamely, we are not allowed to use received address for reply directly
109aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerand have to mangle it, even if we are not interested in flowinfo subtleties.
110aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
111aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{NB}
112aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	RFC2553 adds new requirement: to clear \verb|sin6_flowinfo|.
113aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	Certainly, it is not solution but rather attempt to force applications
114aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	to make unnecessary work. Well, as usually, one mistake in design
115aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	is followed by attempts	to patch the hole and more mistakes...
116aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{NB}
117aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
118aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerAnother problem is Linux specific. Historically Linux IPv6 did not
119aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerinitialize \verb|sin6_flowinfo| at all, so that, if kernel does not
120aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingersupport flow labels, this field is not zero, but a random number.
121aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerSome applications also did not take care about it. 
122aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
123aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{NB}
124aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerFollowing RFC2553 such applications can be considered as broken,
125aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerbut I still think that they are right: clearing all the address
126aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerbefore filling known fields is robust but stupid solution.
127aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerUseless wasting CPU cycles and
128aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingermemory bandwidth is not a good idea. Such patches are acceptable
129aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeras temporary hacks, but not as standard of the future.
130aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{NB}
131aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
132aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
133aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\paragraph{Implementation.}
134aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\addcontentsline{toc}{subsection}{Implementation}
135aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerBy default Linux IPv6 does not read \verb|sin6_flowinfo| field
136aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerassuming that common applications are not obliged to initialize it
137aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerand are permitted to consider it as pure alignment padding.
138aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerIn order to tell kernel that application
139aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeris aware of this field, it is necessary to set socket option
140aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\verb|IPV6_FLOWINFO_SEND|.
141aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
142aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
143aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  int on = 1;
144aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  setsockopt(sock, SOL_IPV6, IPV6_FLOWINFO_SEND,
145aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger             (void*)&on, sizeof(on));
146aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
147aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
148aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerLinux kernel never fills \verb|sin6_flowinfo| field, when passing
149aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingermessage to user space, though the kernels which support flow labels
150aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerinitialize it to zero. If user wants to get received flowinfo, he
151aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerwill set option \verb|IPV6_FLOWINFO| and after this he will receive
152aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerflowinfo as ancillary data object of type \verb|IPV6_FLOWINFO|
153aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger(cf.\ RFC2292).
154aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
155aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
156aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  int on = 1;
157aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  setsockopt(sock, SOL_IPV6, IPV6_FLOWINFO, (void*)&on, sizeof(on));
158aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
159aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
160aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerFlowinfo received and latched by a connected TCP socket also may be fetched
161aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerwith \verb|getsockopt()| \verb|IPV6_PKTOPTIONS| together with
162aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeranother optional information.
163aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
164aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerBesides that, in the spirit of RFC2292 the option \verb|IPV6_FLOWINFO|
165aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingermay be used as alternative way to send flowinfo with \verb|sendmsg()| or
166aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerto latch it with \verb|IPV6_PKTOPTIONS|.
167aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
168aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\paragraph{Note about IPv6 options and destination address.}
169aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\addcontentsline{toc}{subsection}{IPv6 options and destination address}
170aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerIf \verb|sin6_flowinfo| does contain not zero flow label,
171aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerdestination address in \verb|sin6_addr| and non-fragmentable
172aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerextension headers are ignored. Instead, kernel uses the values
173aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingercached at flow setup (see below). However, for connected sockets
174aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerkernel prefers the values set at connection time.
175aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
176aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\paragraph{Example.}
177aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\addcontentsline{toc}{subsection}{Example}
178aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerAfter setting socket option \verb|IPV6_FLOWINFO|
179aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerflowlabel and DS field are received as ancillary data object
180aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerof type \verb|IPV6_FLOWINFO| and level \verb|SOL_IPV6|.
181aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerIn the cases when it is convenient to use \verb|recvfrom(2)|,
182aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerit is possible to replace library variant with your own one,
183aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingersort of:
184aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
185aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
186aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#include <sys/socket.h>
187aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#include <netinet/in6.h>
188aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
189aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingersize_t recvfrom(int fd, char *buf, size_t len, int flags,
190aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                struct sockaddr *addr, int *addrlen)
191aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger{
192aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  size_t cc;
193aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  char cbuf[128];
194aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  struct cmsghdr *c;
195aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  struct iovec iov = { buf, len };
196aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  struct msghdr msg = { addr, *addrlen,
197aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                        &iov,  1,
198aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                        cbuf, sizeof(cbuf),
199aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                        0 };
200aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
201aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  cc = recvmsg(fd, &msg, flags);
202aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  if (cc < 0)
203aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger    return cc;
204aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  ((struct sockaddr_in6*)addr)->sin6_flowinfo = 0;
205aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  *addrlen = msg.msg_namelen;
206aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  for (c=CMSG_FIRSTHDR(&msg); c; c = CMSG_NEXTHDR(&msg, c)) {
207aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger    if (c->cmsg_level != SOL_IPV6 ||
208aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger      c->cmsg_type != IPV6_FLOWINFO)
209aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        continue;
210aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger    ((struct sockaddr_in6*)addr)->sin6_flowinfo = *(__u32*)CMSG_DATA(c);
211aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  }
212aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger  return cc;
213aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger}
214aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
215aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
216aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
217aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
218aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\section{Flow label management.}
219aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
220aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\paragraph{Discussion.}
221aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\addcontentsline{toc}{subsection}{Discussion}
222aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerRequirements of RFC2460 are pretty tough. Particularly, lifetimes
223aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerlonger than boot time require to store allocated labels at stable
224aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerstorage, so that the full implementation necessarily includes user space flow
225aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerlabel manager. There are at least three different approaches:
226aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
227aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{enumerate}
228aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item {\bf ``Cooperative''. } We could leave flow label allocation wholly
229aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerto user space. When user needs label he requests manager directly. The approach
230aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeris valid, but as any ``cooperative'' approach it suffers of security problems.
231aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
232aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{NB}
233aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerOne idea is to disallow not privileged user to allocate flow
234aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerlabels, but instead to pass the socket to manager via \verb|SCM_RIGHTS|
235aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingercontrol message, so that it will allocate label and assign it to socket
236aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeritself. Hmm... the idea is interesting.
237aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{NB}
238aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
239aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item {\bf ``Indirect''.} Kernel redirects requests to user level daemon
240aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerand does not install label until the daemon acknowledged the request.
241aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerThe approach is the most promising, it is especially pleasant to recognize
242aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerparallel with IPsec API [RFC2367,Craig]. Actually, it may share API with
243aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerIPsec.
244aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
245aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item {\bf ``Stupid''.} To allocate labels in kernel space. It is the simplest
246aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingermethod, but it suffers of two serious flaws: the first,
247aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerwe cannot lease labels with lifetimes longer than boot time, the second, 
248aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerit is sensitive to DoS attacks. Kernel have to remember all the obsolete
249aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerlabels until their expiration and malicious user may fastly eat all the
250aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerflow label space.
251aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
252aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{enumerate}
253aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
254aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerCertainly, I choose the most ``stupid'' method. It is the cheapest one
255aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerfor implementor (i.e.\ me), and taking into account that flow labels
256aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerstill have no serious applications it is not useful to work on more
257aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeradvanced API, especially, taking into account that eventually we
258aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerwill get it for no fee together with IPsec.
259aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
260aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
261aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\paragraph{Implementation.}
262aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\addcontentsline{toc}{subsection}{Implementation}
263aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerSocket option \verb|IPV6_FLOWLABEL_MGR| allows to
264aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerrequest flow label manager to allocate new flow label, to reuse
265aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeralready allocated one or to delete old flow label.
266aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerIts argument is \verb|struct| \verb|in6_flowlabel_req|:
267aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
268aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
269aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerstruct in6_flowlabel_req
270aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger{
271aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        struct in6_addr flr_dst;
272aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        __u32           flr_label;
273aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        __u8            flr_action;
274aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        __u8            flr_share;
275aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        __u16           flr_flags;
276aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        __u16           flr_expires;
277aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        __u16           flr_linger;
278aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        __u32         __flr_reserved;
279aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        /* Options in format of IPV6_PKTOPTIONS */
280aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger};
281aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
282aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
283aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{itemize}
284aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
285aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|dst| is IPv6 destination address associated with the label.
286aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
287aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|label| is flow label value in network byte order. If it is zero,
288aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerkernel will allocate new pseudo-random number. Otherwise, kernel will try
289aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerto lease flow label ordered by user. In this case, it is user task to provide
290aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingernecessary flow label randomness.
291aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
292aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|action| is requested operation. Currently, only three operations
293aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerare defined:
294aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
295aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
296aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_A_GET   0   /* Get flow label */
297aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_A_PUT   1   /* Release flow label */
298aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_A_RENEW 2   /* Update expire time */
299aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
300aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
301aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|flags| are optional modifiers. Currently
302aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeronly \verb|IPV6_FL_A_GET| has modifiers:
303aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
304aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
305aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_F_CREATE 1   /* Allowed to create new label */
306aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_F_EXCL   2   /* Do not create new label */
307aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
308aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
309aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
310aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|share| defines who is allowed to reuse the same flow label.
311aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
312aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
313aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_S_NONE    0   /* Not defined */
314aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_S_EXCL    1   /* Label is private */
315aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_S_PROCESS 2   /* May be reused by this process */
316aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_S_USER    3   /* May be reused by this user */
317aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger#define IPV6_FL_S_ANY     255 /* Anyone may reuse it */
318aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
319aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
320aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|linger| is time in seconds. After the last user releases flow
321aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerlabel, it will not be reused with different destination and options at least
322aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerduring this time. If \verb|share| is not \verb|IPV6_FL_S_EXCL| the label
323aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerstill can be shared by another sockets. Current implementation does not allow
324aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerunprivileged user to set linger longer than 60 sec.
325aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
326aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|expires| is time in seconds. Flow label will be kept at least
327aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerfor this time, but it will not be destroyed before user released it explicitly
328aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingeror closed all the sockets using it. Current implementation does not allow
329aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerunprivileged user to set timeout longer than 60 sec. Proviledged applications
330aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerMAY set longer lifetimes, but in this case they MUST save allocated
331aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerlabels at stable storage and restore them back after reboot before the first
332aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerapplication allocates new flow.
333aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
334aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{itemize}
335aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
336aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerThis structure is followed by optional extension headers associated
337aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerwith this flow label in format of \verb|IPV6_PKTOPTIONS|. Only
338aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\verb|IPV6_HOPOPTS|, \verb|IPV6_RTHDR| and, if \verb|IPV6_RTHDR| presents,
339aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\verb|IPV6_DSTOPTS| are allowed.
340aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
341aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\paragraph{Example.}
342aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\addcontentsline{toc}{subsection}{Example}
343aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger The function \verb|get_flow_label| allocates
344aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerprivate flow label.
345aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
346aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
347aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerint get_flow_label(int fd, struct sockaddr_in6 *dst, __u32 fl)
348aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger{
349aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        int on = 1;
350aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        struct in6_flowlabel_req freq;
351aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
352aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        memset(&freq, 0, sizeof(freq));
353aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        freq.flr_label = htonl(fl);
354aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        freq.flr_action = IPV6_FL_A_GET;
355aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        freq.flr_flags = IPV6_FL_F_CREATE | IPV6_FL_F_EXCL;
356aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        freq.flr_share = IPV6_FL_S_EXCL;
357aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        memcpy(&freq.flr_dst, &dst->sin6_addr, 16);
358aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        if (setsockopt(fd, SOL_IPV6, IPV6_FLOWLABEL_MGR,
359aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                       &freq, sizeof(freq)) == -1) {
360aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                perror ("can't lease flowlabel");
361aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                return -1;
362aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        }
363aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        dst->sin6_flowinfo |= freq.flr_label;
364aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
365aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        if (setsockopt(fd, SOL_IPV6, IPV6_FLOWINFO_SEND,
366aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                       &on, sizeof(on)) == -1) {
367aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                perror ("can't send flowinfo");
368aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
369aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                freq.flr_action = IPV6_FL_A_PUT;
370aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                setsockopt(fd, SOL_IPV6, IPV6_FLOWLABEL_MGR,
371aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                           &freq, sizeof(freq));
372aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger                return -1;
373aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        }
374aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger        return 0;
375aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger}
376aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
377aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
378aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerA bit more complicated example using routing header can be found
379aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerin \verb|ping6| utility (\verb|iputils| package). Linux rsvpd backend
380aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingercontains an example of using operation \verb|IPV6_FL_A_RENEW|.
381aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
382aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\paragraph{Listing flow labels.} 
383aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\addcontentsline{toc}{subsection}{Listing flow labels}
384aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerList of currently allocated
385aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerflow labels may be read from \verb|/proc/net/ip6_flowlabel|.
386aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
387aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
388aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerLabel S Owner Users Linger Expires Dst                              Opt
389aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerA1BE5 1 0     0     6      3       3ffe2400000000010a0020fffe71fb30 0
390aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
391aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
392aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{itemize}
393aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|Label| is hexadecimal flow label value.
394aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|S| is sharing style.
395aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|Owner| is ID of creator, it is zero, pid or uid, depending on
396aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger		sharing style.
397aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|Users| is number of applications using the label now.
398aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|Linger| is \verb|linger| of this label in seconds.
399aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|Expires| is time until expiration of the label in seconds. It may
400aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	be negative, if the label is in use.
401aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|Dst| is IPv6 destination address.
402aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\item \verb|Opt| is length of options, associated with the label. Option
403aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger	data are not accessible.
404aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{itemize}
405aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
406aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
407aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\paragraph{Flow labels and RSVP.} 
408aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\addcontentsline{toc}{subsection}{Flow labels and RSVP}
409aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerRSVP daemon supports IPv6 flow labels
410aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerwithout any modifications to standard ISI RAPI. Sender must allocate
411aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerflow label, fill corresponding sender template and submit it to local rsvp
412aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerdaemon. rsvpd will check the label and start to announce it in PATH
413aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingermessages. Rsvpd on sender node will renew the flow label, so that it will not
414aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerbe reused before path state expires and all the intermediate
415aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerrouters and receiver purge flow state.
416aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
417aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\verb|rtap| utility is modified to parse flow labels. F.e.\ if user allocated
418aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerflow label \verb|0xA1234|, he may write:
419aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
420aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
421aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerRTAP> sender 3ffe:2400::1/FL0xA1234 <Tspec>
422aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
423aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
424aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerReceiver makes reservation with command:
425aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\begin{verbatim}
426aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemmingerRTAP> reserve ff 3ffe:2400::1/FL0xA1234 <Flowspec>
427aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{verbatim}
428aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger
429aba5acdfdb347d2c21fc67d613d83d4430ca3937osdl.org!shemminger\end{document}
430