diff options
author | Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com> | 2019-01-28 12:29:07 +0000 |
---|---|---|
committer | Simon Horman <simon.horman@netronome.com> | 2019-01-31 10:53:10 +0100 |
commit | f8b63e59301fda6211e8ab69bd2e32c3f98325c9 (patch) | |
tree | e980c9969b3c169ff8f1d6aef9462ad18e53060d /include/sparse | |
parent | 68c00e3eed72a58e4b9e29a0fd1cafbcf6fff3a8 (diff) | |
download | openvswitch-f8b63e59301fda6211e8ab69bd2e32c3f98325c9.tar.gz |
lib/tc: make pedit mask calculations byte order agnostic
pedit allows setting entire words with an optional mask and OVS
makes use of such masks to allow setting fields that do not span
entire words.
The struct tc_pedit_key structure, which is part of the kernel
ABI, uses host byte order fields to store the mask and value for
a pedit action, however, these fields contain values in network
byte order.
In order to allow static analysis tools to check for endianness
problems this patch adds a local version of struct tc_pedit_key
which uses big endian types and refactors the relevant code as
appropriate.
In the course of making this change it became apparent that the
calculation of masks was occurring using host byte order although
the values are in network byte order. This patch also fixes that
problem by shifting values in host byte order and then converting
them to network byte order. It is believe this fixes a bug on big
endian systems although we are not in a position to test that.
Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Diffstat (limited to 'include/sparse')
-rw-r--r-- | include/sparse/automake.mk | 3 | ||||
-rw-r--r-- | include/sparse/linux/tc_act/tc_pedit.h | 29 |
2 files changed, 31 insertions, 1 deletions
diff --git a/include/sparse/automake.mk b/include/sparse/automake.mk index 985ee6a2f..4c7b17783 100644 --- a/include/sparse/automake.mk +++ b/include/sparse/automake.mk @@ -26,4 +26,5 @@ noinst_HEADERS += \ include/sparse/sys/sysmacros.h \ include/sparse/sys/types.h \ include/sparse/sys/wait.h \ - include/sparse/threads.h + include/sparse/threads.h \ + include/sparse/linux/tc_act/tc_pedit.h diff --git a/include/sparse/linux/tc_act/tc_pedit.h b/include/sparse/linux/tc_act/tc_pedit.h new file mode 100644 index 000000000..ca5c1f1fe --- /dev/null +++ b/include/sparse/linux/tc_act/tc_pedit.h @@ -0,0 +1,29 @@ +#ifndef FIX_LINUX_TC_PEDIT_H +#define FIX_LINUX_TC_PEDIT_H + +#ifndef __CHECKER__ +#error "Use this header only with sparse. It is not a correct implementation." +#endif + +#include_next <linux/tc_act/tc_pedit.h> + +/* Fixes endianness of 'mask' and 'val' members. */ +#define tc_pedit_key rpl_tc_pedit_key +struct rpl_tc_pedit_key { + ovs_be32 mask; /* AND */ + ovs_be32 val; /* XOR */ + __u32 off; /* offset */ + __u32 at; + __u32 offmask; + __u32 shift; +}; + +#define tc_pedit_sel rpl_tc_pedit_sel +struct rpl_tc_pedit_sel { + tc_gen; + unsigned char nkeys; + unsigned char flags; + struct tc_pedit_key keys[0]; +}; + +#endif |