summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2023-11-15 22:08:30 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-11-16 03:26:57 +0100
commit461ef3981f1a45150b6e2047bb3c789ac50ba3cf (patch)
tree3f3074e646d48da3197d3bba2bef0adbfb39cb97
parentMerge pull request #30040 from yuwata/assert-return-fixes (diff)
downloadsystemd-461ef3981f1a45150b6e2047bb3c789ac50ba3cf.tar.xz
systemd-461ef3981f1a45150b6e2047bb3c789ac50ba3cf.zip
sd-dhcp: use CMSG_FIND_AND_COPY_DATA to avoid build failures on x32 architectures
On architectures where timeval is 64bit but size_t is 32bit we have to use CMSG_FIND_AND_COPY_DATA. This affects x32 and riscv32. Follow-up for 905d0ea7b0080dd
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index bf19226d4f..0993c20afd 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -2201,7 +2201,6 @@ static int client_receive_message_raw(
.msg_control = &control,
.msg_controllen = sizeof(control),
};
- struct cmsghdr *cmsg;
bool checksum = true;
triple_timestamp t = {};
ssize_t buflen, len;
@@ -2231,15 +2230,13 @@ static int client_receive_message_raw(
return 0;
}
- CMSG_FOREACH(cmsg, &msg)
- if (cmsg->cmsg_level == SOL_PACKET && cmsg->cmsg_type == PACKET_AUXDATA) {
- struct tpacket_auxdata *aux = CMSG_TYPED_DATA(cmsg, struct tpacket_auxdata);
- checksum = !(aux->tp_status & TP_STATUS_CSUMNOTREADY);
+ struct tpacket_auxdata *aux = CMSG_FIND_AND_COPY_DATA(&msg, SOL_PACKET, PACKET_AUXDATA, struct tpacket_auxdata);
+ if (aux)
+ checksum = !(aux->tp_status & TP_STATUS_CSUMNOTREADY);
- } else if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMP) {
- struct timeval *tv = CMSG_TYPED_DATA(cmsg, struct timeval);
- triple_timestamp_from_realtime(&t, timeval_load(tv));
- }
+ struct timeval *tv = CMSG_FIND_AND_COPY_DATA(&msg, SOL_SOCKET, SCM_TIMESTAMP, struct timeval);
+ if (tv)
+ triple_timestamp_from_realtime(&t, timeval_load(tv));
if (dhcp_packet_verify_headers(packet, len, checksum, client->port) < 0)
return 0;