libnl 3.5.0

Modules
Queueing Disciplines
Routing Library (libnl-route) » Traffic Control

## Modules
| (Fast) Prio
| Blackhole
| Class Based Queueing (CBQ)
| Differentiated Services Marker (DSMARK)
| Fair Queue CoDel
| Hierachical Token Bucket (HTB)
| Hierarchical Fair Service Curve (HFSC)
| Ingress qdisc
| Network Emulator
| For further documentation see http://linux-net.osdl.org/index.php/Netem.
| Packet/Bytes FIFO (pfifo/bfifo)
| The FIFO qdisc comes in two flavours:
| Plug/Unplug Traffic (PLUG)
| Queue traffic until an explicit release command.
| Random Early Detection (RED)
| Stochastic Fairness Queueing (SFQ)
| Token Bucket Filter (TBF)

## Allocation/Freeing
struct rtnl_qdisc * | rtnl_qdisc_alloc (void)
void | rtnl_qdisc_put (struct rtnl_qdisc *qdisc)

## Addition / Modification / Deletion
int | rtnl_qdisc_build_add_request (struct rtnl_qdisc *qdisc, int flags, struct nl_msg **result)
| Build a netlink message requesting the addition of a qdisc. More...
int | rtnl_qdisc_add (struct nl_sock *sk, struct rtnl_qdisc *qdisc, int flags)
| Add qdisc. More...
int | rtnl_qdisc_build_update_request (struct rtnl_qdisc *qdisc, struct rtnl_qdisc *new, int flags, struct nl_msg **result)
| Build netlink message requesting the update of a qdisc. More...
int | rtnl_qdisc_update (struct nl_sock *sk, struct rtnl_qdisc *qdisc, struct rtnl_qdisc *new, int flags)
| Update qdisc. More...
int | rtnl_qdisc_build_delete_request (struct rtnl_qdisc *qdisc, struct nl_msg **result)
| Build netlink message requesting the deletion of a qdisc. More...
int | rtnl_qdisc_delete (struct nl_sock *sk, struct rtnl_qdisc *qdisc)
| Delete qdisc. More...

## Cache Related Functions
int | rtnl_qdisc_alloc_cache (struct nl_sock *sk, struct nl_cache **result)
| Allocate a cache and fill it with all configured qdiscs. More...
struct rtnl_qdisc * | rtnl_qdisc_get_by_parent (struct nl_cache *cache, int ifindex, uint32_t parent)
| Search qdisc by interface index and parent. More...
struct rtnl_qdisc * | rtnl_qdisc_get (struct nl_cache *cache, int ifindex, uint32_t handle)
| Search qdisc by interface index and handle. More...

