From 5a5aa73158027ae74eef3433388350c214b908f1 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Thu, 14 Feb 2013 12:34:57 +0100 Subject: [PATCH] bridge: Provide rtnl_link_bridge_alloc() Signed-off-by: Thomas Graf --- include/netlink/route/link/bridge.h | 2 ++ lib/route/link/bridge.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/netlink/route/link/bridge.h b/include/netlink/route/link/bridge.h index 5522fc0..71dcc24 100644 --- a/include/netlink/route/link/bridge.h +++ b/include/netlink/route/link/bridge.h @@ -30,6 +30,8 @@ enum rtnl_link_bridge_flags { RTNL_BRIDGE_FAST_LEAVE = 0x0008, }; +extern struct rtnl_link *rtnl_link_bridge_alloc(void); + extern int rtnl_link_is_bridge(struct rtnl_link *); extern int rtnl_link_bridge_has_ext_info(struct rtnl_link *); diff --git a/lib/route/link/bridge.c b/lib/route/link/bridge.c index a306c9c..eb02b22 100644 --- a/lib/route/link/bridge.c +++ b/lib/route/link/bridge.c @@ -183,6 +183,27 @@ static int bridge_compare(struct rtnl_link *_a, struct rtnl_link *_b, } /** @endcond */ +/** + * Allocate link object of type bridge + * + * @return Allocated link object or NULL. + */ +struct rtnl_link *rtnl_link_bridge_alloc(void) +{ + struct rtnl_link *link; + int err; + + if (!(link = rtnl_link_alloc())) + return NULL; + + if ((err = rtnl_link_set_type(link, "bridge")) < 0) { + rtnl_link_put(link); + return NULL; + } + + return link; +} + /** * Check if a link is a bridge * @arg link Link object -- 2.40.0