libteam: Libteam core funtions

libteam 1.32

Loading...
Searching...
No Matches
Macros | Functions
Libteam core funtions
Libteam

## 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

  th | libteam library context
  eventfd | eventfd 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

  th | libteam library context
  carrier_up | where 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

  th | libteam library context
  carrier_up | carrier 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

  th | libteam library context
  handler | event handler structure
  priv | event 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

  th | libteam library context
  handler | event handler structure
  priv | event 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

  th | libteam library context
  handler | event handler structure
  priv | event handler func private data

Unregisters custom handler structure.

## ◆ team_check_events()

TEAM_EXPORT int team_check_events | ( | struct team_handle * | th | ) |

Parameters

  th | libteam 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

  th | libteam library context
  team_name | new 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

  th | libteam 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

  th | libteam 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

  th | libteam library context
  ifindex | where 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

  th | libteam library context
  fp | where 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

  th | libteam 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

  th | libteam library context
  eventfd | eventfd 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

  th | libteam 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

  th | libteam 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

  th | libteam library context
  count | where 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

  th | libteam library context
  interval | where 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

  th | libteam library context
  mode_name | where 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

  th | libteam library context
  eventfd | eventfd 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

  th | libteam library context
  count | where 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

  th | libteam library context
  interval | where 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

  th | libteam library context
  port_ifindex | port interface index
  enabled | where 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

  th | libteam library context
  port_ifindex | port interface index
  priority | where 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

  th | libteam library context
  port_ifindex | port interface index
  linkup | where 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

  th | libteam 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

  th | libteam library context
  ifindex | interface index
  addr | address will be written here
  addr_len | length 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

  th | libteam library context
  ifindex | interface 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

  th | libteam library context
  ifindex | interface index
  addr | address to be set
  addr_len | length 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

  th | libteam library context
  ifindex | interface index
  ifname | where the interface name will be stored
  maxlen | length 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

  th | libteam library context
  ifname | interface 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

  th | libteam library context
  ifindex | team 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

  th | libteam library context
  port_ifindex | port 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

  th | libteam library context
  port_ifindex | port 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

  th | libteam library context
  port_ifindex | port 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

  th | libteam library context
  team_name | new 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

  th | libteam 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

  th | libteam library context
  ifindex | interface 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

  th | libteam library context
  fp | prepared 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(* | log_fn )(struct team_handle *th, int priority, const char *file, int line, const char *fn, const char *format, va_list args) )

Parameters

  th | libteam library context
  log_fn | function 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

  th | libteam library context
  priority | the 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

  th | libteam library context
  count | number 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

  th | libteam library context
  interval | interval 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

  th | libteam library context
  mode_name | name 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

  th | libteam library context
  count | number 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

  th | libteam library context
  interval | interval 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

  th | libteam library context
  port_ifindex | port interface index
  val | boolean 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

  th | libteam library context
  port_ifindex | port interface index
  priority | desired 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

  th | libteam library context
  port_ifindex | port interface index
  queue_id | desired 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

  th | libteam library context
  port_ifindex | port interface index
  linkup | desired 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

  th | libteam library context
  port_ifindex | port interface index
  val | boolean value

Enables or disable user linkup for port identified by port_ifindex

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