libnl 3.11.0

Data Structures

struct  bond_info
 

Macros

#define BOND_HAS_MODE   (1 << 0)
 
#define BOND_HAS_ACTIVE_SLAVE   (1 << 1)
 
#define BOND_HAS_HASHING_TYPE   (1 << 2)
 
#define BOND_HAS_MIIMON   (1 << 3)
 
#define BOND_HAS_MIN_LINKS   (1 << 4)
 
#define IS_BOND_INFO_ASSERT(link)
 

Functions

void rtnl_link_bond_set_activeslave (struct rtnl_link *link, int active_slave)
 Set active slave for bond.
 
int rtnl_link_bond_get_activeslave (struct rtnl_link *link, int *active_slave)
 Get active slave for bond.
 
void rtnl_link_bond_set_mode (struct rtnl_link *link, uint8_t mode)
 Set bond mode.
 
int rtnl_link_bond_get_mode (struct rtnl_link *link, uint8_t *mode)
 Get bond mode.
 
void rtnl_link_bond_set_hashing_type (struct rtnl_link *link, uint8_t type)
 Set hashing type.
 
int rtnl_link_bond_get_hashing_type (struct rtnl_link *link, uint8_t *type)
 Get hashing type.
 
void rtnl_link_bond_set_miimon (struct rtnl_link *link, uint32_t miimon)
 Set MII monitoring interval.
 
int rtnl_link_bond_get_miimon (struct rtnl_link *link, uint32_t *miimon)
 Get MII monitoring interval.
 
void rtnl_link_bond_set_min_links (struct rtnl_link *link, uint32_t min_links)
 Set the minimum number of member ports that must be up before marking the bond device as up.
 
int rtnl_link_bond_get_min_links (struct rtnl_link *link, uint32_t *min_links)
 Get the minimum number of member ports that must be up before marking the bond device as up.
 
struct rtnl_linkrtnl_link_bond_alloc (void)
 Allocate link object of type bond.
 
int rtnl_link_bond_add (struct nl_sock *sock, const char *name, struct rtnl_link *opts)
 Create a new kernel bonding device.
 
int rtnl_link_bond_enslave_ifindex (struct nl_sock *sock, int master, int slave)
 Add a link to a bond (enslave)
 
int rtnl_link_bond_enslave (struct nl_sock *sock, struct rtnl_link *master, struct rtnl_link *slave)
 Add a link to a bond (enslave)
 
int rtnl_link_bond_release_ifindex (struct nl_sock *sock, int slave)
 Release a link from a bond.
 
int rtnl_link_bond_release (struct nl_sock *sock, struct rtnl_link *slave)
 Release a link from a bond.
 

Detailed Description

Link Type Name: "bond"

Bonding Documentation (Netlink Routing Development Guide)

Macro Definition Documentation

◆ BOND_HAS_MODE

#define BOND_HAS_MODE   (1 << 0)

Definition at line 25 of file bonding.c.

◆ BOND_HAS_ACTIVE_SLAVE

#define BOND_HAS_ACTIVE_SLAVE   (1 << 1)

Definition at line 26 of file bonding.c.

◆ BOND_HAS_HASHING_TYPE

#define BOND_HAS_HASHING_TYPE   (1 << 2)

Definition at line 27 of file bonding.c.

◆ BOND_HAS_MIIMON

#define BOND_HAS_MIIMON   (1 << 3)

Definition at line 28 of file bonding.c.

◆ BOND_HAS_MIN_LINKS

#define BOND_HAS_MIN_LINKS   (1 << 4)

Definition at line 29 of file bonding.c.

◆ IS_BOND_INFO_ASSERT

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

Definition at line 196 of file bonding.c.

Function Documentation

◆ rtnl_link_bond_set_activeslave()

void rtnl_link_bond_set_activeslave ( struct rtnl_link * link,
int active_slave )

Set active slave for bond.

Parameters
linkLink object of type bond
activeifindex of active slave to set
Returns
void

Definition at line 210 of file bonding.c.

