# netatalk can't communicate with cnid back-end



## Khaine (Dec 10, 2016)

Netatalk has stopped working on a server that I support for my parents.  I'm not sure what has changed to cause it.  From my investigation it looks like getaddrinfo() cannot lookup localhost

This is an extract from /var/log/netatalk.log that shows that netatalk can't connect to the CNID backend due to being unable to resolve localhost


```
Dec 10 19:49:51.186774 afpd[1557] {ad_flush.c:486} (debug:ad): ad_close(DF|HF|SHRMD): END: 0 {d: 0, m: 0, r: 0} [dfd: -1 (ref: 0), mfd: -1 (ref: 0), rfd: -1 (ref: 0)]
Dec 10 19:49:51.186799 afpd[1557] {ad_conv.c:124} (debug:ad): ad_conv_v22ea_hf("/media/backup"): END: -1
Dec 10 19:49:51.186826 afpd[1557] {ad_conv.c:191} (debug:ad): ad_conv_v22ea_hf("/media/backup"): deleting adouble:v2 file: "/media/backup/.AppleDouble/.Parent"
Dec 10 19:49:51.186907 afpd[1557] {ad_conv.c:226} (debug:ad): ad_conv_dehex("/media/backup"): BEGIN
Dec 10 19:49:51.186938 afpd[1557] {ad_conv.c:294} (debug:ad): ad_convert("/media/backup"): END: 0
Dec 10 19:49:51.186976 afpd[1557] {ad_open.c:1849} (debug:ad): ad_open("/media/backup", HF|DIR|O_RDWR|O_CREAT): BEGIN {d: 0, m: 0, r: 0}[dfd: -1 (ref: 0), mfd: -1 (ref: 0), rfd: -1 (ref: 0)]
Dec 10 19:49:51.187066 afpd[1557] {ad_open.c:1205} (debug:ad): ad_open_hf_ea("/media/backup", HF|DIR|O_RDWR|O_CREAT): BEGIN [dfd: -1 (ref: 0), mfd: -1 (ref: 0), rfd: -1 (ref: 0)]
Dec 10 19:49:51.187109 afpd[1557] {ad_open.c:1230} (debug:ad): ad_open_hf_ea("/media/backup"): opening base file for meta adouble EA
Dec 10 19:49:51.233343 afpd[1557] {ad_open.c:1279} (debug:ad): ad_open_hf_ea("/media/backup", HF|DIR|O_RDWR|O_CREAT): END: 0 [dfd: 5 (ref: 1), mfd: 5 (ref: 1), rfd: -1 (ref: 0)]
Dec 10 19:49:51.233415 afpd[1557] {ad_open.c:1912} (debug:ad): ad_open("/media/backup"): END: 0 {d: 0, m: 1, r: 0}[dfd: 5 (ref: 1), mfd: 5 (ref: 1), rfd: -1 (ref: 0)]
Dec 10 19:49:51.233451 afpd[1557] {ad_flush.c:423} (debug:ad): ad_close(HF): BEGIN: {d: 0, m: 1, r: 0} [dfd: 5 (ref: 1), mfd: 5 (ref: 1), rfd: -1 (ref: 0)]
Dec 10 19:49:51.233486 afpd[1557] {ad_flush.c:486} (debug:ad): ad_close(HF): END: 0 {d: 0, m: 0, r: 0} [dfd: -1 (ref: 0), mfd: -1 (ref: 0), rfd: -1 (ref: 0)]
Dec 10 19:49:51.233515 afpd[1557] {cnid_dbd.c:238} (debug:CNID): connecting to CNID server: localhost:4700
Dec 10 19:50:02.271874 afpd[1557] {cnid_dbd.c:81} (error:Default): tsock_getfd: getaddrinfo: CNID server localhost:4700 : hostname nor servname provided, or not known
Dec 10 19:50:02.272053 afpd[1557] {cnid_dbd.c:238} (debug:CNID): connecting to CNID server: localhost:4700
Dec 10 19:50:13.312479 afpd[1557] {cnid_dbd.c:81} (error:Default): tsock_getfd: getaddrinfo: CNID server localhost:4700 : hostname nor servname provided, or not known
Dec 10 19:50:14.321157 afpd[1557] {cnid_dbd.c:238} (debug:CNID): connecting to CNID server: localhost:4700
Dec 10 19:50:25.363216 afpd[1557] {cnid_dbd.c:81} (error:Default): tsock_getfd: getaddrinfo: CNID server localhost:4700 : hostname nor servname provided, or not known
Dec 10 19:50:25.363432 afpd[1557] {cnid_dbd.c:414} (error:CNID): transmit: Request to dbd daemon (volume Backup) timed out.
Dec 10 19:50:25.363488 afpd[1557] {volume.c:865} (error:AFPDaemon): afp_openvol(/media/backup): Fatal error: Unable to get stamp value from CNID backend
Dec 10 19:50:25.363554 afpd[1557] {cnid_dbd.c:498} (debug:CNID): closing database connection for volume 'Backup'
```

