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
c8257540
Commit
c8257540
authored
Mar 28, 2012
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"deprecated" lease-time keyword for IPv6
parent
22407048
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
124 additions
and
107 deletions
+124
-107
CHANGELOG
CHANGELOG
+12
-0
man/dnsmasq.8
man/dnsmasq.8
+6
-2
src/dhcp6.c
src/dhcp6.c
+4
-4
src/dnsmasq.c
src/dnsmasq.c
+33
-16
src/dnsmasq.h
src/dnsmasq.h
+1
-0
src/option.c
src/option.c
+2
-10
src/radv.c
src/radv.c
+45
-59
src/rfc3315.c
src/rfc3315.c
+21
-16
No files found.
CHANGELOG
View file @
c8257540
...
@@ -55,6 +55,18 @@ version 2.61
...
@@ -55,6 +55,18 @@ version 2.61
received from a network which has no valid dhcp-range.
received from a network which has no valid dhcp-range.
Thanks to Stephane Glondu for the bug report.
Thanks to Stephane Glondu for the bug report.
Add a new DHCP lease time keyword, "deprecated" for
--dhcp-range. This is only valid for IPv6, and sets the
preffered lease time for both DHCP and RA to zero. The
effect is that clients can continue to use the address
for existing connections, but new connections will use
other addresses, if they exist. This makes hitless
renumbering at least possible.
Fix bug in address6_available() which caused DHCPv6 lease
aquistion to fail of more than one dhcp-range in use.
version 2.60
version 2.60
Fix compilation problem in Mac OS X Lion. Thanks to Olaf
Fix compilation problem in Mac OS X Lion. Thanks to Olaf
...
...
man/dnsmasq.8
View file @
c8257540
...
@@ -522,8 +522,12 @@ options. If the lease time is given, then leases
...
@@ -522,8 +522,12 @@ options. If the lease time is given, then leases
will be given for that length of time. The lease time is in seconds,
will be given for that length of time. The lease time is in seconds,
or minutes (eg 45m) or hours (eg 1h) or "infinite". If not given,
or minutes (eg 45m) or hours (eg 1h) or "infinite". If not given,
the default lease time is one hour. The
the default lease time is one hour. The
minimum lease time is two minutes. This
minimum lease time is two minutes. For IPv6 ranges, the lease time
option may be repeated, with different addresses, to enable DHCP
maybe "deprecated"; this sets the preferred lifetime sent in a DHCP
lease or router advertisement to zero, which causes clients to use
other addresses, if available, for new connections as a prelude to renumbering.
This option may be repeated, with different addresses, to enable DHCP
service to more than one network. For directly connected networks (ie,
service to more than one network. For directly connected networks (ie,
networks on which the machine running dnsmasq has an interface) the
networks on which the machine running dnsmasq has an interface) the
netmask is optional: dnsmasq will determine it from the interface
netmask is optional: dnsmasq will determine it from the interface
...
...
src/dhcp6.c
View file @
c8257540
...
@@ -229,7 +229,7 @@ int address6_allocate(struct dhcp_context *context, unsigned char *clid, int cl
...
@@ -229,7 +229,7 @@ int address6_allocate(struct dhcp_context *context, unsigned char *clid, int cl
for
(
pass
=
0
;
pass
<=
1
;
pass
++
)
for
(
pass
=
0
;
pass
<=
1
;
pass
++
)
for
(
c
=
context
;
c
;
c
=
c
->
current
)
for
(
c
=
context
;
c
;
c
=
c
->
current
)
if
(
c
->
flags
&
(
CONTEXT_STATIC
|
CONTEXT_RA_STATELESS
))
if
(
c
->
flags
&
(
CONTEXT_
DEPRECATE
|
CONTEXT_
STATIC
|
CONTEXT_RA_STATELESS
))
continue
;
continue
;
else
if
(
!
match_netid
(
c
->
filter
,
netids
,
pass
))
else
if
(
!
match_netid
(
c
->
filter
,
netids
,
pass
))
continue
;
continue
;
...
@@ -282,9 +282,9 @@ struct dhcp_context *address6_available(struct dhcp_context *context,
...
@@ -282,9 +282,9 @@ struct dhcp_context *address6_available(struct dhcp_context *context,
start
=
addr6part
(
&
tmp
->
start6
);
start
=
addr6part
(
&
tmp
->
start6
);
end
=
addr6part
(
&
tmp
->
end6
);
end
=
addr6part
(
&
tmp
->
end6
);
if
(
!
(
tmp
->
flags
&
(
CONTEXT_STATIC
|
CONTEXT_
PROXY
))
&&
if
(
!
(
tmp
->
flags
&
(
CONTEXT_STATIC
|
CONTEXT_
RA_STATELESS
))
&&
is_same_net6
(
&
context
->
start6
,
taddr
,
context
->
prefix
)
&&
is_same_net6
(
&
tmp
->
start6
,
taddr
,
tmp
->
prefix
)
&&
is_same_net6
(
&
context
->
end6
,
taddr
,
context
->
prefix
)
&&
is_same_net6
(
&
tmp
->
end6
,
taddr
,
tmp
->
prefix
)
&&
addr
>=
start
&&
addr
>=
start
&&
addr
<=
end
&&
addr
<=
end
&&
match_netid
(
tmp
->
filter
,
netids
,
1
))
match_netid
(
tmp
->
filter
,
netids
,
1
))
...
...
src/dnsmasq.c
View file @
c8257540
...
@@ -530,7 +530,7 @@ int main (int argc, char **argv)
...
@@ -530,7 +530,7 @@ int main (int argc, char **argv)
my_syslog
(
MS_DHCP
|
LOG_INFO
,
_
(
"IPv6 router advertisement enabled"
));
my_syslog
(
MS_DHCP
|
LOG_INFO
,
_
(
"IPv6 router advertisement enabled"
));
#ifdef HAVE_DHCP
#ifdef HAVE_DHCP
if
(
daemon
->
dhcp
||
daemon
->
dhcp6
)
if
(
daemon
->
dhcp
||
daemon
->
dhcp6
||
daemon
->
ra_contexts
)
{
{
struct
dhcp_context
*
dhcp_tmp
;
struct
dhcp_context
*
dhcp_tmp
;
int
family
=
AF_INET
;
int
family
=
AF_INET
;
...
@@ -543,7 +543,7 @@ int main (int argc, char **argv)
...
@@ -543,7 +543,7 @@ int main (int argc, char **argv)
{
{
void
*
start
=
&
dhcp_tmp
->
start
;
void
*
start
=
&
dhcp_tmp
->
start
;
void
*
end
=
&
dhcp_tmp
->
end
;
void
*
end
=
&
dhcp_tmp
->
end
;
#ifdef HAVE_DHCP6
#ifdef HAVE_DHCP6
if
(
family
==
AF_INET6
)
if
(
family
==
AF_INET6
)
{
{
...
@@ -551,31 +551,48 @@ int main (int argc, char **argv)
...
@@ -551,31 +551,48 @@ int main (int argc, char **argv)
end
=
&
dhcp_tmp
->
end6
;
end
=
&
dhcp_tmp
->
end6
;
struct
in6_addr
subnet
=
dhcp_tmp
->
start6
;
struct
in6_addr
subnet
=
dhcp_tmp
->
start6
;
setaddr6part
(
&
subnet
,
0
);
setaddr6part
(
&
subnet
,
0
);
inet_ntop
(
AF_INET6
,
&
subnet
,
daemon
->
dhcp_buff2
,
256
);
inet_ntop
(
AF_INET6
,
&
subnet
,
daemon
->
addrbuff
,
256
);
}
}
#endif
#endif
prettyprint_time
(
daemon
->
namebuff
,
dhcp_tmp
->
lease_time
);
if
(
family
!=
AF_INET
&&
(
dhcp_tmp
->
flags
&
CONTEXT_DEPRECATE
))
inet_ntop
(
family
,
start
,
daemon
->
dhcp_buff
,
256
);
strcpy
(
daemon
->
namebuff
,
_
(
"prefix deprecated"
));
inet_ntop
(
family
,
end
,
daemon
->
dhcp_buff3
,
256
);
else
{
char
*
p
=
daemon
->
namebuff
;
p
+=
sprintf
(
p
,
_
(
"lease time "
));
prettyprint_time
(
p
,
dhcp_tmp
->
lease_time
);
}
if
(
daemon
->
dhcp_buff
)
inet_ntop
(
family
,
start
,
daemon
->
dhcp_buff
,
256
);
if
(
daemon
->
dhcp_buff3
)
inet_ntop
(
family
,
end
,
daemon
->
dhcp_buff3
,
256
);
if
((
dhcp_tmp
->
flags
&
CONTEXT_DHCP
)
||
family
==
AF_INET
)
if
((
dhcp_tmp
->
flags
&
CONTEXT_DHCP
)
||
family
==
AF_INET
)
my_syslog
(
MS_DHCP
|
LOG_INFO
,
my_syslog
(
MS_DHCP
|
LOG_INFO
,
#ifdef HAVE_DHCP6
(
dhcp_tmp
->
flags
&
CONTEXT_RA_STATELESS
)
?
(
dhcp_tmp
->
flags
&
CONTEXT_RA_STATELESS
)
?
_
(
"SLAAC and stateless DHCPv6 on %.0s%s%.0s"
)
:
_
(
"stateless DHCPv6 on %s%.0s%.0s"
)
:
#endif
(
dhcp_tmp
->
flags
&
CONTEXT_STATIC
)
?
(
dhcp_tmp
->
flags
&
CONTEXT_STATIC
)
?
_
(
"DHCP, static leases only on %.0s%s,
lease time
%s"
)
:
_
(
"DHCP, static leases only on %.0s%s, %s"
)
:
(
dhcp_tmp
->
flags
&
CONTEXT_PROXY
)
?
(
dhcp_tmp
->
flags
&
CONTEXT_PROXY
)
?
_
(
"DHCP, proxy on subnet %.0s%s%.0s"
)
:
_
(
"DHCP, proxy on subnet %.0s%s%.0s"
)
:
_
(
"DHCP, IP range %s -- %s,
lease time
%s"
),
_
(
"DHCP, IP range %s -- %s, %s"
),
daemon
->
dhcp_buff
,
daemon
->
dhcp_buff3
,
daemon
->
namebuff
);
daemon
->
dhcp_buff
,
daemon
->
dhcp_buff3
,
daemon
->
namebuff
);
#ifdef HAVE_DHCP6
if
(
dhcp_tmp
->
flags
&
CONTEXT_RA_NAME
)
if
(
dhcp_tmp
->
flags
&
CONTEXT_RA_NAME
)
my_syslog
(
MS_DHCP
|
LOG_INFO
,
_
(
"SLAAC and DHCPv4-derived names on %s"
),
daemon
->
dhcp_buff2
);
my_syslog
(
MS_DHCP
|
LOG_INFO
,
_
(
"DHCPv4-derived IPv6 names on %s"
),
if
(
dhcp_tmp
->
flags
&
CONTEXT_RA_ONLY
)
daemon
->
addrbuff
);
my_syslog
(
MS_DHCP
|
LOG_INFO
,
_
(
"SLAAC on %s"
),
daemon
->
dhcp_buff2
);
if
(
dhcp_tmp
->
flags
&
(
CONTEXT_RA_ONLY
|
CONTEXT_RA_NAME
|
CONTEXT_RA_STATELESS
))
#endif
{
if
(
!
(
dhcp_tmp
->
flags
&
CONTEXT_DEPRECATE
))
{
char
*
p
=
daemon
->
namebuff
;
p
+=
sprintf
(
p
,
_
(
"prefix valid "
));
prettyprint_time
(
p
,
dhcp_tmp
->
lease_time
>
7200
?
dhcp_tmp
->
lease_time
:
7200
);
}
my_syslog
(
MS_DHCP
|
LOG_INFO
,
_
(
"SLAAC on %s %s"
),
daemon
->
addrbuff
,
daemon
->
namebuff
);
}
}
}
#ifdef HAVE_DHCP6
#ifdef HAVE_DHCP6
...
...
src/dnsmasq.h
View file @
c8257540
...
@@ -655,6 +655,7 @@ struct dhcp_context {
...
@@ -655,6 +655,7 @@ struct dhcp_context {
#define CONTEXT_RA_NAME 64
#define CONTEXT_RA_NAME 64
#define CONTEXT_RA_STATELESS 128
#define CONTEXT_RA_STATELESS 128
#define CONTEXT_DHCP 256
#define CONTEXT_DHCP 256
#define CONTEXT_DEPRECATE 512
struct
ping_result
{
struct
ping_result
{
struct
in_addr
addr
;
struct
in_addr
addr
;
...
...
src/option.c
View file @
c8257540
...
@@ -2118,6 +2118,8 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
...
@@ -2118,6 +2118,8 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
{
{
if
(
strcmp
(
a
[
leasepos
],
"infinite"
)
==
0
)
if
(
strcmp
(
a
[
leasepos
],
"infinite"
)
==
0
)
new
->
lease_time
=
0xffffffff
;
new
->
lease_time
=
0xffffffff
;
else
if
(
strcmp
(
a
[
leasepos
],
"deprecated"
)
==
0
)
new
->
flags
|=
CONTEXT_DEPRECATE
;
else
else
{
{
int
fac
=
1
;
int
fac
=
1
;
...
@@ -2150,16 +2152,6 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
...
@@ -2150,16 +2152,6 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
}
}
}
}
}
}
#ifdef HAVE_DHCP6
/* lifetimes must be min 2 hrs, by RFC 2462.
This gets enforced in radv.c for DHCP ranges
which are legitimately less. */
if
((
new
->
flags
&
CONTEXT_RA_ONLY
)
&&
new
->
lease_time
<
7200
)
new
->
lease_time
=
7200
;
#endif
break
;
break
;
}
}
...
...
src/radv.c
View file @
c8257540
...
@@ -276,9 +276,8 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
...
@@ -276,9 +276,8 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
static
int
add_prefixes
(
struct
in6_addr
*
local
,
int
prefix
,
static
int
add_prefixes
(
struct
in6_addr
*
local
,
int
prefix
,
int
scope
,
int
if_index
,
int
dad
,
void
*
vparam
)
int
scope
,
int
if_index
,
int
dad
,
void
*
vparam
)
{
{
struct
dhcp_context
*
context
,
*
tmp
;
struct
dhcp_context
*
context
;
struct
ra_param
*
param
=
vparam
;
struct
ra_param
*
param
=
vparam
;
struct
prefix_opt
*
opt
;
(
void
)
scope
;
/* warning */
(
void
)
scope
;
/* warning */
(
void
)
dad
;
(
void
)
dad
;
...
@@ -291,13 +290,17 @@ static int add_prefixes(struct in6_addr *local, int prefix,
...
@@ -291,13 +290,17 @@ static int add_prefixes(struct in6_addr *local, int prefix,
!
IN6_IS_ADDR_LINKLOCAL
(
local
)
&&
!
IN6_IS_ADDR_LINKLOCAL
(
local
)
&&
!
IN6_IS_ADDR_MULTICAST
(
local
))
!
IN6_IS_ADDR_MULTICAST
(
local
))
{
{
int
do_slaac
=
0
;
int
deprecate
=
0
;
unsigned
int
time
=
0xffffffff
;
struct
in6_addr
*
addr
=
NULL
;
struct
prefix_opt
*
opt
;
for
(
context
=
daemon
->
ra_contexts
;
context
;
context
=
context
->
next
)
for
(
context
=
daemon
->
ra_contexts
;
context
;
context
=
context
->
next
)
if
(
prefix
==
context
->
prefix
&&
if
(
prefix
==
context
->
prefix
&&
is_same_net6
(
local
,
&
context
->
start6
,
prefix
)
&&
is_same_net6
(
local
,
&
context
->
start6
,
prefix
)
&&
is_same_net6
(
local
,
&
context
->
end6
,
prefix
))
is_same_net6
(
local
,
&
context
->
end6
,
prefix
))
{
{
int
do_slaac
=
0
;
if
((
context
->
flags
&
if
((
context
->
flags
&
(
CONTEXT_RA_ONLY
|
CONTEXT_RA_NAME
|
CONTEXT_RA_STATELESS
)))
(
CONTEXT_RA_ONLY
|
CONTEXT_RA_NAME
|
CONTEXT_RA_STATELESS
)))
{
{
...
@@ -314,68 +317,51 @@ static int add_prefixes(struct in6_addr *local, int prefix,
...
@@ -314,68 +317,51 @@ static int add_prefixes(struct in6_addr *local, int prefix,
param
->
other
=
1
;
param
->
other
=
1
;
}
}
if
(
context
->
flags
&
CONTEXT_RA_DONE
)
/* find floor time */
continue
;
if
(
time
>
context
->
lease_time
)
time
=
context
->
lease_time
;
/* subsequent prefixes on the same interface don't need timers */
if
(
context
->
flags
&
CONTEXT_DEPRECATE
)
deprecate
=
1
;
/* subsequent prefixes on the same interface
and subsequent instances of this prefix don't need timers */
if
(
!
param
->
first
)
if
(
!
param
->
first
)
context
->
ra_time
=
0
;
context
->
ra_time
=
0
;
param
->
first
=
0
;
param
->
first
=
0
;
param
->
found_context
=
1
;
param
->
found_context
=
1
;
context
->
flags
|=
CONTEXT_RA_DONE
;
/* mark this subnet and duplicates: as done. */
for
(
tmp
=
context
->
next
;
tmp
;
tmp
=
tmp
->
next
)
if
(
tmp
->
prefix
==
prefix
&&
is_same_net6
(
local
,
&
tmp
->
start6
,
prefix
)
&&
is_same_net6
(
local
,
&
tmp
->
end6
,
prefix
))
{
tmp
->
flags
|=
CONTEXT_RA_DONE
;
context
->
ra_time
=
0
;
/* if any dhcp-range with ra-only on this subnet
set the "do_slaac" bit */
if
(
tmp
->
flags
&
(
CONTEXT_RA_ONLY
|
CONTEXT_RA_NAME
|
CONTEXT_RA_STATELESS
))
{
do_slaac
=
1
;
if
(
context
->
flags
&
CONTEXT_RA_STATELESS
)
param
->
other
=
1
;
}
else
{
/* don't do RA for non-ra-only unless --enable-ra is set */
if
(
!
option_bool
(
OPT_RA
))
continue
;
param
->
managed
=
1
;
param
->
other
=
1
;
}
}
if
((
opt
=
expand
(
sizeof
(
struct
prefix_opt
))))
if
(
context
->
flags
&
CONTEXT_RA_DONE
)
{
continue
;
u64
addrpart
=
addr6part
(
&
context
->
start6
);
u64
mask
=
(
prefix
==
64
)
?
(
u64
)
-
1LL
:
(
1LLU
<<
(
128
-
prefix
))
-
1LLU
;
context
->
flags
|=
CONTEXT_RA_DONE
;
unsigned
int
time
=
context
->
lease_time
;
addr
=
&
context
->
start6
;
/* lifetimes must be min 2 hrs, by RFC 2462 */
if
(
time
<
7200
)
time
=
7200
;
opt
->
type
=
ICMP6_OPT_PREFIX
;
opt
->
len
=
4
;
opt
->
prefix_len
=
prefix
;
/* autonomous only is we're not doing dhcp */
opt
->
flags
=
do_slaac
?
0x40
:
0x00
;
opt
->
valid_lifetime
=
opt
->
preferred_lifetime
=
htonl
(
time
);
opt
->
reserved
=
0
;
opt
->
prefix
=
context
->
start6
;
setaddr6part
(
&
opt
->
prefix
,
addrpart
&
~
mask
);
inet_ntop
(
AF_INET6
,
&
opt
->
prefix
,
daemon
->
addrbuff
,
ADDRSTRLEN
);
my_syslog
(
MS_DHCP
|
LOG_INFO
,
"RTR-ADVERT(%s) %s"
,
param
->
if_name
,
daemon
->
addrbuff
);
}
}
}
if
(
addr
&&
(
opt
=
expand
(
sizeof
(
struct
prefix_opt
))))
{
u64
addrpart
=
addr6part
(
addr
);
u64
mask
=
(
prefix
==
64
)
?
(
u64
)
-
1LL
:
(
1LLU
<<
(
128
-
prefix
))
-
1LLU
;
/* lifetimes must be min 2 hrs, by RFC 2462 */
if
(
time
<
7200
)
time
=
7200
;
opt
->
type
=
ICMP6_OPT_PREFIX
;
opt
->
len
=
4
;
opt
->
prefix_len
=
prefix
;
/* autonomous only is we're not doing dhcp */
opt
->
flags
=
do_slaac
?
0x40
:
0x00
;
opt
->
valid_lifetime
=
htonl
(
time
);
opt
->
preferred_lifetime
=
htonl
(
deprecate
?
0
:
time
);
opt
->
reserved
=
0
;
opt
->
prefix
=
*
addr
;
setaddr6part
(
&
opt
->
prefix
,
addrpart
&
~
mask
);
inet_ntop
(
AF_INET6
,
&
opt
->
prefix
,
daemon
->
addrbuff
,
ADDRSTRLEN
);
my_syslog
(
MS_DHCP
|
LOG_INFO
,
"RTR-ADVERT(%s) %s"
,
param
->
if_name
,
daemon
->
addrbuff
);
}
}
}
}
}
return
1
;
return
1
;
...
...
src/rfc3315.c
View file @
c8257540
...
@@ -513,13 +513,13 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
...
@@ -513,13 +513,13 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
while
(
1
)
while
(
1
)
{
{
struct
in6_addr
alloced_addr
,
*
addrp
=
NULL
;
struct
in6_addr
alloced_addr
,
*
addrp
=
NULL
;
u32
preferr
ed_time
=
0
;
u32
request
ed_time
=
0
;
struct
dhcp_lease
*
lease
=
NULL
;
struct
dhcp_lease
*
lease
=
NULL
;
if
(
ia_option
)
if
(
ia_option
)
{
{
struct
in6_addr
*
req_addr
=
opt6_ptr
(
ia_option
,
0
);
struct
in6_addr
*
req_addr
=
opt6_ptr
(
ia_option
,
0
);
preferr
ed_time
=
opt6_uint
(
ia_option
,
16
,
4
);
request
ed_time
=
opt6_uint
(
ia_option
,
16
,
4
);
if
(
!
address6_available
(
context
,
req_addr
,
tags
)
&&
if
(
!
address6_available
(
context
,
req_addr
,
tags
)
&&
(
!
have_config
(
config
,
CONFIG_ADDR6
)
||
memcmp
(
&
config
->
addr6
,
req_addr
,
IN6ADDRSZ
)
!=
0
))
(
!
have_config
(
config
,
CONFIG_ADDR6
)
||
memcmp
(
&
config
->
addr6
,
req_addr
,
IN6ADDRSZ
)
!=
0
))
...
@@ -621,10 +621,10 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
...
@@ -621,10 +621,10 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
if
(
ia_option
)
if
(
ia_option
)
{
{
if
(
preferr
ed_time
<
120u
)
if
(
request
ed_time
<
120u
)
preferr
ed_time
=
120u
;
/* sanity */
request
ed_time
=
120u
;
/* sanity */
if
(
lease_time
==
0xffffffff
||
(
preferred_time
!=
0xffffffff
&&
preferr
ed_time
<
lease_time
))
if
(
lease_time
==
0xffffffff
||
(
requested_time
!=
0xffffffff
&&
request
ed_time
<
lease_time
))
lease_time
=
preferr
ed_time
;
lease_time
=
request
ed_time
;
}
}
if
(
lease_time
<
min_time
)
if
(
lease_time
<
min_time
)
...
@@ -730,8 +730,9 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
...
@@ -730,8 +730,9 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
{
{
o1
=
new_opt6
(
OPTION6_IAADDR
);
o1
=
new_opt6
(
OPTION6_IAADDR
);
put_opt6
(
addrp
,
sizeof
(
*
addrp
));
put_opt6
(
addrp
,
sizeof
(
*
addrp
));
put_opt6_long
(
lease_time
);
/* preferred lifetime */
put_opt6_long
(
lease_time
);
put_opt6_long
(
this_context
&&
(
this_context
->
flags
&
CONTEXT_DEPRECATE
)
?
0
:
lease_time
);
put_opt6_long
(
lease_time
);
/* valid lifetime */
end_opt6
(
o1
);
end_opt6
(
o1
);
log6_packet
(
make_lease
?
"DHCPREPLY"
:
"DHCPADVERTISE"
,
log6_packet
(
make_lease
?
"DHCPREPLY"
:
"DHCPADVERTISE"
,
...
@@ -842,7 +843,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
...
@@ -842,7 +843,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
{
{
struct
dhcp_lease
*
lease
=
NULL
;
struct
dhcp_lease
*
lease
=
NULL
;
struct
in6_addr
*
req_addr
=
opt6_ptr
(
ia_option
,
0
);
struct
in6_addr
*
req_addr
=
opt6_ptr
(
ia_option
,
0
);
u32
preferr
ed_time
=
opt6_uint
(
ia_option
,
16
,
4
);
u32
request
ed_time
=
opt6_uint
(
ia_option
,
16
,
4
);
unsigned
int
lease_time
;
unsigned
int
lease_time
;
struct
dhcp_context
*
this_context
;
struct
dhcp_context
*
this_context
;
struct
dhcp_config
*
valid_config
=
config
;
struct
dhcp_config
*
valid_config
=
config
;
...
@@ -873,7 +874,10 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
...
@@ -873,7 +874,10 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
if
(
!
address6_available
(
context
,
req_addr
,
tagif
)
||
if
(
!
address6_available
(
context
,
req_addr
,
tagif
)
||
!
(
this_context
=
narrow_context6
(
context
,
req_addr
,
tagif
)))
!
(
this_context
=
narrow_context6
(
context
,
req_addr
,
tagif
)))
lease_time
=
0
;
{
lease_time
=
0
;
this_context
=
NULL
;
}
else
else
{
{
/* get tags from context if we've not used it before */
/* get tags from context if we've not used it before */
...
@@ -895,10 +899,10 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
...
@@ -895,10 +899,10 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
lease_time
=
have_config
(
valid_config
,
CONFIG_TIME
)
?
valid_config
->
lease_time
:
this_context
->
lease_time
;
lease_time
=
have_config
(
valid_config
,
CONFIG_TIME
)
?
valid_config
->
lease_time
:
this_context
->
lease_time
;
if
(
preferr
ed_time
<
120u
)
if
(
request
ed_time
<
120u
)
preferr
ed_time
=
120u
;
/* sanity */
request
ed_time
=
120u
;
/* sanity */
if
(
lease_time
==
0xffffffff
||
(
preferred_time
!=
0xffffffff
&&
preferr
ed_time
<
lease_time
))
if
(
lease_time
==
0xffffffff
||
(
requested_time
!=
0xffffffff
&&
request
ed_time
<
lease_time
))
lease_time
=
preferr
ed_time
;
lease_time
=
request
ed_time
;
lease_set_expires
(
lease
,
lease_time
,
now
);
lease_set_expires
(
lease
,
lease_time
,
now
);
if
(
ia_type
==
OPTION6_IA_NA
&&
hostname
)
if
(
ia_type
==
OPTION6_IA_NA
&&
hostname
)
...
@@ -917,8 +921,9 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
...
@@ -917,8 +921,9 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
o1
=
new_opt6
(
OPTION6_IAADDR
);
o1
=
new_opt6
(
OPTION6_IAADDR
);
put_opt6
(
req_addr
,
sizeof
(
*
req_addr
));
put_opt6
(
req_addr
,
sizeof
(
*
req_addr
));
put_opt6_long
(
lease_time
);
/* preferred lifetime */
put_opt6_long
(
lease_time
);
put_opt6_long
(
this_context
&&
(
this_context
->
flags
&
CONTEXT_DEPRECATE
)
?
0
:
lease_time
);
put_opt6_long
(
lease_time
);
/* valid lifetime */
end_opt6
(
o1
);
end_opt6
(
o1
);
}
}
...
...
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