libnl 3.7.0

MAC-based Virtual LAN link module. More...

MACVLAN Object

struct rtnl_linkrtnl_link_macvlan_alloc (void)
 Allocate link object of type MACVLAN. More...
 
int rtnl_link_is_macvlan (struct rtnl_link *link)
 Check if link is a MACVLAN link. More...
 
int rtnl_link_macvlan_set_mode (struct rtnl_link *link, uint32_t mode)
 Set MACVLAN MODE. More...
 
uint32_t rtnl_link_macvlan_get_mode (struct rtnl_link *link)
 Get MACVLAN Mode. More...
 
int rtnl_link_macvlan_set_macmode (struct rtnl_link *link, uint32_t macmode)
 Set MACVLAN MACMODE. More...
 
int rtnl_link_macvlan_get_macmode (struct rtnl_link *link, uint32_t *out_macmode)
 Get MACVLAN MACMODE. More...
 
int rtnl_link_macvlan_set_flags (struct rtnl_link *link, uint16_t flags)
 Set MACVLAN flags. More...
 
int rtnl_link_macvlan_unset_flags (struct rtnl_link *link, uint16_t flags)
 Unset MACVLAN flags. More...
 
uint16_t rtnl_link_macvlan_get_flags (struct rtnl_link *link)
 Get MACVLAN flags. More...
 
int rtnl_link_macvlan_count_macaddr (struct rtnl_link *link, uint32_t *out_count)
 Get number of MAC-Addr for MACVLAN device in source mode. More...
 
int rtnl_link_macvlan_get_macaddr (struct rtnl_link *link, uint32_t idx, const struct nl_addr **out_addr)
 Get configured remote MAC-Addr from MACVLAN device in source mode. More...
 
int rtnl_link_macvlan_add_macaddr (struct rtnl_link *link, struct nl_addr *addr)
 Add MAC-Addr to MACVLAN device in source mode. More...
 
int rtnl_link_macvlan_del_macaddr (struct rtnl_link *link, struct nl_addr *addr)
 Remove MAC-Addr from MACVLAN device in source mode. More...
 

MACVTAP Object

struct rtnl_linkrtnl_link_macvtap_alloc (void)
 Allocate link object of type MACVTAP. More...
 
int rtnl_link_is_macvtap (struct rtnl_link *link)
 Check if link is a MACVTAP link. More...
 
int rtnl_link_macvtap_set_mode (struct rtnl_link *link, uint32_t mode)
 Set MACVTAP MODE. More...
 
uint32_t rtnl_link_macvtap_get_mode (struct rtnl_link *link)
 Get MACVTAP Mode. More...
 
int rtnl_link_macvtap_set_flags (struct rtnl_link *link, uint16_t flags)
 Set MACVTAP flags. More...
 
int rtnl_link_macvtap_unset_flags (struct rtnl_link *link, uint16_t flags)
 Unset MACVTAP flags. More...
 
uint16_t rtnl_link_macvtap_get_flags (struct rtnl_link *link)
 Get MACVTAP flags. More...
 

Flag Translation

char * rtnl_link_macvlan_flags2str (int flags, char *buf, size_t len)
 
int rtnl_link_macvlan_str2flags (const char *name)
 
char * rtnl_link_macvtap_flags2str (int flags, char *buf, size_t len)
 
int rtnl_link_macvtap_str2flags (const char *name)
 

Mode Translation

char * rtnl_link_macvlan_mode2str (int mode, char *buf, size_t len)
 
int rtnl_link_macvlan_str2mode (const char *name)
 
char * rtnl_link_macvlan_macmode2str (int mode, char *buf, size_t len)
 
int rtnl_link_macvlan_str2macmode (const char *name)
 
char * rtnl_link_macvtap_mode2str (int mode, char *buf, size_t len)
 
int rtnl_link_macvtap_str2mode (const char *name)
 

Detailed Description

MAC-based Virtual LAN link module.

Link Type Name: "macvlan"

MACVLAN Documentation (Netlink Routing Development Guide) MACVTAP Documentation (Netlink Routing Development Guide)

Function Documentation

◆ rtnl_link_macvlan_alloc()

struct rtnl_link * rtnl_link_macvlan_alloc ( void  )

Allocate link object of type MACVLAN.

Returns
Allocated link object or NULL.

Definition at line 307 of file macvlan.c.

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

+ Here is the call graph for this function:

◆ rtnl_link_is_macvlan()

int rtnl_link_is_macvlan ( struct rtnl_link link)

