Re: Netlink Implementation.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 22 October 2004 05:51 pm, Eric Bambach wrote:
> On Wednesday 20 October 2004 08:17 pm, Eric Bambach wrote:
> > Hello,
>
> In response to my previous message, maybe my questions were not specific
> enough. I have been debugging/understanding the code for a little time now
> and constantly run into this problem. I get a SIGSEGV here
>
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)

-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 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, 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 

----------------------------------------
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux