Logo Search packages:      
Sourcecode: libnl2 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
 rtnl_qdisc_put(qdisc);
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
 rtnl_qdisc_put(qdisc);


Modules

 Queueing Discipline Modules
 Queueing Discipline Object

Classes

struct  rtnl_qdisc_ops

QDisc Addition

static int qdisc_build (struct rtnl_qdisc *qdisc, int type, int flags, struct nl_msg **result)
int rtnl_qdisc_add (struct nl_sock *sk, struct rtnl_qdisc *qdisc, int flags)
int rtnl_qdisc_build_add_request (struct rtnl_qdisc *qdisc, int flags, struct nl_msg **result)

Qdisc Cache Management

int rtnl_qdisc_alloc_cache (struct nl_sock *sk, struct nl_cache **result)
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

int rtnl_qdisc_build_change_request (struct rtnl_qdisc *qdisc, struct rtnl_qdisc *new, struct nl_msg **result)
int rtnl_qdisc_change (struct nl_sock *sk, struct rtnl_qdisc *qdisc, struct rtnl_qdisc *new)

QDisc Deletion

int rtnl_qdisc_build_delete_request (struct rtnl_qdisc *qdisc, struct nl_msg **result)
int rtnl_qdisc_delete (struct nl_sock *sk, struct rtnl_qdisc *qdisc)

Functions

static void __exit qdisc_exit (void)
static void __init qdisc_init (void)
static int qdisc_msg_parser (struct nl_cache_ops *ops, struct sockaddr_nl *who, struct nlmsghdr *n, struct nl_parser_param *pp)
static int qdisc_request_update (struct nl_cache *c, struct nl_sock *sk)

Variables

static struct nl_cache_ops rtnl_qdisc_ops


Generated by  Doxygen 1.6.0   Back to index