Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tomas Krizek
Knot Resolver
Commits
b2be1bd4
Commit
b2be1bd4
authored
Jul 25, 2016
by
Karel Slaný
Committed by
Ondřej Surý
Aug 11, 2016
Browse files
Added src parameter in kr_resolve_query_finalize().
parent
d8787137
Changes
3
Hide whitespace changes
Inline
Side-by-side
daemon/worker.c
View file @
b2be1bd4
...
...
@@ -463,8 +463,19 @@ static int qr_task_send(struct qr_task *task, uv_handle_t *handle, struct sockad
return
qr_task_on_send
(
task
,
handle
,
kr_error
(
ENOMEM
));
}
if
(
knot_wire_get_qr
(
pkt
->
wire
)
==
0
)
{
/* Query must be finalised using destination address before sending. */
ret
=
kr_resolve_query_finalize
(
&
task
->
req
,
addr
,
/*
* Query must be finalised using destination address before
* sending.
*
* Libuv does not offer a convenient way how to obtain a source
* IP address from a UDP handle that has been initialised using
* uv_udp_init(). The uv_udp_getsockname() fails because of the
* lazy socket initialisation.
*
* @note -- A solution might be opening a separate socket and
* trying to obtain the IP address from it.
*/
ret
=
kr_resolve_query_finalize
(
&
task
->
req
,
NULL
,
addr
,
handle
->
type
==
UV_UDP
?
SOCK_DGRAM
:
SOCK_STREAM
,
pkt
);
if
(
ret
==
KNOT_STATE_FAIL
)
{
...
...
lib/resolve.c
View file @
b2be1bd4
...
...
@@ -780,6 +780,7 @@ ns_election:
#if defined(ENABLE_COOKIES)
/** Update DNS cookie data in packet. */
static
bool
outbound_request_update_cookies
(
struct
kr_request
*
req
,
const
struct
sockaddr
*
src
,
const
struct
sockaddr
*
dst
)
{
assert
(
req
);
...
...
@@ -791,7 +792,7 @@ static bool outbound_request_update_cookies(struct kr_request *req,
struct
kr_cookie_settings
*
clnt_sett
=
&
req
->
ctx
->
cookie_ctx
.
clnt
;
/* Cookies disabled or packet has no E
N
DS section. */
/* Cookies disabled or packet has no ED
N
S section. */
if
(
!
clnt_sett
->
enabled
)
{
return
true
;
}
...
...
@@ -799,24 +800,17 @@ static bool outbound_request_update_cookies(struct kr_request *req,
/*
* RFC7873 4.1 recommends using also the client address. The matter is
* also discussed in section 6.
*
* Libuv does not offer a convenient way how to obtain a source IP
* address from a UDP handle that has been initialised using
* uv_udp_init(). The uv_udp_getsockname() fails because of the lazy
* socket initialisation.
*
* @note -- A solution might be opening a separate socket and trying
* to obtain the IP address from it.
*/
kr_request_put_cookie
(
&
clnt_sett
->
current
,
req
->
ctx
->
cache_cookie
,
NULL
,
dst
,
req
);
src
,
dst
,
req
);
return
true
;
}
#endif
/* defined(ENABLE_COOKIES) */
int
kr_resolve_query_finalize
(
struct
kr_request
*
request
,
struct
sockaddr
*
dst
,
int
type
,
knot_pkt_t
*
packet
)
int
kr_resolve_query_finalize
(
struct
kr_request
*
request
,
struct
sockaddr
*
src
,
struct
sockaddr
*
dst
,
int
type
,
knot_pkt_t
*
packet
)
{
/* @todo: Update documentation if this function becomes approved. */
...
...
@@ -848,7 +842,7 @@ int kr_resolve_query_finalize(struct kr_request *request, struct sockaddr *dst,
* Also the resolver somehow mangles the query packets before
* building the query i.e. the space needed for the cookie
* cannot be allocated in the cookie layer. */
if
(
!
outbound_request_update_cookies
(
request
,
dst
))
{
if
(
!
outbound_request_update_cookies
(
request
,
src
,
dst
))
{
return
KNOT_STATE_FAIL
;
}
}
...
...
lib/resolve.h
View file @
b2be1bd4
...
...
@@ -183,13 +183,15 @@ int kr_resolve_produce(struct kr_request *request, struct sockaddr **dst, int *t
* @note The function must be called before actual sending of the request packet.
*
* @param request request state (in PRODUCE state)
* @param src address from which the query is going to be sent
* @param dst address of the name server
* @param type used socket type (SOCK_STREAM, SOCK_DGRAM)
* @param packet [in,out] query packet to be finalised
* @return any state
*/
KR_EXPORT
int
kr_resolve_query_finalize
(
struct
kr_request
*
request
,
struct
sockaddr
*
dst
,
int
type
,
knot_pkt_t
*
packet
);
int
kr_resolve_query_finalize
(
struct
kr_request
*
request
,
struct
sockaddr
*
src
,
struct
sockaddr
*
dst
,
int
type
,
knot_pkt_t
*
packet
);
/**
* Finish resolution and commit results if the state is DONE.
...
...
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