$OpenBSD: patch-lib_isc_unix_socket_c,v 1.26 2021/02/27 20:56:03 sthen Exp $

Index: lib/isc/unix/socket.c
--- lib/isc/unix/socket.c.orig
+++ lib/isc/unix/socket.c
@@ -2407,6 +2407,7 @@ again:
 		}
 #endif /* if defined(SO_SNDBUF) */
 	}
+#if !defined(__OpenBSD__) /* pledge doesn't allow "receive ToS" sockopts */
 #ifdef IPV6_RECVTCLASS
 	if ((sock->pf == AF_INET6) &&
 	    (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVTCLASS, (void *)&on,
@@ -2431,6 +2432,7 @@ again:
 				 sock->fd, strbuf);
 	}
 #endif /* ifdef IP_RECVTOS */
+#endif
 #endif /* defined(USE_CMSG) || defined(SET_RCVBUF) || defined(SET_SNDBUF) */
 
 setup_done:
@@ -5148,6 +5150,13 @@ isc_socket_gettype(isc_socket_t *sock0) {
 void
 isc_socket_ipv6only(isc_socket_t *sock0, bool yes) {
 	isc__socket_t *sock = (isc__socket_t *)sock0;
+#ifdef __OpenBSD__
+/*
+ * pledge doesn't allow setting IPV6_V6ONLY, but that's ok,
+ * IPV6_V6ONLY is always enabled on OpenBSD;
+ */
+#undef IPV6_V6ONLY
+#endif
 #if defined(IPV6_V6ONLY)
 	int onoff = yes ? 1 : 0;
 #else  /* if defined(IPV6_V6ONLY) */
