Logo Search packages:      
Sourcecode: libnl version File versions  Download package

Queueing Disciplines
[Traffic Control]

Detailed Description

Qdisc Handles
In general, qdiscs are identified by the major part of a traffic control handle (the upper 16 bits). A few special values exist though:
  • TC_H_ROOT: root qdisc (directly attached to the device)
  • TC_H_INGRESS: ingress qdisc (directly attached to the device)
  • TC_H_UNSPEC: unspecified qdisc (no reference)
1) Adding a Qdisc
 // Allocate a new empty qdisc to be filled out
 struct rtnl_qdisc *qdisc = rtnl_qdisc_alloc();

 // ... specify the kind of the Qdisc
 rtnl_qdisc_set_kind(qdisc, "pfifo");

 // Specify the device the qdisc should be attached to
 rtnl_qdisc_set_ifindex(qdisc, ifindex);

 // ... specify the parent qdisc
 rtnl_qdisc_set_parent(qdisc, TC_H_ROOT);

 // Specifying the handle is not required but makes reidentifying easier
 // and may help to avoid adding a qdisc twice.
 rtnl_qdisc_set_handle(qdisc, 0x000A0000);

 // Now on to specify the qdisc specific options, see the relevant qdisc
 // modules for documentation, in this example we set the upper limit of
 // the packet fifo qdisc to 64
 rtnl_qdisc_fifo_set_limit(qdisc, 64);

 rtnl_qdisc_add(handle, qdisc, NLM_R_REPLACE);

 // Free up the memory
2) Deleting a Qdisc
 // Allocate a new empty qdisc to be filled out with the parameters
 // specifying the qdisc to be deleted. Alternatively a fully equiped
 // Qdisc object from a cache can be used.
 struct rtnl_qdisc *qdisc = rtnl_qdisc_alloc();

 // The interface index of the device the qdisc is on and the parent handle
 // are the least required fields to be filled out.
 // Note: Specify TC_H_ROOT or TC_H_INGRESS as parent handle to delete the
 //       root respectively root ingress qdisc.
 rtnl_qdisc_set_ifindex(qdisc, ifindex);
 rtnl_qdisc_set_parent(qdisc, parent_handle);

 // If required for identification, the handle can be specified as well.
 rtnl_qdisc_set_handle(qdisc, qdisc_handle);

 // Not required but maybe helpful as sanity check, the kind of the qdisc
 // can be specified to avoid mistakes.
 rtnl_qdisc_set_kind(qdisc, "pfifo");

 // Finally delete the qdisc with rtnl_qdisc_delete(), alternatively
 // rtnl_qdisc_build_delete_request() can be invoked to generate an
 // appropritate netlink message to send out.
 rtnl_qdisc_delete(handle, qdisc);

 // Free up the memory


 Class Based Queueing (CBQ)
 Differentiated Services Marker (DSMARK)
 Packet/Bytes FIFO (pfifo/bfifo)
 The FIFO qdisc comes in two flavours:.
 Hierachical Token Bucket (HTB)
 Network Emulator
 For further documentation see http://linux-net.osdl.org/index.php/Netem.
 (Fast) Prio
 Random Early Detection (RED)
 Stochastic Fairness Queueing (SFQ)
 Token Bucket Filter (TBF)


struct  rtnl_qdisc_ops

QDisc Addition

static struct nl_msg * qdisc_build (struct rtnl_qdisc *qdisc, int type, int flags)
int rtnl_qdisc_add (struct nl_handle *handle, struct rtnl_qdisc *qdisc, int flags)
struct nl_msg * rtnl_qdisc_build_add_request (struct rtnl_qdisc *qdisc, int flags)


struct rtnl_qdisc * rtnl_qdisc_alloc (void)
void rtnl_qdisc_free (struct rtnl_qdisc *qdisc)
void rtnl_qdisc_put (struct rtnl_qdisc *qdisc)

Qdisc Cache Management

struct nl_cache * rtnl_qdisc_alloc_cache (struct nl_handle *handle)
struct rtnl_qdisc * rtnl_qdisc_get (struct nl_cache *cache, int ifindex, uint32_t handle)
struct rtnl_qdisc * rtnl_qdisc_get_by_parent (struct nl_cache *cache, int ifindex, uint32_t parent)

QDisc Modification

struct nl_msg * rtnl_qdisc_build_change_request (struct rtnl_qdisc *qdisc, struct rtnl_qdisc *new)
int rtnl_qdisc_change (struct nl_handle *handle, struct rtnl_qdisc *qdisc, struct rtnl_qdisc *new)

QDisc Deletion

struct nl_msg * rtnl_qdisc_build_delete_request (struct rtnl_qdisc *qdisc)
int rtnl_qdisc_delete (struct nl_handle *handle, struct rtnl_qdisc *qdisc)


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

Attribute Modification

uint32_t rtnl_qdisc_get_handle (struct rtnl_qdisc *qdisc)
int rtnl_qdisc_get_ifindex (struct rtnl_qdisc *qdisc)
char * rtnl_qdisc_get_kind (struct rtnl_qdisc *qdisc)
uint32_t rtnl_qdisc_get_parent (struct rtnl_qdisc *qdisc)
uint64_t rtnl_qdisc_get_stat (struct rtnl_qdisc *qdisc, enum rtnl_tc_stats_id id)
void rtnl_qdisc_set_handle (struct rtnl_qdisc *qdisc, uint32_t handle)
void rtnl_qdisc_set_ifindex (struct rtnl_qdisc *qdisc, int ifindex)
void rtnl_qdisc_set_kind (struct rtnl_qdisc *qdisc, const char *name)
void rtnl_qdisc_set_parent (struct rtnl_qdisc *qdisc, uint32_t parent)

Qdisc Specific Options

struct nl_msg * rtnl_qdisc_get_opts (struct rtnl_qdisc *qdisc)

QDisc Module API

int rtnl_qdisc_register (struct rtnl_qdisc_ops *ops)
int rtnl_qdisc_unregister (struct rtnl_qdisc_ops *ops)


static int qdisc_dump_brief (struct nl_object *obj, struct nl_dump_params *p)
static int qdisc_dump_full (struct nl_object *arg, struct nl_dump_params *p)
static int qdisc_dump_stats (struct nl_object *arg, struct nl_dump_params *p)
static void __exit qdisc_exit (void)
static int qdisc_filter (struct nl_object *obj, struct nl_object *filter)
static void qdisc_free_data (struct nl_object *obj)
static void __init qdisc_init (void)
static struct rtnl_qdisc_opsqdisc_lookup_ops (const char *kind)
static int qdisc_msg_parser (struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
static struct rtnl_qdisc_opsqdisc_ops (struct rtnl_qdisc *qdisc)
static int qdisc_request_update (struct nl_cache *c, struct nl_handle *h)


static struct rtnl_qdisc_opsqdisc_ops_list
static struct nl_cache_ops rtnl_qdisc_ops

Generated by  Doxygen 1.6.0   Back to index