Cake - FQ_codel the next generation
 help / color / mirror / Atom feed
From: Dave Taht <dave.taht@gmail.com>
To: cake@lists.bufferbloat.net,
	 "codel@lists.bufferbloat.net" <codel@lists.bufferbloat.net>
Subject: [Cake] [RFC PATCH] Don't give malicious CE senders a free ride
Date: Wed, 5 Oct 2016 21:28:28 -0700	[thread overview]
Message-ID: <CAA93jw79ahtp_RiA1AzY_J3JEacAG9Qpt8hBZjSynC8jpX3iUQ@mail.gmail.com> (raw)

After doing myself in with BBR not respecting CE marks, I'm now thinking
that perhaps the right thing for red/fq_codel/cake/pie/etc to do is actually
*drop* stuff that it sees that is already CE marked, when it too wants
to mark, instead of giving it a free ride.

It's an unfriendly world out there.

Not happy with the name of the function... and to me - it looks like
the existing  call sites for IP_ECN_set_ce would actually be saner if
they always returned 0 instead of !ecn.

diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index dce2d58..3742d84 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -71,6 +71,36 @@ static inline void INET_ECN_dontxmit(struct sock *sk)
                (label) |= htonl(INET_ECN_ECT_0 << 20);                 \
     } while (0)


+/* When CE is already asserted, sometimes it is saner to drop the packet
+   in order to not give malicious CE senders as much of a free ride. */
+
+static inline int IP_ECN_safe_set_ce(struct iphdr *iph)
+{
+       u32 check = (__force u32)iph->check;
+       u32 ecn = (iph->tos + 1) & INET_ECN_MASK;
+
+       /*
+        * After the last operation we have (in binary):
+        * INET_ECN_NOT_ECT => 01
+        * INET_ECN_ECT_1   => 10
+        * INET_ECN_ECT_0   => 11
+        * INET_ECN_CE      => 00
+        */
+       if (!(ecn & 2))
+               return 0;
+
+       /*
+        * The following gives us:
+        * INET_ECN_ECT_1 => check += htons(0xFFFD)
+        * INET_ECN_ECT_0 => check += htons(0xFFFE)
+        */
+       check += (__force u16)htons(0xFFFB) + (__force u16)htons(ecn);
+
+       iph->check = (__force __sum16)(check + (check>=0xFFFF));
+       iph->tos |= INET_ECN_CE;
+       return 1;
+}
+

-- 
Dave Täht
Let's go make home routers and wifi faster! With better software!
http://blog.cerowrt.org

             reply	other threads:[~2016-10-06  4:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-06  4:28 Dave Taht [this message]
2016-10-06  8:18 ` Jonathan Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.bufferbloat.net/postorius/lists/cake.lists.bufferbloat.net/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAA93jw79ahtp_RiA1AzY_J3JEacAG9Qpt8hBZjSynC8jpX3iUQ@mail.gmail.com \
    --to=dave.taht@gmail.com \
    --cc=cake@lists.bufferbloat.net \
    --cc=codel@lists.bufferbloat.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox