diff options
author | HongweiBi <hwbi2008@gmail.com> | 2014-01-02 03:29:42 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-01-14 13:37:58 (GMT) |
commit | 8dabf9fb1a891400511f3c8cd2713bcb5380fb87 (patch) | |
tree | 0a5b5e9ff8abcb6811352d3de66f19aea4c26bd1 /lib/route/link/bridge.c | |
parent | dcc0baac020e033c4325e4d89c92aaab03f01b01 (diff) | |
download | libnl-8dabf9fb1a891400511f3c8cd2713bcb5380fb87.zip libnl-8dabf9fb1a891400511f3c8cd2713bcb5380fb87.tar.gz libnl-8dabf9fb1a891400511f3c8cd2713bcb5380fb87.tar.bz2 |
bridge: add rtnl_link_add_bridge() function
Signed-off-by: HongweiBi <hwbi2008@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/route/link/bridge.c')
-rw-r--r-- | lib/route/link/bridge.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/route/link/bridge.c b/lib/route/link/bridge.c index fcf3272..640b78b 100644 --- a/lib/route/link/bridge.c +++ b/lib/route/link/bridge.c @@ -203,6 +203,34 @@ struct rtnl_link *rtnl_link_bridge_alloc(void) return link; } + +/** + * Create a new kernel bridge device + * @arg sock netlink socket + * @arg name name of the bridge device or NULL + * + * Creates a new bridge device in the kernel. If no name is + * provided, the kernel will automatically pick a name of the + * form "type%d" (e.g. bridge0, vlan1, etc.) + * + * @return 0 on success or a negative error code +*/ +int rtnl_link_bridge_add(struct nl_sock *sk, const char *name) +{ + int err; + struct rtnl_link *link; + + if (!(link = rtnl_link_bridge_alloc())) + return -NLE_NOMEM; + + if(name) + rtnl_link_set_name(link, name); + + err = rtnl_link_add(sk, link, NLM_F_CREATE); + rtnl_link_put(link); + + return err; +} /** * Check if a link is a bridge |