]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/macsec: IFLA_MACSEC_PORT attribute cannot be changed
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Oct 2024 15:22:17 +0000 (00:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 30 Oct 2024 16:06:25 +0000 (01:06 +0900)
Also, though currently not supported by networkd,
  IFLA_MACSEC_CIPHER_SUITE, IFLA_MACSEC_ICV_LEN, IFLA_MACSEC_SCI
cannot be updated.

src/network/netdev/macsec.c

index 15d79906f7737776dd1dbb7769a52628a246f735..6dd434f8037805fba052c5b9a4e820eae399309b 100644 (file)
@@ -509,12 +509,6 @@ static int netdev_macsec_fill_message_create(NetDev *netdev, Link *link, sd_netl
         MACsec *v = MACSEC(netdev);
         int r;
 
-        if (v->port > 0) {
-                r = sd_netlink_message_append_u16(m, IFLA_MACSEC_PORT, v->port);
-                if (r < 0)
-                        return r;
-        }
-
         if (v->encrypt >= 0) {
                 r = sd_netlink_message_append_u8(m, IFLA_MACSEC_ENCRYPT, v->encrypt);
                 if (r < 0)
@@ -525,6 +519,20 @@ static int netdev_macsec_fill_message_create(NetDev *netdev, Link *link, sd_netl
         if (r < 0)
                 return r;
 
+        /* The properties below cannot be updated, and the kernel refuses the whole request if one of the
+         * following attributes is set for an existing interface. */
+        if (netdev->ifindex > 0)
+                return 0;
+
+        if (v->port > 0) {
+                r = sd_netlink_message_append_u16(m, IFLA_MACSEC_PORT, v->port);
+                if (r < 0)
+                        return r;
+        }
+
+        /* Currently not supported by networkd, but IFLA_MACSEC_CIPHER_SUITE, IFLA_MACSEC_ICV_LEN, and
+         * IFLA_MACSEC_SCI can neither set for an existing interface. */
+
         return 0;
 }