libnl 3.5.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. 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_link * | rtnl_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

  link | Link object

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

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

  link | Link object
  mode | MACVLAN mode

Returns
  0 on success or a negative error code

Definition at line 341 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 370 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 391 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 416 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 441 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 463 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 481 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 497 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 526 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 556 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 601 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 653 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 675 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

  link | Link object
  mode | MACVTAP mode

Returns
  0 on success or a negative error code

Definition at line 687 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 705 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 724 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 746 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 764 of file macvlan.c.