0

How to fill NLA_NESTED data in the Userspace Generic Netlink Library data and send to the kernel? please help me

This is my code :

void *msg_h = genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, m_id, 0, 0,
                          SMC_NETLINK_UPD_LOOP_TIMEO, M_GENL_FAMILY_VERSION);

if (!msg_h) {
    return -1
}

struct nlattr *attrs_time = nla_nest_start(msg, M_NLA_LOOP_TIMEO_VAL);
if (nla_put_u32(msg, SMC_NLA_LOOP_TIMEO_VAL_TX_WAIT, info->tx_wait_timeo) < 0)
    return -1;

nla_nest_end(msg, attrs_time);

rc = nl_send_auto(sk, msg);
if (rc < 0)
    return -1;

rc = nl_recvmsgs_default(sk);
if (rc < 0)
    return -1;

return 0;

nl_recvmsgs_default(sk): reported an error: Invalid input data or parameter. How should I fill in NLA_ NESTED data.please help me.

Armali
  • 18,255
  • 14
  • 57
  • 171
zyy
  • 1
  • 1

1 Answers1

0

I have solved the problem. My kernel module genl_family has set two parameters, .maxattr and .policy, which do not correspond to user mode input.

Prasanth Madhavan
  • 12,657
  • 15
  • 62
  • 94
zyy
  • 1
  • 1