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>
This commit is contained in:
Christian Weisgerber 2023-05-05 22:07:32 +02:00
parent 72ec11eab3
commit 0838f527c3
2 changed files with 26 additions and 1 deletions

View file

@ -1,6 +1,6 @@
PORTNAME= openntpd
PORTVERSION= 6.8p1
PORTREVISION= 6
PORTREVISION= 7
PORTEPOCH= 2
CATEGORIES= net
MASTER_SITES= OPENBSD/OpenNTPD

View file

@ -0,0 +1,25 @@
--- 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;