Increase size of ifindex hash heads
The default of 16 is too small for users with 10,000 interfaces.
This commit is contained in:
parent
1da5f6b2ca
commit
1e21ea71a7
12
lib/ll_map.c
12
lib/ll_map.c
|
|
@ -35,7 +35,8 @@ struct idxmap
|
||||||
char name[16];
|
char name[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct idxmap *idxmap[16];
|
#define IDXMAP_SIZE 1024
|
||||||
|
static struct idxmap *idxmap[IDXMAP_SIZE];
|
||||||
|
|
||||||
int ll_remember_index(const struct sockaddr_nl *who,
|
int ll_remember_index(const struct sockaddr_nl *who,
|
||||||
struct nlmsghdr *n, void *arg)
|
struct nlmsghdr *n, void *arg)
|
||||||
|
|
@ -51,15 +52,13 @@ int ll_remember_index(const struct sockaddr_nl *who,
|
||||||
if (n->nlmsg_len < NLMSG_LENGTH(sizeof(ifi)))
|
if (n->nlmsg_len < NLMSG_LENGTH(sizeof(ifi)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
memset(tb, 0, sizeof(tb));
|
memset(tb, 0, sizeof(tb));
|
||||||
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), IFLA_PAYLOAD(n));
|
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), IFLA_PAYLOAD(n));
|
||||||
if (tb[IFLA_IFNAME] == NULL)
|
if (tb[IFLA_IFNAME] == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
h = ifi->ifi_index&0xF;
|
h = ifi->ifi_index & (IDXMAP_SIZE - 1);
|
||||||
|
for (imp = &idxmap[h]; (im=*imp)!=NULL; imp = &im->next)
|
||||||
for (imp=&idxmap[h]; (im=*imp)!=NULL; imp = &im->next)
|
|
||||||
if (im->index == ifi->ifi_index)
|
if (im->index == ifi->ifi_index)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -94,7 +93,8 @@ const char *ll_idx_n2a(unsigned idx, char *buf)
|
||||||
|
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
return "*";
|
return "*";
|
||||||
for (im = idxmap[idx&0xF]; im; im = im->next)
|
|
||||||
|
for (im = idxmap[idx & (IDXMAP_SIZE - 1)]; im; im = im->next)
|
||||||
if (im->index == idx)
|
if (im->index == idx)
|
||||||
return im->name;
|
return im->name;
|
||||||
snprintf(buf, 16, "if%d", idx);
|
snprintf(buf, 16, "if%d", idx);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue