From joseignacio.naranjo at gmail.com  Tue May 19 04:33:57 2009
From: joseignacio.naranjo at gmail.com (Jose Ignacio Naranjo)
Date: Tue, 19 May 2009 10:33:57 +0200
Subject: problem adding a netem qdisc
Message-ID: <1242722037.5624.88.camel@aphrodite>

Hello new list :), I need your help please:

I am using libnl version 1.1-5(according to Debian) and I can't add a
netem qdisc. I've added HTB classes and qdiscs, prio qdiscs, bfifo
leafs... but I can't get working a netem qdisc, because when adding, it
answers me 'Netlink Error (errno = Invalid argument)'.

The construction sequence is:

- Get the handle.
  struct nl_handle *nl_handle = nl_handle_alloc();
  nl_connect(nl_handle, NETLINK_ROUTE);

- Fill the cache the get the ifindex.
  struct nl_cache *cache = rtnl_link_alloc_cache(nl_handle);
  int ifindex = rtnl_link_name2i(cache, INTF);

- Allocate the qdisc and set the parent, handle and interface.
  rtnl_tc_str2handle("1:", &handle),
  struct rtnl_qdisc *qdisc = rtnl_qdisc_alloc();
  rtnl_qdisc_set_ifindex(qdisc, ifindex);
  rtnl_qdisc_set_parent(qdisc, TC_H_ROOT);
  rtnl_qdisc_set_handle(qdisc, handle);

- Set the kind and configure the netem parameters.
  rtnl_qdisc_set_kind(qdisc, "netem");
  rtnl_netem_set_delay(qdisc, delay);
  rtnl_netem_set_jitter(qdisc, jitter);
  rtnl_netem_set_loss(qdisc, loss);

- Finally, add the qdisc.
  rtnl_qdisc_add(nl_handle, qdisc, NLM_F_REPLACE);

Following the same pattern, I can build other qdiscs. Where is the
'invalid argument'?. Am I missing something mandatory for netem?

Thank you very much in advance,
JI

P.D: For more information, find attached the small program I used for
testing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libnl-cl_netem.c
Type: text/x-csrc
Size: 4449 bytes
Desc: not available
URL: <http://bombadil.infradead.org/pipermail/libnl/attachments/20090519/9d0fb3e8/attachment.bin>

