libnl 3.7.0

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 IS_BRIDGE_INFO_ASSERT(link)
 

Enumerations

enum  rtnl_link_bridge_flags {
  RTNL_BRIDGE_HAIRPIN_MODE = 0x0001 ,
  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
}
 Bridge flags. More...
 

Functions

struct rtnl_linkrtnl_link_bridge_alloc (void)
 Allocate link object of type bridge. More...
 
int rtnl_link_bridge_add (struct nl_sock *sk, const char *name)
 Create a new kernel bridge device. More...
 
int rtnl_link_is_bridge (struct rtnl_link *link)
 Check if a link is a bridge. More...
 
int rtnl_link_bridge_has_ext_info (struct rtnl_link *link)
 Check if bridge has extended information. More...
 
int rtnl_link_bridge_set_port_state (struct rtnl_link *link, uint8_t state)
 Set Spanning Tree Protocol (STP) port state. More...
 
int rtnl_link_bridge_get_port_state (struct rtnl_link *link)
 Get Spanning Tree Protocol (STP) port state. More...
 
int rtnl_link_bridge_set_priority (struct rtnl_link *link, uint16_t prio)
 Set priority. More...
 
int rtnl_link_bridge_get_priority (struct rtnl_link *link)
 Get priority. More...
 
int rtnl_link_bridge_set_cost (struct rtnl_link *link, uint32_t cost)
 Set Spanning Tree Protocol (STP) path cost. More...
 
int rtnl_link_bridge_get_cost (struct rtnl_link *link, uint32_t *cost)
 Get Spanning Tree Protocol (STP) path cost. More...
 
int rtnl_link_bridge_unset_flags (struct rtnl_link *link, unsigned int flags)
 Unset flags. More...
 
int rtnl_link_bridge_set_flags (struct rtnl_link *link, unsigned int flags)
 Set flags. More...
 
int rtnl_link_bridge_get_flags (struct rtnl_link *link)
 Get flags. More...
 
int rtnl_link_bridge_set_self (struct rtnl_link *link)
 Set link change type to self. More...
 
int rtnl_link_bridge_get_hwmode (struct rtnl_link *link, uint16_t *hwmode)
 Get hardware mode. More...
 
int rtnl_link_bridge_set_hwmode (struct rtnl_link *link, uint16_t hwmode)
 Set hardware mode. More...
 
int rtnl_link_bridge_pvid (struct rtnl_link *link)
 
int rtnl_link_bridge_has_vlan (struct rtnl_link *link)
 
struct rtnl_link_bridge_vlanrtnl_link_bridge_get_port_vlan (struct rtnl_link *link)
 
void rtnl_link_bridge_set_vlan_filtering (struct rtnl_link *link, uint8_t vlan_filtering)
 Set VLAN filtering flag. More...
 
int rtnl_link_bridge_get_vlan_filtering (struct rtnl_link *link, uint8_t *vlan_filtering)
 Get VLAN filtering flag. More...
 
void rtnl_link_bridge_set_vlan_protocol (struct rtnl_link *link, uint16_t vlan_protocol)
 Set VLAN protocol. More...
 
int rtnl_link_bridge_get_vlan_protocol (struct rtnl_link *link, uint16_t *vlan_protocol)
 Get VLAN protocol. More...
 
void rtnl_link_bridge_set_vlan_stats_enabled (struct rtnl_link *link, uint8_t vlan_stats_enabled)
 Set VLAN stats enabled flag. More...
 
int rtnl_link_bridge_get_vlan_stats_enabled (struct rtnl_link *link, uint8_t *vlan_stats_enabled)
 Get VLAN stats enabled flag. More...
 

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)
 

Detailed Description

Macro Definition Documentation

◆ VLAN_VID_MASK

#define VLAN_VID_MASK   0x0fff /* VLAN Identifier */

Definition at line 22 of file bridge.c.

◆ BRIDGE_ATTR_VLAN_FILTERING

#define BRIDGE_ATTR_VLAN_FILTERING   (1 << 0)

Definition at line 18 of file bridge_info.c.

◆ BRIDGE_ATTR_VLAN_PROTOCOL

#define BRIDGE_ATTR_VLAN_PROTOCOL   (1 << 1)

Definition at line 19 of file bridge_info.c.

◆ BRIDGE_ATTR_VLAN_STATS_ENABLED

#define BRIDGE_ATTR_VLAN_STATS_ENABLED   (1 << 2)

Definition at line 20 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 136 of file bridge_info.c.

Enumeration Type Documentation

◆ 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 458 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
sknetlink socket
namename 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 484 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
linkLink object
Returns
1 if the link is a bridge, 0 otherwise.

Definition at line 507 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
linkLink 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:

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

Definition at line 526 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
linkLink object of type bridge
stateNew 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_OPNOTSUPPLink is not a bridge
-NLE_INVALInvalid state value (0..BR_STATE_BLOCKING)

Definition at line 555 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
linkLink 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_OPNOTSUPPLink is not a bridge

Definition at line 579 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
linkLink object of type bridge
prioBridge priority
See also
rtnl_link_bridge_get_priority()
Returns
0 on success or a negative error code.
Return values
-NLE_OPNOTSUPPLink is not a bridge

Definition at line 598 of file bridge.c.

◆ rtnl_link_bridge_get_priority()

int rtnl_link_bridge_get_priority ( struct rtnl_link link)

Get priority.

Parameters
linkLink object of type bridge
See also
rtnl_link_bridge_set_priority()
Returns
0 on success or a negative error code.
Return values
-NLE_OPNOTSUPPLink is not a bridge

Definition at line 619 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
linkLink object of type bridge
costNew STP path cost value
See also
rtnl_link_bridge_get_cost()
Returns
The bridge priority or a negative error code.
Return values
-NLE_OPNOTSUPPLink is not a bridge

Definition at line 638 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
linkLink object of type bridge
costPointer to store STP cost value
See also
rtnl_link_bridge_set_cost()
Returns
0 on success or a negative error code.
Return values
-NLE_OPNOTSUPPLink is not a bridge
-NLE_INVALcost is not a valid pointer

Definition at line 661 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
linkLink object of type bridge
flagsBridging 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_OPNOTSUPPLink is not a bridge

Definition at line 686 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
linkLink object of type bridge
flagsBridging 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
See also
rtnl_link_bridge_unset_flags()
rtnl_link_bridge_get_flags()
Returns
0 on success or a negative error code.
Return values
-NLE_OPNOTSUPPLink is not a bridge

Definition at line 719 of file bridge.c.

◆ rtnl_link_bridge_get_flags()

int rtnl_link_bridge_get_flags ( struct rtnl_link link)

Get flags.

Parameters
linkLink 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_OPNOTSUPPLink is not a bridge

Definition at line 742 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
linkLink 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 762 of file bridge.c.

Referenced by rtnl_link_bridge_set_hwmode().

+ Here is the caller graph for this function:

◆ rtnl_link_bridge_get_hwmode()

int rtnl_link_bridge_get_hwmode ( struct rtnl_link link,
uint16_t *  hwmode 
)

Get hardware mode.

Parameters
linkLink object of type bridge
hwmodeOutput 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 785 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
linkLink object of type bridge
hwmodeHardware 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 818 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 851 of file bridge.c.

◆ rtnl_link_bridge_str2flags()

int rtnl_link_bridge_str2flags ( const char *  name)

Definition at line 856 of file bridge.c.

◆ rtnl_link_bridge_portstate2str()

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

Definition at line 876 of file bridge.c.

◆ rtnl_link_bridge_str2portstate()

int rtnl_link_bridge_str2portstate ( const char *  name)

Definition at line 881 of file bridge.c.

◆ rtnl_link_bridge_hwmode2str()

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

Definition at line 899 of file bridge.c.

◆ rtnl_link_bridge_str2hwmode()

uint16_t rtnl_link_bridge_str2hwmode ( const char *  name)

Definition at line 903 of file bridge.c.

◆ rtnl_link_bridge_pvid()

int rtnl_link_bridge_pvid ( struct rtnl_link link)

Definition at line 910 of file bridge.c.

◆ rtnl_link_bridge_has_vlan()

int rtnl_link_bridge_has_vlan ( struct rtnl_link link)

Definition at line 923 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 944 of file bridge.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
linkLink object of type bridge
vlan_filteringVLAN_filtering boolean flag to set.
See also
rtnl_link_bridge_get_vlan_filtering()
Returns
void

Definition at line 152 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
linkLink object of type bridge
vlan_filteringOutput 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 175 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
linkLink object of type bridge
vlan_protocolVLAN protocol to set. The protocol numbers is in host byte order.
See also
rtnl_link_bridge_get_vlan_protocol()
Returns
void

Definition at line 202 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
linkLink object of type bridge
vlan_protocolOutput 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 225 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
linkLink object of type bridge
vlan_stats_enabledVLAN stats enabled flag to set
See also
rtnl_link_bridge_get_vlan_stats_enabled()
Returns
void

Definition at line 252 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
linkLink object of type bridge
vlan_stats_enabledOutput 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 275 of file bridge_info.c.