[PATCH 3/5] lib/route: Extend Bridge Flags
Jef Oliver
jef.oliver at intel.com
Wed Aug 31 17:27:07 PDT 2016
This patch adds support for the following bridge port flags:
IFLA_BRPORT_UNICAST_FLOOD
IFLA_BRPORT_LEARNING
IFLA_BRPORT_LEARNING_SYNC
Signed-off-by: Jef Oliver <jef.oliver at intel.com>
---
include/netlink/route/link/bridge.h | 3 +++
lib/route/link/bridge.c | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/include/netlink/route/link/bridge.h b/include/netlink/route/link/bridge.h
index b5f9b81..b7b9ae9 100644
--- a/include/netlink/route/link/bridge.h
+++ b/include/netlink/route/link/bridge.h
@@ -38,6 +38,9 @@ enum rtnl_link_bridge_flags {
RTNL_BRIDGE_BPDU_GUARD = 0x0002,
RTNL_BRIDGE_ROOT_BLOCK = 0x0004,
RTNL_BRIDGE_FAST_LEAVE = 0x0008,
+ RTNL_BRIDGE_UNICAST_FLOOD = 0x0010,
+ RTNL_BRIDGE_LEARNING = 0x0020,
+ RTNL_BRIDGE_LEARNING_SYNC = 0x0040,
};
extern struct rtnl_link *rtnl_link_bridge_alloc(void);
diff --git a/lib/route/link/bridge.c b/lib/route/link/bridge.c
index 015d24f..a47b79b 100644
--- a/lib/route/link/bridge.c
+++ b/lib/route/link/bridge.c
@@ -111,6 +111,9 @@ static struct nla_policy br_attrs_policy[IFLA_BRPORT_MAX+1] = {
[IFLA_BRPORT_GUARD] = { .type = NLA_U8 },
[IFLA_BRPORT_PROTECT] = { .type = NLA_U8 },
[IFLA_BRPORT_FAST_LEAVE] = { .type = NLA_U8 },
+ [IFLA_BRPORT_LEARNING] = { .type = NLA_U8 },
+ [IFLA_BRPORT_LEARNING_SYNC] = { .type = NLA_U8 },
+ [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NLA_U8 },
};
static void check_flag(struct rtnl_link *link, struct nlattr *attrs[],
@@ -163,6 +166,11 @@ static int bridge_parse_protinfo(struct rtnl_link *link, struct nlattr *attr,
check_flag(link, br_attrs, IFLA_BRPORT_GUARD, RTNL_BRIDGE_BPDU_GUARD);
check_flag(link, br_attrs, IFLA_BRPORT_PROTECT, RTNL_BRIDGE_ROOT_BLOCK);
check_flag(link, br_attrs, IFLA_BRPORT_FAST_LEAVE, RTNL_BRIDGE_FAST_LEAVE);
+ check_flag(link, br_attrs, IFLA_BRPORT_UNICAST_FLOOD,
+ RTNL_BRIDGE_UNICAST_FLOOD);
+ check_flag(link, br_attrs, IFLA_BRPORT_LEARNING, RTNL_BRIDGE_LEARNING);
+ check_flag(link, br_attrs, IFLA_BRPORT_LEARNING_SYNC,
+ RTNL_BRIDGE_LEARNING_SYNC);
return 0;
}
@@ -246,6 +254,18 @@ static int bridge_fill_pi(struct rtnl_link *link, struct nl_msg *msg,
NLA_PUT_U8(msg, IFLA_BRPORT_PROTECT,
bd->b_flags & RTNL_BRIDGE_ROOT_BLOCK);
}
+ if (bd->b_flags_mask & RTNL_BRIDGE_UNICAST_FLOOD) {
+ NLA_PUT_U8(msg, IFLA_BRPORT_UNICAST_FLOOD,
+ bd->b_flags & RTNL_BRIDGE_UNICAST_FLOOD);
+ }
+ if (bd->b_flags_mask & RTNL_BRIDGE_LEARNING) {
+ NLA_PUT_U8(msg, IFLA_BRPORT_LEARNING,
+ bd->b_flags & RTNL_BRIDGE_LEARNING);
+ }
+ if (bd->b_flags_mask & RTNL_BRIDGE_LEARNING_SYNC) {
+ NLA_PUT_U8(msg, IFLA_BRPORT_LEARNING_SYNC,
+ bd->b_flags & RTNL_BRIDGE_LEARNING_SYNC);
+ }
}
if (bd->ce_mask & BRIDGE_ATTR_COST)
@@ -646,6 +666,9 @@ int rtnl_link_bridge_unset_flags(struct rtnl_link *link, unsigned int flags)
* - RTNL_BRIDGE_BPDU_GUARD
* - RTNL_BRIDGE_ROOT_BLOCK
* - RTNL_BRIDGE_FAST_LEAVE
+ * - RTNL_BRIDGE_UNICAST_FLOOD
+ * - RTNL_BRIDGE_LEARNING
+ * - RTNL_BRIDGE_LEARNING_SYNC
*
* @see rtnl_link_bridge_unset_flags()
* @see rtnl_link_bridge_get_flags()
@@ -690,6 +713,9 @@ static const struct trans_tbl bridge_flags[] = {
__ADD(RTNL_BRIDGE_BPDU_GUARD, bpdu_guard),
__ADD(RTNL_BRIDGE_ROOT_BLOCK, root_block),
__ADD(RTNL_BRIDGE_FAST_LEAVE, fast_leave),
+ __ADD(RTNL_BRIDGE_UNICAST_FLOOD, flood),
+ __ADD(RTNL_BRIDGE_LEARNING, learning),
+ __ADD(RTNL_BRIDGE_LEARNING_SYNC, learning_sync),
};
/**
--
2.9.3
More information about the libnl
mailing list