libnl: MACVLAN/MACVTAP

libnl 3.10.0

MACVLAN/MACVTAP
Routing Library (libnl-route) » Links (Interfaces)

MAC-based Virtual LAN link module More...

## MACVLAN Object
struct rtnl_link * | rtnl_link_macvlan_alloc (void)
| Allocate link object of type MACVLAN.
int | rtnl_link_is_macvlan (struct rtnl_link *link)
| Check if link is a MACVLAN link.
int | rtnl_link_macvlan_set_mode (struct rtnl_link *link, uint32_t mode)
| Set MACVLAN MODE.
uint32_t | rtnl_link_macvlan_get_mode (struct rtnl_link *link)
| Get MACVLAN Mode.
int | rtnl_link_macvlan_set_macmode (struct rtnl_link *link, uint32_t macmode)
| Set MACVLAN MACMODE.
int | rtnl_link_macvlan_get_macmode (struct rtnl_link *link, uint32_t *out_macmode)
| Get MACVLAN MACMODE.
int | rtnl_link_macvlan_set_flags (struct rtnl_link *link, uint16_t flags)
| Set MACVLAN flags.
int | rtnl_link_macvlan_unset_flags (struct rtnl_link *link, uint16_t flags)
| Unset MACVLAN flags.
uint16_t | rtnl_link_macvlan_get_flags (struct rtnl_link *link)
| Get MACVLAN flags.
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.
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.
int | rtnl_link_macvlan_add_macaddr (struct rtnl_link *link, struct nl_addr *addr)
| Add MAC-Addr to MACVLAN device in source mode.
int | rtnl_link_macvlan_del_macaddr (struct rtnl_link *link, struct nl_addr *addr)
| Remove MAC-Addr from MACVLAN device in source mode.

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

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

  link | Link object

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

Definition at line 335 of file macvlan.c.

References rtnl_link_info_ops::io_name.

## ◆ rtnl_link_macvlan_set_mode()

int rtnl_link_macvlan_set_mode | ( | struct rtnl_link * | link,
|  | uint32_t | mode )

Set MACVLAN MODE.

Parameters

  link | Link object
  mode | MACVLAN mode

Returns
  0 on success or a negative error code

Definition at line 347 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

  link | Link object

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

Definition at line 377 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

  link | Link object
  mode | MACVLAN mac list modification mode

Only for macvlan SOURCE mode.

Returns
  0 on success or a negative error code

Definition at line 398 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

  link | Link object
  out_macmode | mac list modification mode

Only for SOURCE mode.

Returns
  0 on success or a negative error code.

Definition at line 423 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

  link | Link object
  flags | MACVLAN flags

Returns
  0 on success or a negative error code.

Definition at line 448 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

  link | Link object
  flags | MACVLAN 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 470 of file macvlan.c.

## ◆ rtnl_link_macvlan_get_flags()

uint16_t rtnl_link_macvlan_get_flags | ( | struct rtnl_link * | link | ) |

Get MACVLAN flags.

Parameters

  link | Link object

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

Definition at line 488 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

  link | Link object
  out_count | number of mac addresses

Returns
  0 on success or a negative error code.

Definition at line 504 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

  link | Link object
  out_addr | address 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 533 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

  link | Link object
  addr | MAC-Addr

addr is not release but cloned by this method.

Returns
  0 on success or a negative error code.

Definition at line 563 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

  link | Link object
  addr | MAC-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 608 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 660 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

  link | Link object

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

Definition at line 681 of file macvlan.c.

References rtnl_link_info_ops::io_name.

## ◆ rtnl_link_macvtap_set_mode()

int rtnl_link_macvtap_set_mode | ( | struct rtnl_link * | link,
|  | uint32_t | mode )

Set MACVTAP MODE.

Parameters

  link | Link object
  mode | MACVTAP mode

Returns
  0 on success or a negative error code

Definition at line 693 of file macvlan.c.

## ◆ rtnl_link_macvtap_get_mode()

uint32_t rtnl_link_macvtap_get_mode | ( | struct rtnl_link * | link | ) |

Get MACVTAP Mode.

Parameters

  link | Link object

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

Definition at line 711 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

  link | Link object
  flags | MACVTAP flags

Returns
  0 on success or a negative error code.

Definition at line 730 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

  link | Link object
  flags | MACVTAP 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 752 of file macvlan.c.

## ◆ rtnl_link_macvtap_get_flags()

uint16_t rtnl_link_macvtap_get_flags | ( | struct rtnl_link * | link | ) |

Get MACVTAP flags.

Parameters

  link | Link object

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

Definition at line 770 of file macvlan.c.

## ◆ rtnl_link_macvlan_flags2str()

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

Definition at line 806 of file macvlan.c.

## ◆ rtnl_link_macvlan_str2flags()

int rtnl_link_macvlan_str2flags | ( | const char * | name | ) |

Definition at line 811 of file macvlan.c.

## ◆ rtnl_link_macvtap_flags2str()

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

Definition at line 816 of file macvlan.c.

## ◆ rtnl_link_macvtap_str2flags()

int rtnl_link_macvtap_str2flags | ( | const char * | name | ) |

Definition at line 821 of file macvlan.c.

## ◆ rtnl_link_macvlan_mode2str()

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

Definition at line 833 of file macvlan.c.

## ◆ rtnl_link_macvlan_str2mode()

int rtnl_link_macvlan_str2mode | ( | const char * | name | ) |

Definition at line 838 of file macvlan.c.

## ◆ rtnl_link_macvlan_macmode2str()

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

Definition at line 843 of file macvlan.c.

## ◆ rtnl_link_macvlan_str2macmode()

int rtnl_link_macvlan_str2macmode | ( | const char * | name | ) |

Definition at line 849 of file macvlan.c.

## ◆ rtnl_link_macvtap_mode2str()

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

Definition at line 854 of file macvlan.c.

## ◆ rtnl_link_macvtap_str2mode()

int rtnl_link_macvtap_str2mode | ( | const char * | name | ) |

Definition at line 859 of file macvlan.c.