mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Obtain MTU of interface only when it would be used
MTU were obtained early during iface_allowed check. But often it returned from the function without ever using it. Because calls to kernel might be costy, move fetching it only when it would be assigned.
This commit is contained in:
committed by
Simon Kelley
parent
8b8a4148ec
commit
a8c1474562
@@ -232,7 +232,7 @@ static int iface_allowed(struct iface_param *param, int if_index, char *label,
|
|||||||
union mysockaddr *addr, struct in_addr netmask, int prefixlen, int iface_flags)
|
union mysockaddr *addr, struct in_addr netmask, int prefixlen, int iface_flags)
|
||||||
{
|
{
|
||||||
struct irec *iface;
|
struct irec *iface;
|
||||||
int mtu = 0, loopback;
|
int loopback;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int tftp_ok = !!option_bool(OPT_TFTP);
|
int tftp_ok = !!option_bool(OPT_TFTP);
|
||||||
int dhcp_ok = 1;
|
int dhcp_ok = 1;
|
||||||
@@ -253,9 +253,6 @@ static int iface_allowed(struct iface_param *param, int if_index, char *label,
|
|||||||
if (loopback)
|
if (loopback)
|
||||||
dhcp_ok = 0;
|
dhcp_ok = 0;
|
||||||
|
|
||||||
if (ioctl(param->fd, SIOCGIFMTU, &ifr) != -1)
|
|
||||||
mtu = ifr.ifr_mtu;
|
|
||||||
|
|
||||||
if (!label)
|
if (!label)
|
||||||
label = ifr.ifr_name;
|
label = ifr.ifr_name;
|
||||||
else
|
else
|
||||||
@@ -458,6 +455,11 @@ static int iface_allowed(struct iface_param *param, int if_index, char *label,
|
|||||||
/* add to list */
|
/* add to list */
|
||||||
if ((iface = whine_malloc(sizeof(struct irec))))
|
if ((iface = whine_malloc(sizeof(struct irec))))
|
||||||
{
|
{
|
||||||
|
int mtu = 0;
|
||||||
|
|
||||||
|
if (ioctl(param->fd, SIOCGIFMTU, &ifr) != -1)
|
||||||
|
mtu = ifr.ifr_mtu;
|
||||||
|
|
||||||
iface->addr = *addr;
|
iface->addr = *addr;
|
||||||
iface->netmask = netmask;
|
iface->netmask = netmask;
|
||||||
iface->tftp_ok = tftp_ok;
|
iface->tftp_ok = tftp_ok;
|
||||||
|
|||||||
Reference in New Issue
Block a user