On Sat, Feb 02, 2008 at 12:49:03PM +0100, Filippo Giunchedi wrote:
> On Sat, Feb 02, 2008 at 10:48:32AM +0100, Lionel Elie Mamane wrote:
> [snip]
>> The negative scores are only a particularly noticeable specific case
>> of corruption, other scores may be corrupted in a less noticeable
>> way.
>> - actually look at hip->ip_dst to match ICMP packets with hosts in
>> packet_ok; this one seems more robust to me.
> As always patches are welcome,
Here you are. I also removed the "unsigned and signed comparison"
warnings from the code; feel free to drop the hunks that do that if
you want.
There was the remaining problem that if two (different or not)
hostnames on the command line resolve to the same IP, the ICMP packets
about them could still be confused, corrupting the statistics (if they
both had the same 'seq'). I changed netselect so that it detects
duplicates and treats every IP address only once; another solution
would have been to ensure that they get different 'seq' values, but
that was more complicated for little, if any, gain.
> thus I'm open to co-maintainership if you are interested
I didn't quite take that as "go, upload!", so I'm refraining.
--
Lionel
diff --recursive -uw netselect-0.3.ds1/debian/changelog netselect-0.3.ds1.lio/debian/changelog
--- netselect-0.3.ds1/debian/changelog 2008-03-02 15:53:59.000000000 +0100
+++ netselect-0.3.ds1.lio/debian/changelog 2008-03-02 15:49:58.940774637 +0100
@@ -1,3 +1,10 @@
+netselect (0.3.ds1-12) unstable; urgency=low
+
+ * Don't confuse hosts when more than 256 of them (closes: #431928)
+ * Detect duplicate/aliased hosts
+
+ -- Lionel Elie Mamane <[EMAIL PROTECTED]> Sun, 02 Mar 2008 15:49:55 +0100
+
netselect (0.3.ds1-11) unstable; urgency=low
* updated portuguese translation (Closes: #420362, #439695)
Only in netselect-0.3.ds1.lio/debian: changelog~
diff --recursive -uw netselect-0.3.ds1/netselect.c netselect-0.3.ds1.lio/netselect.c
--- netselect-0.3.ds1/netselect.c 2008-03-02 15:53:59.000000000 +0100
+++ netselect-0.3.ds1.lio/netselect.c 2008-03-02 15:52:36.437441213 +0100
@@ -151,7 +151,8 @@
extern char *optarg;
extern int optind;
int hostcount, startcount, endcount = 0, sent_one, lag, min_lag = 100;
- int ch, seq, ttl, max_ttl = 30, min_tries = 10, num_score = 1;
+ int ch, seq, ttl, max_ttl = 30, num_score = 1;
+ unsigned int min_tries = 10;
struct timeval now;
struct timezone tz;
OPacket outpacket; /* last output (udp) packet */
@@ -420,6 +421,19 @@
{
HostData *host;
+ if (addr)
+ {
+ int hcount;
+ for (hcount = 0, host = hosts; hcount < *numhosts; hcount++, host++)
+ if (host->addr.sin_addr.s_addr == addr->sin_addr.s_addr)
+ {
+ if (verbose >= 1)
+ fprintf(stderr, "\nDuplicate address %s (%s, %s); keeping only under first name.\n",
+ inet_ntoa(addr->sin_addr), host->hostname, hostname);
+ return hosts;
+ }
+ }
+
(*numhosts)++;
if (!hosts)
@@ -562,7 +576,7 @@
result.addr.sin_family = AF_INET;
result.addr.sin_addr.s_addr = inet_addr(names[count]);
- if (result.addr.sin_addr.s_addr != -1)
+ if (result.addr.sin_addr.s_addr != INADDR_NONE)
{
write(pipes[1], &result, sizeof(result));
}
@@ -788,7 +802,7 @@
#if !defined(__GLIBC__)
int fromlen = sizeof(from);
#else /* __GLIBC__ */
- size_t fromlen = sizeof(from);
+ socklen_t fromlen = sizeof(from);
#endif /* __GLIBC__ */
FD_ZERO(&fds);
@@ -859,7 +873,8 @@
if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP &&
up->uh_sport == htons(ident) &&
- up->uh_dport == htons(port + host->seq))
+ up->uh_dport == htons(port + host->seq) &&
+ hip->ip_dst.s_addr == host->addr.sin_addr.s_addr)
{
host->code = (type == ICMP_TIMXCEED ? -1 : code + 1);
return host;