I can ping localhost and host works

`% ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.040 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.060 ms`

`% host localhost
localhost has address 127.0.0.1`

However if I use python's interactive prompt getaddrinfo clearly doesn't return the right value


```
>>> import socket
>>> socket.getaddrinfo('localhost',4077)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
socket.gaierror: [Errno 8] hostname nor servname provided, or not known
>>> socket.getaddrinfo('127.0.0.1',4077)
[(2, 2, 17, '', ('127.0.0.1', 4077)), (2, 1, 6, '', ('127.0.0.1', 4077)), (2, 5, 132, '', ('127.0.0.1', 4077))]
>>> socket.getaddrinfo('www.google.com','www')
[(2, 1, 6, '', ('150.101.161.236', 80))]
```

/etc/hosts is configured as:


```
127.0.0.1               localhost localhost.my.domain
```


/etc/nsswitch.conf is configured as 


```
#
# nsswitch.conf(5) - name service switch configuration file
# $FreeBSD: releng/10.3/etc/nsswitch.conf 224765 2011-08-10 20:52:02Z dougb $
#
group: compat
group_compat: nis
hosts: file dns
networks: files
passwd: compat
passwd_compat: nis
shells: files
services: compat
services_compat: nis
protocols: files
rpc: files
```

I'm running freebsd-10.3-RELEASE and netatalk version 3.1.10

`% freebsd-version 
10.3-RELEASE-p14
% netatalk-config --version
3.1.10`

I'm not sure why getaddrinfo() can't resolve localhost, but can resolve other hosts.  Can anyone help me understand what might be misconfigured.

Many thanks


----------



## Crest (Dec 15, 2016)

Please post your ip6addrctl and sockstat -l output.


----------



## Khaine (Dec 15, 2016)

These are the outputs:


```
sudo sockstat -l
root     sudo       95320 7  stream (not connected)
root     cnid_metad 39598 4  tcp4   127.0.0.1:4700        *:*
root     afpd       39597 4  tcp4   10.0.0.4:548          *:*
root     mDNSRespon 96149 3  udp4   *:20798               *:*
root     mDNSRespon 96149 4  udp4   *:5353                *:*
proxy    ftp-proxy  1160  3  tcp4   127.0.0.1:8021        *:*
root     sshd       1046  3  tcp4   10.0.0.4:22           *:*
root     syslogd    545   4  dgram  /var/run/log
root     syslogd    545   5  dgram  /var/run/logpriv
root     syslogd    545   6  udp6   *:514                 *:*
root     syslogd    545   7  udp4   *:514                 *:*
root     devd       441   4  stream /var/run/devd.pipe
root     devd       441   5  seqpac /var/run/devd.seqpacket.pipe
```


```
sudo ip6addrctl
Prefix                          Prec Label      Use
::1/128                           50     0        0
::/0                              40     1        0
::ffff:0.0.0.0/96                100     4        0
2002::/16                         30     2        0
2001::/32                          5     5        0
fc00::/7                           3    13        0
::/96                              1     3        0
fec0::/10                          1    11        0
3ffe::/16                          1    12        0
```


----------



## Khaine (Dec 23, 2016)

I upgraded the server to 11.0-RELEASE and that appears to have resolved the issue


----------

