Re: netlink & rhashtable status
From: Eric Dumazet <hidden>
Date: 2015-05-13 06:15:43
On Wed, 2015-05-13 at 13:40 +0800, Herbert Xu wrote:
On Tue, May 12, 2015 at 10:30:36PM -0700, Eric Dumazet wrote:quoted
linux-3.17, 3.18, 3.19 and 4.0.2 have issues with netlink/rhashtable, making things like getaddrinfo() not working after a while :Do you use namespaces? Cheers,
No.
Trick is to start about 200 threads using getaddrinfo()
This was spotted using netperf, but you probably can use something like
this program.
Thanks.
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
struct addrinfo *resolve_host(const char *hostname, const char *port,
int family)
{
struct addrinfo hints;
struct addrinfo *ai;
int count;
int error;
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
count = 0;
do {
error = getaddrinfo(hostname, port, &hints, &ai);
count += 1;
if (error == EAI_AGAIN) {
sleep(1);
}
} while ((error == EAI_AGAIN) && (count <= 5));
if (error) {
printf("error\n");
return (NULL);
}
return (ai);
}
int main(int argc, char **argv)
{
const char host[] = "127.0.0.1";
const char *port = NULL;
const int family = 0;
unsigned long iterations, i;
if (argc != 2) {
printf("Expected one arg.\n");
return -1;
}
iterations = atol(argv[1]);
for (i = 0; i < iterations; ++i) {
resolve_host(host, port, family);
}
return 0;
}