From a50eb788faabaf4a93e82cc35cc09d3db96c9539 Mon Sep 17 00:00:00 2001 From: rrs Date: Sun, 17 Jun 2007 01:36:02 +0000 Subject: [PATCH] - For sctp_input/sctp6_input add announcment when a packet arrives (debug) - re-factor the packet drop in sctp_output a bit more, we don't need the trim after all, but the size calc is now corrected. - When a assoc is in the COOKIE-ECHO/COOKIE-WAIT state and the user closes, it should not matter if data is queued, the assoc should be purged. - In error leg a missing free_chunk when iph comes in NULL (should not happen but just in case). --- sys/netinet/sctp_input.c | 2 ++ sys/netinet/sctp_output.c | 7 +++---- sys/netinet/sctp_pcb.c | 6 ++---- sys/netinet6/sctp6_usrreq.c | 3 +++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index f10507f9db09..42303ab946e4 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -4737,6 +4737,8 @@ sctp_input(i_pak, off) } sh = (struct sctphdr *)((caddr_t)ip + iphlen); ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(*sh)); + SCTPDBG(SCTP_DEBUG_INPUT1, + "sctp_input() length:%d iphlen:%d\n", mlen, iphlen); /* SCTP does not allow broadcasts or multicasts */ if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index cb8b93ff31ed..430f85324d33 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -9653,7 +9653,7 @@ sctp_send_packet_dropped(struct sctp_tcb *stcb, struct sctp_nets *net, int len; int was_trunc = 0; struct ip *iph; - int fullsz = 0, trimby = 0; + int fullsz = 0, extra = 0; long spc; asoc = &stcb->asoc; @@ -9674,6 +9674,7 @@ sctp_send_packet_dropped(struct sctp_tcb *stcb, struct sctp_nets *net, chk->copy_by_ref = 0; iph = mtod(m, struct ip *); if (iph == NULL) { + sctp_free_a_chunk(stcb, chk); return; } if (iph->ip_v == IPVERSION) { @@ -9691,10 +9692,8 @@ sctp_send_packet_dropped(struct sctp_tcb *stcb, struct sctp_nets *net, /* * only send 1 mtu worth, trim off the excess on the end. */ - fullsz = len + SCTP_MAX_OVERHEAD; + fullsz = len - extra; len = min(stcb->asoc.smallest_mtu, MCLBYTES) - SCTP_MAX_OVERHEAD; - trimby = len - fullsz; - m_adj(m, trimby); was_trunc = 1; } chk->asoc = &stcb->asoc; diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index d5d5ffdc4fd4..66b037e11180 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -2560,10 +2560,8 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) if ((SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_COOKIE_WAIT) || (SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_COOKIE_ECHOED)) { /* Just abandon things in the front states */ - if (asoc->asoc.total_output_queue_size == 0) { - sctp_free_assoc(inp, asoc, SCTP_PCBFREE_NOFORCE, SCTP_FROM_SCTP_PCB + SCTP_LOC_2); - continue; - } + sctp_free_assoc(inp, asoc, SCTP_PCBFREE_NOFORCE, SCTP_FROM_SCTP_PCB + SCTP_LOC_2); + continue; } SCTP_TCB_LOCK(asoc); /* Disconnect the socket please */ diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index 190a5e942917..92c23f7166ee 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -102,6 +102,9 @@ sctp6_input(i_pak, offp, proto) ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(struct sctphdr)); iphlen = off; offset = iphlen + sizeof(*sh) + sizeof(*ch); + SCTPDBG(SCTP_DEBUG_INPUT1, + "sctp6_input() length:%d iphlen:%d\n", pkt_len, iphlen); + #if defined(NFAITH) && NFAITH > 0