Where m flag and o flag will be stored in Linux
Asked Answered
S

2

8

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.

Slavery answered 17/5, 2013 at 12:46 Comment(2)
What language are you working in?Monarchism
Of course I'm working in C.Slavery
S
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

Slavery answered 31/5, 2013 at 14:44 Comment(2)
In your blog you mention some library code by IBM. Could you link to that also, thanks in advance.Symphonious
Here is the link to that code link (dev.laptop.org/~mstone/sources/expanded_srpms/…). I used the code from netlink.c file.Slavery
M
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

Marcusmarcy answered 28/5, 2013 at 13:4 Comment(6)
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.Slavery
Here's a list of all the procfs entries in /proc/sys/net/ipv6/. Unfortunately, there are no entries listed for the RA's flags.Tamekia
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/.Tamekia
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.Slavery
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?Tamekia
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.Slavery

© 2022 - 2024 — McMap. All rights reserved.