[BACK]Return to tcp_var.h CVS log [TXT][DIR] Up to [local] / sys / netinet

Annotation of sys/netinet/tcp_var.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: tcp_var.h,v 1.83 2007/06/25 12:17:43 markus Exp $     */
                      2: /*     $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $    */
                      3:
                      4: /*
                      5:  * Copyright (c) 1982, 1986, 1993, 1994
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. Neither the name of the University nor the names of its contributors
                     17:  *    may be used to endorse or promote products derived from this software
                     18:  *    without specific prior written permission.
                     19:  *
                     20:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     21:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     22:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     23:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     24:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     25:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     26:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     27:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     28:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     29:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     30:  * SUCH DAMAGE.
                     31:  *
                     32:  *     @(#)tcp_var.h   8.3 (Berkeley) 4/10/94
                     33:  */
                     34:
                     35: #ifndef _NETINET_TCP_VAR_H_
                     36: #define _NETINET_TCP_VAR_H_
                     37:
                     38: /*
                     39:  * Kernel variables for tcp.
                     40:  */
                     41:
                     42: struct sackblk {
                     43:        tcp_seq start;          /* start seq no. of sack block */
                     44:        tcp_seq end;            /* end seq no. */
                     45: };
                     46:
                     47: struct sackhole {
                     48:        tcp_seq start;          /* start seq no. of hole */
                     49:        tcp_seq end;            /* end seq no. */
                     50:        int     dups;           /* number of dup(s)acks for this hole */
                     51:        tcp_seq rxmit;          /* next seq. no in hole to be retransmitted */
                     52:        struct sackhole *next;  /* next in list */
                     53: };
                     54:
                     55: /*
                     56:  * TCP sequence queue structures.
                     57:  */
                     58: TAILQ_HEAD(tcpqehead, tcpqent);
                     59: struct tcpqent {
                     60:        TAILQ_ENTRY(tcpqent) tcpqe_q;
                     61:        struct tcphdr   *tcpqe_tcp;
                     62:        struct mbuf     *tcpqe_m;       /* mbuf contains packet */
                     63: };
                     64:
                     65: /*
                     66:  * Tcp control block, one per tcp; fields:
                     67:  */
                     68: struct tcpcb {
                     69:        struct tcpqehead t_segq;                /* sequencing queue */
                     70:        struct timeout t_timer[TCPT_NTIMERS];   /* tcp timers */
                     71:        short   t_state;                /* state of this connection */
                     72:        short   t_rxtshift;             /* log(2) of rexmt exp. backoff */
                     73:        short   t_rxtcur;               /* current retransmit value */
                     74:        short   t_dupacks;              /* consecutive dup acks recd */
                     75:        u_short t_maxseg;               /* maximum segment size */
                     76:        char    t_force;                /* 1 if forcing out a byte */
                     77:        u_int   t_flags;
                     78: #define        TF_ACKNOW       0x0001          /* ack peer immediately */
                     79: #define        TF_DELACK       0x0002          /* ack, but try to delay it */
                     80: #define        TF_NODELAY      0x0004          /* don't delay packets to coalesce */
                     81: #define        TF_NOOPT        0x0008          /* don't use tcp options */
                     82: #define        TF_SENTFIN      0x0010          /* have sent FIN */
                     83: #define        TF_REQ_SCALE    0x0020          /* have/will request window scaling */
                     84: #define        TF_RCVD_SCALE   0x0040          /* other side has requested scaling */
                     85: #define        TF_REQ_TSTMP    0x0080          /* have/will request timestamps */
                     86: #define        TF_RCVD_TSTMP   0x0100          /* a timestamp was received in SYN */
                     87: #define        TF_SACK_PERMIT  0x0200          /* other side said I could SACK */
                     88: #define        TF_SIGNATURE    0x0400          /* require TCP MD5 signature */
                     89: #ifdef TCP_ECN
                     90: #define TF_ECN_PERMIT  0x00008000      /* other side said I could ECN */
                     91: #define TF_RCVD_CE     0x00010000      /* send ECE in subsequent segs */
                     92: #define TF_SEND_CWR    0x00020000      /* send CWR in next seg */
                     93: #define TF_DISABLE_ECN 0x00040000      /* disable ECN for this connection */
                     94: #endif
                     95: #define TF_REASSLOCK   0x00080000      /* reassembling or draining */
                     96: #define TF_LASTIDLE    0x00100000      /* no outstanding ACK on last send */
                     97: #define TF_DEAD                0x00200000      /* dead and to-be-released */
                     98: #define TF_PMTUD_PEND  0x00400000      /* Path MTU Discovery pending */
                     99:
                    100:        struct  mbuf *t_template;       /* skeletal packet for transmit */
                    101:        struct  inpcb *t_inpcb;         /* back pointer to internet pcb */
                    102:        struct  timeout t_delack_to;    /* delayed ACK callback */
                    103: /*
                    104:  * The following fields are used as in the protocol specification.
                    105:  * See RFC793, Dec. 1981, page 21.
                    106:  */
                    107: /* send sequence variables */
                    108:        tcp_seq snd_una;                /* send unacknowledged */
                    109:        tcp_seq snd_nxt;                /* send next */
                    110:        tcp_seq snd_up;                 /* send urgent pointer */
                    111:        tcp_seq snd_wl1;                /* window update seg seq number */
                    112:        tcp_seq snd_wl2;                /* window update seg ack number */
                    113:        tcp_seq iss;                    /* initial send sequence number */
                    114:        u_long  snd_wnd;                /* send window */
                    115: #if 1 /*def TCP_SACK*/
                    116:        int     sack_enable;            /* enable SACK for this connection */
                    117:        int     snd_numholes;           /* number of holes seen by sender */
                    118:        struct sackhole *snd_holes;     /* linked list of holes (sorted) */
                    119: #if 1 /*defined(TCP_SACK) && defined(TCP_FACK)*/
                    120:        tcp_seq snd_fack;               /* for FACK congestion control */
                    121:        u_long  snd_awnd;               /* snd_nxt - snd_fack + */
                    122:                                        /* retransmitted data */
                    123:        int retran_data;                /* amount of outstanding retx. data  */
                    124: #endif /* TCP_FACK */
                    125: #endif /* TCP_SACK */
                    126: #if 1 /*defined(TCP_SACK) || defined(TCP_ECN)*/
                    127:        tcp_seq snd_last;               /* for use in fast recovery */
                    128: #endif
                    129: /* receive sequence variables */
                    130:        u_long  rcv_wnd;                /* receive window */
                    131:        tcp_seq rcv_nxt;                /* receive next */
                    132:        tcp_seq rcv_up;                 /* receive urgent pointer */
                    133:        tcp_seq irs;                    /* initial receive sequence number */
                    134: #if 1 /*def TCP_SACK*/
                    135:        tcp_seq rcv_lastsack;           /* last seq number(+1) sack'd by rcv'r*/
                    136:        int     rcv_numsacks;           /* # distinct sack blks present */
                    137:        struct sackblk sackblks[MAX_SACK_BLKS]; /* seq nos. of sack blocks */
                    138: #endif
                    139:
                    140: /*
                    141:  * Additional variables for this implementation.
                    142:  */
                    143: /* receive variables */
                    144:        tcp_seq rcv_adv;                /* advertised window */
                    145: /* retransmit variables */
                    146:        tcp_seq snd_max;                /* highest sequence number sent;
                    147:                                         * used to recognize retransmits
                    148:                                         */
                    149: /* congestion control (for slow start, source quench, retransmit after loss) */
                    150:        u_long  snd_cwnd;               /* congestion-controlled window */
                    151:        u_long  snd_ssthresh;           /* snd_cwnd size threshold for
                    152:                                         * for slow start exponential to
                    153:                                         * linear switch
                    154:                                         */
                    155:        u_short t_maxopd;               /* mss plus options */
                    156:        u_short t_peermss;              /* peer's maximum segment size */
                    157:
                    158: /*
                    159:  * transmit timing stuff.  See below for scale of srtt and rttvar.
                    160:  * "Variance" is actually smoothed difference.
                    161:  */
                    162:        uint32_t t_rcvtime;             /* time last segment received */
                    163:        uint32_t t_rtttime;             /* time we started measuring rtt */
                    164:        tcp_seq t_rtseq;                /* sequence number being timed */
                    165:        short   t_srtt;                 /* smoothed round-trip time */
                    166:        short   t_rttvar;               /* variance in round-trip time */
                    167:        u_short t_rttmin;               /* minimum rtt allowed */
                    168:        u_long  max_sndwnd;             /* largest window peer has offered */
                    169:
                    170: /* out-of-band data */
                    171:        char    t_oobflags;             /* have some */
                    172:        char    t_iobc;                 /* input character */
                    173: #define        TCPOOB_HAVEDATA 0x01
                    174: #define        TCPOOB_HADDATA  0x02
                    175:        short   t_softerror;            /* possible error not yet reported */
                    176:
                    177: /* RFC 1323 variables */
                    178:        u_char  snd_scale;              /* window scaling for send window */
                    179:        u_char  rcv_scale;              /* window scaling for recv window */
                    180:        u_char  request_r_scale;        /* pending window scaling */
                    181:        u_char  requested_s_scale;
                    182:        u_int32_t ts_recent;            /* timestamp echo data */
                    183:        u_int32_t ts_modulate;          /* modulation on timestamp */
                    184:        u_int32_t ts_recent_age;                /* when last updated */
                    185:        tcp_seq last_ack_sent;
                    186:
                    187: /* pointer for syn cache entries*/
                    188:        LIST_HEAD(, syn_cache) t_sc;    /* list of entries by this tcb */
                    189:
                    190: /* Path-MTU Discovery Information */
                    191:        u_int   t_pmtud_mss_acked;      /* MSS acked, lower bound for MTU */
                    192:        u_int   t_pmtud_mtu_sent;       /* MTU used, upper bound for MTU */
                    193:        tcp_seq t_pmtud_th_seq;         /* TCP SEQ from ICMP payload */
                    194:        u_int   t_pmtud_nextmtu;        /* Advertised Next-Hop MTU from ICMP */
                    195:        u_short t_pmtud_ip_len;         /* IP length from ICMP payload */
                    196:        u_short t_pmtud_ip_hl;          /* IP header length from ICMP payload */
                    197:
                    198:        int pf;
                    199:
                    200:        struct  timeout t_reap_to;      /* delayed cleanup timeout */
                    201: };
                    202:
                    203: #define        intotcpcb(ip)   ((struct tcpcb *)(ip)->inp_ppcb)
                    204: #define        sototcpcb(so)   (intotcpcb(sotoinpcb(so)))
                    205:
                    206: #ifdef _KERNEL
                    207: extern int tcp_delack_ticks;
                    208: void   tcp_delack(void *);
                    209:
                    210: #define TCP_INIT_DELACK(tp)                                            \
                    211:        timeout_set(&(tp)->t_delack_to, tcp_delack, tp)
                    212:
                    213: #define TCP_RESTART_DELACK(tp)                                         \
                    214:        timeout_add(&(tp)->t_delack_to, tcp_delack_ticks)
                    215:
                    216: #define        TCP_SET_DELACK(tp)                                              \
                    217: do {                                                                   \
                    218:        if (((tp)->t_flags & TF_DELACK) == 0) {                         \
                    219:                (tp)->t_flags |= TF_DELACK;                             \
                    220:                TCP_RESTART_DELACK(tp);                                 \
                    221:        }                                                               \
                    222: } while (/*CONSTCOND*/0)
                    223:
                    224: #define        TCP_CLEAR_DELACK(tp)                                            \
                    225: do {                                                                   \
                    226:        if ((tp)->t_flags & TF_DELACK) {                                \
                    227:                (tp)->t_flags &= ~TF_DELACK;                            \
                    228:                timeout_del(&(tp)->t_delack_to);                        \
                    229:        }                                                               \
                    230: } while (/*CONSTCOND*/0)
                    231:
                    232: /*
                    233:  * Handy way of passing around TCP option info.
                    234:  */
                    235: struct tcp_opt_info {
                    236:        int             ts_present;
                    237:        u_int32_t       ts_val;
                    238:        u_int32_t       ts_ecr;
                    239:        u_int16_t       maxseg;
                    240: };
                    241:
                    242: /*
                    243:  * Data for the TCP compressed state engine.
                    244:  */
                    245: union syn_cache_sa {
                    246:        struct sockaddr sa;
                    247:        struct sockaddr_in sin;
                    248: #if 1 /*def INET6*/
                    249:        struct sockaddr_in6 sin6;
                    250: #endif
                    251: };
                    252:
                    253: struct syn_cache {
                    254:        TAILQ_ENTRY(syn_cache) sc_bucketq;      /* link on bucket list */
                    255:        struct timeout sc_timer;                /* rexmt timer */
                    256:        union {                                 /* cached route */
                    257:                struct route route4;
                    258: #ifdef INET6
                    259:                struct route_in6 route6;
                    260: #endif
                    261:        } sc_route_u;
                    262: #define sc_route4      sc_route_u.route4
                    263: #ifdef INET6
                    264: #define sc_route6      sc_route_u.route6
                    265: #endif
                    266:        long sc_win;                            /* advertised window */
                    267:        int sc_bucketidx;                       /* our bucket index */
                    268:        u_int32_t sc_hash;
                    269:        u_int32_t sc_timestamp;                 /* timestamp from SYN */
                    270:        u_int32_t sc_modulate;                  /* our timestamp modulator */
                    271: #if 0
                    272:        u_int32_t sc_timebase;                  /* our local timebase */
                    273: #endif
                    274:        union syn_cache_sa sc_src;
                    275:        union syn_cache_sa sc_dst;
                    276:        tcp_seq sc_irs;
                    277:        tcp_seq sc_iss;
                    278:        u_int sc_rxtcur;                        /* current rxt timeout */
                    279:        u_int sc_rxttot;                        /* total time spend on queues */
                    280:        u_short sc_rxtshift;                    /* for computing backoff */
                    281:        u_short sc_flags;
                    282:
                    283: #define        SCF_UNREACH             0x0001          /* we've had an unreach error */
                    284: #define        SCF_TIMESTAMP           0x0002          /* peer will do timestamps */
                    285: #define        SCF_DEAD                0x0004          /* this entry to be released */
                    286: #define        SCF_SACK_PERMIT         0x0008          /* permit sack */
                    287: #define        SCF_ECN_PERMIT          0x0010          /* permit ecn */
                    288: #define        SCF_SIGNATURE           0x0020          /* enforce tcp signatures */
                    289:
                    290:        struct mbuf *sc_ipopts;                 /* IP options */
                    291:        u_int16_t sc_peermaxseg;
                    292:        u_int16_t sc_ourmaxseg;
                    293:        u_int     sc_request_r_scale    : 4,
                    294:                  sc_requested_s_scale  : 4;
                    295:
                    296:        struct tcpcb *sc_tp;                    /* tcb for listening socket */
                    297:        LIST_ENTRY(syn_cache) sc_tpq;           /* list of entries by same tp */
                    298: };
                    299:
                    300: struct syn_cache_head {
                    301:        TAILQ_HEAD(, syn_cache) sch_bucket;     /* bucket entries */
                    302:        u_short sch_length;                     /* # entries in bucket */
                    303: };
                    304:
                    305: static __inline int tcp_reass_lock_try(struct tcpcb *);
                    306: static __inline void tcp_reass_unlock(struct tcpcb *);
                    307: #define tcp_reass_lock(tp) tcp_reass_lock_try(tp)
                    308:
                    309: static __inline int
                    310: tcp_reass_lock_try(struct tcpcb *tp)
                    311: {
                    312:        int s;
                    313:
                    314:        /* Use splvm() due to mbuf allocation. */
                    315:        s = splvm();
                    316:        if (tp->t_flags & TF_REASSLOCK) {
                    317:                splx(s);
                    318:                return (0);
                    319:        }
                    320:        tp->t_flags |= TF_REASSLOCK;
                    321:        splx(s);
                    322:        return (1);
                    323: }
                    324:
                    325: static __inline void
                    326: tcp_reass_unlock(struct tcpcb *tp)
                    327: {
                    328:        int s;
                    329:
                    330:        s = splvm();
                    331:        tp->t_flags &= ~TF_REASSLOCK;
                    332:        splx(s);
                    333: }
                    334: #endif /* _KERNEL */
                    335:
                    336: /*
                    337:  * The smoothed round-trip time and estimated variance
                    338:  * are stored as fixed point numbers scaled by the values below.
                    339:  * For convenience, these scales are also used in smoothing the average
                    340:  * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
                    341:  * With these scales, srtt has 5 bits to the right of the binary point,
                    342:  * and thus an "ALPHA" of 0.875.  rttvar has 4 bits to the right of the
                    343:  * binary point, and is smoothed with an ALPHA of 0.75.
                    344:  */
                    345: #define        TCP_RTT_SHIFT           3       /* shift for srtt; 5 bits frac. */
                    346: #define        TCP_RTTVAR_SHIFT        2       /* shift for rttvar; 4 bits */
                    347: #define        TCP_RTT_BASE_SHIFT      2       /* remaining 2 bit shift */
                    348: #define        TCP_RTT_MAX             (1<<9)  /* maximum rtt */
                    349:
                    350: /*
                    351:  * The initial retransmission should happen at rtt + 4 * rttvar.
                    352:  * Because of the way we do the smoothing, srtt and rttvar
                    353:  * will each average +1/2 tick of bias.  When we compute
                    354:  * the retransmit timer, we want 1/2 tick of rounding and
                    355:  * 1 extra tick because of +-1/2 tick uncertainty in the
                    356:  * firing of the timer.  The bias will give us exactly the
                    357:  * 1.5 tick we need.  But, because the bias is
                    358:  * statistical, we have to test that we don't drop below
                    359:  * the minimum feasible timer (which is 2 ticks).
                    360:  * This macro assumes that the value of (1 << TCP_RTTVAR_SHIFT)
                    361:  * is the same as the multiplier for rttvar.
                    362:  */
                    363: #define        TCP_REXMTVAL(tp) \
                    364:        ((((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) >> TCP_RTT_BASE_SHIFT)
                    365:
                    366: /*
                    367:  * TCP statistics.
                    368:  * Many of these should be kept per connection,
                    369:  * but that's inconvenient at the moment.
                    370:  */
                    371: struct tcpstat {
                    372:        u_int32_t tcps_connattempt;     /* connections initiated */
                    373:        u_int32_t tcps_accepts;         /* connections accepted */
                    374:        u_int32_t tcps_connects;        /* connections established */
                    375:        u_int32_t tcps_drops;           /* connections dropped */
                    376:        u_int32_t tcps_conndrops;       /* embryonic connections dropped */
                    377:        u_int32_t tcps_closed;          /* conn. closed (includes drops) */
                    378:        u_int32_t tcps_segstimed;       /* segs where we tried to get rtt */
                    379:        u_int32_t tcps_rttupdated;      /* times we succeeded */
                    380:        u_int32_t tcps_delack;          /* delayed acks sent */
                    381:        u_int32_t tcps_timeoutdrop;     /* conn. dropped in rxmt timeout */
                    382:        u_int32_t tcps_rexmttimeo;      /* retransmit timeouts */
                    383:        u_int32_t tcps_persisttimeo;    /* persist timeouts */
                    384:        u_int32_t tcps_persistdrop;     /* connections dropped in persist */
                    385:        u_int32_t tcps_keeptimeo;       /* keepalive timeouts */
                    386:        u_int32_t tcps_keepprobe;       /* keepalive probes sent */
                    387:        u_int32_t tcps_keepdrops;       /* connections dropped in keepalive */
                    388:
                    389:        u_int32_t tcps_sndtotal;                /* total packets sent */
                    390:        u_int32_t tcps_sndpack;         /* data packets sent */
                    391:        u_int64_t tcps_sndbyte;         /* data bytes sent */
                    392:        u_int32_t tcps_sndrexmitpack;   /* data packets retransmitted */
                    393:        u_int64_t tcps_sndrexmitbyte;   /* data bytes retransmitted */
                    394:        u_int64_t tcps_sndrexmitfast;   /* Fast retransmits */
                    395:        u_int32_t tcps_sndacks;         /* ack-only packets sent */
                    396:        u_int32_t tcps_sndprobe;        /* window probes sent */
                    397:        u_int32_t tcps_sndurg;          /* packets sent with URG only */
                    398:        u_int32_t tcps_sndwinup;        /* window update-only packets sent */
                    399:        u_int32_t tcps_sndctrl;         /* control (SYN|FIN|RST) packets sent */
                    400:
                    401:        u_int32_t tcps_rcvtotal;        /* total packets received */
                    402:        u_int32_t tcps_rcvpack;         /* packets received in sequence */
                    403:        u_int64_t tcps_rcvbyte;         /* bytes received in sequence */
                    404:        u_int32_t tcps_rcvbadsum;       /* packets received with ccksum errs */
                    405:        u_int32_t tcps_rcvbadoff;       /* packets received with bad offset */
                    406:        u_int32_t tcps_rcvmemdrop;      /* packets dropped for lack of memory */
                    407:        u_int32_t tcps_rcvnosec;        /* packets dropped for lack of ipsec */
                    408:        u_int32_t tcps_rcvshort;        /* packets received too short */
                    409:        u_int32_t tcps_rcvduppack;      /* duplicate-only packets received */
                    410:        u_int64_t tcps_rcvdupbyte;      /* duplicate-only bytes received */
                    411:        u_int32_t tcps_rcvpartduppack;  /* packets with some duplicate data */
                    412:        u_int64_t tcps_rcvpartdupbyte;  /* dup. bytes in part-dup. packets */
                    413:        u_int32_t tcps_rcvoopack;       /* out-of-order packets received */
                    414:        u_int64_t tcps_rcvoobyte;       /* out-of-order bytes received */
                    415:        u_int32_t tcps_rcvpackafterwin; /* packets with data after window */
                    416:        u_int64_t tcps_rcvbyteafterwin; /* bytes rcvd after window */
                    417:        u_int32_t tcps_rcvafterclose;   /* packets rcvd after "close" */
                    418:        u_int32_t tcps_rcvwinprobe;     /* rcvd window probe packets */
                    419:        u_int32_t tcps_rcvdupack;       /* rcvd duplicate acks */
                    420:        u_int32_t tcps_rcvacktoomuch;   /* rcvd acks for unsent data */
                    421:        u_int32_t tcps_rcvacktooold;    /* rcvd acks for old data */
                    422:        u_int32_t tcps_rcvackpack;      /* rcvd ack packets */
                    423:        u_int64_t tcps_rcvackbyte;      /* bytes acked by rcvd acks */
                    424:        u_int32_t tcps_rcvwinupd;       /* rcvd window update packets */
                    425:        u_int32_t tcps_pawsdrop;        /* segments dropped due to PAWS */
                    426:        u_int32_t tcps_predack;         /* times hdr predict ok for acks */
                    427:        u_int32_t tcps_preddat;         /* times hdr predict ok for data pkts */
                    428:
                    429:        u_int32_t tcps_pcbhashmiss;     /* input packets missing pcb hash */
                    430:        u_int32_t tcps_noport;          /* no socket on port */
                    431:        u_int32_t tcps_badsyn;          /* SYN packet with src==dst rcv'ed */
                    432:
                    433:        u_int32_t tcps_rcvbadsig;       /* rcvd bad/missing TCP signatures */
                    434:        u_int64_t tcps_rcvgoodsig;      /* rcvd good TCP signatures */
                    435:        u_int32_t tcps_inhwcsum;        /* input hardware-checksummed packets */
                    436:        u_int32_t tcps_outhwcsum;       /* output hardware-checksummed packets */
                    437:
                    438:        /* ECN stats */
                    439:        u_int32_t tcps_ecn_accepts;     /* ecn connections accepted */
                    440:        u_int32_t tcps_ecn_rcvece;      /* # of rcvd ece */
                    441:        u_int32_t tcps_ecn_rcvcwr;      /* # of rcvd cwr */
                    442:        u_int32_t tcps_ecn_rcvce;       /* # of rcvd ce in ip header */
                    443:        u_int32_t tcps_ecn_sndect;      /* # of cwr sent */
                    444:        u_int32_t tcps_ecn_sndece;      /* # of ece sent */
                    445:        u_int32_t tcps_ecn_sndcwr;      /* # of cwr sent */
                    446:        u_int32_t tcps_cwr_ecn;         /* # of cwnd reduced by ecn */
                    447:        u_int32_t tcps_cwr_frecovery;   /* # of cwnd reduced by fastrecovery */
                    448:        u_int32_t tcps_cwr_timeout;     /* # of cwnd reduced by timeout */
                    449:
                    450:        /* These statistics deal with the SYN cache. */
                    451:        u_int64_t tcps_sc_added;        /* # of entries added */
                    452:        u_int64_t tcps_sc_completed;    /* # of connections completed */
                    453:        u_int64_t tcps_sc_timed_out;    /* # of entries timed out */
                    454:        u_int64_t tcps_sc_overflowed;   /* # dropped due to overflow */
                    455:        u_int64_t tcps_sc_reset;        /* # dropped due to RST */
                    456:        u_int64_t tcps_sc_unreach;      /* # dropped due to ICMP unreach */
                    457:        u_int64_t tcps_sc_bucketoverflow;/* # dropped due to bucket overflow */
                    458:        u_int64_t tcps_sc_aborted;      /* # of entries aborted (no mem) */
                    459:        u_int64_t tcps_sc_dupesyn;      /* # of duplicate SYNs received */
                    460:        u_int64_t tcps_sc_dropped;      /* # of SYNs dropped (no route/mem) */
                    461:        u_int64_t tcps_sc_collisions;   /* # of hash collisions */
                    462:        u_int64_t tcps_sc_retransmitted;/* # of retransmissions */
                    463:
                    464:        u_int64_t tcps_conndrained;     /* # of connections drained */
                    465:
                    466:        u_int64_t tcps_sack_recovery_episode;   /* SACK recovery episodes */
                    467:        u_int64_t tcps_sack_rexmits;            /* SACK rexmit segments */
                    468:        u_int64_t tcps_sack_rexmit_bytes;       /* SACK rexmit bytes */
                    469:        u_int64_t tcps_sack_rcv_opts;           /* SACK options received */
                    470:        u_int64_t tcps_sack_snd_opts;           /* SACK options sent */
                    471: };
                    472:
                    473: /*
                    474:  * Names for TCP sysctl objects.
                    475:  */
                    476:
                    477: #define        TCPCTL_RFC1323          1 /* enable/disable RFC1323 timestamps/scaling */
                    478: #define        TCPCTL_KEEPINITTIME     2 /* TCPT_KEEP value */
                    479: #define TCPCTL_KEEPIDLE                3 /* allow tcp_keepidle to be changed */
                    480: #define TCPCTL_KEEPINTVL       4 /* allow tcp_keepintvl to be changed */
                    481: #define TCPCTL_SLOWHZ          5 /* return kernel idea of PR_SLOWHZ */
                    482: #define TCPCTL_BADDYNAMIC      6 /* return bad dynamic port bitmap */
                    483: #define        TCPCTL_RECVSPACE        7 /* receive buffer space */
                    484: #define        TCPCTL_SENDSPACE        8 /* send buffer space */
                    485: #define        TCPCTL_IDENT            9 /* get connection owner */
                    486: #define        TCPCTL_SACK            10 /* selective acknowledgement, rfc 2018 */
                    487: #define TCPCTL_MSSDFLT        11 /* Default maximum segment size */
                    488: #define        TCPCTL_RSTPPSLIMIT     12 /* RST pps limit */
                    489: #define        TCPCTL_ACK_ON_PUSH     13 /* ACK immediately on PUSH */
                    490: #define        TCPCTL_ECN             14 /* RFC3168 ECN */
                    491: #define        TCPCTL_SYN_CACHE_LIMIT 15 /* max size of comp. state engine */
                    492: #define        TCPCTL_SYN_BUCKET_LIMIT 16 /* max size of hash bucket */
                    493: #define        TCPCTL_RFC3390         17 /* enable/disable RFC3390 increased cwnd */
                    494: #define        TCPCTL_REASS_LIMIT     18 /* max entries for tcp reass queues */
                    495: #define        TCPCTL_DROP            19 /* drop tcp connection */
                    496: #define        TCPCTL_SACKHOLE_LIMIT  20 /* max entries for tcp sack queues */
                    497: #define        TCPCTL_MAXID           21
                    498:
                    499: #define        TCPCTL_NAMES { \
                    500:        { 0, 0 }, \
                    501:        { "rfc1323",    CTLTYPE_INT }, \
                    502:        { "keepinittime",       CTLTYPE_INT }, \
                    503:        { "keepidle",   CTLTYPE_INT }, \
                    504:        { "keepintvl",  CTLTYPE_INT }, \
                    505:        { "slowhz",     CTLTYPE_INT }, \
                    506:        { "baddynamic", CTLTYPE_STRUCT }, \
                    507:        { "recvspace",  CTLTYPE_INT }, \
                    508:        { "sendspace",  CTLTYPE_INT }, \
                    509:        { "ident",      CTLTYPE_STRUCT }, \
                    510:        { "sack",       CTLTYPE_INT }, \
                    511:        { "mssdflt",    CTLTYPE_INT }, \
                    512:        { "rstppslimit",        CTLTYPE_INT }, \
                    513:        { "ackonpush",  CTLTYPE_INT }, \
                    514:        { "ecn",        CTLTYPE_INT }, \
                    515:        { "syncachelimit",      CTLTYPE_INT }, \
                    516:        { "synbucketlimit",     CTLTYPE_INT }, \
                    517:        { "rfc3390",    CTLTYPE_INT }, \
                    518:        { "reasslimit",         CTLTYPE_INT }, \
                    519:        { "drop",       CTLTYPE_STRUCT }, \
                    520:        { "sackholelimit",      CTLTYPE_INT }, \
                    521: }
                    522:
                    523: #define        TCPCTL_VARS { \
                    524:        NULL, \
                    525:        &tcp_do_rfc1323, \
                    526:        &tcptv_keep_init, \
                    527:        &tcp_keepidle, \
                    528:        &tcp_keepintvl, \
                    529:        NULL, \
                    530:        NULL, \
                    531:        &tcp_recvspace, \
                    532:        &tcp_sendspace, \
                    533:        NULL, \
                    534:        NULL, \
                    535:        &tcp_mssdflt, \
                    536:        &tcp_rst_ppslim, \
                    537:        &tcp_ack_on_push, \
                    538:        NULL, \
                    539:        &tcp_syn_cache_limit, \
                    540:        &tcp_syn_bucket_limit, \
                    541:        &tcp_do_rfc3390, \
                    542:        NULL, \
                    543:        NULL, \
                    544:        NULL \
                    545: }
                    546:
                    547: struct tcp_ident_mapping {
                    548:        struct sockaddr_storage faddr, laddr;
                    549:        int euid, ruid;
                    550: };
                    551:
                    552: #ifdef _KERNEL
                    553: extern struct inpcbtable tcbtable;     /* head of queue of active tcpcb's */
                    554: extern struct tcpstat tcpstat; /* tcp statistics */
                    555: extern u_int32_t tcp_now;              /* for RFC 1323 timestamps */
                    556: extern int tcp_do_rfc1323;     /* enabled/disabled? */
                    557: extern int tcp_mssdflt;        /* default maximum segment size */
                    558: extern int tcp_ack_on_push;    /* ACK immediately on PUSH */
                    559: #ifdef TCP_SACK
                    560: extern int tcp_do_sack;        /* SACK enabled/disabled */
                    561: extern struct pool sackhl_pool;
                    562: extern int tcp_sackhole_limit; /* max entries for tcp sack queues */
                    563: #endif
                    564: extern int tcp_do_ecn;         /* RFC3168 ECN enabled/disabled? */
                    565: extern int tcp_do_rfc3390;     /* RFC3390 Increasing TCP's Initial Window */
                    566:
                    567: extern struct pool tcpqe_pool;
                    568: extern int tcp_reass_limit;    /* max entries for tcp reass queues */
                    569:
                    570: extern int tcp_syn_cache_limit; /* max entries for compressed state engine */
                    571: extern int tcp_syn_bucket_limit;/* max entries per hash bucket */
                    572:
                    573: extern int tcp_syn_cache_size;
                    574: extern struct syn_cache_head tcp_syn_cache[];
                    575: extern u_long syn_cache_count;
                    576:
                    577: int     tcp_attach(struct socket *);
                    578: void    tcp_canceltimers(struct tcpcb *);
                    579: struct tcpcb *
                    580:         tcp_close(struct tcpcb *);
                    581: void    tcp_reaper(void *);
                    582: int     tcp_freeq(struct tcpcb *);
                    583: #if defined(INET6) && !defined(TCP6)
                    584: void    tcp6_ctlinput(int, struct sockaddr *, void *);
                    585: #endif
                    586: void    *tcp_ctlinput(int, struct sockaddr *, void *);
                    587: int     tcp_ctloutput(int, struct socket *, int, int, struct mbuf **);
                    588: struct tcpcb *
                    589:         tcp_disconnect(struct tcpcb *);
                    590: struct tcpcb *
                    591:         tcp_drop(struct tcpcb *, int);
                    592: int     tcp_dooptions(struct tcpcb *, u_char *, int, struct tcphdr *,
                    593:                struct mbuf *, int, struct tcp_opt_info *);
                    594: void    tcp_drain(void);
                    595: void    tcp_init(void);
                    596: #if defined(INET6) && !defined(TCP6)
                    597: int     tcp6_input(struct mbuf **, int *, int);
                    598: #endif
                    599: void    tcp_input(struct mbuf *, ...);
                    600: int     tcp_mss(struct tcpcb *, int);
                    601: void    tcp_mss_update(struct tcpcb *);
                    602: u_int   tcp_hdrsz(struct tcpcb *);
                    603: void    tcp_mtudisc(struct inpcb *, int);
                    604: void    tcp_mtudisc_increase(struct inpcb *, int);
                    605: #ifdef INET6
                    606: void   tcp6_mtudisc(struct inpcb *, int);
                    607: void   tcp6_mtudisc_callback(struct in6_addr *);
                    608: #endif
                    609: struct tcpcb *
                    610:         tcp_newtcpcb(struct inpcb *);
                    611: void    tcp_notify(struct inpcb *, int);
                    612: int     tcp_output(struct tcpcb *);
                    613: void    tcp_pulloutofband(struct socket *, u_int, struct mbuf *, int);
                    614: int     tcp_reass(struct tcpcb *, struct tcphdr *, struct mbuf *, int *);
                    615: void    tcp_rscale(struct tcpcb *, u_long);
                    616: void    tcp_respond(struct tcpcb *, caddr_t, struct mbuf *, tcp_seq,
                    617:                tcp_seq, int);
                    618: void    tcp_setpersist(struct tcpcb *);
                    619: void    tcp_slowtimo(void);
                    620: struct mbuf *
                    621:         tcp_template(struct tcpcb *);
                    622: void    tcp_trace(short, short, struct tcpcb *, caddr_t, int, int);
                    623: struct tcpcb *
                    624:         tcp_usrclosed(struct tcpcb *);
                    625: int     tcp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
                    626: #if defined(INET6) && !defined(TCP6)
                    627: int     tcp6_usrreq(struct socket *,
                    628:            int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
                    629: #endif
                    630: int     tcp_usrreq(struct socket *,
                    631:            int, struct mbuf *, struct mbuf *, struct mbuf *);
                    632: void    tcp_xmit_timer(struct tcpcb *, int);
                    633: void    tcpdropoldhalfopen(struct tcpcb *, u_int16_t);
                    634: #ifdef TCP_SACK
                    635: void    tcp_sack_option(struct tcpcb *,struct tcphdr *,u_char *,int);
                    636: void    tcp_update_sack_list(struct tcpcb *tp, tcp_seq, tcp_seq);
                    637: void    tcp_del_sackholes(struct tcpcb *, struct tcphdr *);
                    638: void    tcp_clean_sackreport(struct tcpcb *tp);
                    639: void    tcp_sack_adjust(struct tcpcb *tp);
                    640: struct sackhole *
                    641:         tcp_sack_output(struct tcpcb *tp);
                    642: int     tcp_sack_partialack(struct tcpcb *, struct tcphdr *);
                    643: #ifdef DEBUG
                    644: void    tcp_print_holes(struct tcpcb *tp);
                    645: #endif
                    646: #endif /* TCP_SACK */
                    647: #if defined(TCP_SACK)
                    648: int     tcp_newreno(struct tcpcb *, struct tcphdr *);
                    649: u_long  tcp_seq_subtract(u_long, u_long );
                    650: #endif /* TCP_SACK */
                    651: #ifdef TCP_SIGNATURE
                    652: int    tcp_signature_apply(caddr_t, caddr_t, unsigned int);
                    653: int    tcp_signature(struct tdb *, int, struct mbuf *, struct tcphdr *,
                    654:            int, int, char *);
                    655: #endif /* TCP_SIGNATURE */
                    656: void   tcp_rndiss_init(void);
                    657: tcp_seq        tcp_rndiss_next(void);
                    658: u_int16_t
                    659:        tcp_rndiss_encrypt(u_int16_t);
                    660: void     tcp_set_iss_tsm(struct tcpcb *);
                    661:
                    662: int     syn_cache_add(struct sockaddr *, struct sockaddr *,
                    663:                struct tcphdr *, unsigned int, struct socket *,
                    664:                struct mbuf *, u_char *, int, struct tcp_opt_info *, tcp_seq *);
                    665: void    syn_cache_unreach(struct sockaddr *, struct sockaddr *,
                    666:           struct tcphdr *);
                    667: struct socket *syn_cache_get(struct sockaddr *, struct sockaddr *,
                    668:                struct tcphdr *, unsigned int, unsigned int,
                    669:                struct socket *so, struct mbuf *);
                    670: void    syn_cache_init(void);
                    671: void    syn_cache_insert(struct syn_cache *, struct tcpcb *);
                    672: struct syn_cache *syn_cache_lookup(struct sockaddr *, struct sockaddr *,
                    673:                struct syn_cache_head **);
                    674: void    syn_cache_reset(struct sockaddr *, struct sockaddr *,
                    675:                struct tcphdr *);
                    676: int     syn_cache_respond(struct syn_cache *, struct mbuf *);
                    677: void    syn_cache_timer(void *);
                    678: void    syn_cache_cleanup(struct tcpcb *);
                    679: void    syn_cache_reaper(void *);
                    680:
                    681: #endif /* _KERNEL */
                    682: #endif /* _NETINET_TCP_VAR_H_ */

CVSweb