diff mbox series

[6/6] rtnl: Add l_rtnl_link_set_mtu

Message ID 20240823161553.479576-6-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/6] netlink: Add l_netlink_iter | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success

Commit Message

Denis Kenzior Aug. 23, 2024, 4:15 p.m. UTC
This helper is used to set a given MTU on a network interface (link).
---
 ell/ell.sym |  1 +
 ell/rtnl.c  | 18 ++++++++++++++++++
 ell/rtnl.h  |  4 ++++
 3 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/ell/ell.sym b/ell/ell.sym
index cbeb61ff0f46..00123136a527 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -701,6 +701,7 @@  global:
 	l_rtnl_set_linkmode_and_operstate;
 	l_rtnl_set_mac;
 	l_rtnl_set_powered;
+	l_rtnl_link_set_mtu;
 	l_rtnl_ifaddr4_extract;
 	l_rtnl_ifaddr4_dump;
 	l_rtnl_ifaddr4_add;
diff --git a/ell/rtnl.c b/ell/rtnl.c
index da5d219feb48..fbad795949be 100644
--- a/ell/rtnl.c
+++ b/ell/rtnl.c
@@ -787,6 +787,24 @@  LIB_EXPORT uint32_t l_rtnl_set_powered(struct l_netlink *rtnl, int ifindex,
 	return l_netlink_send(rtnl, nlm, cb, user_data, destroy);
 }
 
+LIB_EXPORT uint32_t l_rtnl_link_set_mtu(struct l_netlink *rtnl, int ifindex,
+				uint32_t mtu,
+				l_netlink_command_func_t cb, void *user_data,
+				l_netlink_destroy_func_t destroy)
+{
+	struct l_netlink_message *nlm = l_netlink_message_new(RTM_SETLINK, 0);
+	struct ifinfomsg ifi;
+
+	memset(&ifi, 0, sizeof(ifi));
+	ifi.ifi_family = AF_UNSPEC;
+	ifi.ifi_index = ifindex;
+
+	l_netlink_message_add_header(nlm, &ifi, sizeof(ifi));
+	l_netlink_message_append_u32(nlm, IFLA_MTU, mtu);
+
+	return l_netlink_send(rtnl, nlm, cb, user_data, destroy);
+}
+
 LIB_EXPORT void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes,
 				char **label, char **ip, char **broadcast)
 {
diff --git a/ell/rtnl.h b/ell/rtnl.h
index fa5d99eb4b53..d44cda24d6fd 100644
--- a/ell/rtnl.h
+++ b/ell/rtnl.h
@@ -103,6 +103,10 @@  uint32_t l_rtnl_set_powered(struct l_netlink *rtnl, int ifindex, bool powered,
 				l_netlink_command_func_t cb, void *user_data,
 				l_netlink_destroy_func_t destroy);
 
+uint32_t l_rtnl_link_set_mtu(struct l_netlink *rtnl, int ifindex, uint32_t mtu,
+				l_netlink_command_func_t cb, void *user_data,
+				l_netlink_destroy_func_t destroy);
+
 void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes,
 				char **label, char **ip, char **broadcast);
 uint32_t l_rtnl_ifaddr4_dump(struct l_netlink *rtnl, l_netlink_command_func_t cb,