Re: [PATCH net-next 01/15] devlink: add value check to devlink_info_version_put()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/8/2025 4:00 AM, Jagielski, Jedrzej wrote:

From: Nelson, Shannon <shannon.nelson@xxxxxxx>
Sent: Tuesday, April 8, 2025 2:31 AM

On 4/7/2025 2:51 PM, Tony Nguyen wrote:
From: Jedrzej Jagielski <jedrzej.jagielski@xxxxxxxxx>

Prevent from proceeding if there's nothing to print.

Suggested-by: Przemek Kitszel <przemyslaw.kitszel@xxxxxxxxx>
Reviewed-by: Jiri Pirko <jiri@xxxxxxxxxx>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@xxxxxxxxxxxx>
Tested-by: Bharath R <bharath.r@xxxxxxxxx>
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@xxxxxxxxx>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@xxxxxxxxx>
---
   net/devlink/dev.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/devlink/dev.c b/net/devlink/dev.c
index d6e3db300acb..02602704bdea 100644
--- a/net/devlink/dev.c
+++ b/net/devlink/dev.c
@@ -775,7 +775,7 @@ static int devlink_info_version_put(struct devlink_info_req *req, int attr,
                  req->version_cb(version_name, version_type,
                                  req->version_cb_priv);

-       if (!req->msg)
+       if (!req->msg || !*version_value)

Personally, I'd like to know that the value was blank if there was
normally a value to be printed.  This is removing a useful indicator of
something that might be wrong.

sln


Actually this still works the same - when there is no entry that means
that the input was blank, so it still gives you some message.
 From my standpoint that's some sort of nice-to-have preventing from printing
the data which has not been inited which most likely is not intentional and
doesn't look good imho.

A label with no accompanying value gives different message than no label at all. If the label doesn't appear at all, the user isn't given the obvious clue that data is missing, and may not even notice there is a line missing. Printing the label without the value clearly shows that there was an expectation of data to be printed.

If the particular driver wants to use the blank value as a decision point for printing the line, then the driver itself should decide to not call on this routine, rather than this routine trying to make that data filtering decision for all other drivers.

If there is a call into devlink routine to print a label and a value, I'd prefer devlink to print that label as it was asked to, whether there is a value or not.

sln




                  return 0;

          nest = nla_nest_start_noflag(req->msg, attr);
--
2.47.1








[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux