libnl: Bridging

libnl 3.12.0

Bridging
Routing Library (libnl-route) » Links (Interfaces)

## Data Structures
struct | bridge_info

## Macros
#define | VLAN_VID_MASK 0x0fff /* VLAN Identifier */
#define | BRIDGE_ATTR_VLAN_FILTERING (1 << 0)
#define | BRIDGE_ATTR_VLAN_PROTOCOL (1 << 1)
#define | BRIDGE_ATTR_VLAN_STATS_ENABLED (1 << 2)
#define | BRIDGE_ATTR_AGEING_TIME (1 << 3)
#define | BRIDGE_ATTR_VLAN_DEFAULT_PVID (1 << 4)
#define | BRIDGE_ATTR_NF_CALL_IPTABLES (1 << 5)
#define | BRIDGE_ATTR_NF_CALL_IP6TABLES (1 << 6)
#define | BRIDGE_ATTR_NF_CALL_ARPTABLES (1 << 7)
#define | BRIDGE_ATTR_STP_STATE (1 << 8)
#define | BRIDGE_ATTR_MCAST_ROUTER (1 << 9)
#define | BRIDGE_ATTR_MCAST_SNOOPING (1 << 10)
#define | BRIDGE_ATTR_BOOLOPT (1 << 11)
#define | IS_BRIDGE_INFO_ASSERT(link)

## Enumerations
enum | rtnl_link_bridge_flags { RTNL_BRIDGE_HAIRPIN_MODE = 1ul << 0 , RTNL_BRIDGE_BPDU_GUARD = 1ul << 1 , RTNL_BRIDGE_ROOT_BLOCK = 1ul << 2 , RTNL_BRIDGE_FAST_LEAVE = 1ul << 3 , RTNL_BRIDGE_UNICAST_FLOOD = 1ul << 4 , RTNL_BRIDGE_LEARNING = 1ul << 5 , RTNL_BRIDGE_LEARNING_SYNC = 1ul << 6 , RTNL_BRIDGE_PROXYARP = 1ul << 7 , RTNL_BRIDGE_PROXYARP_WIFI = 1ul << 8 , RTNL_BRIDGE_MCAST_FLOOD = 1ul << 9 , RTNL_BRIDGE_MCAST_TO_UCAST = 1ul << 10 , RTNL_BRIDGE_VLAN_TUNNEL = 1ul << 11 , RTNL_BRIDGE_BCAST_FLOOD = 1ul << 12 , RTNL_BRIDGE_NEIGH_SUPPRESS = 1ul << 13 , RTNL_BRIDGE_ISOLATED = 1ul << 14 , RTNL_BRIDGE_LOCKED = 1ul << 15 , RTNL_BRIDGE_MAB = 1ul << 16 , RTNL_BRIDGE_NEIGH_VLAN_SUPPRESS = 1ul << 17 }
| Bridge flags. More...

## Functions
struct rtnl_link * | rtnl_link_bridge_alloc (void)
| Allocate link object of type bridge.
int | rtnl_link_bridge_add (struct nl_sock *sk, const char *name)
| Create a new kernel bridge device.
int | rtnl_link_is_bridge (struct rtnl_link *link)
| Check if a link is a bridge.
int | rtnl_link_bridge_has_ext_info (struct rtnl_link *link)
| Check if bridge has extended information.
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_get_port_state (struct rtnl_link *link)
| Get Spanning Tree Protocol (STP) port state.
int | rtnl_link_bridge_set_priority (struct rtnl_link *link, uint16_t prio)
| Set priority.
int | rtnl_link_bridge_get_priority (struct rtnl_link *link)
| Get priority.
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_cost (struct rtnl_link *link, uint32_t *cost)
| Get Spanning Tree Protocol (STP) path cost.
int | rtnl_link_bridge_unset_flags (struct rtnl_link *link, unsigned int flags)
| Unset flags.
int | rtnl_link_bridge_set_flags (struct rtnl_link *link, unsigned int flags)
| Set flags.
int | rtnl_link_bridge_get_flags (struct rtnl_link *link)
| Get flags.
int | rtnl_link_bridge_set_self (struct rtnl_link *link)
| Set link change type to self.
int | rtnl_link_bridge_set_master (struct rtnl_link *link)
| Set link change type to master.
int | rtnl_link_bridge_get_hwmode (struct rtnl_link *link, uint16_t *hwmode)
| Get hardware mode.
int | rtnl_link_bridge_set_hwmode (struct rtnl_link *link, uint16_t hwmode)
| Set hardware mode.
int | rtnl_link_bridge_enable_vlan (struct rtnl_link *link)
| Enable the ability to set vlan info.
int | rtnl_link_bridge_pvid (struct rtnl_link *link)
int | rtnl_link_bridge_has_vlan (struct rtnl_link *link)
struct rtnl_link_bridge_vlan * | rtnl_link_bridge_get_port_vlan (struct rtnl_link *link)
int | rtnl_link_bridge_set_mst_port_state (struct rtnl_link *link, uint16_t instance, uint8_t state)
| Set the Multiple Spanning Tree (MST) port state for a given MST instance.
int | rtnl_link_bridge_get_mst_port_state (struct rtnl_link *link, uint16_t instance)
| Get the Multiple Spanning Tree (MST) port state for a given MST instance.
int | rtnl_link_bridge_del_mst_port_state (struct rtnl_link *link, uint16_t instance)
| Delete the Multiple Spanning Tree (MST) port state for a given MST instance.
int | rtnl_link_bridge_clear_mst_port_state_info (struct rtnl_link *link)
| Delete all Multiple Spanning Tree (MST) port state information.
int | rtnl_link_bridge_foreach_mst_entry (struct rtnl_link *link, void(*cb)(uint16_t instance, uint8_t state, void *arg), void *arg)
| Iterate over all Multiple Spanning Tree (MST) port state entries.
void | rtnl_link_bridge_set_ageing_time (struct rtnl_link *link, uint32_t ageing_time)
| Set ageing time for dynamic forwarding entries.
int | rtnl_link_bridge_get_ageing_time (struct rtnl_link *link, uint32_t *ageing_time)
| Get ageing time for dynamic forwarding entries.
void | rtnl_link_bridge_set_vlan_filtering (struct rtnl_link *link, uint8_t vlan_filtering)
| Set VLAN filtering flag.
int | rtnl_link_bridge_get_vlan_filtering (struct rtnl_link *link, uint8_t *vlan_filtering)
| Get VLAN filtering flag.
void | rtnl_link_bridge_set_vlan_protocol (struct rtnl_link *link, uint16_t vlan_protocol)
| Set VLAN protocol.
int | rtnl_link_bridge_get_vlan_protocol (struct rtnl_link *link, uint16_t *vlan_protocol)
| Get VLAN protocol.
void | rtnl_link_bridge_set_vlan_default_pvid (struct rtnl_link *link, uint16_t default_pvid)
| Set VLAN default pvid.
int | rtnl_link_bridge_get_vlan_default_pvid (struct rtnl_link *link, uint16_t *default_pvid)
| Get VLAN default pvid.
void | rtnl_link_bridge_set_vlan_stats_enabled (struct rtnl_link *link, uint8_t vlan_stats_enabled)
| Set VLAN stats enabled flag.
int | rtnl_link_bridge_get_vlan_stats_enabled (struct rtnl_link *link, uint8_t *vlan_stats_enabled)
| Get VLAN stats enabled flag.
void | rtnl_link_bridge_set_nf_call_iptables (struct rtnl_link *link, uint8_t call_enabled)
| Set call enabled flag for passing IPv4 traffic to iptables.
int | rtnl_link_bridge_get_nf_call_iptables (struct rtnl_link *link, uint8_t *call_enabled)
| Get call enabled flag for passing IPv4 traffic to iptables.
void | rtnl_link_bridge_set_nf_call_ip6tables (struct rtnl_link *link, uint8_t call_enabled)
| Set call enabled flag for passing IPv6 traffic to ip6tables.
int | rtnl_link_bridge_get_nf_call_ip6tables (struct rtnl_link *link, uint8_t *call_enabled)
| Get call enabled flag for passing IPv6 traffic to iptables.
void | rtnl_link_bridge_set_nf_call_arptables (struct rtnl_link *link, uint8_t call_enabled)
| Set call enabled flag for passing ARP traffic to arptables.
int | rtnl_link_bridge_get_nf_call_arptables (struct rtnl_link *link, uint8_t *call_enabled)
| Get call enabled flag for passing ARP traffic to arptables.
void | rtnl_link_bridge_set_stp_state (struct rtnl_link *link, uint32_t stp_state)
| Set STP state.
int | rtnl_link_bridge_get_stp_state (struct rtnl_link *link, uint32_t *stp_state)
| Get STP state.
void | rtnl_link_bridge_set_mcast_router (struct rtnl_link *link, uint8_t type)
| Set multicast router type.
int | rtnl_link_bridge_get_mcast_router (struct rtnl_link *link, uint8_t *type)
| Get multicast router type.
void | rtnl_link_bridge_set_mcast_snooping (struct rtnl_link *link, uint8_t value)
| Set multicast snooping.
int | rtnl_link_bridge_get_mcast_snooping (struct rtnl_link *link, uint8_t *value)
| Get multicast snooping value.
int | rtnl_link_bridge_set_boolopt (struct rtnl_link *link, int opt, int value)
| Set a the value of a boolopt.
int | rtnl_link_bridge_get_boolopt (struct rtnl_link *link, int opt)
| Get the value of a boolopt.

## Flag Translation
char * | rtnl_link_bridge_flags2str (int flags, char *buf, size_t len)
int | rtnl_link_bridge_str2flags (const char *name)

## Port State Translation
char * | rtnl_link_bridge_portstate2str (int st, char *buf, size_t len)
int | rtnl_link_bridge_str2portstate (const char *name)

## Hardware Mode Translation
char * | rtnl_link_bridge_hwmode2str (uint16_t st, char *buf, size_t len)
uint16_t | rtnl_link_bridge_str2hwmode (const char *name)

