Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

devlink: Allow large formatted message of binary output

Devlink supports pair output of name and value. When the value is
binary, it must be presented in an array. If the length of the binary
value exceeds fmsg limitation, break the value into chunks internally.

Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Aya Levin and committed by
David S. Miller
e2cde864 6c086702

+16 -12
+1 -3
include/net/devlink.h
··· 967 967 int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value); 968 968 int devlink_fmsg_u64_put(struct devlink_fmsg *fmsg, u64 value); 969 969 int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value); 970 - int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value, 971 - u16 value_len); 972 970 973 971 int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name, 974 972 bool value); ··· 979 981 int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name, 980 982 const char *value); 981 983 int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name, 982 - const void *value, u16 value_len); 984 + const void *value, u32 value_len); 983 985 984 986 struct devlink_health_reporter * 985 987 devlink_health_reporter_create(struct devlink *devlink,
+15 -9
net/core/devlink.c
··· 4414 4414 } 4415 4415 EXPORT_SYMBOL_GPL(devlink_fmsg_string_put); 4416 4416 4417 - int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value, 4418 - u16 value_len) 4417 + static int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value, 4418 + u16 value_len) 4419 4419 { 4420 4420 return devlink_fmsg_put_value(fmsg, value, value_len, NLA_BINARY); 4421 4421 } 4422 - EXPORT_SYMBOL_GPL(devlink_fmsg_binary_put); 4423 4422 4424 4423 int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name, 4425 4424 bool value) ··· 4526 4527 EXPORT_SYMBOL_GPL(devlink_fmsg_string_pair_put); 4527 4528 4528 4529 int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name, 4529 - const void *value, u16 value_len) 4530 + const void *value, u32 value_len) 4530 4531 { 4532 + u32 data_size; 4533 + u32 offset; 4531 4534 int err; 4532 4535 4533 - err = devlink_fmsg_pair_nest_start(fmsg, name); 4536 + err = devlink_fmsg_arr_pair_nest_start(fmsg, name); 4534 4537 if (err) 4535 4538 return err; 4536 4539 4537 - err = devlink_fmsg_binary_put(fmsg, value, value_len); 4538 - if (err) 4539 - return err; 4540 + for (offset = 0; offset < value_len; offset += data_size) { 4541 + data_size = value_len - offset; 4542 + if (data_size > DEVLINK_FMSG_MAX_SIZE) 4543 + data_size = DEVLINK_FMSG_MAX_SIZE; 4544 + err = devlink_fmsg_binary_put(fmsg, value + offset, data_size); 4545 + if (err) 4546 + return err; 4547 + } 4540 4548 4541 - err = devlink_fmsg_pair_nest_end(fmsg); 4549 + err = devlink_fmsg_arr_pair_nest_end(fmsg); 4542 4550 if (err) 4543 4551 return err; 4544 4552