I have not found any document/note in the kernel that would mandate to pass 16/32-bit
values in netlink messages towards the kernel in network byte order. So my question is if I have to use htonl
/htons
functions when filling up netlink message. Is there such requirement at all?
Asked
Active
Viewed 521 times
0

Mark
- 6,052
- 8
- 61
- 129
-
Otherwise how can you be sure that the order is BIG endian (or network order)? Those calls are no-op on BIG endian CPUs. – 0andriy Apr 19 '17 at 17:28
-
@0andriy, netlink does not traverse beyond the local host, why would it be necessary to ensure the big endian byte order? I think netlink maintains the host byte order? – Mark Apr 20 '17 at 16:51
1 Answers
0
according to this article this could be controlled on per-attribute basis
There are two special flags which may be present in netlink attributes, though I have yet to encounter them in my work.
NLA_F_NESTED: specifies a nested attribute; used as a hint for parsing. Doesn’t always appear to be used, even if nested attributes are present. NLA_F_NET_BYTEORDER: attribute data is stored in network byte order (big endian) instead of host endianness
UPD: looks like native (little) endian does not work well for some cases: I'm getting errno 4097
trying to pass IPSET CREATE timeout using it. network byte order works fine.

Daniel Podolsky
- 81
- 3