Skip to contentSkip to conversation

IPV6_RTHDR with a type-0 routing header

DISCUSSION Steinar H. Gunderson 4 participants 9 messages Aug 20, 2009 – Aug 21, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

I've tried attaching a type-0 routing header to my IPv6 packets with setsockopt(..., IPV6_RTHDR, ...), but the kernel just returns EINVAL. looking at the source, it seems it simply refuses anything that's not type-2; should that really be right? I found the following commit:

http://kerneltrap.org/mailarchive/linux-netdev/2008/11/11/4064594

However, it only seems to change EPERM into EINVAL. I don't see any reasonable explanation why it should not be simply success; in fact, RFC 3452 only seems to talk about using type-0 headers with this option.

Any ideas?

/* Steinar */

Signature · 1 line
Homepage: http://www.sesse.net/
#1 lore raw
Quoted 5 lines · Steinar H. Gunderson

I've tried attaching a type-0 routing header to my IPv6 packets with setsockopt(..., IPV6_RTHDR, ...), but the kernel just returns EINVAL. looking at the source, it seems it simply refuses anything that's not type-2;
should that really be right? I found the following commit:

RT0 headers have been deprecated by IETF. The kernel refuses to use then on purpose.

Signature · 1 line
Rémi Denis-Courmont
#2 lore raw
Quoted 7 lines · Rémi Denis-Courmont
Quoted 5 lines

I've tried attaching a type-0 routing header to my IPv6 packets with setsockopt(..., IPV6_RTHDR, ...), but the kernel just returns EINVAL. looking at the source, it seems it simply refuses anything that's not type-2;
should that really be right? I found the following commit:

RT0 headers have been deprecated by IETF. The kernel refuses to use then on purpose.

Hm, OK. And no replacement has been proposed, the deprecation RFC just refers to "future routing headers"...

/* Steinar */

Signature · 1 line
Homepage: http://www.sesse.net/
#3 lore raw
Quoted 2 lines · Steinar H. Gunderson

Hm, OK. And no replacement has been proposed, the deprecation RFC just refers to "future routing headers"...

It looks like I can use destination options instead, but those don't seem to be too easy to use either. The kernel seems to demand that I put eight bytes of padding at the end?

  #define ipv6_optlen(p)  (((p)->hdrlen+1) << 3)

Why the +1?

FWIW, the program I try to run is at http://home.samfundet.no/~sesse/v6fun.c . If I replace "len" in the setsockopt call by "len + 8", the program runs and the packets get the right option attached -- but also eight padding bytes.

/* Steinar */

Signature · 1 line
Homepage: http://www.sesse.net/
#4 lore raw
Quoted 11 lines · Steinar H. Gunderson
Quoted 2 lines · Steinar H. Gunderson

Hm, OK. And no replacement has been proposed, the deprecation RFC just refers to "future routing headers"...

It looks like I can use destination options instead, but those don't seem to be too easy to use either. The kernel seems to demand that I put eight bytes of padding at the end?

  #define ipv6_optlen(p)  (((p)->hdrlen+1) << 3)

Why the +1?

Because that matches the definition of the hdrlen field in RFC2460.

Quoted 3 lines

FWIW, the program I try to run is at http://home.samfundet.no/~sesse/v6fun.c . If I replace "len" in the setsockopt call by "len + 8", the program runs and the packets get the right option attached -- but also eight padding bytes.

ERROR 404: Not Found.

#5 lore raw
Quoted 8 lines · Jens Rosenboom
Quoted 7 lines

It looks like I can use destination options instead, but those don't seem to be too easy to use either. The kernel seems to demand that I put eight bytes of padding at the end?

  #define ipv6_optlen(p)  (((p)->hdrlen+1) << 3)

Why the +1?

Because that matches the definition of the hdrlen field in RFC2460.

Hm, in that case I guess it's glibc that has one too much indeed (I never write this field).

Quoted 4 lines
Quoted 3 lines

FWIW, the program I try to run is at http://home.samfundet.no/~sesse/v6fun.c . If I replace "len" in the setsockopt call by "len + 8", the program runs and the packets get the right option attached -- but also eight padding bytes.

ERROR 404: Not Found.

Sorry, http://home.samfundet.no/~sesse/v6opt.c

/* Steinar */

Signature · 1 line
Homepage: http://www.sesse.net/
#6 lore raw
Quoted 3 lines · Steinar H. Gunderson
Quoted 1 line

Because that matches the definition of the hdrlen field in RFC2460.

Hm, in that case I guess it's glibc that has one too much indeed (I never write this field).

Yes indeed. It's fixed in more recent glibc:

[BZ #5760]
* inet/inet6_opt.c (inet6_opt_init): Fix ip6h_len computation. Patch by Roland Bless <[email protected]>.

/* Steinar */

Signature · 1 line
Homepage: http://www.sesse.net/
#7 lore raw
In reply to Steinar H. Gunderson
Quoted 7 lines · Steinar H. Gunderson

Hi,

I've tried attaching a type-0 routing header to my IPv6 packets with setsockopt(..., IPV6_RTHDR, ...), but the kernel just returns EINVAL. looking at the source, it seems it simply refuses anything that's not type-2; should that really be right? I found the following commit:

Quoted 7 lines

http://kerneltrap.org/mailarchive/linux-netdev/2008/11/11/4064594

However, it only seems to change EPERM into EINVAL. I don't see any reasonable explanation why it should not be simply success; in fact, RFC 3452 only seems to talk about using type-0 headers with this option.

Any ideas?

How about RFC5095?

#8 lore raw
In reply to Steinar H. Gunderson

Steinar H. Gunderson wrote, at 08/20/2009 07:11 PM:

Quoted 10 lines

Hi,

I've tried attaching a type-0 routing header to my IPv6 packets with setsockopt(..., IPV6_RTHDR, ...), but the kernel just returns EINVAL. looking at the source, it seems it simply refuses anything that's not type-2; should that really be right? I found the following commit:

http://kerneltrap.org/mailarchive/linux-netdev/2008/11/11/4064594

However, it only seems to change EPERM into EINVAL. I don't see any

About the cause of changing EPERM into EINVAL, can refer to
http://marc.info/?l=linux-netdev&m=122046709502496&w=3.

Signature · 2 lines
Best Regards
Shan Wei
Quoted 6 lines

reasonable explanation why it should not be simply success; in fact, RFC 3452 only seems to talk about using type-0 headers with this option.

Any ideas?

/* Steinar */