Check if link is a MACVLAN link.

Parameters
linkLink object
Returns
True if link is a MACVLAN link, otherwise false is returned.

Definition at line 328 of file macvlan.c.

◆ rtnl_link_macvlan_set_mode()

int rtnl_link_macvlan_set_mode ( struct rtnl_link link,
uint32_t  mode 
)

Set MACVLAN MODE.

Parameters
linkLink object
modeMACVLAN mode
Returns
0 on success or a negative error code

Definition at line 340 of file macvlan.c.

References nl_addr_put().

+ Here is the call graph for this function:

◆ rtnl_link_macvlan_get_mode()

uint32_t rtnl_link_macvlan_get_mode ( struct rtnl_link link)

Get MACVLAN Mode.

Parameters
linkLink object
Returns
MACVLAN mode, 0 if not set or a negative error code.

Definition at line 369 of file macvlan.c.

◆ rtnl_link_macvlan_set_macmode()

int rtnl_link_macvlan_set_macmode ( struct rtnl_link link,
uint32_t  macmode 
)

Set MACVLAN MACMODE.

Parameters
linkLink object
modeMACVLAN mac list modification mode

Only for macvlan SOURCE mode.

Returns
0 on success or a negative error code

Definition at line 390 of file macvlan.c.

◆ rtnl_link_macvlan_get_macmode()

int rtnl_link_macvlan_get_macmode ( struct rtnl_link link,
uint32_t *  out_macmode 
)

Get MACVLAN MACMODE.

Parameters
linkLink object
out_macmodemac list modification mode

Only for SOURCE mode.

Returns
0 on success or a negative error code.

Definition at line 415 of file macvlan.c.

◆ rtnl_link_macvlan_set_flags()

int rtnl_link_macvlan_set_flags ( struct rtnl_link link,
uint16_t  flags 
)

Set MACVLAN flags.

Parameters
linkLink object
flagsMACVLAN flags
Returns
0 on success or a negative error code.

Definition at line 440 of file macvlan.c.

◆ rtnl_link_macvlan_unset_flags()

int rtnl_link_macvlan_unset_flags ( struct rtnl_link link,
uint16_t  flags 
)

Unset MACVLAN flags.

Parameters
linkLink object
flagsMACVLAN flags

Note: kernel currently only has a single flag and lacks flags_mask to indicate which flags shall be changed (it always all).

Returns
0 on success or a negative error code.

Definition at line 462 of file macvlan.c.

◆ rtnl_link_macvlan_get_flags()

uint16_t rtnl_link_macvlan_get_flags ( struct rtnl_link link)

Get MACVLAN flags.

Parameters
linkLink object
Returns
MACVLAN flags, 0 if none set, or a negative error code.

Definition at line 480 of file macvlan.c.

◆ rtnl_link_macvlan_count_macaddr()

int rtnl_link_macvlan_count_macaddr ( struct rtnl_link link,
uint32_t *  out_count 
)

Get number of MAC-Addr for MACVLAN device in source mode.

Parameters
linkLink object
out_countnumber of mac addresses
Returns
0 on success or a negative error code.

Definition at line 496 of file macvlan.c.

◆ rtnl_link_macvlan_get_macaddr()

int rtnl_link_macvlan_get_macaddr ( struct rtnl_link link,
uint32_t  idx,
const struct nl_addr **  out_addr 
)

Get configured remote MAC-Addr from MACVLAN device in source mode.

Parameters
linkLink object
out_addraddress object

The returned nl_addr struct needs NOT to be released using nl_addr_put. It is only valid until the address is not removed from this link object or its mode is changed to non-source.

Returns
0 on success or negative error code

Definition at line 525 of file macvlan.c.

◆ rtnl_link_macvlan_add_macaddr()

int rtnl_link_macvlan_add_macaddr ( struct rtnl_link link,
struct nl_addr *  addr 
)

Add MAC-Addr to MACVLAN device in source mode.

Parameters
linkLink object
addrMAC-Addr

addr is not release but cloned by this method.

Returns
0 on success or a negative error code.

Definition at line 555 of file macvlan.c.

References nl_addr_clone(), and nl_addr_get_family().

+ Here is the call graph for this function:

◆ rtnl_link_macvlan_del_macaddr()

int rtnl_link_macvlan_del_macaddr ( struct rtnl_link link,
struct nl_addr *  addr 
)

Remove MAC-Addr from MACVLAN device in source mode.

