initial import
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
|
||||
index 1e21005b..c6067f7e 100644
|
||||
--- a/src/dnsmasq.h
|
||||
+++ b/src/dnsmasq.h
|
||||
@@ -544,7 +544,7 @@ struct serverfd {
|
||||
int fd;
|
||||
union mysockaddr source_addr;
|
||||
char interface[IF_NAMESIZE+1];
|
||||
- unsigned int ifindex, used, preallocated;
|
||||
+ unsigned int ifindex, used;
|
||||
struct serverfd *next;
|
||||
};
|
||||
|
||||
diff --git a/src/network.c b/src/network.c
|
||||
index 3600250b..a2bdf1e3 100644
|
||||
--- a/src/network.c
|
||||
+++ b/src/network.c
|
||||
@@ -1409,11 +1409,15 @@ static struct serverfd *allocate_sfd(union mysockaddr *addr, char *intname, unsi
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+ if (intname && strlen(intname) != 0)
|
||||
+ ifindex = if_nametoindex(intname); /* index == 0 when not binding to an interface */
|
||||
+
|
||||
/* may have a suitable one already */
|
||||
for (sfd = daemon->sfds; sfd; sfd = sfd->next )
|
||||
if (ifindex == sfd->ifindex &&
|
||||
sockaddr_isequal(&sfd->source_addr, addr) &&
|
||||
- strcmp(intname, sfd->interface) == 0)
|
||||
+ strcmp(intname, sfd->interface) == 0 &&
|
||||
+ ifindex == sfd->ifindex)
|
||||
return sfd;
|
||||
|
||||
/* need to make a new one. */
|
||||
@@ -1441,7 +1445,6 @@ static struct serverfd *allocate_sfd(union mysockaddr *addr, char *intname, unsi
|
||||
sfd->source_addr = *addr;
|
||||
sfd->next = daemon->sfds;
|
||||
sfd->ifindex = ifindex;
|
||||
- sfd->preallocated = 0;
|
||||
daemon->sfds = sfd;
|
||||
|
||||
return sfd;
|
||||
@@ -1465,7 +1468,7 @@ void pre_allocate_sfds(void)
|
||||
addr.in.sin_len = sizeof(struct sockaddr_in);
|
||||
#endif
|
||||
if ((sfd = allocate_sfd(&addr, "", 0)))
|
||||
- sfd->preallocated = 1;
|
||||
+ sfd->used = 1;
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.in6.sin6_family = AF_INET6;
|
||||
@@ -1475,7 +1478,7 @@ void pre_allocate_sfds(void)
|
||||
addr.in6.sin6_len = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
if ((sfd = allocate_sfd(&addr, "", 0)))
|
||||
- sfd->preallocated = 1;
|
||||
+ sfd->used = 1;
|
||||
}
|
||||
|
||||
for (srv = daemon->servers; srv; srv = srv->next)
|
||||
@@ -1630,7 +1633,7 @@ void check_servers(void)
|
||||
|
||||
/* don't garbage collect pre-allocated sfds. */
|
||||
for (sfd = daemon->sfds; sfd; sfd = sfd->next)
|
||||
- sfd->used = sfd->preallocated;
|
||||
+ sfd->used = 0;
|
||||
|
||||
for (count = 0, serv = daemon->servers; serv; serv = serv->next)
|
||||
{
|
||||
Reference in New Issue
Block a user