summary refs log tree commit diff
path: root/src/platform
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2020-12-06 21:57:59 +0100
committerMichael Biebl <biebl@debian.org>2020-12-06 21:57:59 +0100
commit65f86e8f56267192d42f2b629fc6b0c99fb9cd0c (patch)
tree180827692f002e5f1dad6a0fa8ca489e6bb6438f /src/platform
parentf2ddac4cbc895837ddcc55015fae112f9859cd0a (diff)
New upstream version 1.28.0 upstream/1.28.0
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/nm-fake-platform.c19
-rw-r--r--src/platform/nm-linux-platform.c4
-rw-r--r--src/platform/nm-platform.c8
-rw-r--r--src/platform/nm-platform.h48
-rw-r--r--src/platform/tests/test-common.c2
-rw-r--r--src/platform/tests/test-link.c3
6 files changed, 62 insertions, 22 deletions
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index 94c3f0e8..5bb0b426 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -225,7 +225,8 @@ link_add_pre(NMPlatform *platform,
              const char *name,
              NMLinkType  type,
              const void *address,
-             size_t      address_len)
+             size_t      address_len,
+             guint32     mtu)
 {
     NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE(platform);
     NMFakePlatformLink *   device;
@@ -251,6 +252,7 @@ link_add_pre(NMPlatform *platform,
     link->ifindex     = name ? ifindex : 0;
     link->type        = type;
     link->kind        = g_intern_string(nm_link_type_to_string(type));
+    link->mtu         = mtu;
     link->initialized = TRUE;
     if (name)
         strcpy(link->name, name);
@@ -285,6 +287,7 @@ link_add(NMPlatform *           platform,
          int                    parent,
          const void *           address,
          size_t                 address_len,
+         guint32                mtu,
          gconstpointer          extra_data,
          const NMPlatformLink **out_link)
 {
@@ -300,7 +303,7 @@ link_add(NMPlatform *           platform,
     NMPObject *                     dev_obj;
     NMPObject *                     dev_lnk = NULL;
 
-    device = link_add_pre(platform, name, type, address, address_len);
+    device = link_add_pre(platform, name, type, address, address_len, mtu);
 
     g_assert(device);
 
@@ -326,7 +329,7 @@ link_add(NMPlatform *           platform,
     case NM_LINK_TYPE_VETH:
         veth_peer = extra_data;
         g_assert(veth_peer);
-        device_veth = link_add_pre(platform, veth_peer, type, NULL, 0);
+        device_veth = link_add_pre(platform, veth_peer, type, NULL, 0, 0);
         break;
     case NM_LINK_TYPE_VLAN:
     {
@@ -401,7 +404,7 @@ link_add_one(NMPlatform *platform,
     NMPCacheOpsType                 cache_op;
     int                             ifindex;
 
-    device = link_add_pre(platform, name, NM_LINK_TYPE_VLAN, NULL, 0);
+    device = link_add_pre(platform, name, NM_LINK_TYPE_VLAN, NULL, 0, 0);
 
     ifindex = NMP_OBJECT_CAST_LINK(device->obj)->ifindex;
 
@@ -1313,10 +1316,10 @@ nm_fake_platform_setup(void)
 
     nm_platform_setup(platform);
 
-    link_add(platform, NM_LINK_TYPE_LOOPBACK, "lo", 0, NULL, 0, NULL, NULL);
-    link_add(platform, NM_LINK_TYPE_ETHERNET, "eth0", 0, NULL, 0, NULL, NULL);
-    link_add(platform, NM_LINK_TYPE_ETHERNET, "eth1", 0, NULL, 0, NULL, NULL);
-    link_add(platform, NM_LINK_TYPE_ETHERNET, "eth2", 0, NULL, 0, NULL, NULL);
+    link_add(platform, NM_LINK_TYPE_LOOPBACK, "lo", 0, NULL, 0, 0, NULL, NULL);
+    link_add(platform, NM_LINK_TYPE_ETHERNET, "eth0", 0, NULL, 0, 0, NULL, NULL);
+    link_add(platform, NM_LINK_TYPE_ETHERNET, "eth1", 0, NULL, 0, 0, NULL, NULL);
+    link_add(platform, NM_LINK_TYPE_ETHERNET, "eth2", 0, NULL, 0, 0, NULL, NULL);
 }
 
 static void
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 3fa70bbc..b377c85e 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -7341,6 +7341,7 @@ link_add(NMPlatform *           platform,
          int                    parent,
          const void *           address,
          size_t                 address_len,
+         guint32                mtu,
          gconstpointer          extra_data,
          const NMPlatformLink **out_link)
 {
@@ -7368,6 +7369,9 @@ link_add(NMPlatform *           platform,
     if (address && address_len)
         NLA_PUT(nlmsg, IFLA_ADDRESS, address_len, address);
 
+    if (mtu)
+        NLA_PUT_U32(nlmsg, IFLA_MTU, mtu);
+
     if (!_nl_msg_new_link_set_linkinfo(nlmsg, type, extra_data))
         return -NME_UNSPEC;
 
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index d1ff6fbc..7969206c 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -1230,11 +1230,13 @@ nm_platform_link_add(NMPlatform *           self,
                      int                    parent,
                      const void *           address,
                      size_t                 address_len,
+                     guint32                mtu,
                      gconstpointer          extra_data,
                      const NMPlatformLink **out_link)
 {
     int  r;
     char addr_buf[NM_UTILS_HWADDR_LEN_MAX * 3];
+    char mtu_buf[16];
     char parent_buf[64];
     char buf[512];
 
@@ -1254,6 +1256,7 @@ nm_platform_link_add(NMPlatform *           self,
            "\"%s\"" /* name */
            "%s%s"   /* parent */
            "%s%s"   /* address */
+           "%s%s"   /* mtu */
            "%s"     /* extra_data */
            "",
            nm_link_type_to_string(type),
@@ -1263,6 +1266,8 @@ nm_platform_link_add(NMPlatform *           self,
            address ? ", address: " : "",
            address ? _nm_utils_hwaddr_ntoa(address, address_len, FALSE, addr_buf, sizeof(addr_buf))
                    : "",
+           mtu ? ", mtu: " : "",
+           mtu ? nm_sprintf_buf(mtu_buf, "%u", mtu) : "",
            ({
                char *buf_p   = buf;
                gsize buf_len = sizeof(buf);
@@ -1345,7 +1350,8 @@ nm_platform_link_add(NMPlatform *           self,
                buf;
            }));
 
-    return klass->link_add(self, type, name, parent, address, address_len, extra_data, out_link);
+    return klass
+        ->link_add(self, type, name, parent, address, address_len, mtu, extra_data, out_link);
 }
 
 /**
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index c7b8017a..a1314000 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -1085,6 +1085,7 @@ typedef struct {
                     int                    parent,
                     const void *           address,
                     size_t                 address_len,
+                    guint32                mtu,
                     gconstpointer          extra_data,
                     const NMPlatformLink **out_link);
     gboolean (*link_delete)(NMPlatform *self, int ifindex);
@@ -1532,6 +1533,7 @@ int nm_platform_link_add(NMPlatform *           self,
                          int                    parent,
                          const void *           address,
                          size_t                 address_len,
+                         guint32                mtu,
                          gconstpointer          extra_data,
                          const NMPlatformLink **out_link);
 
@@ -1541,13 +1543,13 @@ nm_platform_link_veth_add(NMPlatform *           self,
                           const char *           peer,
                           const NMPlatformLink **out_link)
 {
-    return nm_platform_link_add(self, NM_LINK_TYPE_VETH, name, 0, NULL, 0, peer, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_VETH, name, 0, NULL, 0, 0, peer, out_link);
 }
 
 static inline int
 nm_platform_link_dummy_add(NMPlatform *self, const char *name, const NMPlatformLink **out_link)
 {
-    return nm_platform_link_add(self, NM_LINK_TYPE_DUMMY, name, 0, NULL, 0, NULL, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_DUMMY, name, 0, NULL, 0, 0, NULL, out_link);
 }
 
 static inline int
@@ -1555,6 +1557,7 @@ nm_platform_link_bridge_add(NMPlatform *               self,
                             const char *               name,
                             const void *               address,
                             size_t                     address_len,
+                            guint32                    mtu,
                             const NMPlatformLnkBridge *props,
                             const NMPlatformLink **    out_link)
 {
@@ -1564,6 +1567,7 @@ nm_platform_link_bridge_add(NMPlatform *               self,
                                 0,
                                 address,
                                 address_len,
+                                mtu,
                                 props,
                                 out_link);
 }
@@ -1571,19 +1575,19 @@ nm_platform_link_bridge_add(NMPlatform *               self,
 static inline int
 nm_platform_link_bond_add(NMPlatform *self, const char *name, const NMPlatformLink **out_link)
 {
-    return nm_platform_link_add(self, NM_LINK_TYPE_BOND, name, 0, NULL, 0, NULL, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_BOND, name, 0, NULL, 0, 0, NULL, out_link);
 }
 
 static inline int
 nm_platform_link_team_add(NMPlatform *self, const char *name, const NMPlatformLink **out_link)
 {
-    return nm_platform_link_add(self, NM_LINK_TYPE_TEAM, name, 0, NULL, 0, NULL, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_TEAM, name, 0, NULL, 0, 0, NULL, out_link);
 }
 
 static inline int
 nm_platform_link_wireguard_add(NMPlatform *self, const char *name, const NMPlatformLink **out_link)
 {
-    return nm_platform_link_add(self, NM_LINK_TYPE_WIREGUARD, name, 0, NULL, 0, NULL, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_WIREGUARD, name, 0, NULL, 0, 0, NULL, out_link);
 }
 
 static inline int
@@ -1602,6 +1606,7 @@ nm_platform_link_gre_add(NMPlatform *            self,
                                 0,
                                 address,
                                 address_len,
+                                0,
                                 props,
                                 out_link);
 }
@@ -1612,7 +1617,7 @@ nm_platform_link_sit_add(NMPlatform *            self,
                          const NMPlatformLnkSit *props,
                          const NMPlatformLink ** out_link)
 {
-    return nm_platform_link_add(self, NM_LINK_TYPE_SIT, name, 0, NULL, 0, props, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_SIT, name, 0, NULL, 0, 0, props, out_link);
 }
 
 static inline int
@@ -1632,6 +1637,7 @@ nm_platform_link_vlan_add(NMPlatform *           self,
                                 parent,
                                 NULL,
                                 0,
+                                0,
                                 &((NMPlatformLnkVlan){
                                     .id    = vlanid,
                                     .flags = vlanflags,
@@ -1645,7 +1651,7 @@ nm_platform_link_vrf_add(NMPlatform *            self,
                          const NMPlatformLnkVrf *props,
                          const NMPlatformLink ** out_link)
 {
-    return nm_platform_link_add(self, NM_LINK_TYPE_VRF, name, 0, NULL, 0, props, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_VRF, name, 0, NULL, 0, 0, props, out_link);
 }
 
 static inline int
@@ -1654,7 +1660,7 @@ nm_platform_link_vxlan_add(NMPlatform *              self,
                            const NMPlatformLnkVxlan *props,
                            const NMPlatformLink **   out_link)
 {
-    return nm_platform_link_add(self, NM_LINK_TYPE_VXLAN, name, 0, NULL, 0, props, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_VXLAN, name, 0, NULL, 0, 0, props, out_link);
 }
 
 static inline int
@@ -1663,7 +1669,15 @@ nm_platform_link_6lowpan_add(NMPlatform *           self,
                              int                    parent,
                              const NMPlatformLink **out_link)
 {
-    return nm_platform_link_add(self, NM_LINK_TYPE_6LOWPAN, name, parent, NULL, 0, NULL, out_link);
+    return nm_platform_link_add(self,
+                                NM_LINK_TYPE_6LOWPAN,
+                                name,
+                                parent,
+                                NULL,
+                                0,
+                                0,
+                                NULL,
+                                out_link);
 }
 
 static inline int
@@ -1675,7 +1689,7 @@ nm_platform_link_ip6tnl_add(NMPlatform *               self,
     g_return_val_if_fail(props, -NME_BUG);
     g_return_val_if_fail(!props->is_gre, -NME_BUG);
 
-    return nm_platform_link_add(self, NM_LINK_TYPE_IP6TNL, name, 0, NULL, 0, props, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_IP6TNL, name, 0, NULL, 0, 0, props, out_link);
 }
 
 static inline int
@@ -1695,6 +1709,7 @@ nm_platform_link_ip6gre_add(NMPlatform *               self,
                                 0,
                                 address,
                                 address_len,
+                                0,
                                 props,
                                 out_link);
 }
@@ -1707,7 +1722,7 @@ nm_platform_link_ipip_add(NMPlatform *             self,
 {
     g_return_val_if_fail(props, -NME_BUG);
 
-    return nm_platform_link_add(self, NM_LINK_TYPE_IPIP, name, 0, NULL, 0, props, out_link);
+    return nm_platform_link_add(self, NM_LINK_TYPE_IPIP, name, 0, NULL, 0, 0, props, out_link);
 }
 
 static inline int
@@ -1720,7 +1735,15 @@ nm_platform_link_macsec_add(NMPlatform *               self,
     g_return_val_if_fail(props, -NME_BUG);
     g_return_val_if_fail(parent > 0, -NME_BUG);
 
-    return nm_platform_link_add(self, NM_LINK_TYPE_MACSEC, name, parent, NULL, 0, props, out_link);
+    return nm_platform_link_add(self,
+                                NM_LINK_TYPE_MACSEC,
+                                name,
+                                parent,
+                                NULL,
+                                0,
+                                0,
+                                props,
+                                out_link);
 }
 
 static inline int
@@ -1739,6 +1762,7 @@ nm_platform_link_macvlan_add(NMPlatform *                self,
                                 parent,
                                 NULL,
                                 0,
+                                0,
                                 props,
                                 out_link);
 }
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c
index e305357a..fb430046 100644
--- a/src/platform/tests/test-common.c
+++ b/src/platform/tests/test-common.c
@@ -1534,7 +1534,7 @@ nmtstp_link_bridge_add(NMPlatform *               platform,
     }
 
     if (!pllink) {
-        r = nm_platform_link_bridge_add(platform, name, NULL, 0, lnk, &pllink);
+        r = nm_platform_link_bridge_add(platform, name, NULL, 0, 0, lnk, &pllink);
     }
 
     _assert_pllink(platform, r == 0, pllink, name, NM_LINK_TYPE_BRIDGE);
diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c
index 829abcc9..5fd67ec4 100644
--- a/src/platform/tests/test-link.c
+++ b/src/platform/tests/test-link.c
@@ -101,6 +101,7 @@ software_add(NMLinkType link_type, const char *name)
                                                                 name,
                                                                 NULL,
                                                                 0,
+                                                                0,
                                                                 &nm_platform_lnk_bridge_default,
                                                                 NULL));
     case NM_LINK_TYPE_BOND:
@@ -131,6 +132,7 @@ software_add(NMLinkType link_type, const char *name)
                                                              PARENT_NAME,
                                                              NULL,
                                                              0,
+                                                             0,
                                                              &nm_platform_lnk_bridge_default,
                                                              NULL)))
             accept_signal(parent_added);
@@ -581,6 +583,7 @@ test_bridge_addr(void)
                                                               DEVICE_NAME,
                                                               addr,
                                                               sizeof(addr),
+                                                              0,
                                                               &nm_platform_lnk_bridge_default,
                                                               &plink)));
     g_assert(plink);