Parameters
linkLink object
addrMAC-Addr

addr is not release by this method.

Returns
a negative error code on failure, or the number of deleted addresses on success.

Definition at line 600 of file macvlan.c.

References nl_addr_cmp(), nl_addr_get(), nl_addr_get_family(), and nl_addr_put().

+ Here is the call graph for this function:

◆ rtnl_link_macvtap_alloc()

struct rtnl_link * rtnl_link_macvtap_alloc ( void  )

Allocate link object of type MACVTAP.

Returns
Allocated link object or NULL.

Definition at line 652 of file macvlan.c.

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

+ Here is the call graph for this function:

◆ rtnl_link_is_macvtap()

int rtnl_link_is_macvtap ( struct rtnl_link link)

Check if link is a MACVTAP link.

Parameters
linkLink object
Returns
True if link is a MACVTAP link, otherwise false is returned.

Definition at line 673 of file macvlan.c.

◆ rtnl_link_macvtap_set_mode()

int rtnl_link_macvtap_set_mode ( struct rtnl_link link,
uint32_t  mode 
)

Set MACVTAP MODE.

Parameters
linkLink object
modeMACVTAP mode
Returns
0 on success or a negative error code

Definition at line 685 of file macvlan.c.

◆ rtnl_link_macvtap_get_mode()

uint32_t rtnl_link_macvtap_get_mode ( struct rtnl_link link)

Get MACVTAP Mode.

Parameters
linkLink object
Returns
MACVTAP mode, 0 if not set or a negative error code.

Definition at line 703 of file macvlan.c.

◆ rtnl_link_macvtap_set_flags()

int rtnl_link_macvtap_set_flags ( struct rtnl_link link,
uint16_t  flags 
)

Set MACVTAP flags.

Parameters
linkLink object
flagsMACVTAP flags
Returns
0 on success or a negative error code.

Definition at line 722 of file macvlan.c.

◆ rtnl_link_macvtap_unset_flags()

int rtnl_link_macvtap_unset_flags ( struct rtnl_link link,
uint16_t  flags 
)

Unset MACVTAP flags.

Parameters
linkLink object
flagsMACVTAP flags

Note: kernel currently only has a single flag and lacks flags_mask to indicate which flags shall be changed (it always all).

Returns
0 on success or a negative error code.

Definition at line 744 of file macvlan.c.

◆ rtnl_link_macvtap_get_flags()

uint16_t rtnl_link_macvtap_get_flags ( struct rtnl_link link)

Get MACVTAP flags.

Parameters
linkLink object
Returns
MACVTAP flags, 0 if none set, or a negative error code.

Definition at line 762 of file macvlan.c.

◆ rtnl_link_macvlan_flags2str()

char * rtnl_link_macvlan_flags2str ( int  flags,
char *  buf,
size_t  len 
)

Definition at line 798 of file macvlan.c.

◆ rtnl_link_macvlan_str2flags()

int rtnl_link_macvlan_str2flags ( const char *  name)

Definition at line 803 of file macvlan.c.

◆ rtnl_link_macvtap_flags2str()

char * rtnl_link_macvtap_flags2str ( int  flags,
char *  buf,
size_t  len 
)

Definition at line 808 of file macvlan.c.

◆ rtnl_link_macvtap_str2flags()

int rtnl_link_macvtap_str2flags ( const char *  name)

Definition at line 813 of file macvlan.c.

◆ rtnl_link_macvlan_mode2str()

char * rtnl_link_macvlan_mode2str ( int  mode,
char *  buf,
size_t  len 
)

Definition at line 825 of file macvlan.c.

◆ rtnl_link_macvlan_str2mode()

int rtnl_link_macvlan_str2mode ( const char *  name)

Definition at line 830 of file macvlan.c.

◆ rtnl_link_macvlan_macmode2str()

char * rtnl_link_macvlan_macmode2str ( int  mode,
char *  buf,
size_t  len 
)

Definition at line 835 of file macvlan.c.

◆ rtnl_link_macvlan_str2macmode()

int rtnl_link_macvlan_str2macmode ( const char *  name)

Definition at line 841 of file macvlan.c.

◆ rtnl_link_macvtap_mode2str()

char * rtnl_link_macvtap_mode2str ( int  mode,
char *  buf,
size_t  len 
)

Definition at line 846 of file macvlan.c.

◆ rtnl_link_macvtap_str2mode()

int rtnl_link_macvtap_str2mode ( const char *  name)

Definition at line 851 of file macvlan.c.