## Quality of Service
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_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_port_vlan_pvid (struct rtnl_link *link, uint16_t pvid)
| Set port primary vlan id.

## Detailed Description

## Macro Definition Documentation

## ◆ VLAN_VID_MASK

#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */

Definition at line 30 of file bridge.c.

## ◆ BRIDGE_ATTR_VLAN_FILTERING

#define BRIDGE_ATTR_VLAN_FILTERING (1 << 0)

Definition at line 23 of file bridge_info.c.

## ◆ BRIDGE_ATTR_VLAN_PROTOCOL

#define BRIDGE_ATTR_VLAN_PROTOCOL (1 << 1)

Definition at line 24 of file bridge_info.c.

## ◆ BRIDGE_ATTR_VLAN_STATS_ENABLED

#define BRIDGE_ATTR_VLAN_STATS_ENABLED (1 << 2)

Definition at line 25 of file bridge_info.c.

## ◆ BRIDGE_ATTR_AGEING_TIME

#define BRIDGE_ATTR_AGEING_TIME (1 << 3)

Definition at line 26 of file bridge_info.c.

## ◆ BRIDGE_ATTR_VLAN_DEFAULT_PVID

#define BRIDGE_ATTR_VLAN_DEFAULT_PVID (1 << 4)

Definition at line 27 of file bridge_info.c.

## ◆ BRIDGE_ATTR_NF_CALL_IPTABLES

#define BRIDGE_ATTR_NF_CALL_IPTABLES (1 << 5)

Definition at line 28 of file bridge_info.c.

## ◆ BRIDGE_ATTR_NF_CALL_IP6TABLES

#define BRIDGE_ATTR_NF_CALL_IP6TABLES (1 << 6)

Definition at line 29 of file bridge_info.c.

## ◆ BRIDGE_ATTR_NF_CALL_ARPTABLES

#define BRIDGE_ATTR_NF_CALL_ARPTABLES (1 << 7)

Definition at line 30 of file bridge_info.c.

## ◆ BRIDGE_ATTR_STP_STATE

#define BRIDGE_ATTR_STP_STATE (1 << 8)

Definition at line 31 of file bridge_info.c.

## ◆ BRIDGE_ATTR_MCAST_ROUTER

#define BRIDGE_ATTR_MCAST_ROUTER (1 << 9)

Definition at line 32 of file bridge_info.c.

## ◆ BRIDGE_ATTR_MCAST_SNOOPING

#define BRIDGE_ATTR_MCAST_SNOOPING (1 << 10)

Definition at line 33 of file bridge_info.c.

## ◆ BRIDGE_ATTR_BOOLOPT

#define BRIDGE_ATTR_BOOLOPT (1 << 11)

Definition at line 34 of file bridge_info.c.

## ◆ IS_BRIDGE_INFO_ASSERT

#define IS_BRIDGE_INFO_ASSERT | ( |  | link | ) |

Value:
do { \
if ((link)->l_info_ops != &bridge_info_ops) { \
APPBUG("Link is not a bridge link. Set type \"bridge\" first."); \
} \
} while (0)

Definition at line 321 of file bridge_info.c.

## Enumeration Type Documentation

## ◆ rtnl_link_bridge_flags

enum rtnl_link_bridge_flags

Bridge flags.

Definition at line 30 of file bridge.h.

## Function Documentation

## ◆ rtnl_link_bridge_alloc()

struct rtnl_link * rtnl_link_bridge_alloc | ( | void |  | ) |

Allocate link object of type bridge.

Returns
  Allocated link object or NULL.

Definition at line 981 of file bridge.c.

References rtnl_link_alloc(), rtnl_link_put(), and rtnl_link_set_type().

Referenced by rtnl_link_bridge_add().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ rtnl_link_bridge_add()

int rtnl_link_bridge_add | ( | struct nl_sock * | sk,
|  | const char * | name )

Create a new kernel bridge device.

Parameters

  sk | netlink socket
  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.)

Returns
  0 on success or a negative error code

Definition at line 1007 of file bridge.c.

References rtnl_link_add(), rtnl_link_bridge_alloc(), rtnl_link_put(), and rtnl_link_set_name().

Here is the call graph for this function:

## ◆ rtnl_link_is_bridge()

int rtnl_link_is_bridge | ( | struct rtnl_link * | link | ) |

Check if a link is a bridge.

Parameters

  link | Link object

Returns
  1 if the link is a bridge, 0 otherwise.

Definition at line 1030 of file bridge.c.

Referenced by rtnl_link_bridge_has_ext_info().

Here is the caller graph for this function:

## ◆ rtnl_link_bridge_has_ext_info()

int rtnl_link_bridge_has_ext_info | ( | struct rtnl_link * | link | ) |

Check if bridge has extended information.

Parameters

  link | Link object of type bridge

Checks if the bridge object has been constructed based on information that is only available in newer kernels. This affectes the following functions:

- rtnl_link_bridge_get_cost()
- rtnl_link_bridge_get_priority()
- rtnl_link_bridge_get_flags()

Returns
  1 if extended information is available, otherwise 0 is returned.

Definition at line 1049 of file bridge.c.

References rtnl_link_is_bridge().

