fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/42403?usp=email )
Change subject: gsup: encode_pdp_info(): fix wrong pdp_address index ......................................................................
gsup: encode_pdp_info(): fix wrong pdp_address index
The `PDP_TYPE_N_IETF_IPv4v6` case encodes two addresses: IPv4 from `pdp_address[0]` and IPv6 from `pdp_address[1]`. The IPv4 part is encoded correctly, but the IPv6 part checks the wrong index.
The decoder decode_pdp_address() correctly puts the IPv4 address in `pdp_address[0]` and the IPv6 address in `pdp_address[1]`. Because `pdp_address[0].sa_family` is `AF_INET` (not `AF_INET6`), the second condition is always false in a proper dual-stack context, so the IPv6 part is silently dropped from every outgoing dual-stack GSUP message.
Change-Id: Ibc4a438ee7b06346839e78dc14d9d5b11b1c5bbd --- M src/gsm/gsup.c 1 file changed, 1 insertion(+), 1 deletion(-)
Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index 4f0a1b5..1e4ee6a 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -689,7 +689,7 @@ pdp_addr.ietf.v4v6.v4 = pdp_info->pdp_address[0].u.sin.sin_addr.s_addr; pdp_addr_len += sizeof(pdp_addr.ietf.v4v6.v4); } - if (pdp_info->pdp_address[0].u.sa.sa_family == AF_INET6) { + if (pdp_info->pdp_address[1].u.sa.sa_family == AF_INET6) { memcpy(pdp_addr.ietf.v4v6.v6, &pdp_info->pdp_address[1].u.sin6.sin6_addr, sizeof(pdp_addr.ietf.v4v6.v6));