libnl 3.0
Modules
Queueing Classes
Traffic Control

Modules

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

Addition/Modification

int rtnl_class_build_add_request (struct rtnl_class *class, int flags, struct nl_msg **result)
 Build a netlink message to add a new class.
int rtnl_class_add (struct nl_sock *sk, struct rtnl_class *class, int flags)
 Add a new class.
int rtnl_class_build_delete_request (struct rtnl_class *class, struct nl_msg **result)
int rtnl_class_delete (struct nl_sock *sk, struct rtnl_class *class)
 Delete a class.

Allocation/Freeing

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

Leaf Qdisc

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

Iterators

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.
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.

Cache Management

int rtnl_class_alloc_cache (struct nl_sock *sk, int ifindex, struct nl_cache **result)
 Build a class cache including all classes attached to the specified interface.
struct rtnl_class * rtnl_class_get (struct nl_cache *cache, int ifindex, uint32_t handle)
 Look up class by its handle in the provided cache.

Function Documentation

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

Build a netlink message to add a new class.

Parameters:
classclass to add
flagsadditional netlink message flags
resultPointer to store resulting message.

Builds a new netlink message requesting an addition of a class. The netlink message header isn't fully equipped with all relevant fields and must be sent out via nl_send_auto_complete() or supplemented as needed.

Common message flags

  • NLM_F_REPLACE - replace possibly existing classes
Returns:
0 on success or a negative error code.

Definition at line 98 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 a new class.

Parameters:
skNetlink socket.
classclass to delete
flagsadditional netlink message flags

Builds a netlink message by calling rtnl_qdisc_build_add_request(), sends the request to the kernel and waits for the next ACK to be received and thus blocks until the request has been processed.

Common message flags

  • NLM_F_REPLACE - replace possibly existing classes
Returns:
0 on success or a negative error code

Definition at line 119 of file class.c.

References nlmsg_free(), and rtnl_class_build_add_request().

Here is the call graph for this function:

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

Delete a class.

Parameters:
skNetlink socket.
classclass to delete

Builds a netlink message by calling rtnl_class_build_delete_request(), sends the request to the kernel and waits for the ACK to be received and thus blocks until the request has been processed.

Returns:
0 on success or a negative error code

Definition at line 173 of file class.c.

References nlmsg_free().

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 class.

Parameters:
classthe parent class
cachea qdisc cache including at laest all qdiscs of the interface the specified class is attached to
Returns:
The qdisc from the cache or NULL if the class has no leaf qdisc

Definition at line 226 of file class.c.

References rtnl_qdisc_get_by_parent().

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.

Parameters:
classthe parent class
cachea class cache including all classes of the interface the specified class is attached to
cbcallback function
argargument to be passed to callback function

Definition at line 258 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.

Parameters:
classthe parent class
cachea filter cache including at least all the filters attached to the specified class
cbcallback function
argargument to be passed to callback function

Definition at line 283 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:

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

Build a class cache including all classes attached to the specified interface.

Parameters:
skNetlink socket.
ifindexinterface index of the link the classes are attached to.

Allocates a new cache, initializes it properly and updates it to include all classes attached to the specified interface.

Returns:
The cache or NULL if an error has occured.

Definition at line 318 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]

Look up class by its handle in the provided cache.

Parameters:
cacheclass cache
ifindexinterface the class is attached to
handleclass handle
Returns:
pointer to class inside the cache or NULL if no match was found.

Definition at line 346 of file class.c.

References nl_object_get().

Here is the call graph for this function: