diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index 94c3f0e833..5bb0b426fe 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 3fa70bbc30..b377c85e7a 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 d1ff6fbc42..7969206cba 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 c7b8017a40..a7396a7107 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 @@ -1564,6 +1566,7 @@ nm_platform_link_bridge_add(NMPlatform * self, 0, address, address_len, + 0, props, out_link); } @@ -1571,19 +1574,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 +1605,7 @@ nm_platform_link_gre_add(NMPlatform * self, 0, address, address_len, + 0, props, out_link); } @@ -1612,7 +1616,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 +1636,7 @@ nm_platform_link_vlan_add(NMPlatform * self, parent, NULL, 0, + 0, &((NMPlatformLnkVlan){ .id = vlanid, .flags = vlanflags, @@ -1645,7 +1650,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 +1659,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 +1668,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 +1688,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 +1708,7 @@ nm_platform_link_ip6gre_add(NMPlatform * self, 0, address, address_len, + 0, props, out_link); } @@ -1707,7 +1721,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 +1734,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 +1761,7 @@ nm_platform_link_macvlan_add(NMPlatform * self, parent, NULL, 0, + 0, props, out_link); }