## Deprecated Functions
void | rtnl_qdisc_foreach_child (struct rtnl_qdisc *qdisc, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
| Call a callback for each child class of a qdisc (deprecated) More...
void | rtnl_qdisc_foreach_cls (struct rtnl_qdisc *qdisc, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
| Call a callback for each filter attached to the qdisc (deprecated) More...
int | rtnl_qdisc_build_change_request (struct rtnl_qdisc *qdisc, struct rtnl_qdisc *new, struct nl_msg **result)
| Build a netlink message requesting the update of a qdisc. More...
int | rtnl_qdisc_change (struct nl_sock *sk, struct rtnl_qdisc *qdisc, struct rtnl_qdisc *new)
| Change attributes of a qdisc. More...

## Detailed Description

## Function Documentation

## ◆ rtnl_qdisc_build_add_request()

int rtnl_qdisc_build_add_request | ( | struct rtnl_qdisc * | qdisc,
|  | int | flags,
|  | struct nl_msg ** | result
| ) |  |

Build a netlink message requesting the addition of a qdisc.

Parameters

  qdisc | Qdisc to add
  flags | Additional netlink message flags
  result | Pointer to store resulting netlink message

The behaviour of this function is identical to rtnl_qdisc_add() with the exception that it will not send the message but return it int the provided return pointer instead.

See also
  rtnl_qdisc_add()

Returns
  0 on success or a negative error code.

Definition at line 115 of file qdisc.c.

Referenced by rtnl_qdisc_add().

Here is the caller graph for this function:

## ◆ rtnl_qdisc_add()

int rtnl_qdisc_add | ( | struct nl_sock * | sk,
|  | struct rtnl_qdisc * | qdisc,
|  | int | flags
| ) |  |

Add qdisc.

Parameters

  sk | Netlink socket
  qdisc | Qdisc to add
  flags | Additional netlink message flags

Builds a `RTM_NEWQDISC` netlink message requesting the addition of a new qdisc and sends the message to the kernel. The configuration of the qdisc is derived from the attributes of the specified qdisc.

The following flags may be specified:

- `NLM_F_CREATE:` Create qdisc if it does not exist, otherwise -NLE_OBJ_NOTFOUND is returned.
- `NLM_F_REPLACE:` If another qdisc is already attached to the parent, replace it even if the handles mismatch.
- `NLM_F_EXCL:` Return -NLE_EXISTS if a qdisc with matching handle exists already.

Existing qdiscs with matching handles will be updated, unless the flag `NLM_F_EXCL` is specified. If their handles do not match, the error -NLE_EXISTS is returned unless the flag `NLM_F_REPLACE` is specified in which case the existing qdisc is replaced with the new one. If no matching qdisc exists, it will be created if the flag `NLM_F_CREATE` is set, otherwise the error -NLE_OBJ_NOTFOUND is returned.

After sending, the function will wait for the ACK or an eventual error message to be received and will therefore block until the operation has been completed.

Note
  Disabling auto-ack (nl_socket_disable_auto_ack()) will cause this function to return immediately after sending. In this case, it is the responsibility of the caller to handle any error messages returned.

Returns
  0 on success or a negative error code.

Definition at line 163 of file qdisc.c.

References nl_send_sync(), and rtnl_qdisc_build_add_request().

Here is the call graph for this function:

## ◆ rtnl_qdisc_build_update_request()

int rtnl_qdisc_build_update_request | ( | struct rtnl_qdisc * | qdisc,
|  | struct rtnl_qdisc * | new,
|  | int | flags,
|  | struct nl_msg ** | result
| ) |  |

Build netlink message requesting the update of a qdisc.

Parameters

  qdisc | Qdisc to update
  new | Qdisc with updated attributes
  flags | Additional netlink message flags
  result | Pointer to store resulting netlink message

The behaviour of this function is identical to rtnl_qdisc_update() with the exception that it will not send the message but return it in the provided return pointer instead.

See also
  rtnl_qdisc_update()

Returns
  0 on success or a negative error code.

Definition at line 189 of file qdisc.c.

References rtnl_tc_set_handle(), rtnl_tc_set_ifindex(), rtnl_tc_set_parent(), and TC_CAST.

Referenced by rtnl_qdisc_build_change_request(), and rtnl_qdisc_update().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ rtnl_qdisc_update()

int rtnl_qdisc_update | ( | struct nl_sock * | sk,
|  | struct rtnl_qdisc * | qdisc,
|  | struct rtnl_qdisc * | new,
|  | int | flags
| ) |  |

Update qdisc.

Parameters

  sk | Netlink socket
  qdisc | Qdisc to update
  new | Qdisc with updated attributes
  flags | Additional netlink message flags

Builds a `RTM_NEWQDISC` netlink message requesting the update of an existing qdisc and sends the message to the kernel.

This function is a varation of rtnl_qdisc_add() to update qdiscs if the qdisc to be updated is available as qdisc object. The behaviour is identical to the one of rtnl_qdisc_add except that before constructing the message, it copies the `ifindex`, `handle`, and `parent` from the original `qdisc` to the `new` qdisc.

After sending, the function will wait for the ACK or an eventual error message to be received and will therefore block until the operation has been completed.

Note
  Disabling auto-ack (nl_socket_disable_auto_ack()) will cause this function to return immediately after sending. In this case, it is the responsibility of the caller to handle any error messages returned.

Returns
  0 on success or a negative error code.

Definition at line 248 of file qdisc.c.

References nl_send_sync(), and rtnl_qdisc_build_update_request().

Referenced by rtnl_qdisc_change().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ rtnl_qdisc_build_delete_request()

int rtnl_qdisc_build_delete_request | ( | struct rtnl_qdisc * | qdisc,
|  | struct nl_msg ** | result
| ) |  |

Build netlink message requesting the deletion of a qdisc.

Parameters

  qdisc | Qdisc to delete
  result | Pointer to store resulting netlink message

The behaviour of this function is identical to rtnl_qdisc_delete() with the exception that it will not send the message but return it in the provided return pointer instead.

See also
  rtnl_qdisc_delete()

Returns
  0 on success or a negative error code.

Definition at line 274 of file qdisc.c.

References NLA_PUT_STRING, nlmsg_alloc_simple(), nlmsg_append(), and nlmsg_free().

Referenced by rtnl_qdisc_delete().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ rtnl_qdisc_delete()

int rtnl_qdisc_delete | ( | struct nl_sock * | sk,
|  | struct rtnl_qdisc * | qdisc
| ) |  |

Delete qdisc.

Parameters

  sk | Netlink socket
  qdisc | Qdisc to add

Builds a `RTM_NEWQDISC` netlink message requesting the deletion of a qdisc and sends the message to the kernel.

The message is constructed out of the following attributes:

- `ifindex` and `parent`
- `handle` (optional, must match if provided)
- `kind` (optional, must match if provided)

All other qdisc attributes including all qdisc type specific attributes are ignored.

After sending, the function will wait for the ACK or an eventual error message to be received and will therefore block until the operation has been completed.

Note
  It is not possible to delete default qdiscs.
  Disabling auto-ack (nl_socket_disable_auto_ack()) will cause this function to return immediately after sending. In this case, it is the responsibility of the caller to handle any error messages returned.

Returns
  0 on success or a negative error code.

Definition at line 341 of file qdisc.c.

References nl_send_sync(), and rtnl_qdisc_build_delete_request().

Here is the call graph for this function:

## ◆ rtnl_qdisc_alloc_cache()

int rtnl_qdisc_alloc_cache | ( | struct nl_sock * | sk,
|  | struct nl_cache ** | result
| ) |  |

Allocate a cache and fill it with all configured qdiscs.

Parameters

  sk | Netlink socket
  result | Pointer to store the created cache

Allocates a new qdisc cache and fills it with a list of all configured qdiscs on all network devices. Release the cache with nl_cache_free().

Returns
  0 on success or a negative error code.

Definition at line 369 of file qdisc.c.

References nl_cache_alloc_and_fill().

Here is the call graph for this function:

## ◆ rtnl_qdisc_get_by_parent()

struct rtnl_qdisc* rtnl_qdisc_get_by_parent | ( | struct nl_cache * | cache,
|  | int | ifindex,
|  | uint32_t | parent
| ) |  |

Search qdisc by interface index and parent.

Parameters

  cache | Qdisc cache
  ifindex | Interface index
  parent | Handle of parent qdisc

Searches a qdisc cache previously allocated with rtnl_qdisc_alloc_cache() and searches for a qdisc matching the interface index and parent qdisc.

The reference counter is incremented before returning the qdisc, therefore the reference must be given back with rtnl_qdisc_put() after usage.

Returns
  pointer to qdisc inside the cache or NULL if no match was found.

Definition at line 388 of file qdisc.c.

Referenced by rtnl_class_leaf_qdisc().

Here is the caller graph for this function:

## ◆ rtnl_qdisc_get()

struct rtnl_qdisc* rtnl_qdisc_get | ( | struct nl_cache * | cache,
|  | int | ifindex,
|  | uint32_t | handle
| ) |  |

Search qdisc by interface index and handle.

Parameters

  cache | Qdisc cache
  ifindex | Interface index
  handle | Handle

Searches a qdisc cache previously allocated with rtnl_qdisc_alloc_cache() and searches for a qdisc matching the interface index and handle.

The reference counter is incremented before returning the qdisc, therefore the reference must be given back with rtnl_qdisc_put() after usage.

Returns
  Qdisc or NULL if no match was found.

Definition at line 420 of file qdisc.c.

## ◆ rtnl_qdisc_foreach_child()

void rtnl_qdisc_foreach_child | ( | struct rtnl_qdisc * | qdisc,
|  | struct nl_cache * | cache,
|  | void(*)(struct nl_object *, void *) | cb,
|  | void * | arg
| ) |  |

Call a callback for each child class of a qdisc (deprecated)

Deprecated:
  Use of this function is deprecated, it does not allow to handle the out of memory situation that can occur.

Definition at line 451 of file qdisc.c.

## ◆ rtnl_qdisc_foreach_cls()

void rtnl_qdisc_foreach_cls | ( | struct rtnl_qdisc * | qdisc,
|  | struct nl_cache * | cache,
|  | void(*)(struct nl_object *, void *) | cb,
|  | void * | arg
| ) |  |

Call a callback for each filter attached to the qdisc (deprecated)

Deprecated:
  Use of this function is deprecated, it does not allow to handle the out of memory situation that can occur.

Definition at line 475 of file qdisc.c.

## ◆ rtnl_qdisc_build_change_request()

int rtnl_qdisc_build_change_request | ( | struct rtnl_qdisc * | qdisc,
|  | struct rtnl_qdisc * | new,
|  | struct nl_msg ** | result
| ) |  |

Build a netlink message requesting the update of a qdisc.

Deprecated:
  Use of this function is deprecated in favour of rtnl_qdisc_build_update_request() due to the missing possibility of specifying additional flags.

Definition at line 497 of file qdisc.c.

References rtnl_qdisc_build_update_request().

Here is the call graph for this function:

## ◆ rtnl_qdisc_change()

int rtnl_qdisc_change | ( | struct nl_sock * | sk,
|  | struct rtnl_qdisc * | qdisc,
|  | struct rtnl_qdisc * | new
| ) |  |

Change attributes of a qdisc.

Deprecated:
  Use of this function is deprecated in favour of rtnl_qdisc_update() due to the missing possibility of specifying additional flags.

Definition at line 512 of file qdisc.c.

References rtnl_qdisc_update().

Here is the call graph for this function: