diff options
author | Hangbin Liu <liuhangbin@gmail.com> | 2018-10-29 14:34:29 +0800 |
---|---|---|
committer | Jiri Pirko <jiri@mellanox.com> | 2018-11-05 17:13:05 +0100 |
commit | c35bece57a4990368a633c88a4c4edb8397c7d16 (patch) | |
tree | b63e2293a00a419317e2bfabba1ed1e02bab9c95 | |
parent | e47d5db538736c74473842b57110b71d3844d7e6 (diff) | |
download | libteam-c35bece57a4990368a633c88a4c4edb8397c7d16.tar.gz |
libteam/options: fix s32/u32 data storage on big endian
When put signed/unsigned int data to long on big endian(PPC64) and read it as
singed/unsigned int, we will read from high bytes and get wrong number, e.g.
wrong active port index and priority values.
Fix it by using signed/unsigned int directly when store s32/u32 values.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
-rw-r--r-- | libteam/options.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libteam/options.c b/libteam/options.c index 3f444cf..71cc99e 100644 --- a/libteam/options.c +++ b/libteam/options.c @@ -258,12 +258,13 @@ int get_options_handler(struct nl_msg *msg, void *arg) bool changed; int nla_type; int opt_type; - long tmp; - bool tmp_bool; void *data; int data_len = 0; int err; struct nlattr *data_attr; + unsigned int tmp_u32; + bool tmp_bool; + int tmp_s32; if (nla_parse_nested(option_attrs, TEAM_ATTR_OPTION_MAX, nl_option, NULL)) { @@ -304,8 +305,8 @@ int get_options_handler(struct nl_msg *msg, void *arg) switch (nla_type) { case NLA_U32: - tmp = (long) nla_get_u32(data_attr); - data = &tmp; + tmp_u32 = nla_get_u32(data_attr); + data = &tmp_u32; opt_type = TEAM_OPTION_TYPE_U32; break; case NLA_STRING: @@ -323,8 +324,8 @@ int get_options_handler(struct nl_msg *msg, void *arg) opt_type = TEAM_OPTION_TYPE_BOOL; break; case NLA_S32: - tmp = (long) nla_get_s32(data_attr); - data = &tmp; + tmp_s32 = nla_get_s32(data_attr); + data = &tmp_s32; opt_type = TEAM_OPTION_TYPE_S32; break; default: |