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
82e3f45a
Commit
82e3f45a
authored
Jan 31, 2014
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Blockdata fixes and tuning.
parent
072e81b3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
13 deletions
+51
-13
src/blockdata.c
src/blockdata.c
+26
-7
src/cache.c
src/cache.c
+18
-5
src/dnsmasq.c
src/dnsmasq.c
+6
-1
src/dnsmasq.h
src/dnsmasq.h
+1
-0
No files found.
src/blockdata.c
View file @
82e3f45a
...
@@ -18,13 +18,29 @@
...
@@ -18,13 +18,29 @@
#ifdef HAVE_DNSSEC
#ifdef HAVE_DNSSEC
static
struct
blockdata
*
keyblock_free
=
NULL
;
static
struct
blockdata
*
keyblock_free
;
static
unsigned
int
blockdata_count
=
0
,
blockdata_hwm
=
0
;
static
unsigned
int
blockdata_count
,
blockdata_hwm
,
blockdata_alloced
;
/* Preallocate some blocks, proportional to cachesize, to reduce heap fragmentation. */
void
blockdata_init
(
void
)
{
int
i
;
blockdata_alloced
=
(
daemon
->
cachesize
*
100
)
/
sizeof
(
struct
blockdata
);
keyblock_free
=
safe_malloc
(
blockdata_alloced
*
sizeof
(
struct
blockdata
));
keyblock_free
[
blockdata_alloced
-
1
].
next
=
NULL
;
for
(
i
=
0
;
i
<
blockdata_alloced
-
1
;
i
++
)
keyblock_free
[
i
].
next
=
&
keyblock_free
[
i
+
1
];
blockdata_count
=
0
;
blockdata_hwm
=
0
;
}
void
blockdata_report
(
void
)
void
blockdata_report
(
void
)
{
{
my_syslog
(
LOG_INFO
,
_
(
"DNSSEC memory in use %u, max %u"
),
my_syslog
(
LOG_INFO
,
_
(
"DNSSEC memory in use %u, max %u
, allocated %u
"
),
blockdata_count
*
sizeof
(
struct
blockdata
),
blockdata_hwm
*
sizeof
(
struct
blockdata
));
blockdata_count
*
sizeof
(
struct
blockdata
),
blockdata_hwm
*
sizeof
(
struct
blockdata
)
,
blockdata_alloced
*
sizeof
(
struct
blockdata
)
);
}
}
struct
blockdata
*
blockdata_alloc
(
char
*
data
,
size_t
len
)
struct
blockdata
*
blockdata_alloc
(
char
*
data
,
size_t
len
)
...
@@ -44,8 +60,8 @@ struct blockdata *blockdata_alloc(char *data, size_t len)
...
@@ -44,8 +60,8 @@ struct blockdata *blockdata_alloc(char *data, size_t len)
else
if
((
block
=
whine_malloc
(
sizeof
(
struct
blockdata
))))
else
if
((
block
=
whine_malloc
(
sizeof
(
struct
blockdata
))))
{
{
blockdata_count
++
;
blockdata_count
++
;
if
(
blockdata_
hwm
<
blockdata_count
)
if
(
blockdata_
alloced
<
blockdata_count
)
blockdata_
hwm
=
blockdata_count
;
blockdata_
alloced
=
blockdata_count
;
}
}
if
(
!
block
)
if
(
!
block
)
...
@@ -55,6 +71,9 @@ struct blockdata *blockdata_alloc(char *data, size_t len)
...
@@ -55,6 +71,9 @@ struct blockdata *blockdata_alloc(char *data, size_t len)
return
NULL
;
return
NULL
;
}
}
if
(
blockdata_hwm
<
blockdata_count
)
blockdata_hwm
=
blockdata_count
;
blen
=
len
>
KEYBLOCK_LEN
?
KEYBLOCK_LEN
:
len
;
blen
=
len
>
KEYBLOCK_LEN
?
KEYBLOCK_LEN
:
len
;
memcpy
(
block
->
key
,
data
,
blen
);
memcpy
(
block
->
key
,
data
,
blen
);
data
+=
blen
;
data
+=
blen
;
...
...
src/cache.c
View file @
82e3f45a
...
@@ -171,6 +171,21 @@ static void cache_hash(struct crec *crecp)
...
@@ -171,6 +171,21 @@ static void cache_hash(struct crec *crecp)
*
up
=
crecp
;
*
up
=
crecp
;
}
}
#ifdef HAVE_DNSSEC
static
void
cache_blockdata_free
(
struct
crec
*
crecp
)
{
if
(
crecp
->
flags
&
F_DNSKEY
)
{
if
(
crecp
->
flags
&
F_DS
)
blockdata_free
(
crecp
->
addr
.
sig
.
keydata
);
else
blockdata_free
(
crecp
->
addr
.
key
.
keydata
);
}
else
if
(
crecp
->
flags
&
F_DS
)
blockdata_free
(
crecp
->
addr
.
ds
.
keydata
);
}
#endif
static
void
cache_free
(
struct
crec
*
crecp
)
static
void
cache_free
(
struct
crec
*
crecp
)
{
{
crecp
->
flags
&=
~
F_FORWARD
;
crecp
->
flags
&=
~
F_FORWARD
;
...
@@ -197,8 +212,7 @@ static void cache_free(struct crec *crecp)
...
@@ -197,8 +212,7 @@ static void cache_free(struct crec *crecp)
}
}
#ifdef HAVE_DNSSEC
#ifdef HAVE_DNSSEC
if
(
crecp
->
flags
&
(
F_DNSKEY
|
F_DS
))
cache_blockdata_free
(
crecp
);
blockdata_free
(
crecp
->
addr
.
key
.
keydata
);
#endif
#endif
}
}
...
@@ -957,8 +971,7 @@ void cache_reload(void)
...
@@ -957,8 +971,7 @@ void cache_reload(void)
for
(
cache
=
hash_table
[
i
],
up
=
&
hash_table
[
i
];
cache
;
cache
=
tmp
)
for
(
cache
=
hash_table
[
i
],
up
=
&
hash_table
[
i
];
cache
;
cache
=
tmp
)
{
{
#ifdef HAVE_DNSSEC
#ifdef HAVE_DNSSEC
if
(
cache
->
flags
&
(
F_DNSKEY
|
F_DS
))
cache_blockdata_free
(
cache
);
blockdata_free
(
cache
->
addr
.
key
.
keydata
);
#endif
#endif
tmp
=
cache
->
hash_next
;
tmp
=
cache
->
hash_next
;
if
(
cache
->
flags
&
(
F_HOSTS
|
F_CONFIG
))
if
(
cache
->
flags
&
(
F_HOSTS
|
F_CONFIG
))
...
...
src/dnsmasq.c
View file @
82e3f45a
...
@@ -304,7 +304,12 @@ int main (int argc, char **argv)
...
@@ -304,7 +304,12 @@ int main (int argc, char **argv)
#endif
#endif
if
(
daemon
->
port
!=
0
)
if
(
daemon
->
port
!=
0
)
{
cache_init
();
cache_init
();
#ifdef HAVE_DNSSEC
blockdata_init
();
#endif
}
if
(
option_bool
(
OPT_DBUS
))
if
(
option_bool
(
OPT_DBUS
))
#ifdef HAVE_DBUS
#ifdef HAVE_DBUS
...
...
src/dnsmasq.h
View file @
82e3f45a
...
@@ -1011,6 +1011,7 @@ struct crec *cache_enumerate(int init);
...
@@ -1011,6 +1011,7 @@ struct crec *cache_enumerate(int init);
/* blockdata.c */
/* blockdata.c */
#ifdef HAVE_DNSSEC
#ifdef HAVE_DNSSEC
void
blockdata_init
(
void
);
void
blockdata_report
(
void
);
void
blockdata_report
(
void
);
struct
blockdata
*
blockdata_alloc
(
char
*
data
,
size_t
len
);
struct
blockdata
*
blockdata_alloc
(
char
*
data
,
size_t
len
);
void
*
blockdata_retrieve
(
struct
blockdata
*
block
,
size_t
len
,
void
*
data
);
void
*
blockdata_retrieve
(
struct
blockdata
*
block
,
size_t
len
,
void
*
data
);
...
...
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