libteam  1.31
Macros | Functions
Libteam core funtions

Macros

#define NETLINK_RCVBUF   196608
 

Functions

TEAM_EXPORT int team_change_handler_register (struct team_handle *th, const struct team_change_handler *handler, void *priv)
 
TEAM_EXPORT int team_change_handler_register_head (struct team_handle *th, const struct team_change_handler *handler, void *priv)
 
TEAM_EXPORT void team_change_handler_unregister (struct team_handle *th, const struct team_change_handler *handler, void *priv)
 
TEAM_EXPORT struct team_handle * team_alloc (void)
 
TEAM_EXPORT int team_create (struct team_handle *th, const char *team_name)
 
TEAM_EXPORT int team_recreate (struct team_handle *th, const char *team_name)
 
TEAM_EXPORT int team_destroy (struct team_handle *th)
 
TEAM_EXPORT int team_init (struct team_handle *th, uint32_t ifindex)
 
TEAM_EXPORT void team_free (struct team_handle *th)
 
TEAM_EXPORT int team_refresh (struct team_handle *th)
 
TEAM_EXPORT void team_set_log_fn (struct team_handle *th, void(*log_fn)(struct team_handle *th, int priority, const char *file, int line, const char *fn, const char *format, va_list args))
 
TEAM_EXPORT int team_get_log_priority (struct team_handle *th)
 
TEAM_EXPORT void team_set_log_priority (struct team_handle *th, int priority)
 
TEAM_EXPORT const struct team_eventfd * team_get_next_eventfd (struct team_handle *th, const struct team_eventfd *eventfd)
 
TEAM_EXPORT int team_get_eventfd_fd (struct team_handle *th, const struct team_eventfd *eventfd)
 
TEAM_EXPORT int team_call_eventfd_handler (struct team_handle *th, const struct team_eventfd *eventfd)
 
TEAM_EXPORT int team_get_event_fd (struct team_handle *th)
 
TEAM_EXPORT int team_handle_events (struct team_handle *th)
 
TEAM_EXPORT int team_check_events (struct team_handle *th)
 
TEAM_EXPORT int team_get_mode_name (struct team_handle *th, char **mode_name)
 
TEAM_EXPORT int team_set_mode_name (struct team_handle *th, const char *mode_name)
 
TEAM_EXPORT int team_get_notify_peers_count (struct team_handle *th, uint32_t *count)
 
TEAM_EXPORT int team_set_notify_peers_count (struct team_handle *th, uint32_t count)
 
TEAM_EXPORT int team_get_notify_peers_interval (struct team_handle *th, uint32_t *interval)
 
TEAM_EXPORT int team_set_notify_peers_interval (struct team_handle *th, uint32_t interval)
 
TEAM_EXPORT int team_get_mcast_rejoin_count (struct team_handle *th, uint32_t *count)
 
TEAM_EXPORT int team_set_mcast_rejoin_count (struct team_handle *th, uint32_t count)
 
TEAM_EXPORT int team_get_mcast_rejoin_interval (struct team_handle *th, uint32_t *interval)
 
TEAM_EXPORT int team_set_mcast_rejoin_interval (struct team_handle *th, uint32_t interval)
 
TEAM_EXPORT int team_get_active_port (struct team_handle *th, uint32_t *ifindex)
 
TEAM_EXPORT int team_set_active_port (struct team_handle *th, uint32_t ifindex)
 
TEAM_EXPORT int team_get_bpf_hash_func (struct team_handle *th, struct sock_fprog *fp)
 
TEAM_EXPORT int team_set_bpf_hash_func (struct team_handle *th, const struct sock_fprog *fp)
 
TEAM_EXPORT int team_set_port_enabled (struct team_handle *th, uint32_t port_ifindex, bool val)
 
TEAM_EXPORT int team_get_port_enabled (struct team_handle *th, uint32_t port_ifindex, bool *enabled)
 
TEAM_EXPORT int team_set_port_user_linkup_enabled (struct team_handle *th, uint32_t port_ifindex, bool val)
 
TEAM_EXPORT int team_get_port_user_linkup (struct team_handle *th, uint32_t port_ifindex, bool *linkup)
 
TEAM_EXPORT int team_set_port_user_linkup (struct team_handle *th, uint32_t port_ifindex, bool linkup)
 
TEAM_EXPORT int team_set_port_queue_id (struct team_handle *th, uint32_t port_ifindex, uint32_t queue_id)
 
TEAM_EXPORT int team_get_port_priority (struct team_handle *th, uint32_t port_ifindex, int32_t *priority)
 
