libnl --Error: Invalid message

josh_powers at selinc.com josh_powers at selinc.com
Mon Jun 27 18:27:18 EDT 2011


I am trying to use libnl from the kernel to user space and libnl debugging 
outputs this 

DBG<3>: Attempting to read from 0x880210
DBG<3>: recvmsgs(0x880210): Read 304 bytes
DBG<3>: recgmsgs(0x880210): Processing valid message...
DBG<2>: msg 0x881260: Allocated new message, maxlen=304
-- Debug: Received Message:
--------------------------   BEGIN NETLINK MESSAGE 
---------------------------
  [HEADER] 16 bytes
    .nlmsg_len = 304
    .nlmsg_type = 24 <0x18>
    .nlmsg_flags = 0 <>
    .nlmsg_seq = 0
    .nlmsg_pid = 0
  [PAYLOAD] 288 bytes
    01 01 00 00 1c 01 01 00 c2 09 00 00 00 00 00 00 7a 79 
................zy
    78 77 00 00 61 62 63 64 65 00 2f 62 69 6e 2f 62 61 73 
xw..abcde./bin/bas
    68 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
h.................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 
..................
---------------------------  END NETLINK MESSAGE 
---------------------------
-- Error: Invalid message: type=0x18 length=304 flags=<> sequence-nr=0 
pid=0
DBG<4>: Returned message reference 0x881260, 0 remaining
DBG<2>: msg 0x881260: Freed
DBG<3>: Attempting to read from 0x880210

The object I am trying to send (at the moment) is just a struct, I decided 
to try to stop using the different types but that wasn't working either 
with a similar error when it failed.  I have been able to send a message 
from user space to kernel space in this app, just not the other way.

In the kernel my netlink related calls are

skb = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
msg_head = genlmsg_put(skb, 0/*pid*/, 0 /*seq*/, &lsmlkm_gnl_family, 0
/*flags*/, LSMLKM_C_MESSAGE);
rc = nla_put(skb, LSMLKM_A_MESSAGE, sizeof(lsmlkm_message), message);
genlmsg_end(skb, msg_head);
genlmsg_unicast(&init_net, skb, pid);

any ideas where I am going wrong?

Thanks





More information about the libnl mailing list