]> git.hungrycats.org Git - linux/commitdiff
[NET] Reorder struct tcp_options_received
authorThomas Graf <tgraf@suug.ch>
Wed, 16 Mar 2005 01:29:26 +0000 (02:29 +0100)
committerThomas Graf <tgraf@suug.ch>
Wed, 16 Mar 2005 01:29:26 +0000 (02:29 +0100)
Reorders struct tcp_options_received to avoid padding and shrinks the
following fields to more appropriate sizes saving 8 bytes.

saw_tstamp: char -> 1 bit
tstamp_ok: char -> 1 bit
sack_ok: char -> 4 bits
wscale_ok: char -> 1 bit
snd_wscale: u8 -> 4 bits
rcv_wscale: u8 -> 4 bits
dsack: u8 -> 1 bit

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/tcp.h
net/ipv4/tcp_input.c
net/ipv4/tcp_output.c

index af8635d8901ea114a5b5095e315f2ce367d50d5b..14a55e3e3a502a77d7ea90b860c415494f541234 100644 (file)
@@ -216,17 +216,16 @@ struct tcp_options_received {
        __u32   ts_recent;      /* Time stamp to echo next              */
        __u32   rcv_tsval;      /* Time stamp value                     */
        __u32   rcv_tsecr;      /* Time stamp echo reply                */
-       char    saw_tstamp;     /* Saw TIMESTAMP on last packet         */
-       char    tstamp_ok;      /* TIMESTAMP seen on SYN packet         */
-       char    sack_ok;        /* SACK seen on SYN packet              */
-       char    wscale_ok;      /* Wscale seen on SYN packet            */
-       __u8    snd_wscale;     /* Window scaling received from sender  */
-       __u8    rcv_wscale;     /* Window scaling to send to receiver   */
+       __u16   saw_tstamp : 1, /* Saw TIMESTAMP on last packet         */
+               tstamp_ok : 1,  /* TIMESTAMP seen on SYN packet         */
+               dsack : 1,      /* D-SACK is scheduled                  */
+               wscale_ok : 1,  /* Wscale seen on SYN packet            */
+               sack_ok : 4,    /* SACK seen on SYN packet              */
+               snd_wscale : 4, /* Window scaling received from sender  */
+               rcv_wscale : 4; /* Window scaling to send to receiver   */
 /*     SACKs data      */
-       __u8    dsack;          /* D-SACK is scheduled                  */
        __u8    eff_sacks;      /* Size of SACK array to send with next packet */
        __u8    num_sacks;      /* Number of SACK blocks                */
-       __u8    __pad;
        __u16   user_mss;       /* mss requested by user in ioctl */
        __u16   mss_clamp;      /* Maximal mss, negotiated at connection setup */
 };
index b2c6878d2e3a79d917ec104a82cadbf2e9bba515..d507da370a40dda8e923019717182893d2b82826 100644 (file)
@@ -3018,15 +3018,16 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                                case TCPOPT_WINDOW:
                                        if(opsize==TCPOLEN_WINDOW && th->syn && !estab)
                                                if (sysctl_tcp_window_scaling) {
+                                                       __u8 snd_wscale = *(__u8 *) ptr;
                                                        opt_rx->wscale_ok = 1;
-                                                       opt_rx->snd_wscale = *(__u8 *)ptr;
-                                                       if(opt_rx->snd_wscale > 14) {
+                                                       if (snd_wscale > 14) {
                                                                if(net_ratelimit())
                                                                        printk(KERN_INFO "tcp_parse_options: Illegal window "
                                                                               "scaling value %d >14 received.\n",
-                                                                              opt_rx->snd_wscale);
-                                                               opt_rx->snd_wscale = 14;
+                                                                              snd_wscale);
+                                                               snd_wscale = 14;
                                                        }
+                                                       opt_rx->snd_wscale = snd_wscale;
                                                }
                                        break;
                                case TCPOPT_TIMESTAMP:
index 6354fa7620d8c1589e7e64abf9d969f452aac12b..13c14cb6dee45254077a0c2d59400c939043631c 100644 (file)
@@ -1427,6 +1427,7 @@ static inline void tcp_connect_init(struct sock *sk)
 {
        struct dst_entry *dst = __sk_dst_get(sk);
        struct tcp_sock *tp = tcp_sk(sk);
+       __u8 rcv_wscale;
 
        /* We'll fix this up when we get a response from the other end.
         * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT.
@@ -1451,8 +1452,9 @@ static inline void tcp_connect_init(struct sock *sk)
                                  &tp->rcv_wnd,
                                  &tp->window_clamp,
                                  sysctl_tcp_window_scaling,
-                                 &tp->rx_opt.rcv_wscale);
+                                 &rcv_wscale);
 
+       tp->rx_opt.rcv_wscale = rcv_wscale;
        tp->rcv_ssthresh = tp->rcv_wnd;
 
        sk->sk_err = 0;