diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2014-04-29 17:38:30 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-04-30 09:08:15 (GMT) |
commit | 0ba7e663ce3f6bd624c0b8f4dc27a33cfcb0f5d1 (patch) | |
tree | 7fecb3bbe188d274d8b281f60fdb60880bc8db15 /lib/route/link/veth.c | |
parent | f55ef93d1eb9d792af2a3b79c055ee21bf14e9ea (diff) | |
download | libnl-0ba7e663ce3f6bd624c0b8f4dc27a33cfcb0f5d1.zip libnl-0ba7e663ce3f6bd624c0b8f4dc27a33cfcb0f5d1.tar.gz libnl-0ba7e663ce3f6bd624c0b8f4dc27a33cfcb0f5d1.tar.bz2 |
veth: grab a reference for rtnl_link_veth_get_peer()
So that users could keep a refcount for the peer.
The capability trick is from Thomas Haller.
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/route/link/veth.c')
-rw-r--r-- | lib/route/link/veth.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/route/link/veth.c b/lib/route/link/veth.c index 19c84f8..e7e4a26 100644 --- a/lib/route/link/veth.c +++ b/lib/route/link/veth.c @@ -167,7 +167,7 @@ static int veth_alloc(struct rtnl_link *link) static void veth_free(struct rtnl_link *link) { - struct rtnl_link *peer = rtnl_link_veth_get_peer(link); + struct rtnl_link *peer = link->l_info; if (peer) { link->l_info = NULL; /* avoid calling this recursively */ @@ -232,6 +232,7 @@ struct rtnl_link *rtnl_link_veth_alloc(void) struct rtnl_link *rtnl_link_veth_get_peer(struct rtnl_link *link) { IS_VETH_LINK_ASSERT(link); + nl_object_get(OBJ_CAST(link->l_info)); return link->l_info; } @@ -278,7 +279,7 @@ int rtnl_link_veth_add(struct nl_sock *sock, const char *name, if (!(link = rtnl_link_veth_alloc())) return -NLE_NOMEM; - peer = rtnl_link_veth_get_peer(link); + peer = link->l_info; if (name && peer_name) { rtnl_link_set_name(link, name); |