diff mbox series

[net-next] rtnetlink: enable alt_ifname for setlink/newlink

Message ID 20220331123728.7267-1-florent.fourcot@wifirst.fr (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] rtnetlink: enable alt_ifname for setlink/newlink | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers fail 2 blamed authors not CCed: davem@davemloft.net jiri@mellanox.com; 6 maintainers not CCed: davem@davemloft.net petrm@nvidia.com pabeni@redhat.com idosch@nvidia.com kuba@kernel.org jiri@mellanox.com
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Florent Fourcot March 31, 2022, 12:37 p.m. UTC
buffer is always valid when called by setlink/newlink,
but contains only empty string when IFLA_IFNAME is not given. So
IFLA_ALT_IFNAME is always ignored

Fixes: 76c9ac0ee878 ("net: rtnetlink: add possibility to use alternative names as message handle")
Signed-off-by: Florent Fourcot <florent.fourcot@wifirst.fr>
Signed-off-by: Brian Baboch <brian.baboch@wifirst.fr>
---
 net/core/rtnetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski April 1, 2022, 3:54 a.m. UTC | #1
On Thu, 31 Mar 2022 14:37:28 +0200 Florent Fourcot wrote:
> buffer is always valid when called by setlink/newlink,
> but contains only empty string when IFLA_IFNAME is not given. So
> IFLA_ALT_IFNAME is always ignored
> 
> Fixes: 76c9ac0ee878 ("net: rtnetlink: add possibility to use alternative names as message handle")

Again, you most definitely need to CC the author of the code under
Fixes, they may have some context we don't.

Since this is a fix the subject tag should be [PATCH net].

> Signed-off-by: Florent Fourcot <florent.fourcot@wifirst.fr>
> Signed-off-by: Brian Baboch <brian.baboch@wifirst.fr>
> ---
>  net/core/rtnetlink.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 3313419bbcba..613065a53b34 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -2979,7 +2979,7 @@ static struct net_device *rtnl_dev_get(struct net *net,
>  {
>  	char buffer[ALTIFNAMSIZ];
>  
> -	if (!ifname) {
> +	if (!ifname || !ifname[0]) {

Unless I'm missing something this function is loading a footgun to 
save copying 16B twice. I'd remove the ifname argument, it's always
populated from ifname_attr by the callers AFAICT.
diff mbox series

Patch

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 3313419bbcba..613065a53b34 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2979,7 +2979,7 @@  static struct net_device *rtnl_dev_get(struct net *net,
 {
 	char buffer[ALTIFNAMSIZ];
 
-	if (!ifname) {
+	if (!ifname || !ifname[0]) {
 		ifname = buffer;
 		if (ifname_attr)
 			nla_strscpy(ifname, ifname_attr, IFNAMSIZ);