summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2017-09-25 17:51:44 +0300
committerDmitry Kozlov <xeb@mail.ru>2017-09-25 17:51:44 +0300
commit2d6a28574b93875d8ca5577f447d886cc60c0b1a (patch)
treec9e0b9aeeaa6893672d46948e982215e13a7ce01
parentb363f179b4cb6de2d3562a992bdb21adeac07639 (diff)
downloadaccel-ppp-2d6a28574b93875d8ca5577f447d886cc60c0b1a.tar.gz
accel-ppp-2d6a28574b93875d8ca5577f447d886cc60c0b1a.zip
libnetlink: added function iplink_set_mtu
-rw-r--r--accel-pppd/libnetlink/iputils.c30
-rw-r--r--accel-pppd/libnetlink/iputils.h1
2 files changed, 31 insertions, 0 deletions
diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c
index 1052b609..601b8954 100644
--- a/accel-pppd/libnetlink/iputils.c
+++ b/accel-pppd/libnetlink/iputils.c
@@ -153,6 +153,36 @@ out:
return r;
}
+int __export iplink_set_mtu(int ifindex, int mtu)
+{
+ struct iplink_req {
+ struct nlmsghdr n;
+ struct ifinfomsg i;
+ char buf[1024];
+ } req;
+ struct rtnl_handle *rth = net->rtnl_get();
+ int r;
+
+ 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);
+
+ r = rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0);
+
+ net->rtnl_put(rth);
+
+ return r;
+}
+
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 301cfed1..9bdc93da 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);