summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2013-11-01 16:58:46 -0700
committerThomas Graf <tgraf@suug.ch>2013-11-06 09:55:01 +0100
commit1f3511c1d1974f6d028fc29d80ce8ba1cc054cad (patch)
treeca1a7673f12a4dd5356927f0d25457cd1a307b68 /lib
parent43e9438d9aa2361a1a216a5728c231c053e0b288 (diff)
downloadlibnl-1f3511c1d1974f6d028fc29d80ce8ba1cc054cad.tar.gz
factor out rtnl_link_fill_info()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/route/link.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/lib/route/link.c b/lib/route/link.c
index a0168995..37938aa9 100644
--- a/lib/route/link.c
+++ b/lib/route/link.c
@@ -1213,19 +1213,8 @@ int rtnl_link_name2i(struct nl_cache *cache, const char *name)
/** @} */
-static int build_link_msg(int cmd, struct ifinfomsg *hdr,
- struct rtnl_link *link, int flags, struct nl_msg **result)
+int rtnl_link_fill_info(struct nl_msg *msg, struct rtnl_link *link)
{
- struct nl_msg *msg;
- struct nlattr *af_spec;
-
- msg = nlmsg_alloc_simple(cmd, flags);
- if (!msg)
- return -NLE_NOMEM;
-
- if (nlmsg_append(msg, hdr, sizeof(*hdr), NLMSG_ALIGNTO) < 0)
- goto nla_put_failure;
-
if (link->ce_mask & LINK_ATTR_ADDR)
NLA_PUT_ADDR(msg, IFLA_ADDRESS, link->l_addr);
@@ -1271,6 +1260,28 @@ static int build_link_msg(int cmd, struct ifinfomsg *hdr,
if (link->ce_mask & LINK_ATTR_GROUP)
NLA_PUT_U32(msg, IFLA_GROUP, link->l_group);
+ return 0;
+
+nla_put_failure:
+ return -NLE_MSGSIZE;
+}
+
+static int build_link_msg(int cmd, struct ifinfomsg *hdr,
+ struct rtnl_link *link, int flags, struct nl_msg **result)
+{
+ struct nl_msg *msg;
+ struct nlattr *af_spec;
+
+ msg = nlmsg_alloc_simple(cmd, flags);
+ if (!msg)
+ return -NLE_NOMEM;
+
+ if (nlmsg_append(msg, hdr, sizeof(*hdr), NLMSG_ALIGNTO) < 0)
+ goto nla_put_failure;
+
+ if (rtnl_link_fill_info(msg, link))
+ goto nla_put_failure;
+
if (link->ce_mask & LINK_ATTR_LINKINFO) {
struct nlattr *info;