Here is the call graph for this function:

## ◆ rtnl_link_bridge_set_port_state()

int rtnl_link_bridge_set_port_state | ( | struct rtnl_link * | link,
|  | uint8_t | state )

Set Spanning Tree Protocol (STP) port state.

Parameters

  link | Link object of type bridge
  state | New STP port state

The value of state must be one of the following:

- BR_STATE_DISABLED
- BR_STATE_LISTENING
- BR_STATE_LEARNING
- BR_STATE_FORWARDING
- BR_STATE_BLOCKING

See also
  rtnl_link_bridge_get_port_state()

Returns
  0 on success or a negative error code.

Return values

  -NLE_OPNOTSUPP | Link is not a bridge
  -NLE_INVAL | Invalid state value (0..BR_STATE_BLOCKING)

Definition at line 1078 of file bridge.c.

## ◆ rtnl_link_bridge_get_port_state()

int rtnl_link_bridge_get_port_state | ( | struct rtnl_link * | link | ) |

Get Spanning Tree Protocol (STP) port state.

Parameters

  link | Link object of type bridge

See also
  rtnl_link_bridge_set_port_state()

Returns
  The STP port state or a negative error code.

Return values

  -NLE_OPNOTSUPP | Link is not a bridge

Definition at line 1102 of file bridge.c.

## ◆ rtnl_link_bridge_set_priority()

int rtnl_link_bridge_set_priority | ( | struct rtnl_link * | link,
|  | uint16_t | prio )

Set priority.

Parameters

  link | Link object of type bridge
  prio | Bridge priority

See also
  rtnl_link_bridge_get_priority()

Returns
  0 on success or a negative error code.

Return values

  -NLE_OPNOTSUPP | Link is not a bridge

Definition at line 1121 of file bridge.c.

## ◆ rtnl_link_bridge_get_priority()

int rtnl_link_bridge_get_priority | ( | struct rtnl_link * | link | ) |

Get priority.

Parameters

  link | Link object of type bridge

See also
  rtnl_link_bridge_set_priority()

Returns
  0 on success or a negative error code.

Return values

  -NLE_OPNOTSUPP | Link is not a bridge

Definition at line 1142 of file bridge.c.

## ◆ rtnl_link_bridge_set_cost()

int rtnl_link_bridge_set_cost | ( | struct rtnl_link * | link,
|  | uint32_t | cost )

Set Spanning Tree Protocol (STP) path cost.

Parameters

  link | Link object of type bridge
  cost | New STP path cost value

See also
  rtnl_link_bridge_get_cost()

Returns
  The bridge priority or a negative error code.

Return values

  -NLE_OPNOTSUPP | Link is not a bridge

Definition at line 1161 of file bridge.c.

## ◆ rtnl_link_bridge_get_cost()

int rtnl_link_bridge_get_cost | ( | struct rtnl_link * | link,
|  | uint32_t * | cost )

Get Spanning Tree Protocol (STP) path cost.

Parameters

  link | Link object of type bridge
  cost | Pointer to store STP cost value

See also
  rtnl_link_bridge_set_cost()

Returns
  0 on success or a negative error code.

Return values

  -NLE_OPNOTSUPP | Link is not a bridge
  -NLE_INVAL | cost is not a valid pointer

Definition at line 1184 of file bridge.c.

## ◆ rtnl_link_bridge_unset_flags()

int rtnl_link_bridge_unset_flags | ( | struct rtnl_link * | link,
|  | unsigned int | flags )

Unset flags.

Parameters

  link | Link object of type bridge
  flags | Bridging flags to unset

See also
  rtnl_link_bridge_set_flags()
  rtnl_link_bridge_get_flags()

Returns
  0 on success or a negative error code.

Return values

  -NLE_OPNOTSUPP | Link is not a bridge

Definition at line 1209 of file bridge.c.

## ◆ rtnl_link_bridge_set_flags()

int rtnl_link_bridge_set_flags | ( | struct rtnl_link * | link,
|  | unsigned int | flags )

Set flags.

Parameters

  link | Link object of type bridge
  flags | Bridging flags to set

Valid flags are:

- RTNL_BRIDGE_HAIRPIN_MODE
- RTNL_BRIDGE_BPDU_GUARD
- RTNL_BRIDGE_ROOT_BLOCK
- RTNL_BRIDGE_FAST_LEAVE
- RTNL_BRIDGE_UNICAST_FLOOD
- RTNL_BRIDGE_LEARNING
- RTNL_BRIDGE_LEARNING_SYNC
- RTNL_BRIDGE_PROXYARP
- RTNL_BRIDGE_PROXYARP_WIFI
- RTNL_BRIDGE_MCAST_FLOOD
- RTNL_BRIDGE_MCAST_TO_UCAST
- RTNL_BRIDGE_VLAN_TUNNEL
- RTNL_BRIDGE_BCAST_FLOOD
- RTNL_BRIDGE_NEIGH_SUPPRESS
- RTNL_BRIDGE_ISOLATED
- RTNL_BRIDGE_LOCKED
- RTNL_BRIDGE_MAB
- RTNL_BRIDGE_NEIGH_VLAN_SUPPRESS

See also
  rtnl_link_bridge_unset_flags()
  rtnl_link_bridge_get_flags()

Returns
  0 on success or a negative error code.

Return values

  -NLE_OPNOTSUPP | Link is not a bridge

Definition at line 1253 of file bridge.c.

## ◆ rtnl_link_bridge_get_flags()

int rtnl_link_bridge_get_flags | ( | struct rtnl_link * | link | ) |

Get flags.

Parameters

  link | Link object of type bridge

See also
  rtnl_link_bridge_set_flags()
  rtnl_link_bridge_unset_flags()

Returns
  Flags or a negative error code.

Return values

  -NLE_OPNOTSUPP | Link is not a bridge

Definition at line 1276 of file bridge.c.

## ◆ rtnl_link_bridge_set_self()

int rtnl_link_bridge_set_self | ( | struct rtnl_link * | link | ) |

Set link change type to self.

Parameters

  link | Link Object of type bridge

This will set the bridge change flag to self, meaning that changes to be applied with this link object will be applied directly to the physical device in a bridge instead of the virtual device.

Returns
  0 on success or negative error code
  -NLE_OPNOTSUP Link is not a bridge

Definition at line 1296 of file bridge.c.

Referenced by rtnl_link_bridge_set_hwmode().

Here is the caller graph for this function:

## ◆ rtnl_link_bridge_set_master()

int rtnl_link_bridge_set_master | ( | struct rtnl_link * | link | ) |

Set link change type to master.

Parameters

  link | Link Object of type bridge

This will set the bridge change flag to master, meaning that changes to be applied with this link object will be applied directly to the virtual device in a bridge instead of the physical device.

Returns
  0 on success or negative error code
  -NLE_OPNOTSUP Link is not a bridge

Definition at line 1319 of file bridge.c.

## ◆ rtnl_link_bridge_get_hwmode()

int rtnl_link_bridge_get_hwmode | ( | struct rtnl_link * | link,
|  | uint16_t * | hwmode )

Get hardware mode.

Parameters

  link | Link object of type bridge
  hwmode | Output argument.

See also
  rtnl_link_bridge_set_hwmode()

Returns
  0 if hardware mode is present and returned in hwmode
  -NLE_NOATTR if hardware mode is not present
  -NLE_OPNOTSUP Link is not a bridge

Definition at line 1342 of file bridge.c.

## ◆ rtnl_link_bridge_set_hwmode()

int rtnl_link_bridge_set_hwmode | ( | struct rtnl_link * | link,
|  | uint16_t | hwmode )

Set hardware mode.

Parameters

  link | Link object of type bridge
  hwmode | Hardware mode to set on link

This will set the hardware mode of a link when it supports hardware offloads for bridging.

See also
  rtnl_link_bridge_get_hwmode()

Valid modes are:

- RTNL_BRIDGE_HWMODE_VEB
- RTNL_BRIDGE_HWMODE_VEPA

When setting hardware mode, the change type will be set to self.

See also
  rtnl_link_bridge_set_self()

Returns
  0 on success or negative error code
  -NLE_OPNOTSUP Link is not a bridge
  -NLE_INVAL when specified hwmode is unsupported.

Definition at line 1375 of file bridge.c.

References rtnl_link_bridge_set_self().

Here is the call graph for this function:

## ◆ rtnl_link_bridge_flags2str()

char * rtnl_link_bridge_flags2str | ( | int | flags,
|  | char * | buf,
|  | size_t | len )

Definition at line 1419 of file bridge.c.

## ◆ rtnl_link_bridge_str2flags()

int rtnl_link_bridge_str2flags | ( | const char * | name | ) |

Definition at line 1424 of file bridge.c.

## ◆ rtnl_link_bridge_portstate2str()

char * rtnl_link_bridge_portstate2str | ( | int | st,
|  | char * | buf,
|  | size_t | len )

Definition at line 1444 of file bridge.c.

## ◆ rtnl_link_bridge_str2portstate()

int rtnl_link_bridge_str2portstate | ( | const char * | name | ) |

Definition at line 1449 of file bridge.c.

## ◆ rtnl_link_bridge_hwmode2str()

char * rtnl_link_bridge_hwmode2str | ( | uint16_t | st,
|  | char * | buf,
|  | size_t | len )

Definition at line 1467 of file bridge.c.

## ◆ rtnl_link_bridge_str2hwmode()

uint16_t rtnl_link_bridge_str2hwmode | ( | const char * | name | ) |

Definition at line 1471 of file bridge.c.

## ◆ rtnl_link_bridge_enable_vlan()

int rtnl_link_bridge_enable_vlan | ( | struct rtnl_link * | link | ) |

Enable the ability to set vlan info.

Parameters

  link | Link object of type bridge

Returns
  0 on success or negative error code
  -NLE_OPNOTSUP Link is not a bridge

Definition at line 1485 of file bridge.c.

## ◆ rtnl_link_bridge_set_port_vlan_map_range()

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.

Parameters

  link | Link object of type bridge
  start | Start of membership range.
  end | End of membership range.
  untagged | Set membership range to be untagged.

