endian issue in conntrack_netlink
Hi Harald,
while working on the conntrack tool I've observed that conntrack_netlink
uses cpu_to_be64, htonl... to flip bits depending on the architecture.
Is this some kind of portability issue?
BTW, what is the equivalence of be64_to_cpu in userspace? Thanks!
--
Pablo
Quoted 4 lines · Pablo Neira
Hi Harald,
while working on the conntrack tool I've observed that
conntrack_netlinkusescpu_to_be64, htonl... to flip bits depending on the architecture. Is this some kind of portability issue?
yes, it means that all the payload of any nfattr will always be in network byte order. This would allow easy transport over a real network in the future (e.g. jamal's netlink2).
The nlmsghdr and the nfattr headers (type and length) are still host byte order. But some easy program (e.g. the deamon that receives from netlink and send sover real network) can just iterate over them and convert them to network byte order - without understanding anything about the payload.
Quoted 1 line
BTW, what is the equivalence of
be64_to_cpuin userspace? Thanks!
Good question. I don't think there's a standard way [yet?], so I'd suggest manually implementing it by "#if little endian" bitshift operations in C (at least for now).
Cheers,
Signature · 5 lines
- Harald Welte <[email protected]> http://netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie