Beattie, David
2004-10-18 03:30:10 UTC
Hi all,
I've discovered (through debugging an application error I was having) a
bug in the ptag id creation. It seems that the value (-1) is used as an
error code in returning from libnet_build_*, and otherwise the return
value from that series of functions is to be a unique integer
representing a tag value for the pblock structure created internally and
linked into the libnet_t structure.
The problem I'm having is that after constructing and sending very many
unique packets (on the order of a billion), the ptag_state incremental
counter which is used to initialize ptag values wraps all the way around
until it contains the unsigned equivalent of (-1), thus artificially
signaling an error code.
Here's my first attempt at fixing the problem on my machine--by adding a
line to libnet_build_tcp.c, libnet_build_ip.c, and libnet_pblock.c, like
the following:
p_data->ptag = ++(l->ptag_state);
l->ptag_state &= 0x7FFFFFFF; /* added line to control
wraparound of ptag_state so it doesn't hit (-1) */
I have tested this fix, and it works fine on my 32-bit
Intel-architecture machine. Before accepting it as the best solution, I
would want people to think about non-32-bit machines, non-Intel
architectures, and any efficiency considerations (although the and
operation I implemented should be very efficient). Any comments?
--David
I've discovered (through debugging an application error I was having) a
bug in the ptag id creation. It seems that the value (-1) is used as an
error code in returning from libnet_build_*, and otherwise the return
value from that series of functions is to be a unique integer
representing a tag value for the pblock structure created internally and
linked into the libnet_t structure.
The problem I'm having is that after constructing and sending very many
unique packets (on the order of a billion), the ptag_state incremental
counter which is used to initialize ptag values wraps all the way around
until it contains the unsigned equivalent of (-1), thus artificially
signaling an error code.
Here's my first attempt at fixing the problem on my machine--by adding a
line to libnet_build_tcp.c, libnet_build_ip.c, and libnet_pblock.c, like
the following:
p_data->ptag = ++(l->ptag_state);
l->ptag_state &= 0x7FFFFFFF; /* added line to control
wraparound of ptag_state so it doesn't hit (-1) */
I have tested this fix, and it works fine on my 32-bit
Intel-architecture machine. Before accepting it as the best solution, I
would want people to think about non-32-bit machines, non-Intel
architectures, and any efficiency considerations (although the and
operation I implemented should be very efficient). Any comments?
--David