From 3fee68f56b87130bb5b0a3abae4b3b24c1a3aa9d Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Fri, 10 Aug 2012 17:32:56 +0400 Subject: [PATCH] net: Put IFLA_LINKINFO attr on newlink if required Veth will fill the linkinfo part for peer. Signed-off-by: Pavel Emelyanov --- net.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/net.c b/net.c index 41f2cacef..85d8d8db1 100644 --- a/net.c +++ b/net.c @@ -146,7 +146,8 @@ struct newlink_req { char buf[1024]; }; -static int restore_one_link(NetDeviceEntry *nde, int nlsk) +static int restore_one_link(NetDeviceEntry *nde, int nlsk, + int (*link_info)(NetDeviceEntry *, struct newlink_req *)) { struct newlink_req req; @@ -163,6 +164,20 @@ static int restore_one_link(NetDeviceEntry *nde, int nlsk) addattr_l(&req.h, sizeof(req), IFLA_IFNAME, nde->name, strlen(nde->name)); addattr_l(&req.h, sizeof(req), IFLA_MTU, &nde->mtu, sizeof(nde->mtu)); + if (link_info) { + struct rtattr *linkinfo; + int ret; + + linkinfo = NLMSG_TAIL(&req.h); + addattr_l(&req.h, sizeof(req), IFLA_LINKINFO, NULL, 0); + + ret = link_info(nde, &req); + if (ret < 0) + return ret; + + linkinfo->rta_len = (void *)NLMSG_TAIL(&req.h) - (void *)linkinfo; + } + pr_info("Restoring netdev idx %d\n", nde->ifindex); return do_rtnl_req(nlsk, &req, req.h.nlmsg_len, restore_link_cb, NULL); } @@ -173,7 +188,7 @@ static int restore_link(NetDeviceEntry *nde, int nlsk) switch (nde->type) { case ND_TYPE__LOOPBACK: - return restore_one_link(nde, nlsk); + return restore_one_link(nde, nlsk, NULL); case ND_TYPE__VETH: break; }