libnl  3.2.24-rc1
Traffic Classes

Modules

 Class Based Queueing (CBQ)
 
 Differentiated Services Marker (DSMARK)
 
 Hierachical Token Bucket (HTB)
 

Allocation/Freeing

struct rtnl_class * rtnl_class_alloc (void)
 
void rtnl_class_put (struct rtnl_class *class)
 

Addition/Modification/Deletion

int rtnl_class_build_add_request (struct rtnl_class *class, int flags, struct nl_msg **result)
 Build a netlink message requesting the addition of a traffic class. More...
 
int rtnl_class_add (struct nl_sock *sk, struct rtnl_class *class, int flags)
 Add/Update traffic class. More...
 
int rtnl_class_build_delete_request (struct rtnl_class *class, struct nl_msg **result)
 Build netlink message requesting the deletion of a traffic class. More...
 
int rtnl_class_delete (struct nl_sock *sk, struct rtnl_class *class)
 Delete traffic class. More...
 

Leaf Qdisc

struct rtnl_qdisc * rtnl_class_leaf_qdisc (struct rtnl_class *class, struct nl_cache *cache)
 Lookup the leaf qdisc of a traffic class. More...
 

Cache Related Functions

int rtnl_class_alloc_cache (struct nl_sock *sk, int ifindex, struct nl_cache **result)
 Allocate a cache and fill it with all configured traffic classes. More...
 
struct rtnl_class * rtnl_class_get (struct nl_cache *cache, int ifindex, uint32_t handle)
 Search traffic class by interface index and handle. More...
 

Deprecated Functions

void rtnl_class_foreach_child (struct rtnl_class *class, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
 Call a callback for each child of a class. More...
 
void rtnl_class_foreach_cls (struct rtnl_class *class, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
 Call a callback for each classifier attached to the class. More...
 

Detailed Description

Function Documentation

int rtnl_class_build_add_request ( struct rtnl_class *  class,
int  flags,
struct nl_msg **  result 
)

Build a netlink message requesting the addition of a traffic class.

Parameters
classTraffic class to add
flagsAdditional netlink message flags
resultPointer to store resulting netlink message

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

See Also
rtnl_class_add()
Returns
0 on success or a negative error code.

Definition at line 129 of file class.c.

Referenced by rtnl_class_add().

+ Here is the caller graph for this function:

int rtnl_class_add ( struct nl_sock *  sk,
struct rtnl_class *  class,
int  flags 
)

Add/Update traffic class.

Parameters
skNetlink socket
classTraffic class to add
flagsAdditional netlink message flags

Builds a RTM_NEWTCLASS netlink message requesting the addition of a new traffic class and sends the message to the kernel. The configuration of the traffic class is derived from the attributes of the specified traffic class.

The following flags may be specified:

  • NLM_F_CREATE: Create traffic class if it does not exist, otherwise -NLE_OBJ_NOTFOUND is returned.
  • NLM_F_EXCL: Return -NLE_EXISTS if a traffic class with matching handle exists already.

Existing traffic classes with matching handles will be updated, unless the flag NLM_F_EXCL is specified. If no matching traffic class exists, it will be created if the flag NLM_F_CREATE is set, otherwise the error -NLE_OBJ_NOTFOUND is returned.

If the parent qdisc does not support classes, the error NLE_OPNOTSUPP 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 171 of file class.c.

References nl_send_sync(), and rtnl_class_build_add_request().

+ Here is the call graph for this function:

int rtnl_class_build_delete_request ( struct rtnl_class *  class,
struct nl_msg **  result 
)

Build netlink message requesting the deletion of a traffic class.

Parameters
classTraffic class to delete
resultPointer to store resulting netlink message

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

See Also
rtnl_class_delete()
Returns
0 on success or a negative error code.

Definition at line 195 of file class.c.

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

Referenced by rtnl_class_delete().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int rtnl_class_delete ( struct nl_sock *  sk,
struct rtnl_class *  class 
)

Delete traffic class.

Parameters
skNetlink socket
classTraffic class to delete

Builds a RTM_DELTCLASS netlink message requesting the deletion of a traffic class and sends the message to the kernel.

The message is constructed out of the following attributes:

  • ifindex and handle (required)
  • parent (optional, must match if provided)

All other class attributes including all class 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
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 252 of file class.c.

References nl_send_sync(), and rtnl_class_build_delete_request().

+ Here is the call graph for this function:

struct rtnl_qdisc* rtnl_class_leaf_qdisc ( struct rtnl_class *  class,
struct nl_cache *  cache 
)
read

Lookup the leaf qdisc of a traffic class.

Parameters
classthe parent traffic class
cachea qdisc cache allocated using rtnl_qdisc_alloc_cache()
Returns
Matching Qdisc or NULL if the traffic class has no leaf qdisc

Definition at line 277 of file class.c.

References rtnl_qdisc_get_by_parent().

+ Here is the call graph for this function:

int rtnl_class_alloc_cache ( struct nl_sock *  sk,
int  ifindex,
struct nl_cache **  result 
)

Allocate a cache and fill it with all configured traffic classes.

Parameters
skNetlink socket
ifindexInterface index of the network device
resultPointer to store the created cache

Allocates a new traffic class cache and fills it with a list of all configured traffic classes on a specific network device. Release the cache with nl_cache_free().

Returns
0 on success or a negative error code.

Definition at line 312 of file class.c.

References nl_cache_alloc(), nl_cache_free(), and nl_cache_refill().

+ Here is the call graph for this function:

struct rtnl_class* rtnl_class_get ( struct nl_cache *  cache,
int  ifindex,
uint32_t  handle 
)
read

Search traffic class by interface index and handle.

Parameters
cacheTraffic class cache
ifindexInterface index
handleID of traffic class

Searches a traffic class cache previously allocated with rtnl_class_alloc_cache() and searches for a traffi class matching the interface index and handle.

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

Returns
Traffic class or NULL if no match was found.

Definition at line 353 of file class.c.

References nl_object_get().

+ Here is the call graph for this function:

void rtnl_class_foreach_child ( struct rtnl_class *  class,
struct nl_cache *  cache,
void(*)(struct nl_object *, void *)  cb,
void *  arg 
)

Call a callback for each child of a class.

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

Definition at line 383 of file class.c.

References nl_cache_foreach_filter(), rtnl_tc_set_ifindex(), rtnl_tc_set_kind(), rtnl_tc_set_parent(), and TC_CAST.

+ Here is the call graph for this function:

void rtnl_class_foreach_cls ( struct rtnl_class *  class,
struct nl_cache *  cache,
void(*)(struct nl_object *, void *)  cb,
void *  arg 
)

Call a callback for each classifier attached to the class.

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

Definition at line 406 of file class.c.

References nl_cache_foreach_filter(), rtnl_tc_set_ifindex(), and rtnl_tc_set_parent().

+ Here is the call graph for this function: