Using GDB for debugging netlink communication

Ranjan Sinha rnjn.sinha at gmail.com
Sat Jul 21 11:46:36 EDT 2012


Hi,
I have a multi-threaded application that communicates with a kernel
module using netlink sockets. One of the threads in user mode
application works as a server and kernel module works as a client.
Roughly the kernel code is as follows:

-------------------------8<------------------------------------------------8<-------------------------------------
timeout = 3500;
netlink_unicast();
__set_current_state(TASK_INTERRUPTIBLE);
wait:
timeout = schedule_timeout(timeout);
__set_current_state(TASK_RUNNING);
if (!timeout)
{
    printk(KERN_ERR "No response received\n");
    return -1;
}
if (message_status != UPDATED)
{
   printk(KERN_ERR "Somebody woke us up before we got a reply. Time
left %d\n", timeout);
   __set_current_state(TASK_INTERRUPTIBLE);
   goto wait;
}

-------------------------8<------------------------------------------------8<-------------------------------------

The message_status variable is updated in the netlink callback when
the user mode application replies to this message. So basically the
idea is to send a message and then wait at max timeout jiffies for the
reply.

Now, using gdb, if I add a break point in any function that is called
by netlink server thread in user mode, the break point is never hit
and the kernel log is flooded with messages like
-------------------------8<------------------------------------------------8<-------------------------------------
    Somebody woke us up before we got a reply. Time left 3499

    Somebody woke us up before we got a reply. Time left 3499

    Somebody woke us up before we got a reply. Time left 3499

    Somebody woke us up before we got a reply. Time left 3499

    ..

    ..

    Somebody woke us up before we got a reply. Time left 3498
-------------------------8<------------------------------------------------8<-------------------------------------

Until I finally get

-------------------------8<------------------------------------------------8<-------------------------------------
    No response received
-------------------------8<------------------------------------------------8<-------------------------------------

What is causing the kernel thread to wake up from the timeout and how
should I debug the user mode code?

-- 
Best Regards,
Ranjan

PS: I am using 2.6.32-71.el6.x86_64 on RHEL 6.0



More information about the Kernelnewbies mailing list