public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Shrink syncookie_secret by 8 byte.
@ 2008-03-10 15:49 Florian Westphal
  2008-03-10 18:05 ` Glenn Griffin
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Westphal @ 2008-03-10 15:49 UTC (permalink / raw)
  To: netdev; +Cc: Florian Westphal, Glenn Griffin

the first u32 copied from syncookie_secret is overwritten by the
minute-counter four lines below.
After adjusting the destination address, the size of syncookie_secret
can be reduced accordingly.

text    data     bss     dec     hex filename
1517       4     144    1665     681 old/net/ipv4/syncookies.o
1517       4     136    1657     679 new/net/ipv4/syncookies.o

CC: Glenn Griffin <ggriffin.kernel@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
AFAICS, the only other user of syncookie_secret[] is the ipv6 syncookie
support.
Because ipv6 syncookies only grab 44 bytes from syncookie_secret[],
this shouldn't affect them in any way.

 include/net/tcp.h     |    2 +-
 net/ipv4/syncookies.c |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 11119e3..66e2970 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -434,9 +434,9 @@ extern int			tcp_disconnect(struct sock *sk, int flags);
 
 extern void			tcp_unhash(struct sock *sk);
 
 /* From syncookies.c */
-extern __u32 syncookie_secret[2][16-3+SHA_DIGEST_WORDS];
+extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
 extern struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, 
 				    struct ip_options *opt);
 extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, 
 				     __u16 *mss);
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 4704f27..abc752d 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -20,9 +20,9 @@
 #include <net/tcp.h>
 
 extern int sysctl_tcp_syncookies;
 
-__u32 syncookie_secret[2][16-3+SHA_DIGEST_WORDS];
+__u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
 EXPORT_SYMBOL(syncookie_secret);
 
 static __init int init_syncookies(void)
 {
@@ -40,9 +40,9 @@ static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport,
 		       u32 count, int c)
 {
 	__u32 *tmp = __get_cpu_var(cookie_scratch);
 
-	memcpy(tmp + 3, syncookie_secret[c], sizeof(syncookie_secret[c]));
+	memcpy(tmp + 4, syncookie_secret[c], sizeof(syncookie_secret[c]));
 	tmp[0] = (__force u32)saddr;
 	tmp[1] = (__force u32)daddr;
 	tmp[2] = ((__force u32)sport << 16) + (__force u32)dport;
 	tmp[3] = count;
-- 
1.5.3.7


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Shrink syncookie_secret by 8 byte.
  2008-03-10 15:49 [PATCH] Shrink syncookie_secret by 8 byte Florian Westphal
@ 2008-03-10 18:05 ` Glenn Griffin
  2008-03-10 18:07   ` Florian Westphal
  0 siblings, 1 reply; 4+ messages in thread
From: Glenn Griffin @ 2008-03-10 18:05 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netdev, Glenn Griffin

> the first u32 copied from syncookie_secret is overwritten by the
> minute-counter four lines below.
> After adjusting the destination address, the size of syncookie_secret
> can be reduced accordingly.

Agreed.

> AFAICS, the only other user of syncookie_secret[] is the ipv6 syncookie
> support.
> Because ipv6 syncookies only grab 44 bytes from syncookie_secret[],
> this shouldn't affect them in any way.

You are correct.  syncookie_secret was declared static before ipv6 support was
added, and shrinking it by 4 bytes wont have any effect on ipv6.

You forgot to change the declaration in net/ipv6/syncookies.c.  Here is
an amended patch to include that.

Acked-by: Glenn Griffin <ggriffin.kernel@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 include/net/tcp.h     |    2 +-
 net/ipv4/syncookies.c |    4 ++--
 net/ipv6/syncookies.c |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 11119e3..66e2970 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -435,7 +435,7 @@ extern int			tcp_disconnect(struct sock *sk, int flags);
 extern void			tcp_unhash(struct sock *sk);
 
 /* From syncookies.c */
-extern __u32 syncookie_secret[2][16-3+SHA_DIGEST_WORDS];
+extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
 extern struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, 
 				    struct ip_options *opt);
 extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, 
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 4704f27..abc752d 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -21,7 +21,7 @@
 
 extern int sysctl_tcp_syncookies;
 
-__u32 syncookie_secret[2][16-3+SHA_DIGEST_WORDS];
+__u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
 EXPORT_SYMBOL(syncookie_secret);
 
 static __init int init_syncookies(void)
@@ -41,7 +41,7 @@ static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport,
 {
 	__u32 *tmp = __get_cpu_var(cookie_scratch);
 
-	memcpy(tmp + 3, syncookie_secret[c], sizeof(syncookie_secret[c]));
+	memcpy(tmp + 4, syncookie_secret[c], sizeof(syncookie_secret[c]));
 	tmp[0] = (__force u32)saddr;
 	tmp[1] = (__force u32)daddr;
 	tmp[2] = ((__force u32)sport << 16) + (__force u32)dport;
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index 827c5aa..3a622e7 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -22,7 +22,7 @@
 #include <net/tcp.h>
 
 extern int sysctl_tcp_syncookies;
-extern __u32 syncookie_secret[2][16-3+SHA_DIGEST_WORDS];
+extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
 
 #define COOKIEBITS 24	/* Upper bits store count */
 #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
-- 
1.5.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Shrink syncookie_secret by 8 byte.
  2008-03-10 18:05 ` Glenn Griffin
@ 2008-03-10 18:07   ` Florian Westphal
  2008-03-24  5:21     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Westphal @ 2008-03-10 18:07 UTC (permalink / raw)
  To: Glenn Griffin; +Cc: Florian Westphal, netdev

Glenn Griffin <ggriffin.kernel@gmail.com> wrote:
> You are correct.  syncookie_secret was declared static before ipv6 support was
> added, and shrinking it by 4 bytes wont have any effect on ipv6.
> 
> You forgot to change the declaration in net/ipv6/syncookies.c.  Here is
> an amended patch to include that.

Oops. Thanks for reviewing and fixing this up!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Shrink syncookie_secret by 8 byte.
  2008-03-10 18:07   ` Florian Westphal
@ 2008-03-24  5:21     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2008-03-24  5:21 UTC (permalink / raw)
  To: fw; +Cc: ggriffin.kernel, netdev

From: Florian Westphal <fw@strlen.de>
Date: Mon, 10 Mar 2008 19:07:07 +0100

> Glenn Griffin <ggriffin.kernel@gmail.com> wrote:
> > You are correct.  syncookie_secret was declared static before ipv6 support was
> > added, and shrinking it by 4 bytes wont have any effect on ipv6.
> > 
> > You forgot to change the declaration in net/ipv6/syncookies.c.  Here is
> > an amended patch to include that.
> 
> Oops. Thanks for reviewing and fixing this up!

Applied to net-2.6.26, thanks everyone.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-03-24  5:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-10 15:49 [PATCH] Shrink syncookie_secret by 8 byte Florian Westphal
2008-03-10 18:05 ` Glenn Griffin
2008-03-10 18:07   ` Florian Westphal
2008-03-24  5:21     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox