Fix: endianness of integers received by filter
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 26 Apr 2016 22:41:04 +0000 (18:41 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 26 Apr 2016 22:43:00 +0000 (18:43 -0400)
We need to byteswap integers passed to the filter when they are tagged
as being in an endianness which differs from the architecture
endianness, so the integer comparisons make sense in terms of value
rather than raw bytes for those fields.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
probes/lttng-tracepoint-event-impl.h

index a87d146af23e701349f5fa259f4fe0b823ae2168..ba906ac49c01fa46b34bf8e8d4a87570ab3b3a9e 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/debugfs.h>
 #include <linux/rculist.h>
 #include <asm/byteorder.h>
 #include <linux/debugfs.h>
 #include <linux/rculist.h>
 #include <asm/byteorder.h>
+#include <linux/swab.h>
 
 #include <probes/lttng.h>
 #include <probes/lttng-types.h>
 
 #include <probes/lttng.h>
 #include <probes/lttng-types.h>
@@ -457,18 +458,24 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len,           \
                case 2:                                                        \
                {                                                              \
                        union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
                case 2:                                                        \
                {                                                              \
                        union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != __BYTE_ORDER)                       \
+                               __swab16s(&__tmp.v);                           \
                        __ctf_tmp_int64 = (int64_t) __tmp.v;                   \
                        break;                                                 \
                }                                                              \
                case 4:                                                        \
                {                                                              \
                        union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
                        __ctf_tmp_int64 = (int64_t) __tmp.v;                   \
                        break;                                                 \
                }                                                              \
                case 4:                                                        \
                {                                                              \
                        union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != __BYTE_ORDER)                       \
+                               __swab32s(&__tmp.v);                           \
                        __ctf_tmp_int64 = (int64_t) __tmp.v;                   \
                        break;                                                 \
                }                                                              \
                case 8:                                                        \
                {                                                              \
                        union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
                        __ctf_tmp_int64 = (int64_t) __tmp.v;                   \
                        break;                                                 \
                }                                                              \
                case 8:                                                        \
                {                                                              \
                        union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != __BYTE_ORDER)                       \
+                               __swab64s(&__tmp.v);                           \
                        __ctf_tmp_int64 = (int64_t) __tmp.v;                   \
                        break;                                                 \
                }                                                              \
                        __ctf_tmp_int64 = (int64_t) __tmp.v;                   \
                        break;                                                 \
                }                                                              \
@@ -488,18 +495,24 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len,           \
                case 2:                                                        \
                {                                                              \
                        union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
                case 2:                                                        \
                {                                                              \
                        union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != __BYTE_ORDER)                       \
+                               __swab16s(&__tmp.v);                           \
                        __ctf_tmp_uint64 = (uint64_t) __tmp.v;                 \
                        break;                                                 \
                }                                                              \
                case 4:                                                        \
                {                                                              \
                        union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
                        __ctf_tmp_uint64 = (uint64_t) __tmp.v;                 \
                        break;                                                 \
                }                                                              \
                case 4:                                                        \
                {                                                              \
                        union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != __BYTE_ORDER)                       \
+                               __swab32s(&__tmp.v);                           \
                        __ctf_tmp_uint64 = (uint64_t) __tmp.v;                 \
                        break;                                                 \
                }                                                              \
                case 8:                                                        \
                {                                                              \
                        union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
                        __ctf_tmp_uint64 = (uint64_t) __tmp.v;                 \
                        break;                                                 \
                }                                                              \
                case 8:                                                        \
                {                                                              \
                        union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != __BYTE_ORDER)                       \
+                               __swab64s(&__tmp.v);                           \
                        __ctf_tmp_uint64 = (uint64_t) __tmp.v;                 \
                        break;                                                 \
                }                                                              \
                        __ctf_tmp_uint64 = (uint64_t) __tmp.v;                 \
                        break;                                                 \
                }                                                              \
This page took 0.026505 seconds and 4 git commands to generate.