mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-25 15:00:31 +01:00
platform: Add change link functions to nm-platform
Since updating options of bridge is now done with netlink we need support function for that in nm-platform.
This commit is contained in:
parent
9b4bf36bf1
commit
e4ad8f8a9b
3 changed files with 67 additions and 0 deletions
|
|
@ -7538,6 +7538,21 @@ out:
|
|||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
link_change(NMPlatform *platform, NMLinkType type, int ifindex, gconstpointer extra_data)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
|
||||
nlmsg = _nl_msg_new_link(RTM_NEWLINK, 0, ifindex, 0);
|
||||
if (!nlmsg)
|
||||
return -NME_UNSPEC;
|
||||
|
||||
if (!_nl_msg_new_link_set_linkinfo(nlmsg, type, extra_data))
|
||||
return -NME_UNSPEC;
|
||||
|
||||
return do_change_link(platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
link_add(NMPlatform *platform,
|
||||
NMLinkType type,
|
||||
|
|
@ -9920,6 +9935,7 @@ nm_linux_platform_class_init(NMLinuxPlatformClass *klass)
|
|||
platform_class->sysctl_get = sysctl_get;
|
||||
|
||||
platform_class->link_add = link_add;
|
||||
platform_class->link_change = link_change;
|
||||
platform_class->link_delete = link_delete;
|
||||
|
||||
platform_class->link_refresh = link_refresh;
|
||||
|
|
|
|||
|
|
@ -1304,6 +1304,45 @@ nm_platform_link_add(NMPlatform *self,
|
|||
->link_add(self, type, name, parent, address, address_len, mtu, extra_data, out_link);
|
||||
}
|
||||
|
||||
int
|
||||
nm_platform_link_change(NMPlatform *self, NMLinkType type, int ifindex, gconstpointer extra_data)
|
||||
{
|
||||
char buf[512];
|
||||
const char *name = nm_platform_link_get_name(self, ifindex);
|
||||
|
||||
_CHECK_SELF(self, klass, -NME_BUG);
|
||||
|
||||
_LOG2D("link: changing link: "
|
||||
"%s " /* type */
|
||||
"\"%s\"" /* name */
|
||||
"%s" /* extra_data */
|
||||
"",
|
||||
nm_link_type_to_string(type),
|
||||
name,
|
||||
({
|
||||
char *buf_p = buf;
|
||||
gsize buf_len = sizeof(buf);
|
||||
|
||||
buf[0] = '\0';
|
||||
|
||||
switch (type) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_bridge_to_string((const NMPlatformLnkBridge *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
default:
|
||||
nm_assert(!extra_data);
|
||||
break;
|
||||
}
|
||||
|
||||
buf;
|
||||
}));
|
||||
|
||||
return klass->link_change(self, type, ifindex, extra_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_link_delete:
|
||||
* @self: platform instance
|
||||
|
|
|
|||
|
|
@ -1113,6 +1113,9 @@ typedef struct {
|
|||
guint32 mtu,
|
||||
gconstpointer extra_data,
|
||||
const NMPlatformLink **out_link);
|
||||
|
||||
int (*link_change)(NMPlatform *self, NMLinkType type, int ifindex, gconstpointer extra_data);
|
||||
|
||||
gboolean (*link_delete)(NMPlatform *self, int ifindex);
|
||||
gboolean (*link_refresh)(NMPlatform *self, int ifindex);
|
||||
gboolean (*link_set_netns)(NMPlatform *self, int ifindex, int netns_fd);
|
||||
|
|
@ -1586,6 +1589,9 @@ int nm_platform_link_add(NMPlatform *self,
|
|||
gconstpointer extra_data,
|
||||
const NMPlatformLink **out_link);
|
||||
|
||||
int
|
||||
nm_platform_link_change(NMPlatform *self, NMLinkType type, int ifindex, gconstpointer extra_data);
|
||||
|
||||
static inline int
|
||||
nm_platform_link_veth_add(NMPlatform *self,
|
||||
const char *name,
|
||||
|
|
@ -1621,6 +1627,12 @@ nm_platform_link_bridge_add(NMPlatform *self,
|
|||
out_link);
|
||||
}
|
||||
|
||||
static inline int
|
||||
nm_platform_link_bridge_change(NMPlatform *self, int ifindex, const NMPlatformLnkBridge *props)
|
||||
{
|
||||
return nm_platform_link_change(self, NM_LINK_TYPE_BRIDGE, ifindex, props);
|
||||
}
|
||||
|
||||
static inline int
|
||||
nm_platform_link_bond_add(NMPlatform *self, const char *name, const NMPlatformLink **out_link)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue