Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
24
Issues
24
List
Boards
Labels
Service Desk
Milestones
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
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
Knot projects
Knot DNS
Commits
fd346d4b
Commit
fd346d4b
authored
May 02, 2018
by
Wolfgang Jung
Committed by
Daniel Salzman
May 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config: add rfc1912 dateserial policy
close
#582
parent
0b2887a5
Pipeline
#35957
passed with stages
in 8 minutes and 46 seconds
Changes
9
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
94 additions
and
9 deletions
+94
-9
.gitignore
.gitignore
+5
-0
NEWS
NEWS
+8
-0
doc/man/knot.conf.5in
doc/man/knot.conf.5in
+9
-1
doc/reference.rst
doc/reference.rst
+5
-1
src/knot/conf/schema.c
src/knot/conf/schema.c
+3
-2
src/knot/conf/schema.h
src/knot/conf/schema.h
+3
-2
src/knot/zone/serial.c
src/knot/zone/serial.c
+24
-0
src/knot/zone/serial.h
src/knot/zone/serial.h
+2
-1
tests/knot/test_zone_serial.c
tests/knot/test_zone_serial.c
+35
-2
No files found.
.gitignore
View file @
fd346d4b
...
...
@@ -79,3 +79,8 @@ version.h
# Vagrant
.vagrant
# eclipse
/.project
/.cproject
/.settings/
\ No newline at end of file
NEWS
View file @
fd346d4b
Knot DNS 2.7.0 (2018-xx-xx)
===========================
Features:
---------
- New zone serial policy DATESERIAL: yyyyMMDDvv (Thanks to Wolfgang Jung)
Knot DNS 2.6.0 (2017-09-29)
===========================
...
...
doc/man/knot.conf.5in
View file @
fd346d4b
...
...
@@ -983,7 +983,7 @@ zone:
dnssec\-signing: BOOL
dnssec\-policy: STR
request\-edns\-option: INT:[HEXSTR]
serial\-policy: increment | unixtime
serial\-policy: increment | unixtime
| dateserial
min\-refresh\-interval: TIME
max\-refresh\-interval: TIME
module: STR/STR ...
...
...
@@ -1219,6 +1219,12 @@ Possible values:
\fBincrement\fP – The serial is incremented according to serial number arithmetic
.IP \(bu 2
\fBunixtime\fP – The serial is set to the current unix time
.IP \(bu 2
.INDENT 2.0
.TP
\fBdateserial\fP – The 10\-digit serial (YYYYMMDDnn) is incremented, the first
8 digits match the current iso\-date
.UNINDENT
.UNINDENT
.sp
\fBNOTE:\fP
...
...
@@ -1228,6 +1234,8 @@ If your serial was in other than unix time format, be careful
with the transition to unix time. It may happen that the new serial will
be \(aqlower\(aq than the old one. If this is the case, the transition should be
done by hand (\fI\%RFC 1982\fP).
.sp
Use dateserial only if you expect less than 100 updates per day per zone.
.UNINDENT
.UNINDENT
.sp
...
...
doc/reference.rst
View file @
fd346d4b
...
...
@@ -1110,7 +1110,7 @@ Definition of zones served by the server.
dnssec-signing: BOOL
dnssec-policy: STR
request-edns-option: INT:[HEXSTR]
serial-policy: increment | unixtime
serial-policy: increment | unixtime
| dateserial
min-refresh-interval: TIME
max-refresh-interval: TIME
module: STR/STR ...
...
...
@@ -1382,6 +1382,8 @@ Possible values:
- ``increment`` – The serial is incremented according to serial number arithmetic
- ``unixtime`` – The serial is set to the current unix time
- ``dateserial`` – The 10-digit serial (YYYYMMDDnn) is incremented, the first
8 digits match the current iso-date
.. NOTE::
If your serial was in other than unix time format, be careful
...
...
@@ -1389,6 +1391,8 @@ Possible values:
be \'lower\' than the old one. If this is the case, the transition should be
done by hand (:rfc:`1982`).
Use dateserial only if you expect less than 100 updates per day per zone.
*Default:* increment
.. _zone_min-refresh-interval:
...
...
src/knot/conf/schema.c
View file @
fd346d4b
...
...
@@ -87,8 +87,9 @@ const knot_lookup_t acl_actions[] = {
};
static
const
knot_lookup_t
serial_policies
[]
=
{
{
SERIAL_POLICY_INCREMENT
,
"increment"
},
{
SERIAL_POLICY_UNIXTIME
,
"unixtime"
},
{
SERIAL_POLICY_INCREMENT
,
"increment"
},
{
SERIAL_POLICY_UNIXTIME
,
"unixtime"
},
{
SERIAL_POLICY_DATESERIAL
,
"dateserial"
},
{
0
,
NULL
}
};
...
...
src/knot/conf/schema.h
View file @
fd346d4b
...
...
@@ -129,8 +129,9 @@ enum {
};
enum
{
SERIAL_POLICY_INCREMENT
=
1
,
SERIAL_POLICY_UNIXTIME
=
2
,
SERIAL_POLICY_INCREMENT
=
1
,
SERIAL_POLICY_UNIXTIME
=
2
,
SERIAL_POLICY_DATESERIAL
=
3
,
};
enum
{
...
...
src/knot/zone/serial.c
View file @
fd346d4b
...
...
@@ -35,6 +35,28 @@ serial_cmp_result_t serial_compare(uint32_t s1, uint32_t s2)
return
diffbrief2result
[
diffbrief
];
}
static
uint32_t
serial_next_date
(
uint32_t
current
)
{
uint32_t
next
=
current
+
1
;
struct
tm
now
;
time_t
current_time
=
time
(
NULL
);
struct
tm
*
gmtime_result
=
gmtime_r
(
&
current_time
,
&
now
);
if
(
gmtime_result
==
NULL
)
{
return
next
;
}
uint32_t
yyyyMMdd00
=
(
1900
+
now
.
tm_year
)
*
1000000
+
(
1
+
now
.
tm_mon
)
*
10000
+
(
now
.
tm_mday
)
*
100
;
if
(
next
<
yyyyMMdd00
)
{
next
=
yyyyMMdd00
;
}
return
next
;
}
uint32_t
serial_next
(
uint32_t
current
,
int
policy
)
{
switch
(
policy
)
{
...
...
@@ -42,6 +64,8 @@ uint32_t serial_next(uint32_t current, int policy)
return
current
+
1
;
case
SERIAL_POLICY_UNIXTIME
:
return
time
(
NULL
);
case
SERIAL_POLICY_DATESERIAL
:
return
serial_next_date
(
current
);
default:
assert
(
0
);
return
0
;
...
...
src/knot/zone/serial.h
View file @
fd346d4b
...
...
@@ -47,7 +47,8 @@ inline static bool serial_equal(uint32_t a, uint32_t b)
* \brief Get next serial for given serial update policy.
*
* \param current Current SOA serial.
* \param policy SERIAL_POLICY_INCREMENT or SERIAL_POLICY_UNIXTIME.
* \param policy SERIAL_POLICY_INCREMENT, SERIAL_POLICY_UNIXTIME or
* SERIAL_POLICY_DATESERIAL.
*
* \return New serial.
*/
...
...
tests/knot/test_zone_serial.c
View file @
fd346d4b
/* Copyright (C) 201
5
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 201
8
CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -14,10 +14,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <tap/basic.h>
#include <stdlib.h>
#include <time.h>
#include "knot/zone/serial.h"
#include "knot/conf/schema.h"
#include "contrib/strtonum.h"
enum
serials
{
S_LOWEST
=
0
,
// lowest value
...
...
@@ -38,9 +42,36 @@ static uint32_t random_serial(void)
return
s
;
}
static
void
check_dateserial
(
uint32_t
current
,
uint32_t
expected
,
const
char
*
msg
)
{
uint32_t
next
=
serial_next
(
current
,
SERIAL_POLICY_DATESERIAL
);
ok
(
next
==
expected
,
"dateserial: %s"
,
msg
);
}
static
void
test_dateserial
(
void
)
{
time_t
now
=
time
(
NULL
);
struct
tm
*
gm_ret
=
gmtime
(
&
now
);
assert
(
gm_ret
);
char
str
[
32
];
int
ret
=
strftime
(
str
,
sizeof
(
str
),
"%Y%m%d00"
,
gm_ret
);
assert
(
ret
>
0
);
uint32_t
serial0
;
ret
=
str_to_u32
(
str
,
&
serial0
);
assert
(
ret
==
KNOT_EOK
);
check_dateserial
(
2000010100
,
serial0
,
"from old date"
);
check_dateserial
(
serial0
,
serial0
+
1
,
"today's first increment"
);
check_dateserial
(
serial0
+
98
,
serial0
+
99
,
"today's last increment"
);
check_dateserial
(
2100010100
,
2100010101
,
"from future date"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
plan
(
20
);
plan
_lazy
(
);
/* Serial compare test. */
ok
(
serial_compare
(
S_LOWEST
,
S_BELOW_MIDDLE
)
==
SERIAL_LOWER
,
...
...
@@ -98,5 +129,7 @@ int main(int argc, char *argv[])
ok
(
serial_compare
(
s2
,
s1
)
==
SERIAL_INCOMPARABLE
,
"serial compare: random opposites (s2 < s1)"
);
test_dateserial
();
return
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