Subject: 24.3; Failure to resolve IPv6 addresses in make-network-process

From: [email-masked] (Toke Høiland-Jørgensen)
Date: Wed, 03 Jul 2013 15:33:50 +0200

I'm using ERC to connect to IRC, and was wondering why the connection
used IPv4 rather than IPv6 when the server has both addresses
configured. Messing with the DNS resolver so the address only resolves
to IPv6 made Emacs unable to connect at all.

Investigating this further, it seems that by default
make-network-process does not resolve IPv6 addresses at all unless
specifically asked to do so. More precisely, patch open-network-stream
to pass :family 0 (line 143 of network-stream.el) makes resolution work
as expected (i.e. first IPv6, then v4 if no v6 address exists), but the
default of leaving out the :family parameter (or setting it to nil)
makes resolution IPv4-only, resulting in a 'Name or service not known'
error when trying to connect.

Perusing the source code of process.c, it seems to me that it *should*
do the right thing, when :family is nil, and I can't figure out why it's
not.

I have installed Emacs from the binary packages provided by my
distribution (Arch linux).

Regards,
-Toke

In GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.8.1)
 of 2013-04-29 on eric
Windowing system distributor `The X.Org Foundation', version 11.0.11402000
Configured using:
 `configure '--prefix=/usr' '--sysconfdir=/etc' '--libexecdir=/usr/lib'
 '--localstatedir=/var' '--with-x-toolkit=gtk3' '--with-xft'
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector
 --param=ssp-buffer-size=4'
 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'
 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_MESSAGES: en_GB.UTF-8
  value of $LANG: da_DK.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: ERC

Features:
(shadow bbdb-message mail-extr emacsbug message idna rfc822 mml mml-sec
mm-decode mm-bodies mm-encode gmm-utils mailheader sendmail mail-utils
misearch multi-isearch gnutls network-stream starttls erc-menu erc-join
erc-ring erc-pcomplete erc-track erc-match erc-button erc-fill erc-stamp
erc-netsplit autoinsert eieio-opt helm-misc helm-files image-dired ffap
helm-tags helm-bookmark helm-adaptative helm-info helm-net browse-url
helm-plugin bookmark helm-locate helm-help helm-match-plugin
helm-external helm-buffers helm-grep helm-regexp grep helm-elscreen
helm-utils helm find-file-in-repository-autoloads flymake-lua-autoloads
lua-mode-autoloads sauron-autoloads yaml-mode-autoloads package xcscope
helm-config sunrise-x-loop sunrise-commander recentf tree-widget
wid-edit sort hl-line find-dired esh-var esh-io esh-cmd esh-opt esh-ext
esh-proc esh-arg eldoc esh-groups eshell esh-util esh-module esh-mode
enriched dired-x dired-aux desktop preview-latex tex-site auto-loads
undo-tree autopair browse-kill-ring iedit gnus-article-treat-patch
gnus-dired dired magit-bisect magit-key-mode magit epa epg epg-config
diff-mode uniquify auto-complete-config auto-complete popup pydoc-info
info-look info python-mode rx cc-cmds compile ropemacs pymacs cc-styles
cc-align cc-engine cc-vars cc-defs bbdb-mua bbdb-vcard bbdb-com crm
mailabbrev vcard bbdb timezone bbdb-loaddefs znc erc-services
erc-networks erc-spelling flyspell ispell erc-goodies erc erc-backend
erc-compat thingatpt pp notify dbus w3m-load multi-term term disp-table
ehelp electric post ox-beamer org-caldav icalendar diary-lib
diary-loaddefs org-id ox-latex ox-icalendar ox-html ox-ascii ox-publish
ox org-element url-http tls url url-proxy url-privacy url-expand
url-methods url-history mailcap url-auth mail-parse rfc2231 rfc2047
rfc2045 ietf-drums url-cookie url-domsuf url-gw url-dav url-handlers
url-util url-parse url-vars xml org-protocol org org-macro org-footnote
org-pcomplete org-list org-faces org-entities noutline outline
org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob ob-table
ob-keys ob-exp ob-comint ob-core ob-eval org-compat org-macs
org-loaddefs find-func cal-menu calendar cal-loaddefs
solarized-dark-theme solarized-definitions ido autorevert alist pym
static apel-ver product jka-compr protbuf tramp tramp-compat auth-source
eieio warnings byte-opt bytecomp byte-compile cconv inversion gnus-util
mm-util mail-prsvr password-cache tramp-loaddefs shell pcomplete comint
ansi-color format-spec nxhtml-autostart nxhtml-autoload majmodpri vc-git
nxhtml-menu web-autoload nxhtml-base wc yasnippet help-mode skeleton
paren cus-start cus-load log-edit ring pcvs-util add-log server
zencoding-mode ebib derived advice advice-preload help-fns cl-macs gv
bibtex easymenu cl cl-lib edmacro kmacro gnus-load easy-mmode time-date
tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
register page menu-bar rfn-eshadow timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face macroexp files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)