[net-next-2.6 PATCH v8 0/7] TCPCT part 1: cookie option exchange

Previous thread: [net-next-2.6 PATCH 1/3] e1000e: check_polarity function pointers not set for 8257x by Jeff Kirsher on Wednesday, December 2, 2009 - 8:02 pm. (4 messages)

Next thread: README: net-next-2.6 plans... by David Miller on Thursday, December 3, 2009 - 12:01 am. (2 messages)
From: William Allen Simpson
Date: Wednesday, December 2, 2009 - 9:04 pm

Initiator                            Responder
=========                            =========
<SYN>                          ->
Cookie
                                 <-   <SYN,ACK(SYN)>
                                      Cookie
                                      optional data


V8:
Updated to patch cleanly with recent large commits.

Compiled and lightly tested.  Awaiting performance testing results.

Cosmetic changes, based on review by David Miller.

Merged some part 2 code to relieve ennui.


V7:
Updated to patch cleanly with recent large commits.

Compiled and lightly tested.  Awaiting performance testing results.

Revised RCU spinlocks, based on review by Eric and Joe.

Trivial savings of 2 if tests, based on review by Joe.

Cosmetic changes to comment blocks, based on review by Eric.

Processing optional SYNACK data removed until later.


V6:
The new TCP_MSS_* symbols are now in an entirely separate patch.  Applied.

Updated and reorganized to split the code base into several pieces, as
requested by Eric.  No significant changes.

...
--

From: William Allen Simpson
Date: Wednesday, December 2, 2009 - 9:07 pm

Add optional function parameters associated with sending SYNACK.
These parameters are not needed after sending SYNACK, and are not
used for retransmission.  Avoids extending struct tcp_request_sock,
and avoids allocating kernel memory.

Also affects DCCP as it uses common struct request_sock_ops,
but this parameter is currently reserved for future use.

Signed-off-by: William.Allen.Simpson@gmail.com
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
---
  include/net/request_sock.h      |    8 +++++++-
  include/net/tcp.h               |    3 ++-
  net/dccp/ipv4.c                 |    5 +++--
  net/dccp/ipv6.c                 |    5 +++--
  net/dccp/minisocks.c            |    2 +-
  net/ipv4/inet_connection_sock.c |    2 +-
  net/ipv4/tcp_ipv4.c             |   18 ++++++++++--------
  net/ipv4/tcp_minisocks.c        |    2 +-
  net/ipv4/tcp_output.c           |    3 ++-
  net/ipv6/tcp_ipv6.c             |   27 ++++++++++++---------------
  10 files changed, 42 insertions(+), 33 deletions(-)
From: William Allen Simpson
Date: Wednesday, December 2, 2009 - 9:12 pm

Define (missing) hash message size for SHA1.

Define hashing size constants specific to TCP cookies.

Add new function: tcp_cookie_generator().

Maintain global secret values for tcp_cookie_generator().

This is a significantly revised implementation of earlier (15-year-old)
Photuris [RFC-2522] code for the KA9Q cooperative multitasking platform.

Linux RCU technique appears to be well-suited to this application, though
neither of the circular queue items are freed.

These functions will also be used in subsequent patches that implement
additional features.

Signed-off-by: William.Allen.Simpson@gmail.com
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
---
  include/linux/cryptohash.h |    1 +
  include/net/tcp.h          |    8 +++
  net/ipv4/tcp.c             |  140 ++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 149 insertions(+), 0 deletions(-)
From: William Allen Simpson
Date: Wednesday, December 2, 2009 - 9:14 pm

Define sysctl (tcp_cookie_size) to turn on and off the cookie option
default globally, instead of a compiled configuration option.

Define per socket option (TCP_COOKIE_TRANSACTIONS) for setting constant
data values, retrieving variable cookie values, and other facilities.

Move inline tcp_clear_options() unchanged from net/tcp.h to linux/tcp.h,
near its corresponding struct tcp_options_received (prior to changes).

This is a straightforward re-implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):

    http://thread.gmane.org/gmane.linux.network/102586

These functions will also be used in subsequent patches that implement
additional features.

Requires:
   net: TCP_MSS_DEFAULT, TCP_MSS_DESIRED

Signed-off-by: William.Allen.Simpson@gmail.com
---
  Documentation/networking/ip-sysctl.txt |    8 +++++++
  include/linux/tcp.h                    |   33 +++++++++++++++++++++++++++++++-
  include/net/tcp.h                      |    6 +----
  net/ipv4/sysctl_net_ipv4.c             |    8 +++++++
  net/ipv4/tcp_output.c                  |    3 ++
  5 files changed, 52 insertions(+), 6 deletions(-)
From: William Allen Simpson
Date: Wednesday, December 2, 2009 - 9:17 pm

Data structures are carefully composed to require minimal additions.
For example, the struct tcp_options_received cookie_plus variable fits
between existing 16-bit and 8-bit variables, requiring no additional
space (taking alignment into consideration).  There are no additions to
tcp_request_sock, and only 1 pointer in tcp_sock.

This is a significantly revised implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):

    http://thread.gmane.org/gmane.linux.network/102586

The principle difference is using a TCP option to carry the cookie nonce,
instead of a user configured offset in the data.  This is more flexible and
less subject to user configuration error.  Such a cookie option has been
suggested for many years, and is also useful without SYN data, allowing
several related concepts to use the same extension option.

    "Re: SYN floods (was: does history repeat itself?)", September 9, 1996.
    http://www.merit.net/mail.archives/nanog/1996-09/msg00235.html

    "Re: what a new TCP header might look like", May 12, 1998.
    ftp://ftp.isi.edu/end2end/end2end-interest-1998.mail

These functions will also be used in subsequent patches that implement
additional features.

Requires:
   TCPCT part 1a: add request_values parameter for sending SYNACK
   TCPCT part 1b: generate Responder Cookie secret
   TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS

Signed-off-by: William.Allen.Simpson@gmail.com
---
  include/linux/tcp.h      |   29 +++++++++++++---
  include/net/tcp.h        |   83 ++++++++++++++++++++++++++++++++++++++++++++++
  net/ipv4/tcp_ipv4.c      |   20 +++++++++++
  net/ipv4/tcp_minisocks.c |   46 +++++++++++++++++++++----
  net/ipv6/tcp_ipv6.c      |   13 +++++++
  5 files changed, 177 insertions(+), 14 deletions(-)
From: William Allen Simpson
Date: Wednesday, December 2, 2009 - 9:19 pm

Provide per socket control of the TCP cookie option and SYN/SYNACK data.

This is a straightforward re-implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):

    http://thread.gmane.org/gmane.linux.network/102586

The principle difference is using a TCP option to carry the cookie nonce,
instead of a user configured offset in the data.

Allocations have been rearranged to avoid requiring GFP_ATOMIC.

Requires:
   net: TCP_MSS_DEFAULT, TCP_MSS_DESIRED
   TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS
   TCPCT part 1d: define TCP cookie option, extend existing struct's

Signed-off-by: William.Allen.Simpson@gmail.com
---
  net/ipv4/tcp.c |  133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
  1 files changed, 131 insertions(+), 2 deletions(-)
From: William Allen Simpson
Date: Wednesday, December 2, 2009 - 9:23 pm

Calculate and format <SYN> TCP_COOKIE option.

This is a significantly revised implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):

    http://thread.gmane.org/gmane.linux.network/102586

Requires:
   TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS
   TCPCT part 1d: define TCP cookie option, extend existing struct's

Signed-off-by: William.Allen.Simpson@gmail.com
---
  net/ipv4/tcp_output.c |  193 +++++++++++++++++++++++++++++++++++++++++--------
  1 files changed, 163 insertions(+), 30 deletions(-)
From: William Allen Simpson
Date: Wednesday, December 2, 2009 - 9:25 pm

Parse incoming TCP_COOKIE option(s).

Calculate <SYN,ACK> TCP_COOKIE option.

Send optional <SYN,ACK> data.

This is a significantly revised implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):

    http://thread.gmane.org/gmane.linux.network/102586

Requires:
   TCPCT part 1a: add request_values parameter for sending SYNACK
   TCPCT part 1b: generate Responder Cookie secret
   TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS
   TCPCT part 1d: define TCP cookie option, extend existing struct's
   TCPCT part 1e: implement socket option TCP_COOKIE_TRANSACTIONS
   TCPCT part 1f: Initiator Cookie => Responder

Signed-off-by: William.Allen.Simpson@gmail.com
---
  include/net/tcp.h        |    1 +
  net/ipv4/syncookies.c    |    5 +-
  net/ipv4/tcp_input.c     |   75 +++++++++++++++++++++++++++++----
  net/ipv4/tcp_ipv4.c      |   47 +++++++++++++++++++--
  net/ipv4/tcp_minisocks.c |   14 ++++---
  net/ipv4/tcp_output.c    |  103 ++++++++++++++++++++++++++++++++++++++--------
  net/ipv6/syncookies.c    |    5 +-
  net/ipv6/tcp_ipv6.c      |   52 ++++++++++++++++++++++-
  8 files changed, 259 insertions(+), 43 deletions(-)
From: David Miller
Date: Wednesday, December 2, 2009 - 11:13 pm

From: William Allen Simpson <william.allen.simpson@gmail.com>

All applied, thanks.

I had to apply the following fix on top to cure a warning on 64-bit.

tcp: Fix warning on 64-bit.

net/ipv4/tcp_output.c: In function ‘tcp_make_synack’:
net/ipv4/tcp_output.c:2488: warning: cast from pointer to integer of different size

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/ipv4/tcp_output.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 2ac8bef..c08e06d 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2485,7 +2485,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
 
 			/* recommended */
 			*tail-- ^= ((th->dest << 16) | th->source);
-			*tail-- ^= (u32)cvp; /* per sockopt */
+			*tail-- ^= (u32)(unsigned long)cvp; /* per sockopt */
 
 			sha_transform((__u32 *)&xvp->cookie_bakery[0],
 				      (char *)mess,
-- 
1.6.5

--

From: David Miller
Date: Wednesday, December 2, 2009 - 11:19 pm

From: David Miller <davem@davemloft.net>

I also had to apply another patch to fix build failures:

tcp: sysctl_tcp_cookie_size needs to be exported to modules.

Otherwise:

ERROR: "sysctl_tcp_cookie_size" [net/ipv6/ipv6.ko] undefined!
make[1]: *** [__modpost] Error 1

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/ipv4/tcp_output.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index c08e06d..93316a9 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -60,6 +60,7 @@ int sysctl_tcp_base_mss __read_mostly = 512;
 int sysctl_tcp_slow_start_after_idle __read_mostly = 1;
 
 int sysctl_tcp_cookie_size __read_mostly = 0; /* TCP_COOKIE_MAX */
+EXPORT_SYMBOL_GPL(sysctl_tcp_cookie_size);
 
 
 /* Account for new data that has been sent to the network. */
-- 
1.6.5

--

Previous thread: [net-next-2.6 PATCH 1/3] e1000e: check_polarity function pointers not set for 8257x by Jeff Kirsher on Wednesday, December 2, 2009 - 8:02 pm. (4 messages)

Next thread: README: net-next-2.6 plans... by David Miller on Thursday, December 3, 2009 - 12:01 am. (2 messages)