mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-21 18:23:59 +00:00
Fix network test failure when using VPN client
When using certain VPN clients, the interface info returned by 'getifaddrs' does not have the address family filled in for the ifa_netmask component (this is allowed by the standard, since the value is not specified). The resulting address info causes network tests suite failures. Fix by copying the address family from the returned interface address. * src/process.c (network_interface_list): Copy the interface address sa_family to the netmask address. (Fnetwork_lookup_address_info): Fix test for non-IP addresses to properly account for IPv6. * test/src/process-tests.el (process-tests-check-bug-74907): New test, checks that 'network-interface-list' output is as expected. (Bug#74907)
This commit is contained in:
parent
64dbb01993
commit
d8e8e1d5ed
@ -4351,6 +4351,10 @@ network_interface_list (bool full, unsigned short match)
|
||||
|
||||
if (full)
|
||||
{
|
||||
/* Sometimes sa_family is only filled in correctly in the
|
||||
interface address, not the netmask, so copy it across
|
||||
(Bug#74907). */
|
||||
it->ifa_netmask->sa_family = it->ifa_addr->sa_family;
|
||||
elt = Fcons (conv_sockaddr_to_lisp (it->ifa_netmask, len), elt);
|
||||
/* There is an it->ifa_broadaddr field, but its contents are
|
||||
unreliable, so always calculate the broadcast address from
|
||||
@ -4764,13 +4768,17 @@ returned from the lookup. */)
|
||||
{
|
||||
for (lres = res; lres; lres = lres->ai_next)
|
||||
{
|
||||
#ifndef AF_INET6
|
||||
if (lres->ai_family != AF_INET)
|
||||
continue;
|
||||
/* Avoid converting non-IP addresses (Bug#74907). */
|
||||
if (lres->ai_family == AF_INET
|
||||
#ifdef AF_INET6
|
||||
|| lres->ai_family == AF_INET6
|
||||
#endif
|
||||
addresses = Fcons (conv_sockaddr_to_lisp (lres->ai_addr,
|
||||
lres->ai_addrlen),
|
||||
addresses);
|
||||
)
|
||||
addresses = Fcons (conv_sockaddr_to_lisp (lres->ai_addr,
|
||||
lres->ai_addrlen),
|
||||
addresses);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
addresses = Fnreverse (addresses);
|
||||
|
||||
|
@ -519,6 +519,17 @@ See Bug#30460."
|
||||
|
||||
;; End of tests requiring DNS
|
||||
|
||||
(ert-deftest process-tests-check-bug-74907 ()
|
||||
"Check that the result of `network-interface-list' is well-formed.
|
||||
(Bug#74907)"
|
||||
(dolist (info (network-interface-list t))
|
||||
(should (stringp (car info)))
|
||||
(should (length= info 4))
|
||||
(should (cl-every #'vectorp (cdr info)))
|
||||
(let ((alen (length (cadr info))))
|
||||
(should (memq alen '(5 9))) ; Address info also has a port number
|
||||
(should (cl-every (lambda (elt) (length= elt alen)) (cdr info))))))
|
||||
|
||||
(defmacro process-tests--ignore-EMFILE (&rest body)
|
||||
"Evaluate BODY, ignoring EMFILE errors."
|
||||
(declare (indent 0) (debug t))
|
||||
|
Loading…
Reference in New Issue
Block a user