TEAM_EXPORT int team_set_port_priority (struct team_handle *th, uint32_t port_ifindex, int32_t priority)
 
TEAM_EXPORT uint32_t team_ifname2ifindex (struct team_handle *th, const char *ifname)
 
TEAM_EXPORT char * team_ifindex2ifname (struct team_handle *th, uint32_t ifindex, char *ifname, unsigned int maxlen)
 
TEAM_EXPORT int team_port_add (struct team_handle *th, uint32_t port_ifindex)
 
TEAM_EXPORT bool team_is_our_port (struct team_handle *th, uint32_t port_ifindex)
 
TEAM_EXPORT int team_port_remove (struct team_handle *th, uint32_t port_ifindex)
 
TEAM_EXPORT int team_carrier_set (struct team_handle *th, bool carrier_up)
 
TEAM_EXPORT int team_carrier_get (struct team_handle *th, bool *carrier_up)
 
TEAM_EXPORT int team_hwaddr_set (struct team_handle *th, uint32_t ifindex, const char *addr, unsigned int addr_len)
 
TEAM_EXPORT int team_hwaddr_get (struct team_handle *th, uint32_t ifindex, char *addr, unsigned int addr_len)
 
TEAM_EXPORT int team_hwaddr_len_get (struct team_handle *th, uint32_t ifindex)
 
TEAM_EXPORT struct team_ifinfo * team_get_ifinfo (struct team_handle *th)
 

Detailed Description

Libteam core funtions

Header

#include <team.h>

Function Documentation

◆ team_alloc()

TEAM_EXPORT struct team_handle* team_alloc ( void  )

Allocates library context, sockets, initializes rtnl netlink connection.

Returns
New libteam library context.

◆ team_call_eventfd_handler()

TEAM_EXPORT int team_call_eventfd_handler ( struct team_handle *  th,
const struct team_eventfd *  eventfd 
)
Parameters
thlibteam library context
eventfdeventfd structure

Call eventfd handler.

Returns
Zero on success or negative number in case of an error.
Deprecated:
Use of this function is deprecated. User should use team_handle_events() funstion instead.

◆ team_carrier_get()

TEAM_EXPORT int team_carrier_get ( struct team_handle *  th,
bool *  carrier_up 
)
Parameters
thlibteam library context
carrier_upwhere the carrier state will be stored

Gets carrier status of the master network interface

Returns
Zero on success or negative number in case of an error.

◆ team_carrier_set()

TEAM_EXPORT int team_carrier_set ( struct team_handle *  th,
bool  carrier_up 
)
Parameters
thlibteam library context
carrier_upcarrier state to be set

Sets carrier status for the master network interface

Returns
Zero on success or negative number in case of an error.

◆ team_change_handler_register()

TEAM_EXPORT int team_change_handler_register ( struct team_handle *  th,
const struct team_change_handler *  handler,
void *  priv 
)
Parameters
thlibteam library context
handlerevent handler structure
privevent handler func private data

Registers custom handler structure which defines a function which going to be called on defined events. The handler will be added at the end of the list.

Returns
Zero on success or negative number in case of an error.

◆ team_change_handler_register_head()

TEAM_EXPORT int team_change_handler_register_head ( struct team_handle *  th,
const struct team_change_handler *  handler,
void *  priv 
)
Parameters
thlibteam library context
handlerevent handler structure
privevent handler func private data

Registers custom handler structure which defines a function which going to be called on defined events. The handler will be added at the start of the list.

Returns
Zero on success or negative number in case of an error.

◆ team_change_handler_unregister()

TEAM_EXPORT void team_change_handler_unregister ( struct team_handle *  th,
const struct team_change_handler *  handler,
void *  priv 
)
Parameters
thlibteam library context
handlerevent handler structure
privevent handler func private data

Unregisters custom handler structure.

◆ team_check_events()

TEAM_EXPORT int team_check_events ( struct team_handle *  th)
Parameters
thlibteam library context

Check for events pending to be processed on event socket and process them one by one. This is safe to be called even if no data present on event socket file descriptor.

Returns
Zero on success or negative number in case of an error.

◆ team_create()

TEAM_EXPORT int team_create ( struct team_handle *  th,
const char *  team_name 
)
Parameters
thlibteam library context
team_namenew team device name

Create new team device by given name. If NULL is passed, name will be allocated automatically.

Returns
Zero on success or negative number in case of an error.

◆ team_destroy()

TEAM_EXPORT int team_destroy ( struct team_handle *  th)
Parameters
thlibteam library context

Destroy current initialized team device.

Returns
Zero on success or negative number in case of an error.

◆ team_free()

TEAM_EXPORT void team_free ( struct team_handle *  th)
Parameters
thlibteam library context

Do library context cleanup.

◆ team_get_active_port()

TEAM_EXPORT int team_get_active_port ( struct team_handle *  th,
uint32_t *  ifindex 
)
Parameters
thlibteam library context
ifindexwhere the port interface index will be stored

Get interface index of active port. Note this is possible only if team is in "activebackup" mode.

Returns
Zero on success or negative number in case of an error.

◆ team_get_bpf_hash_func()

TEAM_EXPORT int team_get_bpf_hash_func ( struct team_handle *  th,
struct sock_fprog *  fp 
)
Parameters
thlibteam library context
fpwhere current BPF instruction set will be stored

Get tx port selecting hash function. Note this is possible only if team is in "loadbalance" mode.

Returns
Zero on success or negative number in case of an error.

◆ team_get_event_fd()

TEAM_EXPORT int team_get_event_fd ( struct team_handle *  th)
Parameters
thlibteam library context

Get event filedesctiptor.

Returns
fd.

◆ team_get_eventfd_fd()

TEAM_EXPORT int team_get_eventfd_fd ( struct team_handle *  th,
const struct team_eventfd *  eventfd 
)
Parameters
thlibteam library context
eventfdeventfd structure

Get eventfd filedesctiptor.

Returns
fd.
Deprecated:
Use of this function is deprecated. User should use team_get_event_fd() funstion instead.

◆ team_get_ifinfo()

TEAM_EXPORT struct team_ifinfo* team_get_ifinfo ( struct team_handle *  th)
Parameters
thlibteam library context

Get team device rtnetlink interface info.

Returns
Pointer to appropriate team_ifinfo structure.

◆ team_get_log_priority()

TEAM_EXPORT int team_get_log_priority ( struct team_handle *  th)
Parameters
thlibteam library context
Returns
The current logging priority.

◆ team_get_mcast_rejoin_count()

TEAM_EXPORT int team_get_mcast_rejoin_count ( struct team_handle *  th,
uint32_t *  count 
)
Parameters
thlibteam library context
countwhere the count will be stored

Get number of bursts of multicast group rejoins to be sent.

Returns
Zero on success or negative number in case of an error.

◆ team_get_mcast_rejoin_interval()

TEAM_EXPORT int team_get_mcast_rejoin_interval ( struct team_handle *  th,
uint32_t *  interval 
)
Parameters
thlibteam library context
intervalwhere the interval will be stored

Get interval (in milliseconds) in which bursts of rejoins are sent.

Returns
Zero on success or negative number in case of an error.

◆ team_get_mode_name()

TEAM_EXPORT int team_get_mode_name ( struct team_handle *  th,
char **  mode_name 
)
Parameters
thlibteam library context
mode_namewhere the mode name will be stored

Get name of currect mode.

Returns
Zero on success or negative number in case of an error.

◆ team_get_next_eventfd()

TEAM_EXPORT const struct team_eventfd* team_get_next_eventfd ( struct team_handle *  th,
const struct team_eventfd *  eventfd 
)
Parameters
thlibteam library context
eventfdeventfd structure

Get next eventfd in list.

Returns
eventfd next to eventfd passed.
Deprecated:
Use of this function is deprecated.

◆ team_get_notify_peers_count()

TEAM_EXPORT int team_get_notify_peers_count ( struct team_handle *  th,
uint32_t *  count 
)
Parameters
thlibteam library context
countwhere the count will be stored

Get number of bursts of NAs and ARPs notifications sent to peers.

Returns
Zero on success or negative number in case of an error.

◆ team_get_notify_peers_interval()

TEAM_EXPORT int team_get_notify_peers_interval ( struct team_handle *  th,
uint32_t *  interval 
)
Parameters
thlibteam library context
intervalwhere the interval will be stored

Get interval (in milliseconds) in which bursts of NAs and ARPs notifications are sent to peers.

Returns
Zero on success or negative number in case of an error.

◆ team_get_port_enabled()

TEAM_EXPORT int team_get_port_enabled ( struct team_handle *  th,
uint32_t  port_ifindex,
bool *  enabled 
)
Parameters
thlibteam library context
port_ifindexport interface index
enabledwhere the enabled state will be stored

Gets enabled state for port identified by port_ifindex

Returns
Zero on success or negative number in case of an error.

◆ team_get_port_priority()

TEAM_EXPORT int team_get_port_priority ( struct team_handle *  th,
uint32_t  port_ifindex,
int32_t *  priority 
)
Parameters
thlibteam library context
port_ifindexport interface index
prioritywhere the port priority will be stored

Gets priority for port identified by port_ifindex

Returns
Zero on success or negative number in case of an error.

◆ team_get_port_user_linkup()

TEAM_EXPORT int team_get_port_user_linkup ( struct team_handle *  th,
uint32_t  port_ifindex,
bool *  linkup 
)
Parameters
thlibteam library context
port_ifindexport interface index
linkupwhere the port user link state will be stored

Gets user linkup for port identified by port_ifindex

Returns
Zero on success or negative number in case of an error.

◆ team_handle_events()

TEAM_EXPORT int team_handle_events ( struct team_handle *  th)
Parameters
thlibteam library context

Handler events which happened on event filedescriptor.

Returns
Zero on success or negative number in case of an error.

◆ team_hwaddr_get()

TEAM_EXPORT int team_hwaddr_get ( struct team_handle *  th,
uint32_t  ifindex,
char *  addr,
unsigned int  addr_len 
)
Parameters
thlibteam library context
ifindexinterface index
addraddress will be written here
addr_lenlength of addr buffer

Gets hardware address (MAC) of network interface by given interface index.

Returns
Zero on success or negative number in case of an error.

◆ team_hwaddr_len_get()

TEAM_EXPORT int team_hwaddr_len_get ( struct team_handle *  th,
uint32_t  ifindex 
)
Parameters
thlibteam library context
ifindexinterface index

Gets length of hardware address (MAC) of network interface by given interface index.

Returns
Number of bytes on success or negative number in case of an error.

◆ team_hwaddr_set()

TEAM_EXPORT int team_hwaddr_set ( struct team_handle *  th,
uint32_t  ifindex,
const char *  addr,
unsigned int  addr_len 
)
Parameters
thlibteam library context
ifindexinterface index
addraddress to be set
addr_lenlength of addr

Sets given hardware address (MAC) for network interface by given interface index.

Returns
Zero on success or negative number in case of an error.

◆ team_ifindex2ifname()

TEAM_EXPORT char* team_ifindex2ifname ( struct team_handle *  th,
uint32_t  ifindex,
char *  ifname,
unsigned int  maxlen 
)
Parameters
thlibteam library context
ifindexinterface index
ifnamewhere the interface name will be stored
maxlenlength of ifname buffer

Looks up for interface of given index and gets its name.

Returns
NULL if interface is not found, ifname otherwise.

◆ team_ifname2ifindex()

TEAM_EXPORT uint32_t team_ifname2ifindex ( struct team_handle *  th,
const char *  ifname 
)

SECTION: RTNL helpers

Parameters
thlibteam library context
ifnameinterface name

Looks up for interface of given name and gets its index.

Returns
Zero if interface is not found, interface index as reffered by in kernel otherwise.

◆ team_init()

TEAM_EXPORT int team_init ( struct team_handle *  th,
uint32_t  ifindex 
)
Parameters
thlibteam library context
ifindexteam device interface index

Do library context initialization. Sets up team generic netlink connection.

Returns
Zero on success or negative number in case of an error.

◆ team_is_our_port()

TEAM_EXPORT bool team_is_our_port ( struct team_handle *  th,
uint32_t  port_ifindex 
)
Parameters
thlibteam library context
port_ifindexport interface index

Find out if interface is port of this team.

Returns
True if interface is port of this team.

◆ team_port_add()

TEAM_EXPORT int team_port_add ( struct team_handle *  th,
uint32_t  port_ifindex 
)
Parameters
thlibteam library context
port_ifindexport interface index

Adds port into team.

Returns
Zero on success or negative number in case of an error.

◆ team_port_remove()

TEAM_EXPORT int team_port_remove ( struct team_handle *  th,
uint32_t  port_ifindex 
)
Parameters
thlibteam library context
port_ifindexport interface index

Removes port from team.

Returns
Zero on success or negative number in case of an error.

◆ team_recreate()

TEAM_EXPORT int team_recreate ( struct team_handle *  th,
const char *  team_name 
)
Parameters
thlibteam library context
team_namenew team device name

Does the same as team_create only if device with team_name already exists it will be deleted first.

Returns
Zero on success or negative number in case of an error.

◆ team_refresh()

TEAM_EXPORT int team_refresh ( struct team_handle *  th)
Parameters
thlibteam library context

This is used for user to refresh internal lists and call event handlers.

Returns
Zero on success or negative number in case of an error.

◆ team_set_active_port()

TEAM_EXPORT int team_set_active_port ( struct team_handle *  th,
uint32_t  ifindex 
)
Parameters
thlibteam library context
ifindexinterface index of new active port

Set new active port by given ifindex. Note this is possible only if team is in "activebackup" mode.

Returns
Zero on success or negative number in case of an error.

◆ team_set_bpf_hash_func()

TEAM_EXPORT int team_set_bpf_hash_func ( struct team_handle *  th,
const struct sock_fprog *  fp 
)
Parameters
thlibteam library context
fpprepared BPF instruction set

Set tx port selecting hash function. Note this is possible only if team is in "loadbalance" mode. Passing NULL clears current function.

Returns
Zero on success or negative number in case of an error.

◆ team_set_log_fn()

TEAM_EXPORT void team_set_log_fn ( struct team_handle *  th,
void(*)(struct team_handle *th, int priority, const char *file, int line, const char *fn, const char *format, va_list args)  log_fn 
)
Parameters
thlibteam library context
log_fnfunction to be called for logging messages

The built-in logging writes to stderr. It can be overridden by a custom function, to plug log messages into the user's logging functionality.

◆ team_set_log_priority()

TEAM_EXPORT void team_set_log_priority ( struct team_handle *  th,
int  priority 
)
Parameters
thlibteam library context
prioritythe new logging priority

Set the current logging priority. The value controls which messages are logged.

◆ team_set_mcast_rejoin_count()

TEAM_EXPORT int team_set_mcast_rejoin_count ( struct team_handle *  th,
uint32_t  count 
)
Parameters
thlibteam library context
countnumber of bursts

Set number of bursts of multicast group rejoins to be sent.

Returns
Zero on success or negative number in case of an error.

◆ team_set_mcast_rejoin_interval()

TEAM_EXPORT int team_set_mcast_rejoin_interval ( struct team_handle *  th,
uint32_t  interval 
)
Parameters
thlibteam library context
intervalinterval of bursts

Set interval (in milliseconds) in which bursts of rejoins are sent.

Returns
Zero on success or negative number in case of an error.

◆ team_set_mode_name()

TEAM_EXPORT int team_set_mode_name ( struct team_handle *  th,
const char *  mode_name 
)
Parameters
thlibteam library context
mode_namename of mode to be set

Set team mode.

Returns
Zero on success or negative number in case of an error.

◆ team_set_notify_peers_count()

TEAM_EXPORT int team_set_notify_peers_count ( struct team_handle *  th,
uint32_t  count 
)
Parameters
thlibteam library context
countnumber of bursts

Set number of bursts of NAs and ARPs notifications sent to peers.

Returns
Zero on success or negative number in case of an error.

◆ team_set_notify_peers_interval()

TEAM_EXPORT int team_set_notify_peers_interval ( struct team_handle *  th,
uint32_t  interval 
)
Parameters
thlibteam library context
intervalinterval of bursts

Set interval (in milliseconds) in which bursts of NAs and ARPs notifications will be sent to peers.

Returns
Zero on success or negative number in case of an error.

◆ team_set_port_enabled()

TEAM_EXPORT int team_set_port_enabled ( struct team_handle *  th,
uint32_t  port_ifindex,
bool  val 
)
Parameters
thlibteam library context
port_ifindexport interface index
valboolean value

Enables or disable port identified by port_ifindex

Returns
Zero on success or negative number in case of an error.

◆ team_set_port_priority()

TEAM_EXPORT int team_set_port_priority ( struct team_handle *  th,
uint32_t  port_ifindex,
int32_t  priority 
)
Parameters
thlibteam library context
port_ifindexport interface index
prioritydesired priority

Sets priority for port identified by port_ifindex

Returns
Zero on success or negative number in case of an error.

◆ team_set_port_queue_id()

TEAM_EXPORT int team_set_port_queue_id ( struct team_handle *  th,
uint32_t  port_ifindex,
uint32_t  queue_id 
)
Parameters
thlibteam library context
port_ifindexport interface index
queue_iddesired queue id

Sets queue id for port identified by port_ifindex

Returns
Zero on success or negative number in case of an error.

◆ team_set_port_user_linkup()

TEAM_EXPORT int team_set_port_user_linkup ( struct team_handle *  th,
uint32_t  port_ifindex,
bool  linkup 
)
Parameters
thlibteam library context
port_ifindexport interface index
linkupdesired link state

Sets user linkup for port identified by port_ifindex

Returns
Zero on success or negative number in case of an error.

◆ team_set_port_user_linkup_enabled()

TEAM_EXPORT int team_set_port_user_linkup_enabled ( struct team_handle *  th,
uint32_t  port_ifindex,
bool  val 
)
Parameters
thlibteam library context
port_ifindexport interface index
valboolean value

Enables or disable user linkup for port identified by port_ifindex

Returns
Zero on success or negative number in case of an error.