2009-05-27 08:43:35     Issue in the Netlink communication between the application and kernel

Document created by Aaronwu Employee on Aug 15, 2013
Version 1Show Document
  • View in full screen mode

2009-05-27 08:43:35     Issue in the Netlink communication between the application and kernel

ThangarJ P (INDIA)

Message: 74645   

 

Dear All,

 

I am working with BF527EZkit and uClinux distribution(Linux version 2.6.28.7-ADI-2009R1-pre and gcc version 4.1.2 (ADI svn)).

 

I am facing an issue with netlink communication between application and kernel.

 

The userspace attempts to send the pid to Kernel space. But  it seems kernel space doesnt receive the pid.

 

I have attached the kernel and application file to read the netlink message.

 

In the kernel driver init function we are calling the below API.

 

nl_sk = netlink_kernel_create(&init_net,NETLINK_TEST,0,readNetlinkMessage,NULL,THIS_MODULE);

 

we expect readNetlinkMessage() function should run while the userspace sending the process id.

 

but thats is not happening.

 

But we are not facing this issue in the 2008R1.5 distribution.

 

Please provide your suggestion.

 

Thanks.

 

Application.c

Kernalfile.c

QuoteReplyEditDelete

 

 

2009-05-27 18:16:09     Re: Issue in the Netlink communication between the application and kernel

Robin Getz (UNITED STATES)

Message: 74677   

 

ThangarJ:

 

I looked at linux-2.6.x/Documentation/connector/ and the basic examples didn't work for me either. I'll need to dig into it tomorrow...

 

-Robin

 

QuoteReplyEditDelete

 

 

2009-05-29 00:18:09     Re: Issue in the Netlink communication between the application and kernel

ThangarJ P (INDIA)

Message: 74742   

 

Hi Robin,

 

Any update on this.

 

 

 

Thanks

QuoteReplyEditDelete

 

 

2009-05-29 09:39:51     Re: Issue in the Netlink communication between the application and kernel

Robin Getz (UNITED STATES)

Message: 74770   

 

Thangar:

 

Nope - been working on fixing other things.

 

Sorry for the delay.

 

-Robin

QuoteReplyEditDelete

 

 

2009-06-03 07:41:24     Re: Issue in the Netlink communication between the application and kernel

Sada M (INDIA)

Message: 75124   

 

Hi Robin,

 

Could you please help us to resolve this issue.

 

Regards,

 

Sada.

QuoteReplyEditDelete

 

 

2009-06-05 03:31:19     Re: Issue in the Netlink communication between the application and kernel

Sada M (INDIA)

Message: 75225   

 

Dear Robin,

 

Could you please let us know when this issue is expected to be resolved ?

 

Regards,

 

Sada.

QuoteReplyEditDelete

 

 

2009-06-16 03:31:41     Re: Issue in the Netlink communication between the application and kernel

Sada M (INDIA)

Message: 75763   

 

Dear Robin,

 

Is this issues is resolvable ?

 

If so, could you please let us know when this issue is expected to be resolved ?

 

Based on your inputs  if this is not resolvable, we have to see other alternatives and hence expecting your quick reply.

 

Regards,

 

Sada.

QuoteReplyEditDelete

 

 

2009-06-16 10:32:05     Re: Issue in the Netlink communication between the application and kernel

Robin Getz (UNITED STATES)

Message: 75822   

 

Sada:

 

There is no schedule - I have not had a chance to look at it yet.

 

-Robin

QuoteReplyEditDelete

 

 

2009-07-15 08:06:46     Re: Issue in the Netlink communication between the application and kernel

Sudhakar GN (INDIA)

Message: 77356   

 

Robin:

 

Any chances that this issue is already resolved in 2009R1-RC1?

 

-Sudhakar

QuoteReplyEditDelete

 

 

2009-07-15 08:20:29     Re: Issue in the Netlink communication between the application and kernel

Robin Getz (UNITED STATES)

Message: 77360   

 

Nope.

QuoteReplyEditDelete

 

 

2009-07-15 17:09:24     Re: Issue in the Netlink communication between the application and kernel

Mike Frysinger (UNITED STATES)

Message: 77409   

 

this is because the connector code requires all consumers to register in connector.h but the test code does not do this.  and since its id is larger than the valid one, no messages get sent.

 

change cn_test_id to read something like:

... cn_test_id = { 1, 0x456 };

 

and then it should work fine

QuoteReplyEditDelete

 

 

2009-07-17 03:08:50     Re: Issue in the Netlink communication between the application and kernel

ThangarJ P (INDIA)

Message: 77499   

 

hi Mike,

 

we are using  netlink APIs only for unicasting.

 

I think  there is no relation with our code and connector driver.

 

so how your suggestion will resolve this issue.

 

please provide your suggestion regarding on this.

 

And also is there any alternative methods instead of netlinks?

 

 

 

 

 

