ports/net/openntpd/files/patch-src_client.c
Christian Weisgerber 0838f527c3 net/openntpd: fix for NICs with hardware timestamp support
OpenNTPD enables the reception of a timestamp with datagrams.
Network adapters that support hardware timestamping of packets,
e.g. mlx5en(4), create a SCM_TIME_INFO control message in addition
to the SCM_TIMESTAMP one.  Provide a sufficiently large buffer to
accommodate this and avoid a MSG_CTRUNC error.

PR:		271224
Obtained from:	Dmitry Wagin <dmitry.wagin@ya.ru>
2023-05-06 00:01:17 +02:00

25 lines
729 B
C

--- src/client.c.orig 2023-05-05 18:43:35 UTC
+++ src/client.c
@@ -274,6 +274,13 @@ handle_auto(uint8_t trusted, double offset)
}
+#ifdef SCM_TIME_INFO
+#define CMSG_MAXLEN (CMSG_SPACE(sizeof(struct timeval)) + \
+ CMSG_SPACE(sizeof(struct sock_timestamp_info)))
+#else
+#define CMSG_MAXLEN CMSG_SPACE(sizeof(struct timeval))
+#endif
+
/*
* -1: Not processed, not an NTP message (e.g. icmp induced ECONNREFUSED)
* 0: Not prrocessed due to validation issues
@@ -289,7 +296,7 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime,
char buf[NTP_MSGSIZE];
union {
struct cmsghdr hdr;
- char buf[CMSG_SPACE(sizeof(tv))];
+ char buf[CMSG_MAXLEN];
} cmsgbuf;
#ifdef SO_TIMESTAMP
struct cmsghdr *cmsg;