Older IPv6 implementations may not have an IPV6_TCLASS option. Tolerate this situation by simply returning an error if an attempt is made to use IPV6_TCLASS on such a system.
Signed-off-by: Kyle J. McKay <mack...@gmail.com> --- CHANGES SINCE v1: * Regenerate patch so it applies cleanly; no other changes For those using the libressl-2.5.4.tar.gz distribution, an equivalent patch that updates the tarball files instead can be found here (#0002): https://gist.github.com/11ab5545aaa431b6cecda2188cbda73d Older darwin IPv6 stacks are afflicted by this issue. It would be nice if they (and other affected systems) could build nc from libressl-portable without needing to hack up netcat.c first. The "ENOPROTOOPT" code used is a POSIX-specified error code and is the one that would normally be returned by setsockopt for an unknown option. src/usr.bin/nc/netcat.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index 69070850..cbd1ef49 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c @@ -1444,9 +1444,15 @@ set_common_sockopts(int s, int af) IP_TOS, &Tflag, sizeof(Tflag)) == -1) err(1, "set IP ToS"); +#ifdef IPV6_TCLASS else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &Tflag, sizeof(Tflag)) == -1) err(1, "set IPv6 traffic class"); +#else + else if (af == AF_INET6) + errno = ENOPROTOOPT, + err(1, "set IPv6 traffic class not supported"); +#endif } if (Iflag) { if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, ---