All of lore.kernel.org
 help / color / mirror / Atom feed
* Calling mnl_socket_sendto caused error of netlink attribute type 1 has an invalid length
@ 2019-12-30  8:50 JH
  2019-12-31  0:32 ` Duncan Roe
  0 siblings, 1 reply; 3+ messages in thread
From: JH @ 2019-12-30  8:50 UTC (permalink / raw)
  To: netfilter-devel

Hi,

I have following error of attribute type 1 has an invalid length when
calling following mnl_socket_sendto(channel->mnlSocket, nlh,
nlh->nlmsg_len), I cannot see what was wrong about it, the
nlh->nlmsg_len = 40 which is from libnml, is that wrong? Please advise
how to fix it.

[ 3240.939609] netlink: 'wifi_signal': attribute type 1 has an invalid
length. I have a WiFi function using nml API:

typedef struct {
        struct mnl_socket *mnlSocket;
        char buf[BUFFER_SIZE];
        uint16_t channelId;
        uint32_t interfaceIndex;
        uint32_t sequence;
        void *context;
} __attribute__ ((packed)) Netlink80211Channel_t;

void WiFiScan::Send80211Message(struct nlmsghdr *nlh,
Netlink80211Channel_t *channel) {
    if (mnl_socket_sendto(channel->mnlSocket, nlh, nlh->nlmsg_len) < 0) {
         std::cout << "Failed to send socket" << std::endl;
    }
}

Thank you.

- jh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Calling mnl_socket_sendto caused error of netlink attribute type 1 has an invalid length
  2019-12-30  8:50 Calling mnl_socket_sendto caused error of netlink attribute type 1 has an invalid length JH
@ 2019-12-31  0:32 ` Duncan Roe
  2020-01-02  7:59   ` JH
  0 siblings, 1 reply; 3+ messages in thread
From: Duncan Roe @ 2019-12-31  0:32 UTC (permalink / raw)
  To: JH; +Cc: netfilter-devel

On Mon, Dec 30, 2019 at 07:50:56PM +1100, JH wrote:
> Hi,
>
> I have following error of attribute type 1 has an invalid length when
> calling following mnl_socket_sendto(channel->mnlSocket, nlh,
> nlh->nlmsg_len), I cannot see what was wrong about it, the
> nlh->nlmsg_len = 40 which is from libnml, is that wrong? Please advise
> how to fix it.
>
> [ 3240.939609] netlink: 'wifi_signal': attribute type 1 has an invalid
> length. I have a WiFi function using nml API:
>
> typedef struct {
>         struct mnl_socket *mnlSocket;
>         char buf[BUFFER_SIZE];
>         uint16_t channelId;
>         uint32_t interfaceIndex;
>         uint32_t sequence;
>         void *context;
> } __attribute__ ((packed)) Netlink80211Channel_t;
>
> void WiFiScan::Send80211Message(struct nlmsghdr *nlh,
> Netlink80211Channel_t *channel) {
>     if (mnl_socket_sendto(channel->mnlSocket, nlh, nlh->nlmsg_len) < 0) {
>          std::cout << "Failed to send socket" << std::endl;
>     }
> }
>
> Thank you.
>
> - jh
>
The kernel is complaining about the content of the message, rather than the
length. The message you send should consist of a header followed by a series of
attributes. Attributes are of the form <type> <length> <data>. <type> is always
uint8_t. The kernel has seen the an attribute of type 1 (NLA_U8) but the
following lenth byte was not 1 as it should have been. Quite possibly the
message is garbage.

The error message you see is output by function validate_nla() in file
lib/nlattr.c at line 178.

To get a more helpful answer, you would need to post a lot more code. Is it on
gitbub?

Cheers ... Duncan.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Calling mnl_socket_sendto caused error of netlink attribute type 1 has an invalid length
  2019-12-31  0:32 ` Duncan Roe
@ 2020-01-02  7:59   ` JH
  0 siblings, 0 replies; 3+ messages in thread
From: JH @ 2020-01-02  7:59 UTC (permalink / raw)
  To: JH, netfilter-devel

Thanks Duncan, you are right, it was the wrong type and fixed.

Thank you and appreciate your helps.

Cheers.

- jh

On 12/31/19, Duncan Roe <duncan_roe@optusnet.com.au> wrote:
> On Mon, Dec 30, 2019 at 07:50:56PM +1100, JH wrote:
>> Hi,
>>
>> I have following error of attribute type 1 has an invalid length when
>> calling following mnl_socket_sendto(channel->mnlSocket, nlh,
>> nlh->nlmsg_len), I cannot see what was wrong about it, the
>> nlh->nlmsg_len = 40 which is from libnml, is that wrong? Please advise
>> how to fix it.
>>
>> [ 3240.939609] netlink: 'wifi_signal': attribute type 1 has an invalid
>> length. I have a WiFi function using nml API:
>>
>> typedef struct {
>>         struct mnl_socket *mnlSocket;
>>         char buf[BUFFER_SIZE];
>>         uint16_t channelId;
>>         uint32_t interfaceIndex;
>>         uint32_t sequence;
>>         void *context;
>> } __attribute__ ((packed)) Netlink80211Channel_t;
>>
>> void WiFiScan::Send80211Message(struct nlmsghdr *nlh,
>> Netlink80211Channel_t *channel) {
>>     if (mnl_socket_sendto(channel->mnlSocket, nlh, nlh->nlmsg_len) < 0) {
>>          std::cout << "Failed to send socket" << std::endl;
>>     }
>> }
>>
>> Thank you.
>>
>> - jh
>>
> The kernel is complaining about the content of the message, rather than the
> length. The message you send should consist of a header followed by a series
> of
> attributes. Attributes are of the form <type> <length> <data>. <type> is
> always
> uint8_t. The kernel has seen the an attribute of type 1 (NLA_U8) but the
> following lenth byte was not 1 as it should have been. Quite possibly the
> message is garbage.
>
> The error message you see is output by function validate_nla() in file
> lib/nlattr.c at line 178.
>
> To get a more helpful answer, you would need to post a lot more code. Is it
> on
> gitbub?
>
> Cheers ... Duncan.
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-02  7:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-30  8:50 Calling mnl_socket_sendto caused error of netlink attribute type 1 has an invalid length JH
2019-12-31  0:32 ` Duncan Roe
2020-01-02  7:59   ` JH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.