diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2011-05-06 21:14:06 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2011-05-06 21:14:06 +0000 |
commit | 853419fe376b7d5635d60a9526cf51d33fa834cc (patch) | |
tree | 296d39cf3e98199f219bd5fa712cdecfa156396d /usr.bin | |
parent | 8792ac73ad5298cd2cd4d9cae9322dfb172c0968 (diff) |
set traffic class for IPv6 traffic as we do for IPv4 TOS;
patch from lionel AT mamane.lu via Colin Watson in bz#1855;
ok markus@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/packet.c | 36 | ||||
-rw-r--r-- | usr.bin/ssh/packet.h | 3 |
2 files changed, 22 insertions, 17 deletions
diff --git a/usr.bin/ssh/packet.c b/usr.bin/ssh/packet.c index d14e0982389..8d781d4258c 100644 --- a/usr.bin/ssh/packet.c +++ b/usr.bin/ssh/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.172 2010/11/13 23:27:50 djm Exp $ */ +/* $OpenBSD: packet.c,v 1.173 2011/05/06 21:14:05 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -418,10 +418,8 @@ packet_set_state(int mode, u_int32_t seqnr, u_int64_t blocks, u_int32_t packets, state->bytes = bytes; } -/* returns 1 if connection is via ipv4 */ - -int -packet_connection_is_ipv4(void) +static int +packet_connection_af(void) { struct sockaddr_storage to; socklen_t tolen = sizeof(to); @@ -430,9 +428,7 @@ packet_connection_is_ipv4(void) if (getsockname(active_state->connection_out, (struct sockaddr *)&to, &tolen) < 0) return 0; - if (to.ss_family != AF_INET) - return 0; - return 1; + return to.ss_family; } /* Sets the connection into non-blocking mode. */ @@ -1736,14 +1732,24 @@ packet_not_very_much_data_to_write(void) static void packet_set_tos(int tos) { - if (!packet_connection_is_on_socket() || - !packet_connection_is_ipv4()) + if (!packet_connection_is_on_socket()) return; - debug3("%s: set IP_TOS 0x%02x", __func__, tos); - if (setsockopt(active_state->connection_in, IPPROTO_IP, IP_TOS, &tos, - sizeof(tos)) < 0) - error("setsockopt IP_TOS %d: %.100s:", - tos, strerror(errno)); + switch (packet_connection_af()) { + case AF_INET: + debug3("%s: set IP_TOS 0x%02x", __func__, tos); + if (setsockopt(active_state->connection_in, + IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) + error("setsockopt IP_TOS %d: %.100s:", + tos, strerror(errno)); + break; + case AF_INET6: + debug3("%s: set IPV6_TCLASS 0x%02x", __func__, tos); + if (setsockopt(active_state->connection_in, + IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)) < 0) + error("setsockopt IPV6_TCLASS %d: %.100s:", + tos, strerror(errno)); + break; + } } /* Informs that the current session is interactive. Sets IP flags for that. */ diff --git a/usr.bin/ssh/packet.h b/usr.bin/ssh/packet.h index 30bbf98731c..bae70a637c5 100644 --- a/usr.bin/ssh/packet.h +++ b/usr.bin/ssh/packet.h @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.h,v 1.55 2010/11/13 23:27:50 djm Exp $ */ +/* $OpenBSD: packet.h,v 1.56 2011/05/06 21:14:05 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -86,7 +86,6 @@ int packet_have_data_to_write(void); int packet_not_very_much_data_to_write(void); int packet_connection_is_on_socket(void); -int packet_connection_is_ipv4(void); int packet_remaining(void); void packet_send_ignore(int); void packet_add_padding(u_char); |