diff options
author | andre <andre@FreeBSD.org> | 2007-04-20 13:51:34 +0000 |
---|---|---|
committer | andre <andre@FreeBSD.org> | 2007-04-20 13:51:34 +0000 |
commit | 707a7006195c6c0989100a57e7cc70ded2ac57ff (patch) | |
tree | a49d8ce2b83617ba81374f679e958eb93d291d8c /sys/netinet/tcp_syncache.c | |
parent | e7ec21637e6dd18c3e21ba5798215a8f0754ff00 (diff) | |
download | FreeBSD-src-707a7006195c6c0989100a57e7cc70ded2ac57ff.zip FreeBSD-src-707a7006195c6c0989100a57e7cc70ded2ac57ff.tar.gz |
Simplifly syncache_expand() and clarify its semantics. Zero is returned
when the ACK is invalid and doesn't belong to any registered connection,
either in syncache or through SYN cookies. True but a NULL struct socket
is returned when the 3WHS completed but the socket could not be created
due to insufficient resources or limits reached.
For both cases an RST is sent back in tcp_input().
A logic error leading to a panic is fixed where syncache_expand() would
free the mbuf on socket allocation failure but tcp_input() later supplies
it to tcp_dropwithreset() to issue a RST to the peer.
Reported by: kris (the panic)
Diffstat (limited to 'sys/netinet/tcp_syncache.c')
-rw-r--r-- | sys/netinet/tcp_syncache.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 939a49c..6d1d1a2 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -758,7 +758,6 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, { struct syncache *sc; struct syncache_head *sch; - struct socket *so; struct syncache scs; /* @@ -803,25 +802,12 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, if (th->th_ack != sc->sc_iss + 1) goto failed; - so = syncache_socket(sc, *lsop, m); + *lsop = syncache_socket(sc, *lsop, m); - if (so == NULL) { -#if 0 -resetandabort: - /* XXXjlemon check this - is this correct? */ - (void) tcp_respond(NULL, m, m, th, - th->th_seq + tlen, (tcp_seq)0, TH_RST|TH_ACK); -#endif - m_freem(m); /* XXX: only needed for above */ + if (*lsop == NULL) tcpstat.tcps_sc_aborted++; - if (sc != &scs) { - syncache_insert(sc, sch); /* try again later */ - sc = NULL; - } - goto failed; - } else + else tcpstat.tcps_sc_completed++; - *lsop = so; if (sc != &scs) syncache_free(sc); @@ -829,6 +815,7 @@ resetandabort: failed: if (sc != NULL && sc != &scs) syncache_free(sc); + *lsop = NULL; return (0); } |