◆ rtnl_link_bond_get_activeslave()

int rtnl_link_bond_get_activeslave ( struct rtnl_link * link,
int * active_slave )

Get active slave for bond.

Parameters
linkLink object of type bond
active_slaveOutput argument
Returns
Zero on success, otherwise a negative error code.
Return values
-NLE_NOATTR
-NLE_INVAL

Definition at line 230 of file bonding.c.

◆ rtnl_link_bond_set_mode()

void rtnl_link_bond_set_mode ( struct rtnl_link * link,
uint8_t mode )

Set bond mode.

Parameters
linkLink object of type bond
modebond mode to set
Returns
void

Definition at line 254 of file bonding.c.

◆ rtnl_link_bond_get_mode()

int rtnl_link_bond_get_mode ( struct rtnl_link * link,
uint8_t * mode )

Get bond mode.

Parameters
linkLink object of type bond
modeOutput argument
Returns
Zero on success, otherwise a negative error code.
Return values
-NLE_NOATTR
-NLE_INVAL

Definition at line 274 of file bonding.c.

◆ rtnl_link_bond_set_hashing_type()

void rtnl_link_bond_set_hashing_type ( struct rtnl_link * link,
uint8_t type )

Set hashing type.

Parameters
linkLink object of type bond
typebond hashing type to set
Returns
void

Definition at line 298 of file bonding.c.

◆ rtnl_link_bond_get_hashing_type()

int rtnl_link_bond_get_hashing_type ( struct rtnl_link * link,
uint8_t * type )

Get hashing type.

Parameters
linkLink object of type bond
typeOutput argument
Returns
Zero on success, otherwise a negative error code.
Return values
-NLE_NOATTR
-NLE_INVAL

Definition at line 318 of file bonding.c.

◆ rtnl_link_bond_set_miimon()

void rtnl_link_bond_set_miimon ( struct rtnl_link * link,
uint32_t miimon )

Set MII monitoring interval.

Parameters
linkLink object of type bond
miimoninterval in milliseconds
Returns
void

Definition at line 342 of file bonding.c.

◆ rtnl_link_bond_get_miimon()

int rtnl_link_bond_get_miimon ( struct rtnl_link * link,
uint32_t * miimon )

Get MII monitoring interval.

Parameters
linkLink object of type bond
miimonOutput argument
Returns
Zero on success, otherwise a negative error code.
Return values
-NLE_NOATTR
-NLE_INVAL

Definition at line 362 of file bonding.c.

◆ rtnl_link_bond_set_min_links()

void rtnl_link_bond_set_min_links ( struct rtnl_link * link,
uint32_t min_links )

Set the minimum number of member ports that must be up before marking the bond device as up.

Parameters
linkLink object of type bond
min_linksNumber of links
Returns
void

Definition at line 387 of file bonding.c.

◆ rtnl_link_bond_get_min_links()

int rtnl_link_bond_get_min_links ( struct rtnl_link * link,
uint32_t * min_links )

Get the minimum number of member ports that must be up before marking the bond device as up.

Parameters
linkLink object of type bond
min_linksOutput argument.
Returns
Zero on success, otherwise a negative error code.
Return values
-NLE_NOATTR
-NLE_INVAL

Definition at line 407 of file bonding.c.

◆ rtnl_link_bond_alloc()

struct rtnl_link * rtnl_link_bond_alloc ( void )

Allocate link object of type bond.

Returns
Allocated link object or NULL.

Definition at line 429 of file bonding.c.

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

Referenced by rtnl_link_bond_add(), and rtnl_link_bond_enslave_ifindex().

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

◆ rtnl_link_bond_add()

int rtnl_link_bond_add ( struct nl_sock * sock,
const char * name,
struct rtnl_link * opts )

Create a new kernel bonding device.

Parameters
socknetlink socket
namename of bonding device or NULL
optsbonding options (currently unused)

Creates a new bonding device in the kernel. If no name is provided, the kernel will automatically pick a name of the form "type%d" (e.g. bond0, vlan1, etc.)

The opts argument is currently unused. In the future, it may be used to carry additional bonding options to be set when creating the bonding device.

Note
When letting the kernel assign a name, it will become difficult to retrieve the interface afterwards because you have to guess the name the kernel has chosen. It is therefore not recommended to not provide a device name.
See also
rtnl_link_bond_enslave()
rtnl_link_bond_release()
Returns
0 on success or a negative error code

Definition at line 468 of file bonding.c.

References rtnl_link_add(), rtnl_link_bond_alloc(), rtnl_link_get_name(), rtnl_link_put(), and rtnl_link_set_name().

+ Here is the call graph for this function:

◆ rtnl_link_bond_enslave_ifindex()

int rtnl_link_bond_enslave_ifindex ( struct nl_sock * sock,
int master,
int slave )

Add a link to a bond (enslave)

Parameters
socknetlink socket
masterifindex of bonding master
slaveifindex of slave link to add to bond

This function is identical to rtnl_link_bond_enslave() except that it takes interface indices instead of rtnl_link objcets.

See also
rtnl_link_bond_enslave()
Returns
0 on success or a negative error code.

Definition at line 503 of file bonding.c.

References rtnl_link_bond_alloc(), rtnl_link_change(), rtnl_link_get_kernel(), rtnl_link_get_master(), rtnl_link_put(), rtnl_link_set_ifindex(), and rtnl_link_set_master().

Referenced by rtnl_link_bond_enslave(), and rtnl_link_bond_release_ifindex().

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

◆ rtnl_link_bond_enslave()

int rtnl_link_bond_enslave ( struct nl_sock * sock,
struct rtnl_link * master,
struct rtnl_link * slave )

Add a link to a bond (enslave)

Parameters
socknetlink socket
masterbonding master
slaveslave link to add to bond

Constructs a RTM_NEWLINK or RTM_SETLINK message adding the slave to the master and sends the request via the specified netlink socket.

Note
The feature of enslaving/releasing via netlink has only been added recently to the kernel (Feb 2011). Also, the kernel does not signal if the operation is not supported. Therefore this function will verify if the master assignment has changed and will return -NLE_OPNOTSUPP if it did not.
See also
rtnl_link_bond_enslave_ifindex()
rtnl_link_bond_release()
Returns
0 on success or a negative error code.

Definition at line 559 of file bonding.c.

References rtnl_link_bond_enslave_ifindex(), and rtnl_link_get_ifindex().

+ Here is the call graph for this function:

◆ rtnl_link_bond_release_ifindex()

int rtnl_link_bond_release_ifindex ( struct nl_sock * sock,
int slave )

Release a link from a bond.

Parameters
socknetlink socket
slaveslave link to be released

This function is identical to rtnl_link_bond_release() except that it takes an interface index instead of a rtnl_link object.

See also
rtnl_link_bond_release()
Returns
0 on success or a negative error code.

Definition at line 579 of file bonding.c.

References rtnl_link_bond_enslave_ifindex().

Referenced by rtnl_link_bond_release().

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

◆ rtnl_link_bond_release()

int rtnl_link_bond_release ( struct nl_sock * sock,
struct rtnl_link * slave )

Release a link from a bond.

Parameters
socknetlink socket
slaveslave link to be released

Constructs a RTM_NEWLINK or RTM_SETLINK message releasing the slave from its master and sends the request via the specified netlink socket.

Note
The feature of enslaving/releasing via netlink has only been added recently to the kernel (Feb 2011). Also, the kernel does not signal if the operation is not supported. Therefore this function will verify if the master assignment has changed and will return -NLE_OPNOTSUPP if it did not.
See also
rtnl_link_bond_release_ifindex()
rtnl_link_bond_enslave()
Returns
0 on success or a negative error code.

Definition at line 603 of file bonding.c.

References rtnl_link_bond_release_ifindex(), and rtnl_link_get_ifindex().

+ Here is the call graph for this function: