]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/hsr: add protocol version to fill_info output
authorJan Vaclav <jvaclav@redhat.com>
Thu, 9 Oct 2025 21:09:08 +0000 (23:09 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 14 Oct 2025 13:09:01 +0000 (15:09 +0200)
Currently, it is possible to configure IFLA_HSR_VERSION, but
there is no way to check in userspace what the currently
configured HSR protocol version is.

Add it to the output of hsr_fill_info(), when the interface
is using the HSR protocol. Let's not expose it when using
the PRP protocol, since it only has one version and it's
not possible to set it from userspace.

This info could then be used by e.g. ip(8), like so:
$ ip -d link show hsr0
12: hsr0: <BROADCAST,MULTICAST> mtu ...
    ...
    hsr slave1 veth0 slave2 veth1 ... proto 0 version 1
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Signed-off-by: Jan Vaclav <jvaclav@redhat.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20251009210903.1055187-6-jvaclav@redhat.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/hsr/hsr_netlink.c

index b120470246cc5660cd43bf85f18edfa5ac7ca349..4461adf696234b0410449d11e65f0b34d398221b 100644 (file)
@@ -166,6 +166,8 @@ static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
                goto nla_put_failure;
        if (hsr->prot_version == PRP_V1)
                proto = HSR_PROTOCOL_PRP;
+       else if (nla_put_u8(skb, IFLA_HSR_VERSION, hsr->prot_version))
+               goto nla_put_failure;
        if (nla_put_u8(skb, IFLA_HSR_PROTOCOL, proto))
                goto nla_put_failure;