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
37c9cceb
Commit
37c9cceb
authored
Jan 09, 2013
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DHCPv6 address allocation - same DUID, two IAIDs
parent
71c73ac1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
32 deletions
+49
-32
src/dhcp6.c
src/dhcp6.c
+23
-15
src/dnsmasq.h
src/dnsmasq.h
+3
-0
src/rfc3315.c
src/rfc3315.c
+23
-17
No files found.
src/dhcp6.c
View file @
37c9cceb
...
@@ -328,6 +328,7 @@ int address6_allocate(struct dhcp_context *context, unsigned char *clid, int cl
...
@@ -328,6 +328,7 @@ int address6_allocate(struct dhcp_context *context, unsigned char *clid, int cl
return
0
;
return
0
;
}
}
/* can dynamically allocate addr */
struct
dhcp_context
*
address6_available
(
struct
dhcp_context
*
context
,
struct
dhcp_context
*
address6_available
(
struct
dhcp_context
*
context
,
struct
in6_addr
*
taddr
,
struct
in6_addr
*
taddr
,
struct
dhcp_netid
*
netids
)
struct
dhcp_netid
*
netids
)
...
@@ -352,6 +353,22 @@ struct dhcp_context *address6_available(struct dhcp_context *context,
...
@@ -352,6 +353,22 @@ struct dhcp_context *address6_available(struct dhcp_context *context,
return
NULL
;
return
NULL
;
}
}
/* address OK if configured */
struct
dhcp_context
*
address6_valid
(
struct
dhcp_context
*
context
,
struct
in6_addr
*
taddr
,
struct
dhcp_netid
*
netids
)
{
struct
dhcp_context
*
tmp
;
for
(
tmp
=
context
;
tmp
;
tmp
=
tmp
->
current
)
if
((
tmp
->
flags
&
CONTEXT_STATIC
)
&&
is_same_net6
(
&
tmp
->
start6
,
taddr
,
tmp
->
prefix
)
&&
match_netid
(
tmp
->
filter
,
netids
,
1
))
return
tmp
;
return
NULL
;
}
struct
dhcp_context
*
narrow_context6
(
struct
dhcp_context
*
context
,
struct
dhcp_context
*
narrow_context6
(
struct
dhcp_context
*
context
,
struct
in6_addr
*
taddr
,
struct
in6_addr
*
taddr
,
struct
dhcp_netid
*
netids
)
struct
dhcp_netid
*
netids
)
...
@@ -366,21 +383,12 @@ struct dhcp_context *narrow_context6(struct dhcp_context *context,
...
@@ -366,21 +383,12 @@ struct dhcp_context *narrow_context6(struct dhcp_context *context,
struct
dhcp_context
*
tmp
;
struct
dhcp_context
*
tmp
;
if
(
!
(
tmp
=
address6_available
(
context
,
taddr
,
netids
)))
if
(
!
(
tmp
=
address6_available
(
context
,
taddr
,
netids
))
&&
{
!
(
tmp
=
address6_valid
(
context
,
taddr
,
netids
)))
for
(
tmp
=
context
;
tmp
;
tmp
=
tmp
->
current
)
for
(
tmp
=
context
;
tmp
;
tmp
=
tmp
->
current
)
if
(
match_netid
(
tmp
->
filter
,
netids
,
1
)
&&
if
(
match_netid
(
tmp
->
filter
,
netids
,
1
)
&&
is_same_net6
(
taddr
,
&
tmp
->
start6
,
tmp
->
prefix
)
&&
is_same_net6
(
taddr
,
&
tmp
->
start6
,
tmp
->
prefix
))
(
tmp
->
flags
&
CONTEXT_STATIC
))
break
;
break
;
if
(
!
tmp
)
for
(
tmp
=
context
;
tmp
;
tmp
=
tmp
->
current
)
if
(
match_netid
(
tmp
->
filter
,
netids
,
1
)
&&
is_same_net6
(
taddr
,
&
tmp
->
start6
,
tmp
->
prefix
)
&&
!
(
tmp
->
flags
&
CONTEXT_PROXY
))
break
;
}
/* Only one context allowed now */
/* Only one context allowed now */
if
(
tmp
)
if
(
tmp
)
...
...
src/dnsmasq.h
View file @
37c9cceb
...
@@ -1149,6 +1149,9 @@ int is_addr_in_context6(struct dhcp_context *context, struct in6_addr *addr);
...
@@ -1149,6 +1149,9 @@ int is_addr_in_context6(struct dhcp_context *context, struct in6_addr *addr);
struct
dhcp_context
*
address6_available
(
struct
dhcp_context
*
context
,
struct
dhcp_context
*
address6_available
(
struct
dhcp_context
*
context
,
struct
in6_addr
*
taddr
,
struct
in6_addr
*
taddr
,
struct
dhcp_netid
*
netids
);
struct
dhcp_netid
*
netids
);
struct
dhcp_context
*
address6_valid
(
struct
dhcp_context
*
context
,
struct
in6_addr
*
taddr
,
struct
dhcp_netid
*
netids
);
struct
dhcp_context
*
narrow_context6
(
struct
dhcp_context
*
context
,
struct
dhcp_context
*
narrow_context6
(
struct
dhcp_context
*
context
,
struct
in6_addr
*
taddr
,
struct
in6_addr
*
taddr
,
struct
dhcp_netid
*
netids
);
struct
dhcp_netid
*
netids
);
...
...
src/rfc3315.c
View file @
37c9cceb
...
@@ -525,32 +525,38 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
...
@@ -525,32 +525,38 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
{
{
struct
in6_addr
*
req_addr
=
opt6_ptr
(
ia_option
,
0
);
struct
in6_addr
*
req_addr
=
opt6_ptr
(
ia_option
,
0
);
requested_time
=
opt6_uint
(
ia_option
,
16
,
4
);
requested_time
=
opt6_uint
(
ia_option
,
16
,
4
);
struct
dhcp_context
*
dynamic
;
if
(
!
address6_available
(
context
,
req_addr
,
tags
)
&&
(
!
have_config
(
config
,
CONFIG_ADDR6
)
||
memcmp
(
&
config
->
addr6
,
req_addr
,
IN6ADDRSZ
)
!=
0
))
if
((
dynamic
=
address6_available
(
context
,
req_addr
,
tags
))
||
address6_valid
(
context
,
req_addr
,
tags
))
{
{
if
(
msg_type
==
DHCP6REQUEST
)
if
(
!
dynamic
&&
!
(
have_config
(
config
,
CONFIG_ADDR6
)
&&
memcmp
(
&
config
->
addr6
,
req_addr
,
IN6ADDRSZ
)
==
0
)
)
{
{
/*
host has a lease, but it's not on the correct link
*/
/*
Static range, not configured.
*/
o1
=
new_opt6
(
OPTION6_STATUS_CODE
);
o1
=
new_opt6
(
OPTION6_STATUS_CODE
);
put_opt6_short
(
DHCP6
NOTONLINK
);
put_opt6_short
(
DHCP6
UNSPEC
);
put_opt6_string
(
"
Not on link
"
);
put_opt6_string
(
"
Address unavailable
"
);
end_opt6
(
o1
);
end_opt6
(
o1
);
}
}
else
if
(
lease6_find_by_addr
(
req_addr
,
128
,
0
)
&&
!
(
lease
=
lease6_find
(
clid
,
clid_len
,
ia_type
==
OPTION6_IA_NA
?
LEASE_NA
:
LEASE_TA
,
iaid
,
req_addr
)))
{
/* Address leased to another DUID/IAID */
o1
=
new_opt6
(
OPTION6_STATUS_CODE
);
put_opt6_short
(
DHCP6UNSPEC
);
put_opt6_string
(
"Address in use"
);
end_opt6
(
o1
);
}
else
addrp
=
req_addr
;
}
}
else
if
((
lease
=
lease6_find
(
NULL
,
0
,
ia_type
==
OPTION6_IA_NA
?
LEASE_NA
:
LEASE_TA
,
else
if
(
msg_type
==
DHCP6REQUEST
)
iaid
,
req_addr
))
&&
(
clid_len
!=
lease
->
clid_len
||
memcmp
(
clid
,
lease
->
clid
,
clid_len
)
!=
0
))
{
{
/*
Address leased to another DUID
*/
/*
requested address not on the correct link
*/
o1
=
new_opt6
(
OPTION6_STATUS_CODE
);
o1
=
new_opt6
(
OPTION6_STATUS_CODE
);
put_opt6_short
(
DHCP6
UNSPEC
);
put_opt6_short
(
DHCP6
NOTONLINK
);
put_opt6_string
(
"
Address in use
"
);
put_opt6_string
(
"
Not on link
"
);
end_opt6
(
o1
);
end_opt6
(
o1
);
}
}
else
addrp
=
req_addr
;
}
}
else
else
{
{
...
...
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