This will set the vlan membership range for a bridge port. This will unset the untagged membership if untagged is false. Supported range is 1-4094

Returns
  0 on success or negative error code
  -NLE_NOATTR if port vlan attribute not present
  -NLE_OPNOTSUP Link is not a bridge
  -NLE_INVAL range is not in supported range.

Definition at line 1517 of file bridge.c.

## ◆ rtnl_link_bridge_unset_port_vlan_map_range()

int rtnl_link_bridge_unset_port_vlan_map_range | ( | struct rtnl_link * | link,
|  | uint16_t | start,
|  | uint16_t | end )

Unset port vlan membership range.

Parameters

  link | Link object of type bridge
  start | Start of membership range.
  end | End of membership range.

This will unset the vlan membership range for a bridge port for both tagged and untagged membership. Supported range is 1-4094

Returns
  0 on success or negative error code
  -NLE_NOATTR if port vlan attribute not present
  -NLE_OPNOTSUP Link is not a bridge
  -NLE_INVAL range is not in supported range.

Definition at line 1558 of file bridge.c.

## ◆ rtnl_link_bridge_set_port_vlan_pvid()

int rtnl_link_bridge_set_port_vlan_pvid | ( | struct rtnl_link * | link,
|  | uint16_t | pvid )

Set port primary vlan id.

Parameters

  link | Link object of type bridge
  pvid | PVID to set.
  untagged | Set vlan id to be untagged.

This will set the primary vlan id for a bridge port. Supported range is 0-4094, Setting pvid to 0 will unset it. You will most likely want to set/unset pvid in the vlan map.

See also
  rtnl_link_bridge_set_port_vlan_map_range()
  rtnl_link_bridge_unset_port_vlan_map_range()

Returns
  0 on success or negative error code
  -NLE_NOATTR if port vlan attribute not present
  -NLE_OPNOTSUP Link is not a bridge
  -NLE_INVAL PVID is above supported range.

Definition at line 1597 of file bridge.c.

## ◆ rtnl_link_bridge_pvid()

int rtnl_link_bridge_pvid | ( | struct rtnl_link * | link | ) |

Definition at line 1618 of file bridge.c.

## ◆ rtnl_link_bridge_has_vlan()

int rtnl_link_bridge_has_vlan | ( | struct rtnl_link * | link | ) |

Definition at line 1631 of file bridge.c.

## ◆ rtnl_link_bridge_get_port_vlan()

struct rtnl_link_bridge_vlan * rtnl_link_bridge_get_port_vlan | ( | struct rtnl_link * | link | ) |

Definition at line 1652 of file bridge.c.

## ◆ rtnl_link_bridge_set_mst_port_state()

int rtnl_link_bridge_set_mst_port_state | ( | struct rtnl_link * | link,
|  | uint16_t | instance,
|  | uint8_t | state )

Set the Multiple Spanning Tree (MST) port state for a given MST instance.

Parameters

  link | Link object of type bridge
  instance | MST instance number
  state | Port state to set (BR_STATE_*)

Returns
  0 on success or a negative error code
  -NLE_INVAL link is NULL
  -NLE_OPNOTSUP Link is not a bridge
  -NLE_NOMEM Memory allocation failed

Definition at line 1677 of file bridge.c.

## ◆ rtnl_link_bridge_get_mst_port_state()

int rtnl_link_bridge_get_mst_port_state | ( | struct rtnl_link * | link,
|  | uint16_t | instance )

Get the Multiple Spanning Tree (MST) port state for a given MST instance.

Parameters

  link | Link object of type bridge
  instance | MST instance number

Returns
  The state (BR_STATE_*) on success, or a negative error code
  -NLE_INVAL link is NULL
  -NLE_OPNOTSUP Link is not a bridge
  -NLE_OBJ_NOTFOUND MST instance not found

Definition at line 1720 of file bridge.c.

## ◆ rtnl_link_bridge_del_mst_port_state()

int rtnl_link_bridge_del_mst_port_state | ( | struct rtnl_link * | link,
|  | uint16_t | instance )

Delete the Multiple Spanning Tree (MST) port state for a given MST instance.

Parameters

  link | Link object of type bridge
  instance | MST instance number

Returns
  0 on success or a negative error code
  -NLE_INVAL link is NULL
  -NLE_OPNOTSUP Link is not a bridge
  -NLE_OBJ_NOTFOUND MST instance not found

Definition at line 1753 of file bridge.c.

## ◆ rtnl_link_bridge_clear_mst_port_state_info()

int rtnl_link_bridge_clear_mst_port_state_info | ( | struct rtnl_link * | link | ) |

Delete all Multiple Spanning Tree (MST) port state information.

Parameters

  link | Link object of type bridge

Returns
  0 on success or a negative error code
  -NLE_INVAL link is NULL
  -NLE_OPNOTSUP Link is not a bridge

Definition at line 1789 of file bridge.c.

## ◆ rtnl_link_bridge_foreach_mst_entry()

int rtnl_link_bridge_foreach_mst_entry | ( | struct rtnl_link * | link,
|  | void(* | cb )(uint16_t instance, uint8_t state, void *arg),
|  | void * | arg )

