libnl/lib
Jose Ignacio Naranjo Hernández 52d6b8b9ee Fix a bug when calculating ticks_per_usec
I've noticed a wrong behavior when setting up some delays in a netem
qdisc.  I will try to make the things easier for the reader describing
the calls path.

To set up a delay (or jitter...) I use 'rtnl_netem_set_delay' which
requires an int parameter that tells the delay in micro seconds. Inside
this func, the delay is set up with the help of 'nl_us2ticks', which is
just an arithmetic operation (us * ticks_per_usec), where us is the
input parameter and ticks_per_usec is a global variable initialized in
'get_psched_settings'. And here is the problem:

If this variable is going to be calculated using '/proc/net/psched', I
think the file scan is not done properly.

I don't understand what the meaning of the asterisk is here:

int r = fscanf(fd, "%08x%08x%08x%*08x", &tick, &us, &nom);
if (4 == r && nom == 1000000 && !got_tick)
        ticks_per_usec = (double)tick/(double)us;

The execution path never gets in the if statement, because r is always
3, and if the fourth parameter is read (avoiding the asterisk), there is
no variable to store it in, so it comes a segv. In my opinion we can get
rid of the if statement, because I think the proc psched file has always
a fixed format of 4 parameters, and 'nom' is always 1000000
(http://lxr.linux.no/#linux+v2.6.32/net/sched/sch_api.c#L1678).

Find attached a patch I did, if I am correct.
2010-03-10 16:18:54 +01:00
..
fib_lookup restructure module documentation order 2008-12-10 18:12:30 +01:00
genl restructure module documentation order 2008-12-10 18:12:30 +01:00
netfilter new function nfnl_queue_msg_send_verdict_payload() 2010-03-10 16:02:01 +01:00
route one more fix, u32.c 2009-12-07 16:27:59 +01:00
.gitignore Build separate libraries for each netilnk family 2008-05-15 18:01:50 +02:00
addr.c restructure module documentation order 2008-12-10 18:12:30 +01:00
attr.c Introduce nla_strdup() to help parse strings attributes 2008-06-13 16:40:41 +02:00
cache.c Remove old line counting while dumping 2008-05-23 23:45:14 +02:00
cache_mngr.c Fix up naming changes 2008-12-10 18:16:31 +01:00
cache_mngt.c restructure module documentation order 2008-12-10 18:12:30 +01:00
data.c restructure module documentation order 2008-12-10 18:12:30 +01:00
doc.c Documentation update 2008-12-03 19:58:41 +01:00
error.c libnl: add ERANGE to errno translation 2009-11-10 11:29:07 +01:00
handlers.c restructure module documentation order 2008-12-10 18:12:30 +01:00
Makefile.am libnl: fix automake breakage 2009-11-10 11:28:51 +01:00
msg.c Patch for unexpectedly aligned messages 2009-09-02 18:43:03 +02:00
nl.c new feature nl_send_iovec(), nl_auto_complete() and code refactoring. 2010-03-10 16:01:46 +01:00
object.c nl_object_clone: properly clone ce_mask field 2009-07-20 11:58:57 +02:00
socket.c release_local_port: properly compute the bitmap position 2009-05-04 14:56:24 +02:00
utils.c Fix a bug when calculating ticks_per_usec 2010-03-10 16:18:54 +01:00