tcp/sack: Move scoreboard block start/end setup into alloc function
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 13 Apr 2012 06:31:55 +0000 (14:31 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 13 Apr 2012 06:32:59 +0000 (14:32 +0800)
This paves way for further SACK scoreboard block allocation optimization

sys/netinet/tcp_sack.c

index d0e239d..c8448e2 100644 (file)
@@ -147,9 +147,16 @@ sack_block_lookup(struct scoreboard *scb, tcp_seq seq, struct sackblock **sb)
  * Allocate a SACK block.
  */
 static __inline struct sackblock *
-alloc_sackblock(void)
+alloc_sackblock(const struct raw_sackblock *raw_sb)
 {
-       return (kmalloc(sizeof(struct sackblock), M_SACKBLOCK, M_NOWAIT));
+       struct sackblock *sb;
+
+       sb = kmalloc(sizeof(struct sackblock), M_SACKBLOCK, M_NOWAIT);
+       if (sb != NULL) {
+               sb->sblk_start = raw_sb->rblk_start;
+               sb->sblk_end = raw_sb->rblk_end;
+       }
+       return sb;
 }
 
 /*
@@ -265,13 +272,11 @@ tcp_sack_add_blocks(struct tcpcb *tp, struct tcpopt *to)
                }
                tcpstat.tcps_sacksbupdate++;
 
-               sb = alloc_sackblock();
+               sb = alloc_sackblock(newsackblock);
                if (sb == NULL) {       /* do some sort of cleanup? XXX */
                        tcpstat.tcps_sacksbfailed++;
                        break;          /* just skip rest of blocks */
                }
-               sb->sblk_start = newsackblock->rblk_start;
-               sb->sblk_end = newsackblock->rblk_end;
                insert_block(scb, sb);
        }
 }