[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0a842600-9707-4465-a5ea-6acfb38a9a70@tahiti.vyatta.com>
Date: Thu, 04 Oct 2012 15:06:34 -0700 (PDT)
From: Stephen Hemminger <stephen.hemminger@...tta.com>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: netdev@...r.kernel.org, David Miller <davem@...emloft.net>
Subject: Re: [PATCH] udp: port starting location not random
Nevermind, it depends on random being big enough. This shows that it
works with large enough random(). The hash I was getting from VXLAN
was too small...
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int main(int ac, char **av) {
int low, high, remaining;
unsigned int rand;
unsigned short first;
low = atoi(av[1]);
high = atoi(av[2]);
remaining = (high - low) + 1;
srandom(getpid());
rand = (uint32_t) random();
first = (((uint64_t)rand * remaining) >> 32) + low;
printf("%d %d %u => %u\n", low, high, rand, first);
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists