From 5b094971badd26eba1286c09d5d02dd60609c945 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 22 Sep 2020 00:24:06 +0000 Subject: socket.c v4/v6 error log Change-Id: I0fd12b08e0788ce3af6dc519ff8c82ad196a115f --- src/socket.c | 18 +++++++++++++++++- tests/socket/socket_sctp_test.err | 8 ++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/socket.c b/src/socket.c index 229f72e3..f725ec19 100644 --- a/src/socket.c +++ b/src/socket.c @@ -710,6 +710,18 @@ int osmo_sock_init2_multiaddr(uint16_t family, uint16_t type, uint8_t proto, loc_has_v4addr = rem_has_v4addr = (family == AF_INET); loc_has_v6addr = rem_has_v6addr = (family == AF_INET6); + LOGP(DLGLOBAL, LOGL_DEBUG, "%s(): family %s\n", + __func__, family == AF_INET ? "AF_INET" : (family == AF_INET6 ? "AF_INET6" : "?")); + + for (i = 0; i < local_hosts_cnt; i++) { + LOGP(DLGLOBAL, LOGL_DEBUG, "%s(): local host %d: %s:%d\n", + __func__, i, local_hosts[i], local_port); + } + for (i = 0; i < remote_hosts_cnt; i++) { + LOGP(DLGLOBAL, LOGL_DEBUG, "%s(): remote host %d: %s:%d\n", + __func__, i, remote_hosts[i], remote_port); + } + /* TODO: So far this function is only aimed for SCTP, but could be reused in the future for other protocols with multi-addr support */ if (proto != IPPROTO_SCTP) @@ -755,7 +767,11 @@ int osmo_sock_init2_multiaddr(uint16_t family, uint16_t type, uint8_t proto, if (((flags & OSMO_SOCK_F_BIND) && (flags & OSMO_SOCK_F_CONNECT)) && !addrinfo_has_in6addr_any((const struct addrinfo **)res_loc, local_hosts_cnt) && (loc_has_v4addr != rem_has_v4addr || loc_has_v6addr != rem_has_v6addr)) { - LOGP(DLGLOBAL, LOGL_ERROR, "Invalid v4 vs v6 in local vs remote addresses\n"); + LOGP(DLGLOBAL, LOGL_ERROR, "Invalid v4 vs v6 in local vs remote addresses: " + "local:%s%s remote:%s%s\n", + loc_has_v4addr ? " v4" : "", loc_has_v6addr ? " v6" : "", + rem_has_v4addr ? " v4" : "", rem_has_v6addr ? " v6" : "" + ); rc = -EINVAL; goto ret_freeaddrinfo; } diff --git a/tests/socket/socket_sctp_test.err b/tests/socket/socket_sctp_test.err index 996d0922..7583a2a2 100644 --- a/tests/socket/socket_sctp_test.err +++ b/tests/socket/socket_sctp_test.err @@ -1,8 +1,8 @@ invalid: you have to specify either BIND or CONNECT flags -Invalid v4 vs v6 in local vs remote addresses -Invalid v4 vs v6 in local vs remote addresses +Invalid v4 vs v6 in local vs remote addresses: local: v4 remote: v6 +Invalid v4 vs v6 in local vs remote addresses: local: v6 remote: v4 invalid: you have to specify either BIND or CONNECT flags -Invalid v4 vs v6 in local vs remote addresses -Invalid v4 vs v6 in local vs remote addresses +Invalid v4 vs v6 in local vs remote addresses: local: v4 remote: v6 +Invalid v4 vs v6 in local vs remote addresses: local: v6 remote: v4 getaddrinfo(::1, 0) failed: Address family for hostname not supported getaddrinfo(127.0.0.1, 0) failed: Address family for hostname not supported -- cgit v1.2.3