Iterate over all Multiple Spanning Tree (MST) port state entries.

Parameters

  link | Link object of type bridge
  cb | Callback function
  arg | User provided data argument to pass to the callback function

The callback function is called for each MST entry. It is passed the MST instance ID, state (BR_STATE_*), and an optional user provided data argument. MST entries should not be added or removed by the callback function.

Returns
  0 on success or a negative error code
  -NLE_INVAL link or cb is NULL
  -NLE_OPNOTSUP Link is not a bridge

Definition at line 1823 of file bridge.c.

## ◆ rtnl_link_bridge_set_ageing_time()

void rtnl_link_bridge_set_ageing_time | ( | struct rtnl_link * | link,
|  | uint32_t | ageing_time )

Set ageing time for dynamic forwarding entries.

Parameters

  link | Link object of type bridge
  ageing_time | Interval to set.

See also
  rtnl_link_bridge_get_ageing_time()

Returns
  void

Definition at line 337 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_ageing_time()

int rtnl_link_bridge_get_ageing_time | ( | struct rtnl_link * | link,
|  | uint32_t * | ageing_time )

Get ageing time for dynamic forwarding entries.

Parameters

  link | Link object of type bridge
  ageing_time | Output argument.

See also
  rtnl_link_bridge_set_ageing_time()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 359 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_vlan_filtering()

void rtnl_link_bridge_set_vlan_filtering | ( | struct rtnl_link * | link,
|  | uint8_t | vlan_filtering )

Set VLAN filtering flag.

Parameters

  link | Link object of type bridge
  vlan_filtering | VLAN_filtering boolean flag to set.

See also
  rtnl_link_bridge_get_vlan_filtering()

Returns
  void

Definition at line 386 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_vlan_filtering()

int rtnl_link_bridge_get_vlan_filtering | ( | struct rtnl_link * | link,
|  | uint8_t * | vlan_filtering )

Get VLAN filtering flag.

Parameters

  link | Link object of type bridge
  vlan_filtering | Output argument.

See also
  rtnl_link_bridge_set_vlan_filtering()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 409 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_vlan_protocol()

void rtnl_link_bridge_set_vlan_protocol | ( | struct rtnl_link * | link,
|  | uint16_t | vlan_protocol )

Set VLAN protocol.

Parameters

  link | Link object of type bridge
  vlan_protocol | VLAN protocol to set. The protocol numbers is in host byte order.

See also
  rtnl_link_bridge_get_vlan_protocol()

Returns
  void

Definition at line 436 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_vlan_protocol()

int rtnl_link_bridge_get_vlan_protocol | ( | struct rtnl_link * | link,
|  | uint16_t * | vlan_protocol )

Get VLAN protocol.

Parameters

  link | Link object of type bridge
  vlan_protocol | Output argument. The protocol number is in host byte order.

See also
  rtnl_link_bridge_set_vlan_protocol()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 459 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_vlan_default_pvid()

void rtnl_link_bridge_set_vlan_default_pvid | ( | struct rtnl_link * | link,
|  | uint16_t | default_pvid )

Set VLAN default pvid.

Parameters

  link | Link object of type bridge
  default | pvid VLAN default pvid to set.

See also
  rtnl_link_bridge_get_vlan_default_pvid()

Returns
  void

Definition at line 486 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_vlan_default_pvid()

int rtnl_link_bridge_get_vlan_default_pvid | ( | struct rtnl_link * | link,
|  | uint16_t * | default_pvid )

Get VLAN default pvid.

Parameters

  link | Link object of type bridge
  default_pvid | Output argument.

See also
  rtnl_link_bridge_set_vlan_default_pvid()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 509 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_vlan_stats_enabled()

void rtnl_link_bridge_set_vlan_stats_enabled | ( | struct rtnl_link * | link,
|  | uint8_t | vlan_stats_enabled )

Set VLAN stats enabled flag.

Parameters

  link | Link object of type bridge
  vlan_stats_enabled | VLAN stats enabled flag to set

See also
  rtnl_link_bridge_get_vlan_stats_enabled()

Returns
  void

Definition at line 536 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_vlan_stats_enabled()

int rtnl_link_bridge_get_vlan_stats_enabled | ( | struct rtnl_link * | link,
|  | uint8_t * | vlan_stats_enabled )

Get VLAN stats enabled flag.

Parameters

  link | Link object of type bridge
  vlan_stats_enabled | Output argument.

See also
  rtnl_link_bridge_set_vlan_stats_enabled()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 559 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_nf_call_iptables()

void rtnl_link_bridge_set_nf_call_iptables | ( | struct rtnl_link * | link,
|  | uint8_t | call_enabled )

Set call enabled flag for passing IPv4 traffic to iptables.

Parameters

  link | Link object of type bridge
  call_enabled | call enabled boolean flag to set.

See also
  rtnl_link_bridge_get_nf_call_iptables()

Returns
  void

Definition at line 586 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_nf_call_iptables()

int rtnl_link_bridge_get_nf_call_iptables | ( | struct rtnl_link * | link,
|  | uint8_t * | call_enabled )

