]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: hsr: reject unresolved interlink ifindex
authorLuka Gejak <luka.gejak@linux.dev>
Wed, 13 May 2026 18:26:57 +0000 (20:26 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 16 May 2026 00:31:00 +0000 (17:31 -0700)
In hsr_newlink(), a provided but invalid IFLA_HSR_INTERLINK attribute
was silently ignored if __dev_get_by_index() returned NULL. This leads
to incorrect RedBox topology creation without notifying the user.

Fix this by returning -EINVAL and an extack message when the
interlink attribute is present but cannot be resolved.

Reviewed-by: Felix Maurer <fmaurer@redhat.com>
Signed-off-by: Luka Gejak <luka.gejak@linux.dev>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Link: https://patch.msgid.link/20260513182657.20346-3-luka.gejak@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/hsr/hsr_netlink.c

index db0b0af7a69202a0a52fbfc335de5a9f37970146..f0ca23da3ab99cea7563aaa1fddf1c64ba706641 100644 (file)
@@ -76,9 +76,14 @@ static int hsr_newlink(struct net_device *dev,
                return -EINVAL;
        }
 
-       if (data[IFLA_HSR_INTERLINK])
+       if (data[IFLA_HSR_INTERLINK]) {
                interlink = __dev_get_by_index(link_net,
                                               nla_get_u32(data[IFLA_HSR_INTERLINK]));
+               if (!interlink) {
+                       NL_SET_ERR_MSG_MOD(extack, "Interlink does not exist");
+                       return -EINVAL;
+               }
+       }
 
        if (interlink && interlink == link[0]) {
                NL_SET_ERR_MSG_MOD(extack, "Interlink and Slave1 are the same");