From 874fc85dab83a309cabb5434e233301b4d4628d1 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Mon, 25 Sep 2017 17:51:44 +0300 Subject: libnetlink: added function iplink_set_mtu --- accel-pppd/libnetlink/iputils.c | 27 +++++++++++++++++++++++++++ accel-pppd/libnetlink/iputils.h | 1 + 2 files changed, 28 insertions(+) diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c index 59483003..9bdb03f3 100644 --- a/accel-pppd/libnetlink/iputils.c +++ b/accel-pppd/libnetlink/iputils.c @@ -189,6 +189,33 @@ int __export iplink_get_stats(int ifindex, struct rtnl_link_stats *stats) return 0; } +int __export iplink_set_mtu(int ifindex, int mtu) +{ + struct iplink_req { + struct nlmsghdr n; + struct ifinfomsg i; + char buf[1024]; + } req; + + if (!rth) + open_rth(); + + if (!rth) + return -1; + + memset(&req, 0, sizeof(req) - 1024); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); + req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; + req.n.nlmsg_type = RTM_SETLINK; + req.i.ifi_family = AF_UNSPEC; + req.i.ifi_index = ifindex; + + addattr_l(&req.n, 1024, IFLA_MTU, &mtu, 4); + + return rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0); +} + int __export iplink_vlan_add(const char *ifname, int ifindex, int vid) { struct iplink_req { diff --git a/accel-pppd/libnetlink/iputils.h b/accel-pppd/libnetlink/iputils.h index cd3eb17f..1ca3de8d 100644 --- a/accel-pppd/libnetlink/iputils.h +++ b/accel-pppd/libnetlink/iputils.h @@ -7,6 +7,7 @@ typedef int (*iplink_list_func)(int index, int flags, const char *name, int ifli int iplink_list(iplink_list_func func, void *arg); int iplink_get_stats(int ifindex, struct rtnl_link_stats *stats); +int iplink_set_mtu(int ifindex, int mtu); int iplink_vlan_add(const char *ifname, int ifindex, int vid); int iplink_vlan_del(int ifindex); -- cgit v1.2.3