Get call enabled flag for passing IPv4 traffic to iptables.

Parameters

  link | Link object of type bridge
  call_enabled | Output argument.

See also
  rtnl_link_bridge_set_nf_call_iptables()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 609 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_nf_call_ip6tables()

void rtnl_link_bridge_set_nf_call_ip6tables | ( | struct rtnl_link * | link,
|  | uint8_t | call_enabled )

Set call enabled flag for passing IPv6 traffic to ip6tables.

Parameters

  link | Link object of type bridge
  call_enabled | call enabled boolean flag to set.

See also
  rtnl_link_bridge_get_nf_call_ip6tables()

Returns
  void

Definition at line 636 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_nf_call_ip6tables()

int rtnl_link_bridge_get_nf_call_ip6tables | ( | struct rtnl_link * | link,
|  | uint8_t * | call_enabled )

Get call enabled flag for passing IPv6 traffic to iptables.

Parameters

  link | Link object of type bridge
  call_enabled | Output argument.

See also
  rtnl_link_bridge_set_nf_call_ip6tables()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 659 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_nf_call_arptables()

void rtnl_link_bridge_set_nf_call_arptables | ( | struct rtnl_link * | link,
|  | uint8_t | call_enabled )

Set call enabled flag for passing ARP traffic to arptables.

Parameters

  link | Link object of type bridge
  call_enabled | call enabled boolean flag to set.

See also
  rtnl_link_bridge_get_nf_call_arptables()

Returns
  void

Definition at line 686 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_nf_call_arptables()

int rtnl_link_bridge_get_nf_call_arptables | ( | struct rtnl_link * | link,
|  | uint8_t * | call_enabled )

Get call enabled flag for passing ARP traffic to arptables.

Parameters

  link | Link object of type bridge
  call_enabled | Output argument.

See also
  rtnl_link_bridge_set_nf_call_arptables()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 709 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_stp_state()

void rtnl_link_bridge_set_stp_state | ( | struct rtnl_link * | link,
|  | uint32_t | stp_state )

Set STP state.

Parameters

  link | Link object of type bridge
  stp_state | STP state to set. Typically 0 or 1.

See also
  rtnl_link_bridge_get_stp_state()

Returns
  void

Definition at line 736 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_stp_state()

int rtnl_link_bridge_get_stp_state | ( | struct rtnl_link * | link,
|  | uint32_t * | stp_state )

Get STP state.

Parameters

  link | Link object of type bridge
  stp_state | Output argument.

See also
  rtnl_link_bridge_set_stp_state()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 758 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_mcast_router()

void rtnl_link_bridge_set_mcast_router | ( | struct rtnl_link * | link,
|  | uint8_t | type )

Set multicast router type.

Parameters

  link | Link object of type bridge
  type | Multicast router type (MDB_RTR_TYPE_*)

See also
  rtnl_link_bridge_get_mcast_router()

Returns
  void

Definition at line 783 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_mcast_router()

int rtnl_link_bridge_get_mcast_router | ( | struct rtnl_link * | link,
|  | uint8_t * | type )

Get multicast router type.

Parameters

  link | Link object of type bridge
  type | Output argument.

See also
  rtnl_link_bridge_set_mcast_router()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 805 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_mcast_snooping()

void rtnl_link_bridge_set_mcast_snooping | ( | struct rtnl_link * | link,
|  | uint8_t | value )

Set multicast snooping.

Parameters

  link | Link object of type bridge
  value | Value to set. Typically 0 or 1.

See also
  rtnl_link_bridge_get_mcast_snooping()

Returns
  void

Definition at line 830 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_mcast_snooping()

int rtnl_link_bridge_get_mcast_snooping | ( | struct rtnl_link * | link,
|  | uint8_t * | value )

Get multicast snooping value.

Parameters

  link | Link object of type bridge
  value | Output argument.

See also
  rtnl_link_bridge_set_mcast_snooping()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 852 of file bridge_info.c.

## ◆ rtnl_link_bridge_set_boolopt()

int rtnl_link_bridge_set_boolopt | ( | struct rtnl_link * | link,
|  | int | opt,
|  | int | value )

Set a the value of a boolopt.

Parameters

  link | Link object of type bridge
  opt | Option to modify (BR_BOOLOPT_*)
  value | Value to set the option to. 0 or 1.

See also
  rtnl_link_bridge_get_boolopt()

Returns
  Zero on success, otherwise a negative error code.

Return values

  -NLE_INVAL |

Definition at line 879 of file bridge_info.c.

## ◆ rtnl_link_bridge_get_boolopt()

int rtnl_link_bridge_get_boolopt | ( | struct rtnl_link * | link,
|  | int | opt )

Get the value of a boolopt.

Parameters

  link | Link object of type bridge
  opt | Option to get (BR_BOOLOPT_*).

See also
  rtnl_link_bridge_set_boolopt()

Returns
  The value of the boolopt (0 or 1), otherwise a negative error code.

Return values

  -NLE_NOATTR |
  -NLE_INVAL |

Definition at line 913 of file bridge_info.c.