]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
geneve: Reuse ipv6_addr_type() result in geneve_nl2info().
authorKuniyuki Iwashima <kuniyu@google.com>
Tue, 2 Jun 2026 19:03:41 +0000 (19:03 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 4 Jun 2026 01:07:41 +0000 (18:07 -0700)
geneve_nl2info() calls ipv6_addr_type() to check if the remote
IPv6 address is link-local.

Then, it also calls ipv6_addr_is_multicast() for the same address.

Let's not call ipv6_addr_is_multicast() and reuse ipv6_addr_type().

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260602190436.139591-2-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/geneve.c

index e8ff03ed87dc5d10a7668aded3eb6ae5d993d645..8413c21fee6fcca964e5121559e009acbca25173 100644 (file)
@@ -1924,6 +1924,8 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[],
 
        if (data[IFLA_GENEVE_REMOTE6]) {
 #if IS_ENABLED(CONFIG_IPV6)
+               int addr_type;
+
                if (changelink && (ip_tunnel_info_af(info) == AF_INET)) {
                        attrtype = IFLA_GENEVE_REMOTE6;
                        goto change_notsup;
@@ -1933,13 +1935,13 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[],
                info->key.u.ipv6.dst =
                        nla_get_in6_addr(data[IFLA_GENEVE_REMOTE6]);
 
-               if (ipv6_addr_type(&info->key.u.ipv6.dst) &
-                   IPV6_ADDR_LINKLOCAL) {
+               addr_type = ipv6_addr_type(&info->key.u.ipv6.dst);
+               if (addr_type & IPV6_ADDR_LINKLOCAL) {
                        NL_SET_ERR_MSG_ATTR(extack, data[IFLA_GENEVE_REMOTE6],
                                            "Remote IPv6 address cannot be link-local");
                        return -EINVAL;
                }
-               if (ipv6_addr_is_multicast(&info->key.u.ipv6.dst)) {
+               if (addr_type & IPV6_ADDR_MULTICAST) {
                        NL_SET_ERR_MSG_ATTR(extack, data[IFLA_GENEVE_REMOTE6],
                                            "Remote IPv6 address cannot be Multicast");
                        return -EINVAL;