Thanks

QuoteReplyEditDelete

 

 

2009-07-17 07:39:21     Re: Issue in the Netlink communication between the application and kernel

Robin Getz (UNITED STATES)

Message: 77546   

 

ThangarJ:

 

Mike got the test code in the kernel working - can you do the same to prove out that things work?

 

-Robin

QuoteReplyEditDelete

 

 

2009-07-17 08:17:49     Re: Issue in the Netlink communication between the application and kernel

ThangarJ P (INDIA)

Message: 77552   

 

Hi Robin,

 

Mike has changed the connector device id to 1 from 123 in the teste code as like below

 

cn_test_id = { 1, 0x456 } ->modified by mike

 

cn_test_id = { 123, 0x456 } ->before modified

 

and also mike suggested to add all the consumer in connector.h file

 

but the id is cn_test_id = { 123, 0x456 } in 2008R1.5..its working know

 

But in our code we didnt pass any id to netlinks like in the test code and we are doing unicasting only.but in the test code using multicasting.

 

is this id used for muticasting purpose?

 

so please suggest how the abovechange will resolve the issue in netlinks.

 

And also clarify anyother things need to modify.

 

 

 

Thanks

QuoteReplyEditDelete

 

 

2009-07-17 08:31:30     Re: Issue in the Netlink communication between the application and kernel

Robin Getz (UNITED STATES)

Message: 77557   

 

Thangar:

 

If the test code is working - then the kernel is working - right? Therefore - the problem is in your app?

 

-Robin

QuoteReplyEditDelete

 

 

2009-07-17 09:34:49     Re: Issue in the Netlink communication between the application and kernel

ThangarJ P (INDIA)

Message: 77564   

 

Hi Robin,

 

Please find out my code below,

 

Please suggest are we need to modify anything in the code .

 

because we are using the same code in 2008R1.5.

 

user space application

 

  sock_fd = socket(PF_NETLINK, SOCK_RAW,NETLINK_CONNECTOR); /* 17 - netlink protocol type - NETLINK_TEST */

        memset(&src_addr, 0, sizeof(src_addr));

        memset(buf, 0, MSG_SIZE);

 

        src_addr.nl_family = AF_NETLINK;

        src_addr.nl_pid = getpid();  /* self pid */

        src_addr.nl_groups = 0;  /* not in mcast groups */

 

           bind(sock_fd, (struct sockaddr*)&src_addr,

          sizeof(src_addr));

 

        nl_hdr = (struct nlmsghdr *)buf;

        nl_hdr->nlmsg_len = MSG_SIZE;

        nl_hdr->nlmsg_pid = getpid();

        nl_hdr->nlmsg_flags = 0;

 

 

        u32retval = send(sock_fd, buf ,MSG_SIZE , 0);

 

 

In Kernel:

 

void readNetlinkMessage (struct sock *sk, int len)   /*This callback is not calling while send from userspace*/

{

 

        struct sk_buff *skb;

        struct nlmsghdr *nlh = NULL;

        u8 *payload = NULL;

        while((skb =  skb_dequeue(&sk->sk_receive_queue)) != NULL)

        {

                nlh = (struct nlmsghdr *)skb->data;

                payload = NLMSG_DATA(nlh);

                pid = nlh->nlmsg_pid;

          }

 

}

 

 

int __init Init_IR_Remote(void)

{

        int RetVal;

        nl_sk = netlink_kernel_create(&init_net,NETLINK_TEST,0,readNetlinkMessage,NULL,THIS_MODULE);

          misc_register(&IRDev);

 

                return(0);

 

}

QuoteReplyEditDelete

 

 

2009-07-17 23:48:16     Re: Issue in the Netlink communication between the application and kernel

Mike Frysinger (UNITED STATES)

Message: 77591   

 

the connector test code suggests .nl_groups is a group mask.  setting it to 0 seems like a bad idea if that is the case.

QuoteReplyEditDelete

 

 

2009-07-18 08:33:56     Re: Issue in the Netlink communication between the application and kernel

ThangarJ P (INDIA)

Message: 77604   

 

Hi Mike,

 

I have tested with the variable .nl_groups of value other than 0.thats also not working.

 

In the kernel driver init function we are calling the below API.

 

nl_sk = netlink_kernel_create(&init_net,NETLINK_TEST,0,readNetlinkMessage,NULL,THIS_MODULE);

 

we expect readNetlinkMessage() function should run while the userspace calling the send API.

 

i have already sent the user and kernel space codes.

 

Are we missing any initilization or headers?

 

please suggest how to debug this issue.

 

 

 

Thanks

QuoteReplyEditDelete

 

 

2009-07-20 01:36:49     Re: Issue in the Netlink communication between the application and kernel

Mike Frysinger (UNITED STATES)

Message: 77682   

 

if you only need basic netlink functionality, why dont you use the connector driver instead

Attachments

Outcomes