Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/43581?usp=email )
Change subject: build: pass FFTWF_CFLAGS to arch/common
......................................................................
build: pass FFTWF_CFLAGS to arch/common
configure looks up fftw3f with pkg-config for the multi-ARFCN build and
puts FFTWF_LIBS on the link line of the transceiver, but
Transceiver52M/arch/common/Makefile.am, where fft.c lives, never uses
FFTWF_CFLAGS. The compile of fft.c therefore only works where fftw3.h
is in a default include directory.
With fftw from Homebrew on macOS ARM64 the header is in
/opt/homebrew/include, which clang does not search by default:
arch/common/fft.c:26:10: fatal error: 'fftw3.h' file not found
Add FFTWF_CFLAGS to AM_CFLAGS in that directory. No change where the
header was already found.
Change-Id: I3243ce00bd42a22ff0fbbdd5ff3d00c7441662d0
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M Transceiver52M/arch/common/Makefile.am
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/81/43581/1
diff --git a/Transceiver52M/arch/common/Makefile.am b/Transceiver52M/arch/common/Makefile.am
index a27174d..c23d3b4 100644
--- a/Transceiver52M/arch/common/Makefile.am
+++ b/Transceiver52M/arch/common/Makefile.am
@@ -1,4 +1,4 @@
-AM_CFLAGS = -Wall -std=gnu99
+AM_CFLAGS = -Wall -std=gnu99 $(FFTWF_CFLAGS)
noinst_LTLIBRARIES = libarch_common.la
--
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/43581?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I3243ce00bd42a22ff0fbbdd5ff3d00c7441662d0
Gerrit-Change-Number: 43581
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/43580?usp=email )
Change subject: build: probe UHD version with PKG_CHECK_EXISTS
......................................................................
build: probe UHD version with PKG_CHECK_EXISTS
configure.ac appends -lboost_thread for libuhd < 4.2, which needs it
because of a bug in its own code. The probe is a second
PKG_CHECK_MODULES(UHD, uhd < 004.002, ...) reusing the UHD variable
prefix of the first one.
That never asks pkg-config. PKG_CHECK_MODULES expands _PKG_CONFIG,
which opens with
if test -n "$$1"; then
pkg_cv_[]$1="$$1"
so once UHD_CFLAGS and UHD_LIBS are set by the earlier
PKG_CHECK_MODULES(UHD, uhd >= 003.011), the second call takes those
values as its answer, leaves pkg_failed at no, and runs the
action-if-found branch whatever the installed version is.
-lboost_thread is therefore always appended.
On GNU/Linux that only adds a library that is usually present, so the
bug is invisible. On macOS ARM64 with UHD 4.10 from Homebrew there is
no such library on the link path and the build stops:
ld: library 'boost_thread' not found
Use PKG_CHECK_EXISTS, which asks pkg-config and sets no variables. The
workaround then applies where it was meant to, on libuhd < 4.2.
Change-Id: Icbd8af94f258128ea75c0268e0a240dc423ff69e
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M configure.ac
1 file changed, 2 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/80/43580/1
diff --git a/configure.ac b/configure.ac
index a384495..0cd388d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -195,9 +195,8 @@
# code and therefore requires linking against boost_thread. It's missing in
# uhd.pc, so work around it here.
# https://github.com/EttusResearch/uhd/commit/04a83b6e76beef970854da69ba882d7…
- PKG_CHECK_MODULES(UHD, uhd < 004.002,
- [LIBS="$LIBS -lboost_thread"],
- []
+ PKG_CHECK_EXISTS([uhd < 004.002],
+ [LIBS="$LIBS -lboost_thread"]
)
])
--
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/43580?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: Icbd8af94f258128ea75c0268e0a240dc423ff69e
Gerrit-Change-Number: 43580
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/43579?usp=email )
Change subject: build: require C++17 for the UHD 4.x headers
......................................................................
build: require C++17 for the UHD 4.x headers
configure asks for C++11 through AX_CXX_COMPILE_STDCXX_11. The public
headers of UHD 4.10 use std::optional, std::is_same_v and
std::is_arithmetic_v, none of which exist in C++11, so UHDDevice.cpp
fails to compile against them:
uhd/utils/cast.hpp:70:15: error: no template named 'is_same_v' in
namespace 'std'
uhd/rfnoc/actions.hpp:104:15: error: no template named 'optional' in
namespace 'std'
UHD 4.10 builds its own sources as C++20, and a consumer of its public
headers needs at least C++17.
Ask for C++17 with AX_CXX_COMPILE_STDCXX, the same macro already
shipped in config/. The osmo-trx sources compile unchanged under the
newer standard.
Seen with UHD 4.10.0.0 from Homebrew on macOS ARM64. The version, not
the platform, is what decides this: any distribution carrying UHD 4.10
reaches the same headers.
Change-Id: If8d80f0708f3856f36d56e637ad8d57f3d3d1bad
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M configure.ac
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/79/43579/1
diff --git a/configure.ac b/configure.ac
index a384495..d7795b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,7 @@
AM_PROG_AS
AC_PROG_CC
AC_PROG_CXX
-AX_CXX_COMPILE_STDCXX_11
+AX_CXX_COMPILE_STDCXX([17], [ext], [mandatory])
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INSTALL
--
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/43579?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: If8d80f0708f3856f36d56e637ad8d57f3d3d1bad
Gerrit-Change-Number: 43579
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hlr/+/43578?usp=email )
Change subject: gsupclient: add LIBOSMOGSM_LIBS to LIBADD
......................................................................
gsupclient: add LIBOSMOGSM_LIBS to LIBADD
libosmo-gsup-client calls osmo_gsup_*, osmo_oap_client_* and
osmo_imsi_str_valid(), all exported by libosmogsm, but
libosmo_gsup_client_la_LIBADD in src/gsupclient/Makefile.am lists only
talloc, libosmocore and libosmoabis.
GNU ld accepts undefined symbols in a shared library and defers them to
whatever the executable happens to pull in, so the missing dependency is
invisible on Linux. Darwin's ld64 refuses at link time and the library
fails to build with "symbol(s) not found for architecture arm64".
The same Makefile.am already passes -no-undefined in LDFLAGS, which is
the promise that the library resolves its own symbols. Adding
LIBOSMOGSM_LIBS is what makes that promise true.
With the fix, otool -L on the resulting libosmo-gsup-client.dylib lists
libosmogsm among its dependencies, and the osmo_gsup_* references
resolve through it.
Change-Id: I413ff47aa1e8034ea86c61134d3d6784942b0e3b
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M src/gsupclient/Makefile.am
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/78/43578/1
diff --git a/src/gsupclient/Makefile.am b/src/gsupclient/Makefile.am
index 7611f6e..89533f4 100644
--- a/src/gsupclient/Makefile.am
+++ b/src/gsupclient/Makefile.am
@@ -16,7 +16,7 @@
$(NULL)
libosmo_gsup_client_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined
-libosmo_gsup_client_la_LIBADD = $(TALLOC_LIBS) $(LIBOSMOCORE_LIBS) $(LIBOSMOABIS_LIBS)
+libosmo_gsup_client_la_LIBADD = $(TALLOC_LIBS) $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS)
noinst_PROGRAMS = gsup-test-client
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/43578?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I413ff47aa1e8034ea86c61134d3d6784942b0e3b
Gerrit-Change-Number: 43578
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/43577?usp=email )
Change subject: mgcp_client: include errno.h, not asm-generic
......................................................................
mgcp_client: include errno.h, not asm-generic
src/libosmo-mgcp-client/mgcp_client_pool.c includes
<asm-generic/errno.h> for ECONNABORTED and EINVAL. That is a Linux
kernel UAPI header. It exists on Linux distributions and nowhere else,
so the build stops on Darwin:
mgcp_client_pool.c:21:10: fatal error: 'asm-generic/errno.h' file not
found
Both values come from <errno.h> on every platform, and on Linux glibc's
<errno.h> reaches the same UAPI definitions, so including the kernel
header directly was never needed there either.
No functional change on any platform.
Change-Id: Ie3fc368c04c29aea824002b3bf9839e410e7f045
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M src/libosmo-mgcp-client/mgcp_client_pool.c
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/77/43577/1
diff --git a/src/libosmo-mgcp-client/mgcp_client_pool.c b/src/libosmo-mgcp-client/mgcp_client_pool.c
index 61fb134..42d775e 100644
--- a/src/libosmo-mgcp-client/mgcp_client_pool.c
+++ b/src/libosmo-mgcp-client/mgcp_client_pool.c
@@ -18,7 +18,7 @@
*
*/
-#include <asm-generic/errno.h>
+#include <errno.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/mgcp_client/mgcp_client_internal.h>
#include <osmocom/mgcp_client/mgcp_client_pool_internal.h>
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/43577?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ie3fc368c04c29aea824002b3bf9839e410e7f045
Gerrit-Change-Number: 43577
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/osmo-mgw/+/43576?usp=email )
Change subject: mgcp_client: generate mgcp_common.h with printf
......................................................................
mgcp_client: generate mgcp_common.h with printf
The rule in include/osmocom/mgcp_client/Makefile.am that copies
<osmocom/mgcp/mgcp_common.h> into the mgcp_client include directory
writes its banner with "echo -e". The -e option is a bash extension.
Shells whose echo follows the XSI convention expand the backslash
escapes on their own and do not take options, so -e is passed through
as the first argument to print.
The generated header then starts with
-e /*
and every file that includes it fails to compile:
mgcp_common.h:1:2: error: unknown type name 'e'
Measured on macOS, where /bin/sh is bash invoked as sh: the escapes are
expanded as intended, but the leading "-e " is printed literally. Any
shell with an XSI-style echo, dash among them, behaves the same way.
The build only works where /bin/sh accepts -e.
Replace it with printf and one argument per line. printf is POSIX, takes
no such option, and produces the same seven lines on every shell.
Change-Id: Ibc547513745104212469ccddbc2e636c985cffe5
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M include/osmocom/mgcp_client/Makefile.am
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/76/43576/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/43576?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ibc547513745104212469ccddbc2e636c985cffe5
Gerrit-Change-Number: 43576
Gerrit-PatchSet: 2
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/43576?usp=email )
Change subject: mgcp_client: generate mgcp_common.h banner with printf
......................................................................
mgcp_client: generate mgcp_common.h banner with printf
The rule in include/osmocom/mgcp_client/Makefile.am that copies
<osmocom/mgcp/mgcp_common.h> into the mgcp_client include directory
writes its banner with "echo -e". The -e option is a bash extension.
Shells whose echo follows the XSI convention expand the backslash
escapes on their own and do not take options, so -e is passed through
as the first argument to print.
The generated header then starts with
-e /*
and every file that includes it fails to compile:
mgcp_common.h:1:2: error: unknown type name 'e'
Measured on macOS, where /bin/sh is bash invoked as sh: the escapes are
expanded as intended, but the leading "-e " is printed literally. Any
shell with an XSI-style echo, dash among them, behaves the same way.
The build only works where /bin/sh accepts -e.
Replace it with printf and one argument per line. printf is POSIX, takes
no such option, and produces the same seven lines on every shell.
Change-Id: Ibc547513745104212469ccddbc2e636c985cffe5
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M include/osmocom/mgcp_client/Makefile.am
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/76/43576/1
diff --git a/include/osmocom/mgcp_client/Makefile.am b/include/osmocom/mgcp_client/Makefile.am
index 7415142..5374dc5 100644
--- a/include/osmocom/mgcp_client/Makefile.am
+++ b/include/osmocom/mgcp_client/Makefile.am
@@ -9,7 +9,7 @@
$(NULL)
mgcp_common.h: $(top_srcdir)/include/osmocom/mgcp/mgcp_common.h
- echo -e "/*\n\n DO NOT EDIT THIS FILE!\n THIS IS OVERWRITTEN DURING BUILD\n This is an automatic copy of <osmocom/mgcp/mgcp_common.h>\n\n */" > mgcp_common.h
+ printf '%s\n' "/*" "" " DO NOT EDIT THIS FILE!" " THIS IS OVERWRITTEN DURING BUILD" " This is an automatic copy of <osmocom/mgcp/mgcp_common.h>" "" " */" > mgcp_common.h
cat $(top_srcdir)/include/osmocom/mgcp/mgcp_common.h >> mgcp_common.h
version.h: version.h.tpl
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/43576?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ibc547513745104212469ccddbc2e636c985cffe5
Gerrit-Change-Number: 43576
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmocore/+/43575?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: core/socket: sockaddr_cmp: compare fields
......................................................................
core/socket: sockaddr_cmp: compare fields
osmo_sockaddr_cmp() decides whether two addresses are equal with a
memcmp() over the whole struct sockaddr_in or sockaddr_in6. On Linux
those structures hold only family, port, address and padding, so the
comparison is exact. On Darwin and the BSDs the first byte is sin_len /
sin6_len. The kernel fills it in on recvfrom() and accept(), while an
address the application built from configuration leaves it zero. The
same peer then compares as two different addresses.
Every static NS-VC in gprs_ns2 breaks on this. The answer to the first
NS-RESET arrives from the configured remote, gprs_ns2_udp.c cannot match
it to the NS-VC ("Ignoring NS RESET ACK from newconnection for
non-existing NS-VC", gprs_ns2.c:1066) and the link never leaves RESET.
Observed with osmo-pcu against osmo-sgsn on Darwin loopback: the SGSN
side, which learned the peer from the packet, goes to BLOCKED and then
loses every NS-ALIVE-ACK, while the PCU side stays in RESET. Dynamic
NS-VCs are unaffected because their remote address is a copy of what
recvfrom() returned.
Compare the fields instead of the bytes: port and address for AF_INET,
port, flow info, address and scope id for AF_INET6, in the order
memcmp() visited them, so the ordering the function gives to sorted
users does not change. The default branch keeps its memcmp() over the
full osmo_sockaddr. Linux behaviour is unchanged.
Add tests/sockaddr_cmp covering the two cases that regressed and the
ordering the fix has to preserve: an IPv4 and an IPv6 pair equal in port
and address but differing in the length byte, both expected to compare
equal, and ordering by port, by address, by flow info and by scope id,
each checked in both directions. Against the previous implementation the
two length-byte cases return -16 and -28 instead of 0.
The length byte only exists where the sockaddr carries one, so
configure.ac gains an AC_CHECK_MEMBER for struct sockaddr_in.sin_len,
in the style of the existing s6_addr32 check. Where the member is
absent the two addresses are identical and the expectation is the same,
so the test and its .ok output are the same on every platform.
Note that sin6_flowinfo and sin6_scope_id are compared byte by byte,
which is not numeric order on a little endian host. That is unchanged
from the memcmp() this replaces. The test uses values differing in one
byte only, where both orders agree.
Change-Id: I75fc62a92f546a906dbb1440984d62f962579255
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M configure.ac
M src/core/socket.c
M tests/Makefile.am
A tests/sockaddr_cmp/sockaddr_cmp_test.c
A tests/sockaddr_cmp/sockaddr_cmp_test.ok
M tests/testsuite.at
6 files changed, 201 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/75/43575/3
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/43575?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I75fc62a92f546a906dbb1440984d62f962579255
Gerrit-Change-Number: 43575
Gerrit-PatchSet: 3
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Andrei G has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/libosmocore/+/43575?usp=email )
Change subject: core/socket: sockaddr_cmp: compare fields
......................................................................
core/socket: sockaddr_cmp: compare fields
osmo_sockaddr_cmp() decides whether two addresses are equal with a
memcmp() over the whole struct sockaddr_in or sockaddr_in6. On Linux
those structures hold only family, port, address and padding, so the
comparison is exact. On Darwin and the BSDs the first byte is sin_len /
sin6_len. The kernel fills it in on recvfrom() and accept(), while an
address the application built from configuration leaves it zero. The
same peer then compares as two different addresses.
Every static NS-VC in gprs_ns2 breaks on this. The answer to the first
NS-RESET arrives from the configured remote, gprs_ns2_udp.c cannot match
it to the NS-VC ("Ignoring NS RESET ACK from newconnection for
non-existing NS-VC", gprs_ns2.c:1066) and the link never leaves RESET.
Observed with osmo-pcu against osmo-sgsn on Darwin loopback: the SGSN
side, which learned the peer from the packet, goes to BLOCKED and then
loses every NS-ALIVE-ACK, while the PCU side stays in RESET. Dynamic
NS-VCs are unaffected because their remote address is a copy of what
recvfrom() returned.
Compare the fields instead of the bytes: port and address for AF_INET,
port, flow info, address and scope id for AF_INET6, in the order
memcmp() visited them, so the ordering the function gives to sorted
users does not change. The default branch keeps its memcmp() over the
full osmo_sockaddr. Linux behaviour is unchanged.
Change-Id: I75fc62a92f546a906dbb1440984d62f962579255
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M src/core/socket.c
1 file changed, 30 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/75/43575/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/43575?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I75fc62a92f546a906dbb1440984d62f962579255
Gerrit-Change-Number: 43575
Gerrit-PatchSet: 2
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/43575?usp=email )
Change subject: core/socket: sockaddr_cmp: compare fields, not bytes
......................................................................
core/socket: sockaddr_cmp: compare fields, not bytes
osmo_sockaddr_cmp() decides whether two addresses are equal with a memcmp()
over the whole struct sockaddr_in or sockaddr_in6. On Linux those structures
hold only family, port, address and padding, so the comparison is exact. On
Darwin and the BSDs the first byte is sin_len / sin6_len. The kernel fills
it in on recvfrom() and accept(), while an address the application built
from configuration leaves it zero. The same peer then compares as two
different addresses.
Every static NS-VC in gprs_ns2 breaks on this. The answer to the first
NS-RESET arrives from the configured remote, gprs_ns2_udp.c cannot match it
to the NS-VC ("Ignoring NS RESET ACK from newconnection for non-existing
NS-VC", gprs_ns2.c:1066) and the link never leaves RESET. Observed with
osmo-pcu against osmo-sgsn on Darwin loopback: the SGSN side, which learned
the peer from the packet, goes to BLOCKED and then loses every NS-ALIVE-ACK,
while the PCU side stays in RESET. Dynamic NS-VCs are unaffected because
their remote address is a copy of what recvfrom() returned.
Compare the fields instead of the bytes: port and address for AF_INET, port,
flow info, address and scope id for AF_INET6, in the order memcmp() visited
them, so the ordering the function gives to sorted users does not change.
The default branch keeps its memcmp() over the full osmo_sockaddr. Linux
behaviour is unchanged.
Change-Id: I75fc62a92f546a906dbb1440984d62f962579255
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M src/core/socket.c
1 file changed, 30 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/75/43575/1
diff --git a/src/core/socket.c b/src/core/socket.c
index 3a2d7b7..724d8ef 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -2599,11 +2599,37 @@
return OSMO_CMP(a->u.sa.sa_family, b->u.sa.sa_family);
}
+ /* Compare the address fields, not the raw bytes of the structure.
+ * On the BSDs and Darwin the sockaddr carries a length byte (sin_len,
+ * sin6_len) that the kernel fills in on recvfrom()/accept() and that
+ * is zero in an address the application built itself; a memcmp() over
+ * the whole structure then reports two equal addresses as different.
+ * The order of the comparisons keeps the ordering memcmp() gave. */
switch (a->u.sa.sa_family) {
- case AF_INET:
- return memcmp(&a->u.sin, &b->u.sin, sizeof(struct sockaddr_in));
- case AF_INET6:
- return memcmp(&a->u.sin6, &b->u.sin6, sizeof(struct sockaddr_in6));
+ case AF_INET: {
+ int rc = memcmp(&a->u.sin.sin_port, &b->u.sin.sin_port,
+ sizeof(a->u.sin.sin_port));
+ if (rc)
+ return rc;
+ return memcmp(&a->u.sin.sin_addr, &b->u.sin.sin_addr,
+ sizeof(a->u.sin.sin_addr));
+ }
+ case AF_INET6: {
+ int rc = memcmp(&a->u.sin6.sin6_port, &b->u.sin6.sin6_port,
+ sizeof(a->u.sin6.sin6_port));
+ if (rc)
+ return rc;
+ rc = memcmp(&a->u.sin6.sin6_flowinfo, &b->u.sin6.sin6_flowinfo,
+ sizeof(a->u.sin6.sin6_flowinfo));
+ if (rc)
+ return rc;
+ rc = memcmp(&a->u.sin6.sin6_addr, &b->u.sin6.sin6_addr,
+ sizeof(a->u.sin6.sin6_addr));
+ if (rc)
+ return rc;
+ return memcmp(&a->u.sin6.sin6_scope_id, &b->u.sin6.sin6_scope_id,
+ sizeof(a->u.sin6.sin6_scope_id));
+ }
default:
/* fallback to memcmp for remaining AF over the full osmo_sockaddr length */
return memcmp(a, b, sizeof(struct osmo_sockaddr));
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/43575?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I75fc62a92f546a906dbb1440984d62f962579255
Gerrit-Change-Number: 43575
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>