Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Dnsmasq
Commits
9380ba70
Commit
9380ba70
authored
Apr 16, 2012
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set SO_BINDTODEVICE on DHCP sockets when doing DHCP on one interface
only. Fixes OpenSTack use-case.
parent
1023dcbc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
2 deletions
+70
-2
CHANGELOG
CHANGELOG
+7
-0
src/dhcp-common.c
src/dhcp-common.c
+35
-0
src/dnsmasq.c
src/dnsmasq.c
+15
-0
src/dnsmasq.h
src/dnsmasq.h
+4
-1
src/network.c
src/network.c
+9
-1
No files found.
CHANGELOG
View file @
9380ba70
...
...
@@ -80,6 +80,13 @@ version 2.61
Don't cache data from non-recursive nameservers, since it
may erroneously look like a valid CNAME to a non-exitant
name. Thanks to Ben Winslow for finding this.
Call SO_BINDTODEVICE on the DHCP socket(s) when doing DHCP
on exacly one interface and --bind-interfaces is set. This
makes the OpenStack use-case of one dnsmasq per virtual
interface work. This is only available on Linux; it's not
supported on other platforms. Thanks to Vishvananda Ishaya
and thr OpenStack team for the suggestion.
version 2.60
...
...
src/dhcp-common.c
View file @
9380ba70
...
...
@@ -451,6 +451,41 @@ void join_multicast(void)
}
#endif
#ifdef HAVE_LINUX_NETWORK
void
bindtodevice
(
int
fd
)
{
/* If we are doing DHCP on exactly one interface, and running linux, do SO_BINDTODEVICE
to that device. This is for the use case of (eg) OpenStack, which runs a new
dnsmasq instance for each VLAN interface it creates. Without the BINDTODEVICE,
individual processes don't always see the packets they should.
SO_BINDTODEVICE is only available Linux. */
struct
irec
*
iface
,
*
found
;
for
(
found
=
NULL
,
iface
=
daemon
->
interfaces
;
iface
;
iface
=
iface
->
next
)
if
(
iface
->
dhcp_ok
)
{
if
(
!
found
)
found
=
iface
;
else
if
(
strcmp
(
found
->
name
,
iface
->
name
)
!=
0
)
{
/* more than one. */
found
=
NULL
;
break
;
}
}
if
(
found
)
{
struct
ifreq
ifr
;
strcpy
(
ifr
.
ifr_name
,
found
->
name
);
/* only allowed by root. */
if
(
setsockopt
(
fd
,
SOL_SOCKET
,
SO_BINDTODEVICE
,
(
void
*
)
&
ifr
,
sizeof
(
ifr
))
==
-
1
&&
errno
!=
EPERM
)
die
(
_
(
"failed to set SO_BINDTODEVICE on DHCP socket: %s"
),
NULL
,
EC_BADNET
);
}
}
#endif
static
const
struct
opttab_t
{
char
*
name
;
...
...
src/dnsmasq.c
View file @
9380ba70
...
...
@@ -209,6 +209,21 @@ int main (int argc, char **argv)
for
(
if_tmp
=
daemon
->
if_names
;
if_tmp
;
if_tmp
=
if_tmp
->
next
)
if
(
if_tmp
->
name
&&
!
if_tmp
->
used
)
die
(
_
(
"unknown interface %s"
),
if_tmp
->
name
,
EC_BADNET
);
#if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP)
/* after enumerate_interfaces() */
if
(
daemon
->
dhcp
)
{
bindtodevice
(
daemon
->
dhcpfd
);
if
(
daemon
->
enable_pxe
)
bindtodevice
(
daemon
->
pxefd
);
}
#endif
#if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP6)
if
(
daemon
->
dhcp6
)
bindtodevice
(
daemon
->
dhcp6fd
);
#endif
}
else
create_wildcard_listeners
();
...
...
src/dnsmasq.h
View file @
9380ba70
...
...
@@ -388,7 +388,7 @@ struct server {
struct
irec
{
union
mysockaddr
addr
;
struct
in_addr
netmask
;
/* only valid for IPv4 */
int
tftp_ok
,
mtu
,
done
,
dad
;
int
tftp_ok
,
dhcp_ok
,
mtu
,
done
,
dad
;
char
*
name
;
struct
irec
*
next
;
};
...
...
@@ -1108,6 +1108,9 @@ u16 lookup_dhcp_opt(int prot, char *name);
u16
lookup_dhcp_len
(
int
prot
,
u16
val
);
char
*
option_string
(
int
prot
,
unsigned
int
opt
,
unsigned
char
*
val
,
int
opt_len
,
char
*
buf
,
int
buf_len
);
#ifdef HAVE_LINUX_NETWORK
void
bindtodevice
(
int
fd
);
#endif
# ifdef HAVE_DHCP6
void
display_opts6
(
void
);
void
join_multicast
(
void
);
...
...
src/network.c
View file @
9380ba70
...
...
@@ -162,6 +162,7 @@ static int iface_allowed(struct irec **irecp, int if_index,
int
fd
,
mtu
=
0
,
loopback
;
struct
ifreq
ifr
;
int
tftp_ok
=
daemon
->
tftp_unlimited
;
int
dhcp_ok
=
1
;
#ifdef HAVE_DHCP
struct
iname
*
tmp
;
#endif
...
...
@@ -190,6 +191,9 @@ static int iface_allowed(struct irec **irecp, int if_index,
}
loopback
=
ifr
.
ifr_flags
&
IFF_LOOPBACK
;
if
(
loopback
)
dhcp_ok
=
0
;
if
(
ioctl
(
fd
,
SIOCGIFMTU
,
&
ifr
)
!=
-
1
)
mtu
=
ifr
.
ifr_mtu
;
...
...
@@ -238,7 +242,10 @@ static int iface_allowed(struct irec **irecp, int if_index,
#ifdef HAVE_DHCP
for
(
tmp
=
daemon
->
dhcp_except
;
tmp
;
tmp
=
tmp
->
next
)
if
(
tmp
->
name
&&
(
strcmp
(
tmp
->
name
,
ifr
.
ifr_name
)
==
0
))
tftp_ok
=
0
;
{
tftp_ok
=
0
;
dhcp_ok
=
0
;
}
#endif
#ifdef HAVE_IPV6
...
...
@@ -254,6 +261,7 @@ static int iface_allowed(struct irec **irecp, int if_index,
iface
->
addr
=
*
addr
;
iface
->
netmask
=
netmask
;
iface
->
tftp_ok
=
tftp_ok
;
iface
->
dhcp_ok
=
dhcp_ok
;
iface
->
mtu
=
mtu
;
iface
->
dad
=
dad
;
iface
->
done
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment