Subject: Re: [RFC PATCH v2 net-next 1/3] netlink: add support for formatted extack messages

From: Jakub Kicinski <[email-masked]>
Date: Thu, 13 Oct 2022 08:29:13 -0700

On Thu, 13 Oct 2022 10:23:00 +0100 [email-masked] wrote:
> +	if (snprintf(__extack->_msg_buf, NETLINK_MAX_FMTMSG_LEN,	\
> +		     (fmt), ##args) >= NETLINK_MAX_FMTMSG_LEN)		\
> +		net_warn_ratelimited("truncated extack: " fmt "\n",	\
> +				     ##args);				\
> +									\

Some "take it or leave it" comments:
 - Jiri's idea of always printing may be worth exploring
 - my preference would also be to produce a warning on overflow,
   rather than the exact print, because I always worry about people
   starting to depend on the print.

   And WARN_ON() is really heavy and may trigger remediations even
   tho truncated extack is just a minor nuisance.

   I'd do:

   pr(extack formatting overflow $__FILE__:$__func__:$__LINE__ $needed_len)
   
   (I think splicing the "trunced extack:" with fmt will result
    in the format string getting stored in .ro twice?)