All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Bambach <eric@cisu.net>
To: linux-kernel@vger.kernel.org
Subject: Re: Netlink Implementation.
Date: Sun, 24 Oct 2004 13:59:55 -0500	[thread overview]
Message-ID: <200410241359.55369.eric@cisu.net> (raw)
In-Reply-To: <200410221751.30798.eric@cisu.net>

LKML,

	Here is my post from Linux-net. I am re-posting here because it's appropriate 
and I have not met with a resolution on linux-net :(

Hello again code gurus :)

	Yes another fight in my netlink saga. Thanks to all who have replied before 
and I have learned alot from the rfc's and zebra/iproute and have contructed 
a much more robust implementation. I have sent the kernel a message defined 
as below. However I have not learned what exactly I should be expecting from 
the kernel. That is, my message gets a reply from the kernel about eth0, 
however on my machine i have eth0,1,2,ppp0 and I would like information about 
them all. I have NLM_F_ROOT set on the packet as I was under the impression 
that this would dump information about all the interfaces. I have also tried 
incrementing   msg.info.ifi_index to 0,1,2,3 etc. No matter what these values 
I always recieve this output form my program.
#./nl_test_prog
Found device: eth0 - 1
Found address:             <--(Dont care about blank yet, main problem is only
					    1 if shows. This is minor)
Received end of msg.

-Am I wrong to expect the kernel to send me data about all the interfaces? 
-Am I calling this wrong?
-What can I do to query all the interfaces?

 I do loop through all the rta messages and I receive only 1 nlmsg packet from 
the kernel when calling recvmsg(). I have also tried without OR'ing 
NLM_F_MATCH. I have run it through a debugger and confirmed although there 
are multiple RTA atributes in my netlink packet but they all refer to eth0.

-Should I be expecting multiple packets (NLM_F_MULTI)?

Here is my nl_packet construction.

  msg.hdr.nlmsg_len = sizeof(msg);
  msg.hdr.nlmsg_type = RTM_GETLINK;
  msg.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT | NLM_F_MATCH; 
  msg.hdr.nlmsg_pid = getpid();
  msg.hdr.nlmsg_seq = seq++; 
  msg.info.ifi_family = AF_UNSPEC; //AF_UNSPEC for ipv4
  msg.info.ifi_type = NETLINK_ROUTE;
  msg.info.ifi_index = 0;
  msg.info.ifi_change =  (0-1); 

----------------Looping over the attributes later in code--------------
/* Loop over the attributes in this message */
    while(RTA_OK(rta, len))
    {
      switch(rta->rta_type)
      {
      case IFLA_IFNAME:
        cout << "Found device: " << (char *)RTA_DATA(rta)<< " - " <<  
info->ifi_index << endl;
        break;
      case IFLA_ADDRESS:
        cout << "Found address: " << (char *)RTA_DATA(rta) << endl;
        break;
      }
      rta = RTA_NEXT(rta, len);
      /* We hit the next packet */
    }// Packet Looping while()


More info/code available upon request.

Any help would be appreciated.

----------------------------------------
EB

> All is fine except that I can reliably "oops" it simply by trying to read
> from /proc/apm (e.g. cat /proc/apm).
> oops output and ksymoops-2.3.4 output is attached.
> Is there anything else I can contribute?

The latitude and longtitude of the bios writers current position, and
a ballistic missile.

		--Alan Cox 2000-12-08 

----------------------------------------

           reply	other threads:[~2004-10-24 18:59 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <200410221751.30798.eric@cisu.net>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200410241359.55369.eric@cisu.net \
    --to=eric@cisu.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.