Skip to content

Commit

Permalink
Merge pull request iovisor#452 from yadutaf/jt-solisten
Browse files Browse the repository at this point in the history
solisten: clean endian conversion hack
  • Loading branch information
drzaeus77 committed Mar 30, 2016
2 parents 6c08dcb + bf33014 commit ff9f231
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions tools/solisten.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@
#include <net/net_namespace.h>
#include <bcc/proto.h>
// Endian conversion. We can't use kernel version here as it uses inline
// assembly, neither libc version as we can't import it here. Adapted from both.
#if defined(__LITTLE_ENDIAN)
#define bcc_be32_to_cpu(x) ((u32)(__builtin_bswap32)((x)))
#define bcc_be64_to_cpu(x) ((u64)(__builtin_bswap64)((x)))
#elif defined(__BIG_ENDIAN)
#define bcc_be32_to_cpu(x) (x)
#define bcc_be64_to_cpu(x) (x)
#else
#error Host endianness not defined
#endif
// Common structure for UDP/TCP IPv4/IPv6
struct listen_evt_t {
u64 ts_us;
Expand Down Expand Up @@ -117,11 +105,11 @@
// Get IP
if (family == AF_INET) {
bpf_probe_read(evt.laddr, sizeof(u32), &(inet->inet_rcv_saddr));
evt.laddr[0] = bcc_be32_to_cpu(evt.laddr[0]);
evt.laddr[0] = be32_to_cpu(evt.laddr[0]);
} else if (family == AF_INET6) {
bpf_probe_read(evt.laddr, sizeof(evt.laddr), sk->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32);
evt.laddr[0] = bcc_be64_to_cpu(evt.laddr[0]);
evt.laddr[1] = bcc_be64_to_cpu(evt.laddr[1]);
evt.laddr[0] = be64_to_cpu(evt.laddr[0]);
evt.laddr[1] = be64_to_cpu(evt.laddr[1]);
}
// Send event to userland
Expand Down

0 comments on commit ff9f231

Please sign in to comment.