You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.8 KiB

  1. From 98da2afa58b7bdf5350de16fd99905ddb04e1b0d Mon Sep 17 00:00:00 2001
  2. From: Dan Walters <dan@walters.io>
  3. Date: Sun, 13 Oct 2019 10:08:36 -0500
  4. Subject: [PATCH] Apply the configured peer socket TOS to UDP sockets, not just
  5. TCP.
  6. ---
  7. libtransmission/session.c | 2 ++
  8. libtransmission/tr-udp.c | 20 ++++++++++++++++++++
  9. libtransmission/tr-udp.h | 1 +
  10. 3 files changed, 23 insertions(+)
  11. --- a/libtransmission/session.c
  12. +++ b/libtransmission/session.c
  13. @@ -2274,6 +2274,8 @@ static void toggle_utp(void* data)
  14. tr_udpSetSocketBuffers(session);
  15. + tr_udpSetSocketTOS(session);
  16. +
  17. /* But don't call tr_utpClose -- see reset_timer in tr-utp.c for an
  18. explanation. */
  19. }
  20. --- a/libtransmission/tr-udp.c
  21. +++ b/libtransmission/tr-udp.c
  22. @@ -125,6 +125,24 @@ void tr_udpSetSocketBuffers(tr_session*
  23. }
  24. }
  25. +void tr_udpSetSocketTOS(tr_session* session)
  26. +{
  27. + if (session->peerSocketTOS == 0)
  28. + {
  29. + return;
  30. + }
  31. +
  32. + if (session->udp_socket != TR_BAD_SOCKET)
  33. + {
  34. + tr_netSetTOS(session->udp_socket, session->peerSocketTOS, TR_AF_INET);
  35. + }
  36. +
  37. + if (session->udp6_socket != TR_BAD_SOCKET)
  38. + {
  39. + tr_netSetTOS(session->udp6_socket, session->peerSocketTOS, TR_AF_INET6);
  40. + }
  41. +}
  42. +
  43. /* BEP-32 has a rather nice explanation of why we need to bind to one
  44. IPv6 address, if I may say so myself. */
  45. @@ -363,6 +381,8 @@ ipv6:
  46. tr_udpSetSocketBuffers(ss);
  47. + tr_udpSetSocketTOS(ss);
  48. +
  49. if (ss->isDHTEnabled)
  50. {
  51. tr_dhtInit(ss);
  52. --- a/libtransmission/tr-udp.h
  53. +++ b/libtransmission/tr-udp.h
  54. @@ -30,5 +30,6 @@ THE SOFTWARE.
  55. void tr_udpInit(tr_session*);
  56. void tr_udpUninit(tr_session*);
  57. void tr_udpSetSocketBuffers(tr_session*);
  58. +void tr_udpSetSocketTOS(tr_session*);
  59. bool tau_handle_message(tr_session* session, uint8_t const* msg, size_t msglen);