tunnel: drop packet if ECN present with not-ECT
authorstephen hemminger <shemminger@vyatta.com>
Tue, 25 Sep 2012 11:02:48 +0000 (11:02 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Sep 2012 22:12:37 +0000 (18:12 -0400)
commiteccc1bb8d4b4cf68d3c9becb083fa94ada7d495c
treeb0be7efd0c4a4eed26ffd63863dc372d3b1f2ca0
parentb0558ef24a792906914fcad277f3befe2420e618
tunnel: drop packet if ECN present with not-ECT

Linux tunnels were written before RFC6040 and therefore never
implemented the corner case of ECN getting set in the outer header
and the inner header not being ready for it.

Section 4.2.  Default Tunnel Egress Behaviour.
 o If the inner ECN field is Not-ECT, the decapsulator MUST NOT
      propagate any other ECN codepoint onwards.  This is because the
      inner Not-ECT marking is set by transports that rely on dropped
      packets as an indication of congestion and would not understand or
      respond to any other ECN codepoint [RFC4774].  Specifically:

      *  If the inner ECN field is Not-ECT and the outer ECN field is
         CE, the decapsulator MUST drop the packet.

      *  If the inner ECN field is Not-ECT and the outer ECN field is
         Not-ECT, ECT(0), or ECT(1), the decapsulator MUST forward the
         outgoing packet with the ECN field cleared to Not-ECT.

This patch moves the ECN decap logic out of the individual tunnels
into a common place.

It also adds logging to allow detecting broken systems that
set ECN bits incorrectly when tunneling (or an intermediate
router might be changing the header).

Overloads rx_frame_error to keep track of ECN related error.

Thanks to Chris Wright who caught this while reviewing the new VXLAN
tunnel.

This code was tested by injecting faulty logic in other end GRE
to send incorrectly encapsulated packets.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/inet_ecn.h
net/ipv4/ip_gre.c
net/ipv4/ipip.c
net/ipv6/ip6_gre.c