14#include "nl-default.h"
16#include <linux/if_bridge.h>
18#include <netlink/netlink.h>
19#include <netlink/attr.h>
20#include <netlink/route/rtnl.h>
21#include <netlink/route/link/bridge.h>
25#include "nl-priv-dynamic-core/nl-core.h"
26#include "nl-priv-static-route/nl-priv-static-route.h"
28#define VLAN_VID_MASK 0x0fff
31#define BRIDGE_ATTR_PORT_STATE (1 << 0)
32#define BRIDGE_ATTR_PRIORITY (1 << 1)
33#define BRIDGE_ATTR_COST (1 << 2)
34#define BRIDGE_ATTR_FLAGS (1 << 3)
35#define BRIDGE_ATTR_PORT_VLAN (1 << 4)
36#define BRIDGE_ATTR_HWMODE (1 << 5)
37#define BRIDGE_ATTR_CONFIG_MODE (1 << 6)
39#define PRIV_FLAG_NEW_ATTRS (1 << 0)
47 uint16_t b_config_mode;
50 uint32_t b_flags_mask;
55static void set_bit(
unsigned nr, uint32_t *addr)
57 if (nr < RTNL_LINK_BRIDGE_VLAN_BITMAP_MAX)
58 addr[nr / 32] |= (((uint32_t) 1) << (nr % 32));
61static void unset_bit(
unsigned nr, uint32_t *addr)
63 if (nr < RTNL_LINK_BRIDGE_VLAN_BITMAP_MAX)
64 addr[nr / 32] &= ~(((uint32_t) 1) << (nr % 32));
71 _nl_assert(vid / 32u < ARRAY_SIZE(vlan_info->untagged_bitmap));
73 mask = vlan_info->untagged_bitmap[vid / 32];
74 bit = (((uint32_t) 1) << vid % 32);
79static int find_next_bit(
int i, uint32_t x)
88 return __builtin_ffs(x);
91 j = __builtin_ffs(x >> i);
97#define IS_BRIDGE_LINK_ASSERT(link) \
98 if (!rtnl_link_is_bridge(link)) { \
99 APPBUG("A function was expecting a link object of type bridge."); \
100 return -NLE_OPNOTSUPP; \
103static inline struct bridge_data *bridge_data(
struct rtnl_link *link)
108static void *bridge_alloc(
struct rtnl_link *link)
110 return calloc(1,
sizeof(
struct bridge_data));
113static void *bridge_clone(
struct rtnl_link *link,
void *data)
115 struct bridge_data *bd;
117 if ((bd = bridge_alloc(link)))
118 memcpy(bd, data,
sizeof(*bd));
123static void bridge_free(
struct rtnl_link *link,
void *data)
151 struct bridge_data *bd = data;
152 struct nlattr *br_attrs[IFLA_BRPORT_MAX+1];
161 bd->ce_mask |= BRIDGE_ATTR_PORT_STATE;
167 br_attrs_policy)) < 0)
170 bd->b_priv_flags |= PRIV_FLAG_NEW_ATTRS;
172 if (br_attrs[IFLA_BRPORT_STATE]) {
173 bd->b_port_state =
nla_get_u8(br_attrs[IFLA_BRPORT_STATE]);
174 bd->ce_mask |= BRIDGE_ATTR_PORT_STATE;
177 if (br_attrs[IFLA_BRPORT_PRIORITY]) {
178 bd->b_priority =
nla_get_u16(br_attrs[IFLA_BRPORT_PRIORITY]);
179 bd->ce_mask |= BRIDGE_ATTR_PRIORITY;
182 if (br_attrs[IFLA_BRPORT_COST]) {
183 bd->b_cost =
nla_get_u32(br_attrs[IFLA_BRPORT_COST]);
184 bd->ce_mask |= BRIDGE_ATTR_COST;
187 check_flag(link, br_attrs, IFLA_BRPORT_MODE, RTNL_BRIDGE_HAIRPIN_MODE);
188 check_flag(link, br_attrs, IFLA_BRPORT_GUARD, RTNL_BRIDGE_BPDU_GUARD);
189 check_flag(link, br_attrs, IFLA_BRPORT_PROTECT, RTNL_BRIDGE_ROOT_BLOCK);
190 check_flag(link, br_attrs, IFLA_BRPORT_FAST_LEAVE, RTNL_BRIDGE_FAST_LEAVE);
191 check_flag(link, br_attrs, IFLA_BRPORT_UNICAST_FLOOD,
192 RTNL_BRIDGE_UNICAST_FLOOD);
193 check_flag(link, br_attrs, IFLA_BRPORT_LEARNING, RTNL_BRIDGE_LEARNING);
194 check_flag(link, br_attrs, IFLA_BRPORT_LEARNING_SYNC,
195 RTNL_BRIDGE_LEARNING_SYNC);
200static int bridge_parse_af_full(
struct rtnl_link *link,
struct nlattr *attr_full,
203 struct bridge_data *bd = data;
204 struct bridge_vlan_info *vinfo = NULL;
205 uint16_t vid_range_start = 0;
206 uint16_t vid_range_flags = -1;
213 if (
nla_type(attr) == IFLA_BRIDGE_MODE) {
215 bd->ce_mask |= BRIDGE_ATTR_HWMODE;
217 }
else if (
nla_type(attr) != IFLA_BRIDGE_VLAN_INFO)
220 if (
nla_len(attr) !=
sizeof(
struct bridge_vlan_info))
224 if (!vinfo->vid || vinfo->vid >= VLAN_VID_MASK)
228 if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) {
229 vid_range_start = vinfo->vid;
230 vid_range_flags = (vinfo->flags ^ BRIDGE_VLAN_INFO_RANGE_BEGIN);
234 if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END) {
236 if (vid_range_flags != (vinfo->flags ^ BRIDGE_VLAN_INFO_RANGE_END)) {
237 NL_DBG(1,
"VLAN range flags differ; can not handle it.\n");
241 vid_range_start = vinfo->vid;
244 for (; vid_range_start <= vinfo->vid; vid_range_start++) {
245 if (vinfo->flags & BRIDGE_VLAN_INFO_PVID)
246 bd->vlan_info.pvid = vinfo->vid;
248 if (vinfo->flags & BRIDGE_VLAN_INFO_UNTAGGED)
249 set_bit(vid_range_start, bd->vlan_info.untagged_bitmap);
251 set_bit(vid_range_start, bd->vlan_info.vlan_bitmap);
252 bd->ce_mask |= BRIDGE_ATTR_PORT_VLAN;
255 vid_range_flags = -1;
263 struct bridge_vlan_info vinfo;
265 int start = -1, prev = -1;
267 bool untagged =
false;
269 for (k = 0; k < RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN; k++)
272 uint32_t a = vlan_info->vlan_bitmap[k];
279 j = find_next_bit(i, a);
283 if (vlan_info->pvid != 0 && j - 1 + base_bit == vlan_info->pvid)
286 if (start < 0 && prev < 0)
288 start = prev = j - 1 + base_bit;
290 untagged = vlan_id_untagged(vlan_info,start);
291 vinfo.flags = BRIDGE_VLAN_INFO_RANGE_BEGIN;
292 vinfo.flags |= untagged ? BRIDGE_VLAN_INFO_UNTAGGED : 0;
297 if (j - 2 + base_bit == prev)
301 if (untagged != vlan_id_untagged(vlan_info,prev))
307 vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN;
308 NLA_PUT(msg,IFLA_BRIDGE_VLAN_INFO,
sizeof(vinfo),&vinfo);
313 NLA_PUT(msg,IFLA_BRIDGE_VLAN_INFO,
sizeof(vinfo),&vinfo);
315 vinfo.flags = BRIDGE_VLAN_INFO_RANGE_END;
316 vinfo.flags |= untagged ? BRIDGE_VLAN_INFO_UNTAGGED : 0;
318 NLA_PUT(msg,IFLA_BRIDGE_VLAN_INFO,
sizeof(vinfo),&vinfo);
321 untagged = !untagged;
322 vinfo.flags = BRIDGE_VLAN_INFO_RANGE_BEGIN;
323 vinfo.flags |= untagged ? BRIDGE_VLAN_INFO_UNTAGGED : 0;
334 if (done && k < RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN - 1)
337 if (vinfo.flags & BRIDGE_VLAN_INFO_RANGE_BEGIN && start != prev)
339 NLA_PUT(msg,IFLA_BRIDGE_VLAN_INFO,
sizeof(vinfo),&vinfo);
341 vinfo.flags = BRIDGE_VLAN_INFO_RANGE_END;
342 vinfo.flags |= untagged ? BRIDGE_VLAN_INFO_UNTAGGED : 0;
344 NLA_PUT(msg,IFLA_BRIDGE_VLAN_INFO,
sizeof(vinfo),&vinfo);
346 else if (start == prev)
348 vinfo.flags = untagged ? BRIDGE_VLAN_INFO_UNTAGGED : 0;
350 NLA_PUT(msg,IFLA_BRIDGE_VLAN_INFO,
sizeof(vinfo),&vinfo);
358 start = prev = j - 1 + base_bit;
359 untagged = vlan_id_untagged(vlan_info,start);
360 vinfo.flags = BRIDGE_VLAN_INFO_RANGE_BEGIN;
361 vinfo.flags |= untagged ? BRIDGE_VLAN_INFO_UNTAGGED : 0;
369 if (vlan_info->pvid != 0)
371 untagged = vlan_id_untagged(vlan_info,vlan_info->pvid);
372 vinfo.flags = BRIDGE_VLAN_INFO_PVID;
373 vinfo.flags |= untagged ? BRIDGE_VLAN_INFO_UNTAGGED : 0;
374 vinfo.vid = vlan_info->pvid;
375 NLA_PUT(msg,IFLA_BRIDGE_VLAN_INFO,
sizeof(vinfo),&vinfo);
384static int bridge_fill_af(
struct rtnl_link *link,
struct nl_msg *msg,
387 struct bridge_data *bd = data;
389 if (bd->ce_mask & BRIDGE_ATTR_HWMODE)
392 bd->b_config_mode = BRIDGE_FLAGS_SELF;
393 bd->ce_mask |= BRIDGE_ATTR_CONFIG_MODE;
396 if (bd->ce_mask & BRIDGE_ATTR_CONFIG_MODE)
397 NLA_PUT_U16(msg, IFLA_BRIDGE_FLAGS, bd->b_config_mode);
399 if (bd->ce_mask & BRIDGE_ATTR_PORT_VLAN) {
400 if (_nl_bridge_fill_vlan_info(msg, &bd->vlan_info)) {
401 goto nla_put_failure;
411static int bridge_fill_pi(
struct rtnl_link *link,
struct nl_msg *msg,
414 struct bridge_data *bd = data;
416 if (bd->ce_mask & BRIDGE_ATTR_FLAGS) {
417 if (bd->b_flags_mask & RTNL_BRIDGE_BPDU_GUARD) {
419 bd->b_flags & RTNL_BRIDGE_BPDU_GUARD);
421 if (bd->b_flags_mask & RTNL_BRIDGE_HAIRPIN_MODE) {
423 bd->b_flags & RTNL_BRIDGE_HAIRPIN_MODE);
425 if (bd->b_flags_mask & RTNL_BRIDGE_FAST_LEAVE) {
427 bd->b_flags & RTNL_BRIDGE_FAST_LEAVE);
429 if (bd->b_flags_mask & RTNL_BRIDGE_ROOT_BLOCK) {
431 bd->b_flags & RTNL_BRIDGE_ROOT_BLOCK);
433 if (bd->b_flags_mask & RTNL_BRIDGE_UNICAST_FLOOD) {
435 bd->b_flags & RTNL_BRIDGE_UNICAST_FLOOD);
437 if (bd->b_flags_mask & RTNL_BRIDGE_LEARNING) {
439 bd->b_flags & RTNL_BRIDGE_LEARNING);
441 if (bd->b_flags_mask & RTNL_BRIDGE_LEARNING_SYNC) {
443 bd->b_flags & RTNL_BRIDGE_LEARNING_SYNC);
447 if (bd->ce_mask & BRIDGE_ATTR_COST)
450 if (bd->ce_mask & BRIDGE_ATTR_PRIORITY)
451 NLA_PUT_U16(msg, IFLA_BRPORT_PRIORITY, bd->b_priority);
453 if (bd->ce_mask & BRIDGE_ATTR_PORT_STATE)
454 NLA_PUT_U8(msg, IFLA_BRPORT_STATE, bd->b_port_state);
462static int bridge_override_rtm(
struct rtnl_link *link) {
463 struct bridge_data *bd;
468 bd = bridge_data(link);
470 if (bd->ce_mask & BRIDGE_ATTR_FLAGS)
476static int bridge_get_af(
struct nl_msg *msg, uint32_t *ext_filter_mask)
478 *ext_filter_mask |= RTEXT_FILTER_BRVLAN;
482static void dump_bitmap(
struct nl_dump_params *p,
const uint32_t *b)
485 int start = -1, prev = -1;
488 for (k = 0; k < RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN; k++) {
496 j = find_next_bit(i, a);
499 if (start < 0 && prev < 0) {
500 start = prev = j - 1 + base_bit;
504 if (j - 2 + base_bit == prev) {
513 if (done && k < RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN - 1)
524 start = prev = j - 1 + base_bit;
536 struct bridge_data *bd)
538 nl_dump(p,
"pvid %u", bd->vlan_info.pvid);
541 dump_bitmap(p, bd->vlan_info.vlan_bitmap);
543 nl_dump(p,
" untagged vlans:");
544 dump_bitmap(p, bd->vlan_info.untagged_bitmap);
547static void bridge_dump_details(
struct rtnl_link *link,
550 struct bridge_data *bd = data;
552 nl_dump_line(p,
" bridge: ");
554 if (bd->ce_mask & BRIDGE_ATTR_PORT_STATE)
555 nl_dump(p,
"port-state %u ", bd->b_port_state);
557 if (bd->ce_mask & BRIDGE_ATTR_PRIORITY)
558 nl_dump(p,
"prio %u ", bd->b_priority);
560 if (bd->ce_mask & BRIDGE_ATTR_COST)
561 nl_dump(p,
"cost %u ", bd->b_cost);
563 if (bd->ce_mask & BRIDGE_ATTR_HWMODE) {
566 rtnl_link_bridge_hwmode2str(bd->b_hwmode, hbuf,
sizeof(hbuf));
570 if (bd->ce_mask & BRIDGE_ATTR_PORT_VLAN)
571 rtnl_link_bridge_dump_vlans(p, bd);
573 if (bd->ce_mask & BRIDGE_ATTR_FLAGS) {
576 rtnl_link_bridge_flags2str(bd->b_flags & bd->b_flags_mask,
585 int family, uint32_t attrs,
int flags)
587 struct bridge_data *a = bridge_data(_a);
588 struct bridge_data *b = bridge_data(_b);
591#define _DIFF(ATTR, EXPR) ATTR_DIFF(attrs, ATTR, a, b, EXPR)
592 diff |= _DIFF(BRIDGE_ATTR_PORT_STATE,
593 a->b_port_state != b->b_port_state);
594 diff |= _DIFF(BRIDGE_ATTR_PRIORITY, a->b_priority != b->b_priority);
595 diff |= _DIFF(BRIDGE_ATTR_COST, a->b_cost != b->b_cost);
596 diff |= _DIFF(BRIDGE_ATTR_PORT_VLAN,
597 memcmp(&a->vlan_info, &b->vlan_info,
599 diff |= _DIFF(BRIDGE_ATTR_HWMODE, a->b_hwmode != b->b_hwmode);
600 diff |= _DIFF(BRIDGE_ATTR_CONFIG_MODE, a->b_config_mode != b->b_config_mode);
602 if (flags & LOOSE_COMPARISON)
603 diff |= _DIFF(BRIDGE_ATTR_FLAGS,
604 (a->b_flags ^ b->b_flags) & b->b_flags_mask);
606 diff |= _DIFF(BRIDGE_ATTR_FLAGS, a->b_flags != b->b_flags);
669 return link->l_family == AF_BRIDGE &&
670 link->l_af_ops == &bridge_ops;
688 struct bridge_data *bd;
693 bd = bridge_data(link);
694 return !!(bd->b_priv_flags & PRIV_FLAG_NEW_ATTRS);
717 struct bridge_data *bd = bridge_data(link);
719 IS_BRIDGE_LINK_ASSERT(link);
721 if (state > BR_STATE_BLOCKING)
724 bd->b_port_state = state;
725 bd->ce_mask |= BRIDGE_ATTR_PORT_STATE;
741 struct bridge_data *bd = bridge_data(link);
743 IS_BRIDGE_LINK_ASSERT(link);
745 return bd->b_port_state;
760 struct bridge_data *bd = bridge_data(link);
762 IS_BRIDGE_LINK_ASSERT(link);
764 bd->b_priority = prio;
765 bd->ce_mask |= BRIDGE_ATTR_PRIORITY;
781 struct bridge_data *bd = bridge_data(link);
783 IS_BRIDGE_LINK_ASSERT(link);
785 return bd->b_priority;
800 struct bridge_data *bd = bridge_data(link);
802 IS_BRIDGE_LINK_ASSERT(link);
805 bd->ce_mask |= BRIDGE_ATTR_COST;
823 struct bridge_data *bd = bridge_data(link);
825 IS_BRIDGE_LINK_ASSERT(link);
848 struct bridge_data *bd = bridge_data(link);
850 IS_BRIDGE_LINK_ASSERT(link);
852 bd->b_flags_mask |= flags;
853 bd->b_flags &= ~flags;
854 bd->ce_mask |= BRIDGE_ATTR_FLAGS;
881 struct bridge_data *bd = bridge_data(link);
883 IS_BRIDGE_LINK_ASSERT(link);
885 bd->b_flags_mask |= flags;
886 bd->b_flags |= flags;
887 bd->ce_mask |= BRIDGE_ATTR_FLAGS;
904 struct bridge_data *bd = bridge_data(link);
906 IS_BRIDGE_LINK_ASSERT(link);
924 struct bridge_data *bd = bridge_data(link);
926 IS_BRIDGE_LINK_ASSERT(link);
928 bd->b_config_mode = BRIDGE_FLAGS_SELF;
929 bd->ce_mask |= BRIDGE_ATTR_CONFIG_MODE;
947 struct bridge_data *bd = bridge_data(link);
949 IS_BRIDGE_LINK_ASSERT(link);
951 bd->b_config_mode = BRIDGE_FLAGS_MASTER;
952 bd->ce_mask |= BRIDGE_ATTR_CONFIG_MODE;
970 struct bridge_data *bd = bridge_data(link);
972 IS_BRIDGE_LINK_ASSERT(link);
974 if (!(bd->ce_mask & BRIDGE_ATTR_HWMODE))
977 *hwmode = bd->b_hwmode;
1004 struct bridge_data *bd = bridge_data(link);
1006 if (hwmode > RTNL_BRIDGE_HWMODE_MAX)
1012 bd->b_hwmode = hwmode;
1013 bd->ce_mask |= BRIDGE_ATTR_HWMODE;
1019static const struct trans_tbl bridge_flags[] = {
1020 __ADD(RTNL_BRIDGE_HAIRPIN_MODE, hairpin_mode),
1021 __ADD(RTNL_BRIDGE_BPDU_GUARD, bpdu_guard),
1022 __ADD(RTNL_BRIDGE_ROOT_BLOCK, root_block),
1023 __ADD(RTNL_BRIDGE_FAST_LEAVE, fast_leave),
1024 __ADD(RTNL_BRIDGE_UNICAST_FLOOD, flood),
1025 __ADD(RTNL_BRIDGE_LEARNING, learning),
1026 __ADD(RTNL_BRIDGE_LEARNING_SYNC, learning_sync),
1034char *rtnl_link_bridge_flags2str(
int flags,
char *buf,
size_t len)
1036 return __flags2str(flags, buf, len, bridge_flags, ARRAY_SIZE(bridge_flags));
1039int rtnl_link_bridge_str2flags(
const char *name)
1041 return __str2flags(name, bridge_flags, ARRAY_SIZE(bridge_flags));
1046static const struct trans_tbl port_states[] = {
1047 __ADD(BR_STATE_DISABLED, disabled),
1048 __ADD(BR_STATE_LISTENING, listening),
1049 __ADD(BR_STATE_LEARNING, learning),
1050 __ADD(BR_STATE_FORWARDING, forwarding),
1051 __ADD(BR_STATE_BLOCKING, blocking),
1059char *rtnl_link_bridge_portstate2str(
int st,
char *buf,
size_t len)
1061 return __type2str(st, buf, len, port_states, ARRAY_SIZE(port_states));
1064int rtnl_link_bridge_str2portstate(
const char *name)
1066 return __str2type(name, port_states, ARRAY_SIZE(port_states));
1071static const struct trans_tbl hw_modes[] = {
1072 __ADD(RTNL_BRIDGE_HWMODE_VEB, veb),
1073 __ADD(RTNL_BRIDGE_HWMODE_VEPA, vepa),
1074 __ADD(RTNL_BRIDGE_HWMODE_UNDEF, undef),
1082char *rtnl_link_bridge_hwmode2str(uint16_t st,
char *buf,
size_t len) {
1083 return __type2str(st, buf, len, hw_modes, ARRAY_SIZE(hw_modes));
1086uint16_t rtnl_link_bridge_str2hwmode(
const char *name)
1088 return __str2type(name, hw_modes, ARRAY_SIZE(hw_modes));
1102 struct bridge_data *bd = bridge_data(link);
1104 IS_BRIDGE_LINK_ASSERT(link);
1106 bd->ce_mask |= BRIDGE_ATTR_PORT_VLAN;
1136 IS_BRIDGE_LINK_ASSERT(link);
1138 vinfo = rtnl_link_bridge_get_port_vlan(link);
1143 if (start == 0 || start > end || end >= VLAN_VID_MASK)
1146 for (uint16_t i = start; i <= end; i++)
1148 set_bit(i,vinfo->vlan_bitmap);
1150 set_bit(i,vinfo->untagged_bitmap);
1152 unset_bit(i,vinfo->untagged_bitmap);
1177 IS_BRIDGE_LINK_ASSERT(link);
1179 vinfo = rtnl_link_bridge_get_port_vlan(link);
1184 if (start == 0 || start > end || end >= VLAN_VID_MASK)
1187 for (uint16_t i = start; i <= end; i++)
1189 unset_bit(i,vinfo->vlan_bitmap);
1190 unset_bit(i,vinfo->untagged_bitmap);
1216 IS_BRIDGE_LINK_ASSERT(link);
1218 vinfo = rtnl_link_bridge_get_port_vlan(link);
1223 if (pvid >= VLAN_VID_MASK)
1233int rtnl_link_bridge_pvid(
struct rtnl_link *link)
1235 struct bridge_data *bd;
1237 IS_BRIDGE_LINK_ASSERT(link);
1239 bd = link->l_af_data[AF_BRIDGE];
1240 if (bd->ce_mask & BRIDGE_ATTR_PORT_VLAN)
1241 return (
int) bd->vlan_info.pvid;
1246int rtnl_link_bridge_has_vlan(
struct rtnl_link *link)
1248 struct bridge_data *bd;
1251 IS_BRIDGE_LINK_ASSERT(link);
1253 bd = link->l_af_data[AF_BRIDGE];
1254 if (bd->ce_mask & BRIDGE_ATTR_PORT_VLAN) {
1255 if (bd->vlan_info.pvid)
1258 for (i = 0; i < RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN; ++i) {
1259 if (bd->vlan_info.vlan_bitmap[i] ||
1260 bd->vlan_info.untagged_bitmap[i])
1269 struct bridge_data *data;
1274 data = link->l_af_data[AF_BRIDGE];
1275 if (data && (data->ce_mask & BRIDGE_ATTR_PORT_VLAN))
1276 return &data->vlan_info;
1283 .ao_alloc = &bridge_alloc,
1284 .ao_clone = &bridge_clone,
1285 .ao_free = &bridge_free,
1286 .ao_parse_protinfo = &bridge_parse_protinfo,
1288 .ao_compare = &bridge_compare,
1289 .ao_parse_af_full = &bridge_parse_af_full,
1290 .ao_get_af = &bridge_get_af,
1291 .ao_fill_af = &bridge_fill_af,
1292 .ao_fill_pi = &bridge_fill_pi,
1293 .ao_fill_pi_flags = NLA_F_NESTED,
1294 .ao_override_rtm = &bridge_override_rtm,
1295 .ao_fill_af_no_nest = 1,
1298static void _nl_init bridge_init(
void)
1303static void _nl_exit bridge_exit(
void)
uint32_t nla_get_u32(const struct nlattr *nla)
Return payload of 32 bit integer attribute.
uint16_t nla_get_u16(const struct nlattr *nla)
Return payload of 16 bit integer attribute.
#define NLA_PUT_U16(msg, attrtype, value)
Add 16 bit integer attribute to netlink message.
#define NLA_PUT_U8(msg, attrtype, value)
Add 8 bit integer attribute to netlink message.
int nla_type(const struct nlattr *nla)
Return type of the attribute.
void * nla_data(const struct nlattr *nla)
Return pointer to the payload section.
int nla_is_nested(const struct nlattr *attr)
Return true if attribute has NLA_F_NESTED flag set.
#define NLA_PUT(msg, attrtype, attrlen, data)
Add unspecific attribute to netlink message.
#define NLA_PUT_U32(msg, attrtype, value)
Add 32 bit integer attribute to netlink message.
uint8_t nla_get_u8(const struct nlattr *nla)
Return value of 8 bit integer attribute.
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, const struct nla_policy *policy)
Create attribute index based on nested attribute.
#define nla_for_each_nested(pos, nla, rem)
Iterate over a stream of nested attributes.
int nla_len(const struct nlattr *nla)
Return length of the payload .
int rtnl_link_bridge_set_cost(struct rtnl_link *link, uint32_t cost)
Set Spanning Tree Protocol (STP) path cost.
int rtnl_link_bridge_get_port_state(struct rtnl_link *link)
Get Spanning Tree Protocol (STP) port state.
int rtnl_link_bridge_set_hwmode(struct rtnl_link *link, uint16_t hwmode)
Set hardware mode.
int rtnl_link_bridge_has_ext_info(struct rtnl_link *link)
Check if bridge has extended information.
int rtnl_link_bridge_set_master(struct rtnl_link *link)
Set link change type to master.
int rtnl_link_bridge_add(struct nl_sock *sk, const char *name)
Create a new kernel bridge device.
int rtnl_link_bridge_set_port_vlan_map_range(struct rtnl_link *link, uint16_t start, uint16_t end, int untagged)
Set port vlan membership range.
int rtnl_link_is_bridge(struct rtnl_link *link)
Check if a link is a bridge.
int rtnl_link_bridge_set_port_state(struct rtnl_link *link, uint8_t state)
Set Spanning Tree Protocol (STP) port state.
int rtnl_link_bridge_enable_vlan(struct rtnl_link *link)
Enable the ability to set vlan info.
int rtnl_link_bridge_set_self(struct rtnl_link *link)
Set link change type to self.
int rtnl_link_bridge_set_port_vlan_pvid(struct rtnl_link *link, uint16_t pvid)
Set port primary vlan id.
struct rtnl_link * rtnl_link_bridge_alloc(void)
Allocate link object of type bridge.
int rtnl_link_bridge_get_hwmode(struct rtnl_link *link, uint16_t *hwmode)
Get hardware mode.
int rtnl_link_bridge_get_flags(struct rtnl_link *link)
Get flags.
int rtnl_link_bridge_get_cost(struct rtnl_link *link, uint32_t *cost)
Get Spanning Tree Protocol (STP) path cost.
int rtnl_link_bridge_get_priority(struct rtnl_link *link)
Get priority.
int rtnl_link_bridge_unset_flags(struct rtnl_link *link, unsigned int flags)
Unset flags.
int rtnl_link_bridge_unset_port_vlan_map_range(struct rtnl_link *link, uint16_t start, uint16_t end)
Unset port vlan membership range.
int rtnl_link_bridge_set_priority(struct rtnl_link *link, uint16_t prio)
Set priority.
int rtnl_link_bridge_set_flags(struct rtnl_link *link, unsigned int flags)
Set flags.
int rtnl_link_af_unregister(struct rtnl_link_af_ops *ops)
Unregister operations for a link address family.
int rtnl_link_af_register(struct rtnl_link_af_ops *ops)
Register operations for a link address family.
void * rtnl_link_af_data(const struct rtnl_link *link, const struct rtnl_link_af_ops *ops)
Return data buffer for link address family modules.
int rtnl_link_add(struct nl_sock *sk, struct rtnl_link *link, int flags)
Add virtual link.
struct rtnl_link * rtnl_link_alloc(void)
Allocate link object.
void rtnl_link_set_name(struct rtnl_link *link, const char *name)
Set name of link object.
void rtnl_link_put(struct rtnl_link *link)
Release a link object reference.
int rtnl_link_set_type(struct rtnl_link *link, const char *type)
Set type of link object.
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
Attribute validation policy.
uint16_t type
Type of attribute or NLA_UNSPEC.
Available operations to modules implementing a link address family.
const unsigned int ao_family
The address family this operations set implements.