Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNSTAP - uv_pipe_bind() failed: address already in use #217

Closed
jguidini opened this issue Mar 26, 2020 · 2 comments · Fixed by #218
Closed

DNSTAP - uv_pipe_bind() failed: address already in use #217

jguidini opened this issue Mar 26, 2020 · 2 comments · Fixed by #218

Comments

@jguidini
Copy link

Hi, I'm configuring DSC on my DNS and compiled with DNSTAP support.
Compiling was smooth and install OK (DSC and DSP).

Versions in use:

DSC: commit d910a84
Merge: cfef1c6 5789f8b
Author: Jerry Lundström lundstrom.jerry@gmail.com
Date: Fri Mar 20 12:46:41 2020 +0100

Merge pull request #215 from jelu/release/2.9.0

Release 2.9.0

SO: Debian 9 amd64
Bind: 9.16.1

See debug (ommited IPs):

/usr/local/bin/dsc -d -D /usr/local/etc/dsc/dsc.conf
adding local address 127.0.0.1
adding local address ::1
setting current directory to /usr/local/dsc/run/e_dns
minfree_bytes 5000000
PID file is: /run/dsc.pid
Opening dnstap /var/lib/named/var/run/named/dnstap.sock
uv_pipe_bind() failed: address already in use
creating dataset qtype
creating dataset rcode
creating dataset opcode
creating dataset rcode_vs_replylen
creating dataset client_subnet
creating dataset qtype_vs_qnamelen
creating dataset qtype_vs_tld
creating dataset certain_qnames_vs_qtype
creating dataset client_subnet2
creating dataset client_addr_vs_rcode
creating dataset chaos_types_and_names
creating dataset idn_qname
creating dataset edns_version
creating dataset edns_bufsiz
creating dataset do_bit
creating dataset rd_bit
creating dataset idn_vs_tld
creating dataset ipv6_rsn_abusers
creating dataset transport_vs_qtype
creating dataset client_port_range
creating dataset direction_vs_ipproto
country_index: No database loaded for GeoIP
asn_index: No database loaded for GeoIP ASN
writing PID to /run/dsc.pid
Running

See the message: uv_pipe_bind() failed: address already in use

I found in https://buildmedia.readthedocs.org/media/pdf/libuv/stable/libuv.pdf this note:

int uv_pipe_bind(uv_pipe_t* handle, const char* name)

Bind the pipe to a file path (Unix) or a name (Windows).

Note: Paths on Unix get truncated to sizeof(sockaddr_un.sun_path) bytes, typically between 92
and 108 bytes.

dsc.conf:
local_address 127.0.0.1;
local_address ::1;
run_dir "/usr/local/dsc/run/e_dns";
minfree_bytes 5000000;
pid_file "/run/dsc.pid";
dnstap_unixsock /var/lib/named/var/run/named/dnstap.sock;
dnstap_network X.X.X.X ::1 53;
dataset qtype dns All:null Qtype:qtype queries-only;
dataset rcode dns All:null Rcode:rcode replies-only;
dataset opcode dns All:null Opcode:opcode queries-only;
dataset rcode_vs_replylen dns Rcode:rcode ReplyLen:msglen replies-only;
dataset client_subnet dns All:null ClientSubnet:client_subnet queries-only max-cells=200;
dataset qtype_vs_qnamelen dns Qtype:qtype QnameLen:qnamelen queries-only;
dataset qtype_vs_tld dns Qtype:qtype TLD:tld queries-only,popular-qtypes max-cells=200;
dataset certain_qnames_vs_qtype dns CertainQnames:certain_qnames Qtype:qtype queries-only;
dataset client_subnet2 dns Class:query_classification ClientSubnet:client_subnet queries-only max-cells=200;
dataset client_addr_vs_rcode dns Rcode:rcode ClientAddr:client replies-only max-cells=50;
dataset chaos_types_and_names dns Qtype:qtype Qname:qname chaos-class,queries-only;
dataset idn_qname dns All:null IDNQname:idn_qname queries-only;
dataset edns_version dns All:null EDNSVersion:edns_version queries-only;
dataset edns_bufsiz dns All:null EDNSBufSiz:edns_bufsiz queries-only;
dataset do_bit dns All:null D0:do_bit queries-only;
dataset rd_bit dns All:null RD:rd_bit queries-only;
dataset idn_vs_tld dns All:null TLD:tld queries-only,idn-only;
dataset ipv6_rsn_abusers dns All:null ClientAddr:client queries-only,aaaa-or-a6-only,root-servers-net-only max-cells=50;
dataset transport_vs_qtype dns Transport:transport Qtype:qtype queries-only;
dataset client_port_range dns All:null PortRange:dns_sport_range queries-only;
dataset direction_vs_ipproto ip Direction:ip_direction IPProto:ip_proto any;

If I change this line: dnstap_unixsock /var/lib/named/var/run/named/dnstap.sock;
to: dnstap_unixsock /var/lib/named/dnstap.sock;

And reconfigure Bind to reflect this, the error message gone away.

So, I suggest put an observation on readme or dsc.conf about the size of path.

Thanks by this great software!

@jelu
Copy link
Member

jelu commented Mar 30, 2020

I think you're running into another things then path length since the long one is just 41 chars.

If the file exists on startup of dsc then you'll also get this error message, can test that with the long path? Have the file, startup, remove the file, startup etc.

I missed to add an unlink() of the socket file at shutdown of dsc, keeping this issue opened for that.

@jguidini
Copy link
Author

Hi!
You're right!

First run:

adding local address 10.0.24.158
setting current directory to /usr/local/dsc/run/teste-compilando-bind-deb9deploy
PID file is: /run/dsc.pid
Opening dnstap /var/lib/named/var/run/named/dnstap.sock
country_index: No database loaded for GeoIP
asn_index: No database loaded for GeoIP ASN
writing PID to /run/dsc.pid
Running
^CReceived signal 2, exiting

Second run:

adding local address 10.0.24.158
setting current directory to /usr/local/dsc/run/teste-compilando-bind-deb9deploy
PID file is: /run/dsc.pid
Opening dnstap /var/lib/named/var/run/named/dnstap.sock
uv_pipe_bind() failed: address already in use
country_index: No database loaded for GeoIP
asn_index: No database loaded for GeoIP ASN
writing PID to /run/dsc.pid
Running
^CReceived signal 2, exiting

I solved this in my Unit adding ExecStartPre, like this:

[Service]
ExecStartPre=/bin/rm /var/lib/named/databases/dnstap.sock

Many thanks for help me, and by this excellent software!

jelu added a commit to jelu/dsc that referenced this issue Apr 1, 2020
- `daemon`: Fix bug with listening for SIGINT when in foreground mode
- `dnstap`:
  - Fix DNS-OARC#217: Unlink UNIX socket on exit if successfully initiated
  - Fix startup bug, `exit()` if unable to initialize
@jelu jelu closed this as completed in #218 Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants