This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[PATCH] DSCP is not set for the connection handshake

Tags: None
(comma "," separated)
kamil
Registered Member
Posts
3
Karma
0
Hello.
I'm using ktorrent 3.3.4 and I've found a bug in the DSCP setting feature.

DSCP field is set only for packets sent AFTER connection is made. Initial handshake has tos/dscp = 0.
This may seem to be a small issue for simple traffic shaping, but it completely breaks policy routing.
For example, I have 2 upstream links and I've set policy routing based on DSCP field to route torrent trafic to another ISP.
In this configuration first packets of the connection go to the different uplink than the rest of transmission, which of course makes it unusable.

Following patch fixes this issue for me:

Code: Select all
diff -u -r ktorrent-3.3.4+dfsg.1-orig/libbtcore/mse/streamsocket.cpp ktorrent-3.3.4+dfsg.1/libbtcore/mse/streamsocket.cpp--- ktorrent-3.3.4+dfsg.1-orig/libbtcore/mse/streamsocket.cpp  2010-02-10 22:14:32.000000000 +0100
+++ ktorrent-3.3.4+dfsg.1/libbtcore/mse/streamsocket.cpp 2010-02-21 15:33:32.000000000 +0100
@@ -54,7 +54,7 @@
      reinserted_data = 0;
      reinserted_data_size = 0;
      reinserted_data_read = 0;
-
+     sock->setTOS(tos);
   }

   StreamSocket::StreamSocket(int fd,int ip_version) : sock(0),enc(0),monitored(false)
@@ -195,9 +195,10 @@
   {
      // we don't wanna block the current thread so set non blocking
      sock->setNonBlocking();
+     sock->setTOS(tos);
+
      if (sock->connectTo(addr))
      {
-        sock->setTOS(tos);
         return true;
      }
      else if (connecting())
@@ -310,9 +311,9 @@

   bool StreamSocket::connectSuccesFull() const
   {
+     sock->setTOS(tos);
+
      bool ret = sock->connectSuccesFull();
-     if (ret)
-        sock->setTOS(tos);

      if (num_connecting > 0)
         num_connecting--;



Best regards.
George
Moderator
Posts
5421
Karma
1
Send that patch in a file, copy pasting from forums usually leads to patches which don't apply.
kamil
Registered Member
Posts
3
Karma
0
George wrote:Send that patch in a file, copy pasting from forums usually leads to patches which don't apply.

Sent to joris@ktorrent.org (the only contact email address I was able to find on the ktorrent.org)
George
Moderator
Posts
5421
Karma
1
OK, patch is committed, had to modify it though, given the recent changes in trunk due to µTP.
kamil
Registered Member
Posts
3
Karma
0
Looks good in svn, thanks.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]