2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 12:58:00 +00:00

7 Commits

Author SHA1 Message Date
Ted Elhourani
f00c47b8f3 dns-resolve: Allow unbound's config file to be set through an env var.
When an unbound context is created, check whether OVS_UNBOUND_CONF has been
set. If a valid config file is supplied then use it to configure the
context. The procedure returns if the config file is invalid. If no config
file is found then the default unbound config is used.

Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ted Elhourani <ted.elhourani@nutanix.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2020-10-08 17:47:24 +02:00
Yifeng Sun
9ff0b84cf8 dns-resolve: Free 'struct ub_result' when callback returns error results
Valgrind reported:

1074: ofproto - flush flows, groups, and meters for controller change

==5499== 695 (288 direct, 407 indirect) bytes in 3 blocks are definitely lost in loss record 344 of 355
==5499==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5499==    by 0x5E7F145: ??? (in /usr/lib/x86_64-linux-gnu/libunbound.so.2.4.0)
==5499==    by 0x5E6EBDE: ub_resolve_async (in /usr/lib/x86_64-linux-gnu/libunbound.so.2.4.0)
==5499==    by 0x55C739: resolve_async__.part.5 (dns-resolve.c:233)
==5499==    by 0x55C85C: resolve_async__ (dns-resolve.c:261)
==5499==    by 0x55C85C: resolve_callback__ (dns-resolve.c:262)
==5499==    by 0x5E6FEF1: ub_process (in /usr/lib/x86_64-linux-gnu/libunbound.so.2.4.0)
==5499==    by 0x55CAF3: dns_resolve (dns-resolve.c:153)
==5499==    by 0x523864: parse_sockaddr_components_dns (socket-util.c:438)
==5499==    by 0x523864: parse_sockaddr_components (socket-util.c:504)
==5499==    by 0x524468: inet_parse_active (socket-util.c:541)
==5499==    by 0x524564: inet_open_active (socket-util.c:579)
==5499==    by 0x5959F9: tcp_open (stream-tcp.c:56)
==5499==    by 0x529192: stream_open (stream.c:228)
==5499==    by 0x529910: stream_open_with_default_port (stream.c:724)
==5499==    by 0x595FAE: vconn_stream_open (vconn-stream.c:81)
==5499==    by 0x535C9B: vconn_open (vconn.c:250)
==5499==    by 0x517C59: reconnect (rconn.c:467)
==5499==    by 0x5184C7: run_BACKOFF (rconn.c:492)
==5499==    by 0x5184C7: rconn_run (rconn.c:660)
==5499==    by 0x457FE8: ofservice_run (connmgr.c:1992)
==5499==    by 0x457FE8: connmgr_run (connmgr.c:367)
==5499==    by 0x41E0F5: ofproto_run (ofproto.c:1845)
==5499==    by 0x40BA63: bridge_run__ (bridge.c:2971)

In ub_resolve_async's callback function, 'struct ub_result' should be
finally freed even if there is a resolving error. This patch fixes it.

Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-09-19 09:23:58 -07:00
Yifeng Sun
9ce4aa8ee7 dns-resolve: Improve on handling of system DNS nameserver
This patch enables OVS on windows to read system nameserver configuration.
In addition, a new environment variable OVS_RESOLV_CONF is introduced.
If set, it can be used as DNS server configuration file. This variable
is supposed to be used for sandboxing other things. It is documented
accordingly.

Suggested-by: Ben Pfaff <blp@ovn.org>
Suggested-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-11-09 13:20:06 -08:00
Yifeng Sun
ba8eb43a07 dns-resolve: Stop dns resolving if no DNS server configured
DNS resolution should fail if no DNS servers are available. This
patch fixes it.

Suggested-by: Ben Pfaff <blp@ovn.org>
Suggested-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-11-09 13:17:53 -08:00
Yifeng Sun
a84b88659e dns-resolve: Fix a bug that frees node inside HMAP_FOR_EACH
HMAP_FOR_EACH_SAFE should be used when node is freed inside.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-08-16 10:40:19 -07:00
Ben Pfaff
70c5afb0e5 dns-resolve: Only ask unbound to read /etc/resolv.conf if it exists.
The unbound library complains if we ask it to read /etc/resolv.conf but
that file doesn't exist.  It's better to just skip reading it in that case.

Reported-by: Flavio Leitner <fbl@sysclose.org>
Reporetd-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-August/350751.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
2018-08-07 14:38:37 -07:00
Yifeng Sun
771680d96f DNS: Add basic support for asynchronous DNS resolving
This patch is a simple implementation for the proposal discussed in
https://mail.openvswitch.org/pipermail/ovs-dev/2017-August/337038.html and
https://mail.openvswitch.org/pipermail/ovs-dev/2017-October/340013.html.

It enables ovs-vswitchd and other utilities to use DNS names when specifying
OpenFlow and OVSDB remotes.

Below are some of the features and limitations of this patch:
    - Resolving is asynchornous in daemon context, avoiding blocking main loop;
    - Resolving is synchronous in general utility context;
    - Both IPv4 and IPv6 are supported;
    - The resolving API is thread-safe;
    - Depends on the unbound library;
    - When multiple ip addresses are returned, only the first one is used;
    - /etc/nsswitch.conf isn't respected as unbound library doesn't look at it;
    - For async-resolving, caller need to retry later; there is no callback.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-06 13:50:00 -07:00