7

I want to know the value of m flag and o flag of recently received Router Advertisement. From the kernel source code I came to know that m flag and o flag are stored.

  /*
   * Remember the managed/otherconf flags from most recently
   * received RA message (RFC 2462) -- yoshfuji
  */
  in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED |
                          IF_RA_OTHERCONF)) |
                          (ra_msg->icmph.icmp6_addrconf_managed ?
                                   IF_RA_MANAGED : 0) |
                           (ra_msg->icmph.icmp6_addrconf_other ?
                                   IF_RA_OTHERCONF : 0);
  .
  .
  .

Then I believe it must be possible to retrieve those values using ioctl or proc filesystem or any other method. Could anyone please point that way.

theB
  • 2,048
  • 2
  • 20
  • 29

2 Answers2

3

At last I found the way. Thanks to Google, Thanks to Shirley Ma. Please get the code from my blog http://kumaran127.blogspot.jp/2013/05/get-m-and-o-flag-of-most-recently.html

theB
  • 2,048
  • 2
  • 20
  • 29
  • In your blog you mention some library code by IBM. Could you link to that also, thanks in advance. – thuovila Jun 12 '13 at 09:16
  • 1
    Here is the link to that code [link](http://dev.laptop.org/~mstone/sources/expanded_srpms/dhcpv6-0.10-44.fc7/dhcp-0.10/) (http://dev.laptop.org/~mstone/sources/expanded_srpms/dhcpv6-0.10-44.fc7/dhcp-0.10/). I used the code from netlink.c file. – theB Jun 13 '13 at 06:16
1

I'm pretty sure you won't find this in procfs but you can analyse these packets with radvdump: see http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/hints-daemons-radvd.html and for reference of how it's implemented: http://svn.dd-wrt.com/browser/src/router/radvd/radvdump.c?rev=11491 .. Here is how they create the icmp6 filter on a raw socket http://svn.dd-wrt.com/browser/src/router/radvd/socket.c?rev=11491 which is then used to listen in on.

Cheers

smassey
  • 5,875
  • 24
  • 37
  • Could you please explain me how you are pretty sure that proc filesystem doesn't have this information. And see the code I shared. Its so clear that the most recent RA's flags are stored for future reference (as the RFC specifies). So there should be some way to retrieve it. – theB May 28 '13 at 13:58
  • 1
    Here's a list of all the `procfs` [entries in /proc/sys/net/ipv6/](http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/proc-sys-net-ipv6..html). Unfortunately, there are no entries listed for the RA's flags. – Vilhelm Gray May 28 '13 at 16:06
  • 1
    The source code you are viewing is probably storing the flags for usage *within* the kernel. If you want access to these flags from userspace, you'll need to rely on a daemon such as **radvd**, or roll your own kernel module (not particularly difficult to accomplish) to print out the flags to **/proc/**. – Vilhelm Gray May 28 '13 at 16:09
  • No the flags are not stored for kernel internal use. As per the RFC a dhcp6 client should start according to the M and O flag of recently received RA. So these flags are stored for the dhcp6 client's purpose. So there should be some way to retrieve it. Also you can read about Netlink sockets to know more. And I'm using **radvd** for sending RA. I don't want to manually read the values. I need to check it and start my dhcp6 client in my code. – theB May 29 '13 at 05:23
  • Please forgive my confusion, I'm not particularly familiar with networking, are you trying to acquire the flags completely in userspace, or in kernelspace which then passes to userspace via `ioctl`, `procfs`, etc? – Vilhelm Gray May 29 '13 at 13:08
  • What I need, is to get those flags in an user space program. For that I tried Netlink sockets. Because there is not procfs entry for those flags as well as no ioctl calls specific to that. Actually its been told that ioctl is an ugly way of implementation. So now ppl prefer Netlink sockets. Using Netlink I'm getting some value. But I'm not sure whether I getting the right values. So I though of implementing a sys entry in procfs and the user space code will use that. If I find some way I'll post it here. Also if you have any suggestions please let me know. Thanks for your interest. – theB May 30 '13 at 05:05