History log of /freebsd-current/sys/netinet/sctp_indata.c
Revision Date Author Comments
# 0d15140d 08-May-2024 Michael Tuexen <tuexen@FreeBSD.org>

sctp: minor cleanup

No functional chnage intended.
MFC after: 3 days


# 2fb174d1 18-Feb-2024 Gordon Bergling <gbe@FreeBSD.org>

sctp(4): Fix a typo in a source code comment

- s/anthing/anything/

MFC after: 3 days


# 847fa61f 24-Aug-2023 Michael Tuexen <tuexen@FreeBSD.org>

sctp: improve handling of socket shutdown for reading

If a socket is marked as cannot read anymore, drop chunks which
should be added to a control element in the receive queue.
This is consistent with dropping control elements instead of
adding them in the same situation.

Reported by: syzbot+291f6581cecb77097b16@syzkaller.appspotmail.com
MFC after: 1 week


# c3179e66 18-Aug-2023 Michael Tuexen <tuexen@FreeBSD.org>

sctp: cleanup cdefs.h include


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 749a7fb5 13-Aug-2023 Michael Tuexen <tuexen@FreeBSD.org>

sctp: cleanup

Do not put a variable in the stcb for passing it to a function.
Just use a parameter of the function. No functional change intended.

MFC after: 1 week


# 979bc32c 03-Aug-2022 Michael Tuexen <tuexen@FreeBSD.org>

sctp: tweak panic message

MFC after: 1 week


# 05b3a428 25-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Fix unused variable warnings in sctp_indata.c

With clang 15, the following -Werror warnings are produced:

sys/netinet/sctp_indata.c:3309:6: error: variable 'tot_retrans' set but not used [-Werror,-Wunused-but-set-variable]
int tot_retrans = 0;
^
sys/netinet/sctp_indata.c:3842:20: error: variable 'resend' set but not used [-Werror,-Wunused-but-set-variable]
int inflight = 0, resend = 0, inbetween = 0, acked = 0, above = 0;
^
sys/netinet/sctp_indata.c:3842:47: error: variable 'acked' set but not used [-Werror,-Wunused-but-set-variable]
int inflight = 0, resend = 0, inbetween = 0, acked = 0, above = 0;
^
sys/netinet/sctp_indata.c:3842:58: error: variable 'above' set but not used [-Werror,-Wunused-but-set-variable]
int inflight = 0, resend = 0, inbetween = 0, acked = 0, above = 0;
^

The 'tot_retrans' variable was used in sctp_strike_gap_ack_chunks(), but
refactoring in 493d8e5a830e got rid of it. Remove the variable since it
no longer serves any purpose.

The 'resend', 'acked', and 'above' variables are only used when
INVARIANTS is undefined. Ensure they are only declared and set in that
case.

MFC after: 3 days


# edc5b6ea 13-May-2022 Michael Tuexen <tuexen@FreeBSD.org>

sctp: use sb_avail() when accessing sb_acc for reading

This is a cleanup to simplify a patch for PR 260116.

PR: 260116
MFC after: 3 days


# 9b2a35b3 13-May-2022 Michael Tuexen <tuexen@FreeBSD.org>

sctp: improve consistency

No functional change intended.

MFC after: 3 days


# e7e65008 29-Mar-2022 Michael Tuexen <tuexen@FreeBSD.org>

sctp: fix typos

Thanks to David Sanders for fixing the typos in the userland stack.

MFC after: 3 days


# 105b68b4 09-Jul-2021 Michael Tuexen <tuexen@FreeBSD.org>

sctp: Fix errno in case of association setup failures

Do not report always ETIMEDOUT, but only when appropriate. In
other cases report ECONNABORTED.

MFC after: 3 days


# 8dc6a1ed 31-Jan-2021 Michael Tuexen <tuexen@FreeBSD.org>

sctp: fix a locking issue for old unordered data

Thanks to Anatoly Korniltsev for reporting the issue for the
userland stack.

MFC after: 3 days


# e597bae4 09-Nov-2020 Michael Tuexen <tuexen@FreeBSD.org>

Fix a potential use-after-free bug introduced in
https://svnweb.freebsd.org/changeset/base/363046

Thanks to Taylor Brandstetter for finding this issue using fuzz testing
and reporting it in https://github.com/sctplab/usrsctp/issues/547


# 9f2d6263 04-Oct-2020 Michael Tuexen <tuexen@FreeBSD.org>

Use __func__ instead of __FUNCTION__ for consistency.

MFC after: 3 days


# d0ed75b3 04-Oct-2020 Michael Tuexen <tuexen@FreeBSD.org>

Cleanup, no functional change intended.

MFC after: 3 days


# 1d1b4bce 27-Sep-2020 Michael Tuexen <tuexen@FreeBSD.org>

Cleanup, no functional change intended.

MFC after: 3 days


# 8f269b82 27-Sep-2020 Michael Tuexen <tuexen@FreeBSD.org>

Improve the handling of receiving unordered and unreliable user
messages using DATA chunks. Don't use fsn_included when not being
sure that it is set to an appropriate value. If the default is
used, which is -1, this can result in SCTP associaitons not
making any user visible progress.

Thanks to Yutaka Takeda for reporting this issue for the the
userland stack in https://github.com/pion/sctp/issues/138.

MFC after: 3 days


# b6db274d 23-Sep-2020 Michael Tuexen <tuexen@FreeBSD.org>

Whitespace changes.

MFC after: 3 days


# 662c1305 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

net: clean up empty lines in .c and .h files


# 91e04f9e 22-Jul-2020 Michael Tuexen <tuexen@FreeBSD.org>

Detect and handle an invalid reassembly constellation, which results in
a memory leak.

Thanks to Felix Weinrank for finding this issue using fuzz testing the
userland stack.

MFC after: 1 week


# 6ddc8438 10-Jul-2020 Michael Tuexen <tuexen@FreeBSD.org>

Fix a use-after-free bug for the userland stack. The kernel
stack is not affected.
Thanks to Mark Wodrich from Google for finding and reporting the
bug.

MFC after: 1 week


# b6734d8f 09-Jul-2020 Michael Tuexen <tuexen@FreeBSD.org>

Optimize flushing of receive queues.
This addresses an issue found and reported for the userland stack in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21243

MFC after: 1 week


# ef9095c7 08-Jul-2020 Michael Tuexen <tuexen@FreeBSD.org>

Fix error description.

MFC after: 1 week


# 132c0738 24-Jun-2020 Michael Tuexen <tuexen@FreeBSD.org>

Fix the acconting for fragmented unordered messages when using
interleaving.
This was reported for the userland stack in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19321

MFC after: 1 week


# 44710431 14-Jun-2020 Michael Tuexen <tuexen@FreeBSD.org>

Cleanups, no functional change.

MFC after: 1 week


# 70486b27 07-Jun-2020 Michael Tuexen <tuexen@FreeBSD.org>

Retire SCTP_SO_LOCK_TESTING.

This was intended to test the locking used in the MacOS X kernel on a
FreeBSD system, to make use of WITNESS and other debugging infrastructure.
This hasn't been used for ages, to take it out to reduce the #ifdef
complexity.

MFC after: 1 week


# 2cf33471 06-Jun-2020 Michael Tuexen <tuexen@FreeBSD.org>

Non-functional changes due to cleanup (upstream removing of Panda support)
of the code

MFC after: 1 week


# 999f86d6 19-May-2020 Michael Tuexen <tuexen@FreeBSD.org>

Replace snprintf() by SCTP_SNPRINTF() and let SCTP_SNPRINTF() map
to snprintf() on FreeBSD. This allows to check for failures of snprintf()
on platforms other than FreeBSD kernel.


# 821bae7c 19-May-2020 Michael Tuexen <tuexen@FreeBSD.org>

Revert r361209:

cem noted that on FreeBSD snprintf() can not fail and code should not
check for that.

A followup commit will replace the usage of snprintf() in the SCTP
sources with a variadic macro SCTP_SNPRINTF, which will simply map to
snprintf() on FreeBSD and do a checking similar to r361209 on
other platforms.


# e708e2a4 18-May-2020 Michael Tuexen <tuexen@FreeBSD.org>

Handle failures of snprintf().

MFC after: 3 days


# daf14341 16-May-2020 Michael Tuexen <tuexen@FreeBSD.org>

Ensure that an stcb is not dereferenced when it is about to be
freed.
This issue was found by SYZKALLER.

MFC after: 3 days


# efd5e692 10-May-2020 Michael Tuexen <tuexen@FreeBSD.org>

Ensure that we have a path when starting the T3 RXT timer.

Reported by: syzbot+f2321629047f89486fa3@syzkaller.appspotmail.com
MFC after: 3 days


# 6fb7b4fb 19-Mar-2020 Michael Tuexen <tuexen@FreeBSD.org>

Consistently provide arguments for timer start and stop routines.
This is another step in cleaning up timer handling.
MFC after: 1 week


# 5555400a 09-Feb-2020 Michael Tuexen <tuexen@FreeBSD.org>

Cleanup timer handling.

Submitted by: Taylor Brandstetter
MFC after: 1 week


# bbf9f080 03-Feb-2020 Michael Tuexen <tuexen@FreeBSD.org>

Improve numbering of debug information.

Submitted by: Taylor Brandstetter
MFC after: 1 week


# 63fb39ba 06-Oct-2019 Michael Tuexen <tuexen@FreeBSD.org>

Plumb an mbuf leak in a code path that should not be taken. Also avoid
that this path is taken by setting the tail pointer correctly.
There is still bug related to handling unordered unfragmented messages
which were delayed in deferred handling.
This issue was found by OSS-Fuzz testing the usrsctp stack and reported in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17794

MFC after: 3 days


# 2b861c15 24-Sep-2019 Michael Tuexen <tuexen@FreeBSD.org>

Plumb a memory leak.
Thnanks to Felix Weinrank for finding this issue using fuzz testing
and reporting it for the userland stack:
https://github.com/sctplab/usrsctp/issues/378

MFC after: 3 days


# 44f2a327 22-Sep-2019 Michael Tuexen <tuexen@FreeBSD.org>

Cleanup the RTO calculation and perform some consistency checks
before computing the RTO.
This should fix an overflow issue reported by Felix Weinrank in
https://github.com/sctplab/usrsctp/issues/375
for the userland stack and found by running a fuzz tester.

MFC after: 3 days


# ec24a1b6 31-Aug-2019 Michael Tuexen <tuexen@FreeBSD.org>

Improve the handling of illegal sequence number combinations in received
data chunks. Abort the association if there are data chunks with larger
fragement sequence numbers than the fragement sequence of the last
fragment.
Thanks to Mark Wodrich from Google who found this issue by fuzz testing
the userland stack and reporting this issue in
https://github.com/sctplab/usrsctp/issues/355

MFC after: 3 days


# f1903dc0 22-Jul-2019 Michael Tuexen <tuexen@FreeBSD.org>

Wakeup the application when doing PD-API for unordered DATA chunks.
Work done with rrs@.

MFC after: 1 week


# 2de5b904 25-Mar-2019 Michael Tuexen <tuexen@FreeBSD.org>

Fix the handling of fragmented unordered messages when using DATA chunks
and FORWARD-TSN.

This bug was reported in https://github.com/sctplab/usrsctp/issues/286
for the userland stack.

This is joint work with rrs@.

MFC after: 1 week


# 1a0b0216 21-Aug-2018 Michael Tuexen <tuexen@FreeBSD.org>

Refactor the SHUTDOWN_PENDING state handling.

This is not a functional change but a preperation for the upcoming
DTrace support. It is necessary to change the state in one
logical operation, even if it involves clearing the sub state
SHUTDOWN_PENDING.

MFC after: 1 month


# 839d21d6 13-Aug-2018 Michael Tuexen <tuexen@FreeBSD.org>

Use the stacb instead of the asoc in state macros.

This is not a functional change. Just a preparation for upcoming
dtrace state change provider support.


# 61a21880 13-Aug-2018 Michael Tuexen <tuexen@FreeBSD.org>

Use consistently the macors to modify the assoc state.

No functional change.


# ab9ed8a1 10-Aug-2018 Devin Teske <dteske@FreeBSD.org>

Fix misspellings of transmitter/transmitted

Reviewed by: emaste, bcr
Sponsored by: Smule, Inc.
Differential Revision: https://reviews.freebsd.org/D16025


# 0053ed28 19-Jul-2018 Michael Tuexen <tuexen@FreeBSD.org>

Whitespace changes due to changes in ident.


# b0471b4b 19-Jul-2018 Michael Tuexen <tuexen@FreeBSD.org>

Revert https://svnweb.freebsd.org/changeset/base/336503
since I also ran the export script with different parameters.


# 7679e49d 19-Jul-2018 Michael Tuexen <tuexen@FreeBSD.org>

Whitespace changes due to change if ident.


# 95844fce 21-May-2018 Michael Tuexen <tuexen@FreeBSD.org>

Make clear why there is an assignment, which is not necessary.


# f6960e20 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

netinet silence warnings


# 67e8b08b 06-May-2018 Michael Tuexen <tuexen@FreeBSD.org>

Ensure we are not dereferencing a NULL pointer.

This was found by Coverity scanning the usrsctp stack (CID 203808).

MFC after: 3 days


# e9a3a1b1 16-Jan-2018 Michael Tuexen <tuexen@FreeBSD.org>

Fix a bug related to fast retransmissions.

When processing a SACK advancing the cumtsn-ack in fast recovery,
increment the miss-indications for all TSN's reported as missing.

Thanks to Fabian Ising for finding the bug and to Timo Voelker
for provinding a fix.

This fix moves also CMT related initialisation of some variables
to a more appropriate place.

MFC after: 1 week


# 51369649 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# 253a63b8 05-Nov-2017 Michael Tuexen <tuexen@FreeBSD.org>

Fix an accounting bug where data was counted twice if on the read
queue and on the ordered or unordered queue.
While there, improve the checking in INVARIANTs when computing the
a_rwnd.

MFC after: 3 days


# af03054c 18-Oct-2017 Michael Tuexen <tuexen@FreeBSD.org>

Fix a signed/unsigned warning.

MFC after: 1 week


# 7f75695a 18-Oct-2017 Michael Tuexen <tuexen@FreeBSD.org>

Abort an SCTP association, when a DATA chunk is followed by an unknown
chunk with a length smaller than the minimum length.

Thanks to Felix Weinrank for making me aware of the problem.
MFC after: 3 days


# 8c8e10b7 14-Oct-2017 Michael Tuexen <tuexen@FreeBSD.org>

Code cleanup, not functional change.

This avoids taking a pointer of a packed structure which allows simpler
compilation of the userland stack.

MFC after: 1 week


# 53999485 21-Sep-2017 Michael Tuexen <tuexen@FreeBSD.org>

Free the control structure after using is, not before.
Found by Coverity while scanning the usrsctp library.
MFC after: 1 week


# d0d8c7de 21-Sep-2017 Michael Tuexen <tuexen@FreeBSD.org>

No need to wakeup, since sctp_add_to_readq() does it.

MFC after: 1 week


# ad608f06 19-Sep-2017 Michael Tuexen <tuexen@FreeBSD.org>

Remove a no longer used variable.

Reported by: Felix Weinrank
MFC after: 1 week


# 72e23aba 17-Sep-2017 Michael Tuexen <tuexen@FreeBSD.org>

Fix an accounting bug and use sctp_timer_start to start a timer.

MFC after: 1 week


# e5a9c519 25-Jul-2017 Michael Tuexen <tuexen@FreeBSD.org>

Remove duplicate statement.


# bbc9dfbc 20-Jul-2017 Michael Tuexen <tuexen@FreeBSD.org>

Fix the explicit EOR mode. If the final messages is not complete, send
an ABORT.
Joint work with rrs@
MFC after: 1 week


# 1f76872c 19-Jul-2017 Michael Tuexen <tuexen@FreeBSD.org>

Avoid shadowed variables.

MFC after: 1 week


# 28cd0699 18-Jul-2017 Michael Tuexen <tuexen@FreeBSD.org>

Fix the accounting and add code to detect errors in accounting.
Joint work with rrs@
MFC after: 1 week


# b7b84c0e 26-Dec-2016 Michael Tuexen <tuexen@FreeBSD.org>

Whitespace changes.

The toolchain for processing the sources has been updated. No functional
change.

MFC after: 3 days


# 3d6fe5d8 17-Dec-2016 Michael Tuexen <tuexen@FreeBSD.org>

Fix the handling of buffered messages in stream reset deferred handling.

Thanks to Eugen-Andrei Gavriloaie for reporting the issue and providing
substantial help in nailing down the issue.

MFC after: 1 week


# 8b9c95f4 11-Dec-2016 Michael Tuexen <tuexen@FreeBSD.org>

Ensure that the reported ppid and tsn are taken from the first fragment.

This fixes a bug where the wrong ppid was reported, if
* I-DATA was used on the first fragement was not received first
* DATA was used and different ppids where used.

Thanks to Julian Cordes for making me aware of the issue.

MFC after: 1 week


# ebecdad8 09-Dec-2016 Michael Tuexen <tuexen@FreeBSD.org>

Don't bundle a SACK chunk with a SHUTDOWN chunk if it is not required.

MFC after: 1 week


# 49656eef 07-Dec-2016 Michael Tuexen <tuexen@FreeBSD.org>

Cleanup the names of SSN, SID, TSN, FSN, PPID and MID.

This made a couple of bugs visible in handling SSN wrap-arounds
when using DATA chunks. Now bulk transfer seems to work fine...
This fixes the issue reported in
https://github.com/sctplab/usrsctp/issues/111

MFC after: 1 week


# 5b495f17 06-Dec-2016 Michael Tuexen <tuexen@FreeBSD.org>

Whitespace changes.

The tools using to generate the sources has been updated and produces
different whitespaces. Commit this seperately to avoid intermixing
these with real code changes.

MFC after: 3 days


# 5cb91655 21-Sep-2016 Michael Tuexen <tuexen@FreeBSD.org>

Fix the handling of unordered fragmented user messages using DATA chunks.

There were two bugs:
* There was an accounting bug resulting in reporting a too small a_rwnd.
* There are a bug when abandoning messages in the reassembly queue.

MFC after: 4 weeks


# be46a7c5 10-Aug-2016 Michael Tuexen <tuexen@FreeBSD.org>

Improve a consistency check to not detect valid cases for
unordered user messages using DATA chunks as invalid ones.
While there, ensure that error causes are provided when
sending ABORT chunks in case of reassembly problems detected.
Thanks to Taylor Brandstetter for making me aware of this problem.
MFC after: 3 days


# d1ea5fa9 05-Aug-2016 Michael Tuexen <tuexen@FreeBSD.org>

Fix various bugs in relation to the I-DATA chunk support

This is joint work with rrs.

MFC after: 3 days


# 0fa7377a 19-Jul-2016 Michael Tuexen <tuexen@FreeBSD.org>

Use correct order of conditions to avoid NULL deref.

MFC after: 3 days
X-MFC with: r302935


# 8e1b295f 17-Jul-2016 Michael Tuexen <tuexen@FreeBSD.org>

Fix the PR-SCTP behaviour.
This is done by rrs@.

MFC after: 3 days


# 26f0250a 17-Jul-2016 Michael Tuexen <tuexen@FreeBSD.org>

Add missing sctps_reasmusrmsgs counter.
Joint work with rrs@.
MFC after: 3 days


# 643fd575 15-Jul-2016 Michael Tuexen <tuexen@FreeBSD.org>

Deal with a portential memory allocation failure, which was reported
by the clang static code analyzer.
Joint work with rrs@.

MFC after: 3 days


# b4bf7221 16-Jul-2016 Michael Tuexen <tuexen@FreeBSD.org>

Don't free a data chunk twice.
Found by the clang static code analyzer running for the userland stack.

MFC after: 3 days


# 574679af 14-May-2016 Michael Tuexen <tuexen@FreeBSD.org>

Fix a locking bug which only shows up on Mac OS X.

MFC after: 1 week


# fd60718d 12-May-2016 Michael Tuexen <tuexen@FreeBSD.org>

Retire net.inet.sctp.strict_sacks and net.inet.sctp.strict_data_order
sysctl's, since they where only there to interop with non-conformant
implementations. This should not be a problem anymore.


# e7f232a0 12-May-2016 Michael Tuexen <tuexen@FreeBSD.org>

Use a format string in snprintf() for consistency.

This was reported by Radek Malcic when using the userland stack in
combination with MinGW.

MFC after: 1 week


# afd67482 02-May-2016 Michael Tuexen <tuexen@FreeBSD.org>

Undo a spell fix introduced in r298942, which breaks compilation.


# cd0a4ff6 02-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

netinet/sctp*: minor spelling fixes in comments.

No functional change.

Reviewed by: tuexen


# c09a1534 27-Apr-2016 Michael Tuexen <tuexen@FreeBSD.org>

Don't use the control argument after calling sctp_add_to_readq().
This breaks the userland stack. There should be no functional change
for the FreeBSD kernel stack.
While there, use consistent variable nameing.


# b1deed45 18-Apr-2016 Michael Tuexen <tuexen@FreeBSD.org>

Address issues found by the XCode code analyzer.


# f8ee69bf 18-Apr-2016 Michael Tuexen <tuexen@FreeBSD.org>

Fix signed/unsigned warnings.


# a39ddef0 18-Apr-2016 Michael Tuexen <tuexen@FreeBSD.org>

Fix a warning about an unused variable.


# 98d5fd97 18-Apr-2016 Michael Tuexen <tuexen@FreeBSD.org>

Put panic() calls under INVARIANTS.


# f2ea2a2d 18-Apr-2016 Michael Tuexen <tuexen@FreeBSD.org>

Cleanup debug output.


# e187bac2 18-Apr-2016 Michael Tuexen <tuexen@FreeBSD.org>

Don't use anonymous unions.


# 44249214 07-Apr-2016 Randall Stewart <rrs@FreeBSD.org>

This is work done by Michael Tuexen and myself at the IETF. This
adds the new I-Data (Interleaved Data) message. This allows a user
to be able to have complete freedom from Head Of Line blocking that
was previously there due to the in-ability to send multiple large
messages without the TSN's being in sequence. The code as been
tested with Michaels various packet drill scripts as well as
inter-networking between the IETF's location in Argentina and Germany.


# 9a8e3088 27-Mar-2016 Michael Tuexen <tuexen@FreeBSD.org>

Improve compilation on windows 64-bit (for the userland stack).

MFC after: 1 week


# ed654363 23-Mar-2016 Michael Tuexen <tuexen@FreeBSD.org>

Add const to several constants. Thanks to Nicholas Nethercote for
providing the patch via
https://bugzilla.mozilla.org/show_bug.cgi?id=1255655

MFC after: 1 week


# fe4a59b3 21-Dec-2015 Michael Tuexen <tuexen@FreeBSD.org>

Stop processing of a SACK when the association has been aborted.

MFC after: 3 days


# d96bef9c 03-Dec-2015 Michael Tuexen <tuexen@FreeBSD.org>

Ensure that outgoing streams get reset when they run dry.

MFC after: 1 week


# 0bfc52be 06-Nov-2015 Michael Tuexen <tuexen@FreeBSD.org>

Use the correct length. The wrong one was too large.

MFC after: 3 days


# b70b526d 06-Nov-2015 Michael Tuexen <tuexen@FreeBSD.org>

Fix typos in field names of struct sctp_extrcvinfo.
Provide defines to allow applications to compile.
Thanks to Jens Hoelscher for making me aware of the typos.

MFC after: 1 week


# 86eda749 12-Sep-2015 Michael Tuexen <tuexen@FreeBSD.org>

Cleanup the handling of error causes for ERROR chunks. This fixes
an inconsistency of the padding handling. The final padding is
now considered to be a chunk padding.

MFC after: 1 week


# e629b9fc 11-Sep-2015 Michael Tuexen <tuexen@FreeBSD.org>

Ensure that ERROR chunks are always padded by implementing this
in the routine, which queues an ERROR chunk, instead on relyinh
on the callers to do so. Since one caller missed this, this actially
fixes a bug.

MFC after: 1 week


# e7e71dd7 02-Aug-2015 Michael Tuexen <tuexen@FreeBSD.org>

Don't take the port numbers for packets containing ABORT chunks from
a freed mbuf. Just use them from the stcb.

MFC after: 3 days


# 9ae56375 28-Jul-2015 Michael Tuexen <tuexen@FreeBSD.org>

Fix a typo reported by Erik Cederstrand.

MFC after: 1 week


# 267dbe63 27-Jul-2015 Michael Tuexen <tuexen@FreeBSD.org>

Provide consistent error causes whenever an ABORT chunk is sent.

MFC after: 1 week


# cf9e47b2 26-Jul-2015 Michael Tuexen <tuexen@FreeBSD.org>

Improve locking on Mac OS X. This does not change the functionality
on FreeBSD.

Reviewed by: rrs
MFC after: 1 week


# 6247db35 26-Jul-2015 Michael Tuexen <tuexen@FreeBSD.org>

Fix and improve a debug message. The SID was reported as an SSN.

MFC after: 1 week


# 7cca1775 22-Jul-2015 Randall Stewart <rrs@FreeBSD.org>

Fix several problems with Stream Reset.
1) We were not handling (or sending) the IN_PROGRESS case if
the other side (or our side) was not able to reset (awaiting more data).
2) We would improperly send a stream-reset when we should not. Not
waiting until the TSN had been assigned when data was inqueue.

Reviewed by: tuexen


# b7d130be 28-May-2015 Michael Tuexen <tuexen@FreeBSD.org>

Fix and cleanup the debug information. This has no user-visible changes.
Thanks to Irene Ruengeler for proving a patch.

MFC after: 3 days


# 548f47a8 28-May-2015 Michael Tuexen <tuexen@FreeBSD.org>

Address some compiler warnings. No functional change.

MFC after: 3 days


# 55f8a4bb 26-Apr-2015 Michael Tuexen <tuexen@FreeBSD.org>

Don't panic under INVARIANTS when receiving a SACK which cumacks
a TSN never sent.
While there, fix two typos.

MFC after: 1 week


# 8427b3fd 24-Mar-2015 Michael Tuexen <tuexen@FreeBSD.org>

Fix the bug in the handling of fragmented abandoned SCTP user messages reported in
https://code.google.com/p/sctp-refimpl/issues/detail?id=11
Thanks to Lally Singh for reporting it.
MFC after: 3 days


# 4be807c4 10-Jan-2015 Michael Tuexen <tuexen@FreeBSD.org>

Minimize the usage of SCTP_BUF_IS_EXTENDED.
This should help Robert...


# 457b4b88 04-Dec-2014 Michael Tuexen <tuexen@FreeBSD.org>

This is the SCTP specific companion of
https://svnweb.freebsd.org/changeset/base/275358
which was provided by Hans Petter Selasky.


# 4e88d37a 02-Dec-2014 Michael Tuexen <tuexen@FreeBSD.org>

Do the renaming of sb_cc to sb_ccc in a way with less code changes by
using a macro.
This is an alternate approach to
https://svnweb.freebsd.org/changeset/base/275326
which is easier to handle upstream.

Discussed with: rrs, glebius


# 0f9d0a73 29-Nov-2014 Gleb Smirnoff <glebius@FreeBSD.org>

Merge from projects/sendfile:

o Introduce a notion of "not ready" mbufs in socket buffers. These
mbufs are now being populated by some I/O in background and are
referenced outside. This forces following implications:
- An mbuf which is "not ready" can't be taken out of the buffer.
- An mbuf that is behind a "not ready" in the queue neither.
- If sockbet buffer is flushed, then "not ready" mbufs shouln't be
freed.

o In struct sockbuf the sb_cc field is split into sb_ccc and sb_acc.
The sb_ccc stands for ""claimed character count", or "committed
character count". And the sb_acc is "available character count".
Consumers of socket buffer API shouldn't already access them directly,
but use sbused() and sbavail() respectively.
o Not ready mbufs are marked with M_NOTREADY, and ready but blocked ones
with M_BLOCKED.
o New field sb_fnrdy points to the first not ready mbuf, to avoid linear
search.
o New function sbready() is provided to activate certain amount of mbufs
in a socket buffer.

A special note on SCTP:
SCTP has its own sockbufs. Unfortunately, FreeBSD stack doesn't yet
allow protocol specific sockbufs. Thus, SCTP does some hacks to make
itself compatible with FreeBSD: it manages sockbufs on its own, but keeps
sb_cc updated to inform the stack of amount of data in them. The new
notion of "not ready" data isn't supported by SCTP. Instead, only a
mechanical substitute is done: s/sb_cc/sb_ccc/.
A proper solution would be to take away struct sockbuf from struct
socket and allow protocols to implement their own socket buffers, like
SCTP already does. This was discussed with rrs@.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# dd973b0e 02-Aug-2014 Michael Tuexen <tuexen@FreeBSD.org>

Add support for the SCTP_PR_SUPPORTED socket option as specified in
http://tools.ietf.org/html/draft-ietf-tsvwg-sctp-prpolicies
Add also a sysctl controlling the default of the end-points.

MFC after: 1 week


# ce11b842 31-Jul-2014 Michael Tuexen <tuexen@FreeBSD.org>

Cleanup sctp_send_initiate() and sctp_send_initiate_ack() to be
in sync as much as possible. This simplifies upcoming changes.


# e432298a 08-Jul-2014 Xin LI <delphij@FreeBSD.org>

Initialize SCTP cmsg's and notification's buffer before copying out
to userland.

Submitted by: tuexen
Security: CVE-2014-3953
Security: FreeBSD-SA-14:17.kmem


# 8be0fd55 23-Apr-2014 Michael Tuexen <tuexen@FreeBSD.org>

Don't free an mbuf twice. This only happens in very rare error
cases where the peer sends illegal sequencing information in
DATA chunks for an existing association.

MFC after: 3 days.


# eb67ee5f 20-Apr-2014 Michael Tuexen <tuexen@FreeBSD.org>

Add consistency checks to ensure that fragments of a user message
have the same U-bit.

MFC after: 3 days


# 2dec1efc 19-Apr-2014 Michael Tuexen <tuexen@FreeBSD.org>

Use consistently debug output instead of an unconditional printf.

MFC after: 3 days


# 32451da4 19-Apr-2014 Michael Tuexen <tuexen@FreeBSD.org>

Send the correct error cause, when a DATA chunk with no user data
is received. This bug was reported by Irene Ruengeler.

MFC after: 3 days


# ff1ffd74 15-Mar-2014 Michael Tuexen <tuexen@FreeBSD.org>

* Provide information in error causes in ASCII instead of
proprietary binary format.
* Add support for a diagnostic information error cause.
The code is sysctlable and the default is 0, which
means it is not sent.

This is joint work with rrs@.

MFC after: 1 week


# 04194e4f 16-Nov-2013 Michael Tuexen <tuexen@FreeBSD.org>

Remove a stray write operation.

MFC after: 3 days


# d4d23375 06-Sep-2013 Michael Tuexen <tuexen@FreeBSD.org>

When computing the partial delivery point, take the
receiver socket buffer size correctly into account.

MFC after: 1 week


# 0ddb4299 03-Sep-2013 Michael Tuexen <tuexen@FreeBSD.org>

Remove redundant field pr_sctp_on.

MFC after: 1 week


# 2c9c61de 12-Aug-2013 Michael Tuexen <tuexen@FreeBSD.org>

Make the features a 64-bit value instead of 32-bit.
This will allow an easier integration of the support
for NDATA.
While there, do also some minor cleanups.
Obtained from: rrs@
MFC after: 2 weeks


# 56f778aa 03-Jul-2013 Michael Tuexen <tuexen@FreeBSD.org>

Code cleanups.

MFC after: 3 days


# c53f854a 11-Feb-2013 Michael Tuexen <tuexen@FreeBSD.org>

Don't send kernel provided information in the User Initiated
ABORT cause, since the user can also provide this kind of
information. So the receiver doesn't know who provided the
information.
While there: Fix a bug where the stack would send a malformed
ABORT chunk when using a send() call with SCTP_ABORT|SCT_SENDALL
flags.

MFC after: 3 days


# c39cfa1f 09-Feb-2013 Michael Tuexen <tuexen@FreeBSD.org>

Fix a bug where HEARTBEATs were still sent in SHUTDOWN_SENT or
SHUTDOWN_ACK_SENT state. While there, make the corresponding
code consistent.

MFC after: 1 week


# eb1b1807 05-Dec-2012 Gleb Smirnoff <glebius@FreeBSD.org>

Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags within sys.

Exceptions:

- sys/contrib not touched
- sys/mbuf.h edited manually


# 325c8c46 16-Nov-2012 Michael Tuexen <tuexen@FreeBSD.org>

Get the accounting working. We now have counters how many
chunks for each SCTP outgoing stream are in the send and
sent queue.
While there, improve the naming of NR-SACK related constants
recently introduced.

MFC after: 1 week


# a7ad6026 07-Nov-2012 Michael Tuexen <tuexen@FreeBSD.org>

Add per outgoing stream accounting for chunks in the send
and sent queue. This provides no functional change, but is
a preparation for an upcoming stream reset improvement.
Done with rrs@.

MFC after: 1 week


# 2a498584 07-Nov-2012 Michael Tuexen <tuexen@FreeBSD.org>

Add some missing changes missed in the last commit.

MFC after: 1 week
X-MFC with: 242708


# 98f2956c 07-Nov-2012 Michael Tuexen <tuexen@FreeBSD.org>

Improve PR-SCTP if used in combination with NR-SACK.
Based on work done by Mohammad Rajiullah.

MFC after: 1 week


# a169d6ec 07-Sep-2012 Michael Tuexen <tuexen@FreeBSD.org>

Don't include a structure containing a flexible array in another
structure.

MFC after: 10 days


# dd294dce 05-Sep-2012 Michael Tuexen <tuexen@FreeBSD.org>

Using %p in a format string requires a void *.

MFC after: 10 days


# b1754ad1 28-Jun-2012 Michael Tuexen <tuexen@FreeBSD.org>

Pass the src and dst address of a received packet explicitly around.

MFC after: 3 days


# 39803b8c 25-Jun-2012 Michael Tuexen <tuexen@FreeBSD.org>

Whitespace cleanup.

MFC after: 3 days


# 20cc2188 24-Jun-2012 Michael Tuexen <tuexen@FreeBSD.org>

Pass the packet length explicitly around.

MFC after: 3 days


# f30ac432 14-Jun-2012 Michael Tuexen <tuexen@FreeBSD.org>

Pass flowid explicitly through the stack instead of taking it from
the mbuf chain at different places.
While there: Fix several bugs related to VRFs.

MFC after: 3 days


# 807aad63 23-May-2012 Michael Tuexen <tuexen@FreeBSD.org>

Use consistent text at the begining of the files.

MFC after: 3 days


# 1edc9dba 13-May-2012 Michael Tuexen <tuexen@FreeBSD.org>

Provide in the SCTP_SEND_FAILED and SCTP_SEND_FAILED_EVENT notifications
the correct ssf_error or ssfe_error as required by RFC 6458.

MFC after: 3 days


# 4b1f78e1 13-May-2012 Michael Tuexen <tuexen@FreeBSD.org>

Provide the error code in SCTP_PEER_ADDR_CHANGE notifications as
specified in RFC 6458.

MFC after: 3 days


# a2b42326 12-May-2012 Michael Tuexen <tuexen@FreeBSD.org>

Provide in the association change notification the received ABORT chunk
if case of SCTP_COMM_LOST or SCTP_CANT_STR_ASSOC as required by RFC 6458.

MFC after: 3 days


# cd3fd531 04-May-2012 Michael Tuexen <tuexen@FreeBSD.org>

Use SCTP_PRINTF() instead of printf() in all SCTP sources.

MFC after: 3 days


# 921569e2 18-Apr-2012 Michael Tuexen <tuexen@FreeBSD.org>

Fix a bug where we copy out more data from a mbuf chain that are
actually in it. This happens when SCTP receives an unknown chunk, which
requires the sending of an ERROR chunk, and there is no final padding but
the chunk is not 4-byte aligned.
Reported by yueting via rwatson@

MFC after: 3 days


# 60990c0c 27-Dec-2011 Michael Tuexen <tuexen@FreeBSD.org>

Address issues found by clang. While there, fix also some style
issues.

MFC after: 3 months.


# 7215cc1b 17-Dec-2011 Michael Tuexen <tuexen@FreeBSD.org>

Fix unused parameter warnings.
While there, fix some whitespace issues.

MFC after: 3 months.


# ca85e948 03-Aug-2011 Michael Tuexen <tuexen@FreeBSD.org>

The result of a joint work between rrs@ and myself at the IETF:
* Decouple the path supervision using a separate HB timer per path.
* Add support for potentially failed state.
* Bring back RTO.min to 1 second.
* Accept packets on IP-addresses already announced via an ASCONF
* While there: do some cleanups.

Approved by: re@
MFC after: 2 months.


# e2e7c62e 15-Jun-2011 Michael Tuexen <tuexen@FreeBSD.org>

Add support for the newly added SCTP API.
In particular add support for:
* SCTP_SNDINFO, SCTP_PRINFO, SCTP_AUTHINFO, SCTP_DSTADDRV4, and
SCTP_DSTADDRV6 cmsgs.
* SCTP_NXTINFO and SCTP_RCVINFO cmgs.
* SCTP_EVENT, SCTP_RECVRCVINFO, SCTP_RECVNXTINFO and SCTP_DEFAULT_SNDINFO
socket option.
* Special association ids (SCTP_FUTURE_ASSOC, ...)
* sctp_recvv() and sctp_sendv() functions.

MFC after: 1 month.


# 14cfa970 29-May-2011 Michael Tuexen <tuexen@FreeBSD.org>

Get rid of unused functions.

MFC after: 1 week.


# 689e6a5f 08-May-2011 Michael Tuexen <tuexen@FreeBSD.org>

Fix a locking issue showing up on Mac OS X when subscribing to
authentication events. DTLS/SCTP renegotiations trigger the bug.

MFC after: 2 weeks.


# f79aab18 08-Mar-2011 Randall Stewart <rrs@FreeBSD.org>

Tunes and fixes the new DC-CC to seem to hit the
right mix. Still may need some tweaks but it
appears to almost not give away too much to an
RFC2581 flow, but can really minimize the amount of
buffers used in the net.

MFC after: 3 months


# 299108c5 26-Feb-2011 Randall Stewart <rrs@FreeBSD.org>

Improvements to CC modules:
1) Add four new points that allow you to get more information
to cc algo's
2) Fix the case where user changes module on a existing TCB, in
such a case, the initialization module needs to be called on all nets.
3) Move htcp_cc structure to a union that other modules can use.
4) Add 5th point for get/set socket options for cc_module specific options

MFC after: 2 months


# 5d40cf5d 04-Feb-2011 Randall Stewart <rrs@FreeBSD.org>

1) Typo correction in comments and one spacing change.
2) Mass update to all copyrights.
MFC after: 3 Months


# 899288ae 02-Feb-2011 Randall Stewart <rrs@FreeBSD.org>

1) Allow a chunk to track the cwnd it was at when sent.
2) Add separate max-bursts for retransmit and hb. These
are set to sysctlable values but not settable via the
socket api. This makes sure we don't blast out HB's or
fast-retransmits.
3) Determine on the first data transmission on a net if
its local-lan (by being under or over a RTT). This
can later be used to think about different algorithms
based on locallan vs big-i (experimental)
4) The cwnd should NOT be allowed to grow when an ECNEcho
is seen (TCP has this same bug). We fix this in SCTP
so an ECNe being seen prevents an advance of cwnd.
5) CWR's should not be sent multiple times to the
same network, instead just updating the TSN being
transmitted if needed.

MFC after: 1 Month


# 493d8e5a 31-Jan-2011 Randall Stewart <rrs@FreeBSD.org>

More ECN fixes:
1) We now remove ECN-Nonce since it will no longer continue as a I-D
2) Eliminate last_tsn_echo, this tied us to an assoc not the net
and thus we were not doing m-homing on the ECN-Echo senders side right.
3) Increment the count going out even if the TSN in lower in the pending
ECN-Echo, this way the receiver knows exactly how many packets were
marked even with network re-ordering
4) Fix so we DO NOT stop doing delayed sack if a ECN Echo is in queue
MFC after: 1 month


# a21779f0 29-Jan-2011 Randall Stewart <rrs@FreeBSD.org>

Fixes to ECN in SCTP.
1) ECN was on an association basis, this is incorrect and
will not work with CMT or for that matter if the user
is sending to multiple addresses. This commit makes
ECN on a per path basis.
2) Adopt the new format for the ECN internet draft. This also
maintains compatability with old format chunks as well.
3) Keep track of the real time of a RTT down to micro seconds.
For some future conditional features (for like a data center
this is good information to have).
MFC after: 1 month


# 20b07a4d 30-Dec-2010 Michael Tuexen <tuexen@FreeBSD.org>

Define and use SCTP_SSN_GE, SCTP_SSN_GT, SCTP_TSN_GE, SCTP_TSN_GT macros
and use them instead of the generic compare_with_wrap.
Retire compare_with_wrap.

MFC after: 3 months.


# 4a9ef3f8 30-Dec-2010 Michael Tuexen <tuexen@FreeBSD.org>

Code cleanup: Use LIST_FOREACH, LIST_FOREACH_SAFE, TAILQ_FOREACH,
TAILQ_FOREACH_SAFE where appropriate.
No functional change.

MFC after: 3 months.


# 7c99d56f 22-Dec-2010 Michael Tuexen <tuexen@FreeBSD.org>

Improve plausibility check in sctp_handle_sack().
Allow cmt_on_off to support values 0 (no CMT), 1 (CMT), and 2 (CMT/RP).

MFC after: 3 months.


# 8f777478 16-Dec-2010 Michael Tuexen <tuexen@FreeBSD.org>

Bugfix: Take also the nr-mapping array into account when detecting
gaps.

Reviewed by: rrs@
MFC after: 3 days.


# 36ec9f81 16-Dec-2010 Michael Tuexen <tuexen@FreeBSD.org>

Add a missing cast. Reported by blade_ly at yahoo.com.cn.

MFC after: 1 day.


# d9c5cfea 04-Dec-2010 Michael Tuexen <tuexen@FreeBSD.org>

Fix a bug where also the number of non-renegable gap reports
was considered to be potentially renegable.

MFC after: 1 day.


# 12af6654 07-Nov-2010 Michael Tuexen <tuexen@FreeBSD.org>

Not only stop all timers when entering the SHUTDOWN_SENT state,
but also when entering the SHUTDOWN_ACK_SEND state.

MFC after: 3 days.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 1ea735c8 19-Sep-2010 Michael Tuexen <tuexen@FreeBSD.org>

Fix a locking issue which resulted in aborted associations
due to a corrupted nr-mapping array.

MFC after: 2 weeks.


# 99ddc825 17-Sep-2010 Michael Tuexen <tuexen@FreeBSD.org>

Fix a bug where the wrong PR-SCTP policy was considered.
While there, use always the same code for the check of
TTL expiration.

MFC after: 2 weeks.


# 24f52bbd 15-Sep-2010 Michael Tuexen <tuexen@FreeBSD.org>

Use TAILQ_EMPTY() for testing if a tail queue is empty.
Set whoFrom to NULL after freeing whoFrom.


# 20083c2e 28-Aug-2010 Michael Tuexen <tuexen@FreeBSD.org>

Fix the switching on/off of CMT using sysctl and socket option.
Fix the switching on/off of PF and NR-SACKs using sysctl.
Add minor improvement in handling malloc failures.
Improve the address checks when sending.

MFC after: 4 weeks


# 44fbe462 29-Jul-2010 Randall Stewart <rrs@FreeBSD.org>

PR SCTP Bugs. Basically a full sized frame of
PR SCTP FWD-TSN's would not be sent and thus
cause a stalled connection. Also the rwnd
Calculation was also off on the receiver side for
PR-SCTP.
MFC after: 1 month


# 2a0266f7 10-Jun-2010 Randall Stewart <rrs@FreeBSD.org>

MFC:
Fix a number of bugs and race conditions.
r208160: Bring back of the iterator thread. It now properly handles VNETS
having only one thread. The old timer based code was full of
LOR's and other issues.

r208852: Cleanup bug. Basically when an un-accepted socket was hanging on a
closed listener, we would leak the inp never cleaning it up

r208853: Enhance the use under invarients of the audit for locks function
and fix a bug where a close collision with a cookie being processed
would cause a crash.

r208854: Use the proper increment macros when working with the
sent_queue_retran_cnt

r208855: Align comments properly, Fix a bug where we were NOT looking at the
resend markings for control chunks and also not decrementing the
retran count which caused extra calls to retransmission. Alos add
a valid no locks call to the output routine.

r208856: Spacing issues in auth/bsd addr.

r208857: Get rid of a windows ifdef that somehow leaked in

r208863: Missing error leg returns in some failure cases

r208864: LOR fix between the iterator and sctp_inpcb_close

r208874: Don't call the sctp_inpcb_free from abort an association since you
don't know what locks you hold and a timer will take care of the
situation when the gone flag is set

r208875: sctp_inpcb_free bug - a socket under the right situation could get
stuck (from the accept queue) and never start the proper cleanup
timer)

r208876: Further enhance invariant lock validation, Fix a bug where a closed
socket and a INIT-ACK could collide and cause a crash

r208878: Clear up another bug in sctp_inpcb_free where we would end up due
to a race in freeing hit a destroy of a contended lock.

r208879: Optimize the cleanup and make some additional fixes in the sysctl
code so that it won't reference a GONE INP and crash us

r208883 & r208891: Fix so we don't open a hole between a sock lock and a call
to socantrcvmore.. we could before hit a race that would kill the
socket underneath us leading to a crash

r208897: CUM-ACK calculation was messed up. So basically large message got
broken from the original NR_sack integration.

r208902: Make sure that we don't move a bit to the NR array that is behind
the cum-ack

r208952: Use both bit maps to calculte the cum-ack.

r208953: Fix bug having to do with freeing an sctp_inpcb_free().
1) make sure not to remove the flag until you get the lock again.
2) make sure all log_closing calls hold the lock.
3) Release all the locks when everthing is done and call callout_drain
not callout_stop..

r208970: Fix some places on user allocation of a new sctp_inpcb where we run
out of resource that we make sure to NULL the so_pcb pointer.
Approved by: re - (bz@freebsd.org)


# 8dcde516 09-Jun-2010 Randall Stewart <rrs@FreeBSD.org>

BUG:Turns out we need to use both bit maps
to calculate the cum-ack (we were not doing
it for the NR-Sack case). With this fix
NR-sack should now work correctly.
MFC after: 1 week


# 9b2e0767 07-Jun-2010 Randall Stewart <rrs@FreeBSD.org>

2 Bugs:

1) Only use both mapping arrays when NR sack is off. This
way we can hold off moving the cumack (not the best but
workable) when NR-sack is on.

2) We must make sure to just return on the move of the
bit to the NR array if the cum-ack as already went
past the TSN. This prevents marking a bit behind the
array and hitting the invariant code that panic's us.

MFC after: 1 week


# 66bd30bd 07-Jun-2010 Randall Stewart <rrs@FreeBSD.org>

This fixes a BUG in the handling of the cum-ack calculation.
We were only paying attention to the nr-mapping-array. Which
seems to make sense on the surface, by definition things
up to the cum-ack should be deliverable thus in the nr-mapping-array.
However (there is always a gotcha) thats not true when it
comes to large messages. The stack may hold the message
while re-assembling it not not deliver it based on several
thresholds. If that happens (which it would for smaller
large messages) then the cum-ack is figured wrong. We
now properly use both arrays in the cum-ack calculation.

MFC after: 1 week.


# 791437b5 05-Jun-2010 Randall Stewart <rrs@FreeBSD.org>

Use the proper increment macro when increasing the
number on sent_queue_retran_cnt.

MFC after: 1 week


# 31bd7e42 16-May-2010 Randall Stewart <rrs@FreeBSD.org>

MFC 207983

More PR-SCTP bugs:
- Make sure that when you kick the streams you add correctly
using a 16 bit unsigned.
- Make sure when sending out you allow FWD-TSN to skip over
and list the ACKED chunks in the stream/seq list (so the
rcv will kick the stream)


# d536af65 16-May-2010 Randall Stewart <rrs@FreeBSD.org>

MFC 207966 (for Michael)

Get rid of unused constants.


# c7a8100b 16-May-2010 Randall Stewart <rrs@FreeBSD.org>

MFC of 207963

This fixes PR-SCTP issues:
- Slide the map at the proper place.
- Mark the bits in the nr_array ONLY if there
is no marking.
- When generating a FWD-TSN we allow us to skip past
ACKED chunks too.


# 83128708 12-May-2010 Randall Stewart <rrs@FreeBSD.org>

More PR-SCTP bugs:
- Make sure that when you kick the streams you add correctly
using a 16 bit unsigned.
- Make sure when sending out you allow FWD-TSN to skip over
and list the ACKED chunks in the stream/seq list (so the
rcv will kick the stream)
MFC after: 3 days


# 091430c1 12-May-2010 Michael Tuexen <tuexen@FreeBSD.org>

Get rid of unused constants.

MFC after: 3 days.


# 7898f408 12-May-2010 Randall Stewart <rrs@FreeBSD.org>

This fixes PR-SCTP issues:
- Slide the map at the proper place.
- Mark the bits in the nr_array ONLY if there
is no marking.
- When generating a FWD-TSN we allow us to skip past
ACKED chunks too.

MFC after: 1 weeks


# 0bd5a0ae 07-May-2010 Michael Tuexen <tuexen@FreeBSD.org>

MFC 206758, 206840, 206891, 206892, 207099, 207191, 207197
* Fix a bug where SACKs are not sent when they should.
* Get delayed SACK working again.
* Really print the nr_mapping array when it should be printed.
* Update highest_tsn variables when sliding mapping arrays.
* Sending a FWDTSN chunk should not affect the retran count.
* Cleanups.


# 475d0674 25-Apr-2010 Michael Tuexen <tuexen@FreeBSD.org>

Undo my lastest fix since that wasn't one at all.

MFC after: 3 days.


# f31e6c7f 23-Apr-2010 Michael Tuexen <tuexen@FreeBSD.org>

* Fix compilation when using SCTP_AUDITING_ENABLED.
* Fix delaying of SACK by taking out old optimization code
which does not optimize anymore.
* Fix fast retransmission of chunks abandoned by the
"number of retransmissions" policy.

MFC after: 3 days.


# ee94f0a2 20-Apr-2010 Michael Tuexen <tuexen@FreeBSD.org>

Update highest_tsn variables when sliding mapping arrays.


# 307b49ef 19-Apr-2010 Michael Tuexen <tuexen@FreeBSD.org>

Get delayed SACK working again.

MFC after: 3 days.


# 37f144eb 16-Apr-2010 Michael Tuexen <tuexen@FreeBSD.org>

Fix a bug where SACKs are not sent when they should.
Move some protection code to INVARIANTS.
Cleanups.

MFC after: 3 days.


# 00993616 16-Apr-2010 Randall Stewart <rrs@FreeBSD.org>

MFC of 206281

Final MFC of all the IETF hack a-thon.. head and stable are
now in sync ;-)


# 17f2eabb 16-Apr-2010 Randall Stewart <rrs@FreeBSD.org>

MFC of 206137

This is Part III of the great IETF hack-a-thon to fix
the NR-Sack code. (the last one on the cpu options
was a lull.. i.e MFC 205629).. still 2 more to go.


# f1fb6dd5 16-Apr-2010 Randall Stewart <rrs@FreeBSD.org>

MFC of 205627

Part II (more to follow) of the great IETF hack-a-thon to
fix the NR-Sack code.


# 6c166096 16-Apr-2010 Randall Stewart <rrs@FreeBSD.org>

MFD 204040

Fixes some argument calsl (u_long vs uint32_t).


# 535f992c 16-Apr-2010 Randall Stewart <rrs@FreeBSD.org>

MFC of 202526

The first round of some of Michael's changes to
get the sack processing in better shape.


# 835d439e 16-Apr-2010 Randall Stewart <rrs@FreeBSD.org>

MFC of 205502

The firste of Michael and my long fight at the IETF to
get the NR sack code fixed and aligned.


# 42fc5018 16-Apr-2010 Randall Stewart <rrs@FreeBSD.org>

Merge of SVN 196507.

This optimizes the sack handling a bit and
restructures it so its much more readable ;-)


# aed5947c 06-Apr-2010 Michael Tuexen <tuexen@FreeBSD.org>

Fix a off-by-one bug in zeroing out the mapping arrays.
Fix sctp_print_mapping_array().

MFC after: 1 week


# b5c16493 03-Apr-2010 Michael Tuexen <tuexen@FreeBSD.org>

* Fix some race condition in SACK/NR-SACK processing.
* Fix handling of mapping arrays when draining mbufs or processing
FORWARD-TSN chunks.
* Cleanup code (no duplicate code anymore for SACKs and NR-SACKs).
Part of this code was developed together with rrs.
MFC after: 2 weeks.


# 77acdc25 24-Mar-2010 Randall Stewart <rrs@FreeBSD.org>

Fix for NR-Sack code. The code was NOT working properly when
enabled. Basically most of the operations were incorrect causing
bad sacks when you enabled nr-sack. The fixes range across
4 files and unifiy most of the processing so that we only test
nr_sack flags to decide which type of sack to generate.

Optimization left for this is to combine the sack generation
code and make it capable of generating either sack thus shrinking
out a routine.

Reviewed by: tuexen@freebsd.org


# 0e13104d 22-Mar-2010 Randall Stewart <rrs@FreeBSD.org>

Fixes a bug where SACKs in the face of
mapping_array expansion would break. Basically
once we expanded the array we no longer had both
mapping arrays in sync which the sack processing code depends on.
This would mean we were randomly referring to memory that was probably
not there. This mostly just gave us bad sack results going back to the peer.
If INVARIENTS was on of course we would hit the panic routine in the sack_check
call.

We also add a print routine for the place where one would panic in
invarients so one can see what the main mapping array holds.

Reviewed by: tuexen@freebsd.org
MFC after: 2 weeks


# 63eda93d 18-Feb-2010 Michael Tuexen <tuexen@FreeBSD.org>

Use uint32_t instead of u_long.

MFC after: 1 week


# cd554309 17-Jan-2010 Michael Tuexen <tuexen@FreeBSD.org>

Get rid of a lot of duplicated code for NR-SACK handle.
Generalize the SACK to code handle also NR-SACKs.


# f222133a 12-Sep-2009 Michael Tuexen <tuexen@FreeBSD.org>

This fixes a bug where the value set by SCTP_PARTIAL_DELIVERY_POINT
was not honored, if the socket buffer size was not 4 times that large.
MFC of 196509.

Approved by: re, rrs (mentor)`


# 24ae5c4a 24-Aug-2009 Michael Tuexen <tuexen@FreeBSD.org>

This fixes a bug where the value set by SCTP_PARTIAL_DELIVERY_POINT
was not honored, if the socket buffer size was not 4 times that large.

Approved by: rrs (mentor)
MFC after: 3 days.


# 0fa753b3 24-Aug-2009 Randall Stewart <rrs@FreeBSD.org>

This fixes two bugs in the NR-Sack code:
1) When calculating the table offset for sliding the sack
array, the two byte values must be "ored" together in order
for us to do the correct sliding of the arrays.
2) We were NOT properly doing CC and other changes to things only
NR-Sacked. The solution here is to make a separate function that
will actually do both CC/updates and free things if its NR sack'd.
This actually shrinks out common code from three places (much better).

MFC after: 3 days


# ca007251 15-Aug-2009 Michael Tuexen <tuexen@FreeBSD.org>

MFC r196260.
* Fix a bug where PR-SCTP settings are ignore when using implicit
association setup.
* Fix a bug where message with illegal stream ids are not deleted.
* Fix a crash when reporting back unsent messages from the send_queue.
* Fix a bug related to INIT retransmission when the socket is already
closed.
* Fix a bug where associations were stalled when partial delivery API
was enabled.
* Fix a bug where the receive buffer size was smaller than the
partial_delivery_point.

Approved by: re, rrs (mentor)


# 810ec536 15-Aug-2009 Michael Tuexen <tuexen@FreeBSD.org>

* Fix a bug where PR-SCTP settings are ignore when using implicit
association setup.
* Fix a bug where message with illegal stream ids are not deleted.
* Fix a crash when reporting back unsent messages from the send_queue.
* Fix a bug related to INIT retransmission when the socket is already
closed.
* Fix a bug where associations were stalled when partial delivery API
was enabled.
* Fix a bug where the receive buffer size was smaller than the
partial_delivery_point.

Approved by: re, rrs (mentor)
MFC after: One day.


# cfde3ff7 28-Jul-2009 Randall Stewart <rrs@FreeBSD.org>

Turns out that when a receiver forwards through its TNS's the
processing code holds the read lock (when processing a
FWD-TSN for pr-sctp). If it finds stranded data that
can be given to the application, it calls sctp_add_to_readq().
The readq function also grabs this lock. So if INVAR is on
we get a double recurse on a non-recursive lock and panic.

This fix will change it so that readq() function gets a
flag to tell if the lock is held, if so then it does not
get the lock.

Approved by: re@freebsd.org (Kostik Belousov)
MFC after: 1 week


# 8e71b694 27-Jul-2009 Michael Tuexen <tuexen@FreeBSD.org>

Fix the handling of unordered messages when using
PR-SCTP.

Approved by: re, rrs (mentor)
MFC after: 3 weeks.


# d50c1d79 16-Jun-2009 Randall Stewart <rrs@FreeBSD.org>

Changes to the NR-Sack code so that:
1) All bit disappears
2) The two sets of gaps (nr and non-nr) are
disjointed, you don't have gaps struck in
both places.

This adjusts us to coorespond to the new draft. Still
to-do, cleanup the code so that there are only one set
of sack routines (original NR-Sack done by E cloned all
sack code).


# 544e35bd 14-Apr-2009 Randall Stewart <rrs@FreeBSD.org>

Move the flight size reduction to right after
we recognize its a retransmit, ahead of the PR-SCTP
work. Without this fix, we end up NOT reducing flight
size and causing an miscalculation when PR-SCTP is active
and data is skipped.

Obtained from: Michael Tuexen.


# abe15ad6 07-Apr-2009 Randall Stewart <rrs@FreeBSD.org>

Fix a FR bug. When doing PR-SCTP with number rtx
set to a low number. The check for skipping was in the
incorrect place. Which meant we would FR chunks we
should not.
MFC after: 1 Month


# 8933fa13 04-Apr-2009 Randall Stewart <rrs@FreeBSD.org>

Many bug fixes (from the IETF hack-fest):
- PR-SCTP had major issues when skipping through a multi-part message.
o Did not look at socket buffer.
o Did not properly handle the reassmebly queue.
o The MARKED segments could interfere and un-skip a chunk causing
a problem with the proper FWD-TSN.
o No FR of FWD-TSN's was being done.
- NR-Sack code was basically disabled. It needed fixes that
never got into the real code.
- CMT code had issues when the two paths were NOT the same b/w. We
found a few small bugs, but also the critcal one here was not
dividing the rwnd amongst the paths.

Obtained from: Michael Tuexen and myself at the IETF hack-fest ;-)


# 0c0982b8 14-Mar-2009 Randall Stewart <rrs@FreeBSD.org>

Fixes several PR-SCTP releated bugs.
- When sending large PR-SCTP messages over a
lossy link we would incorrectly calculate the fwd-tsn
- When receiving large multipart pr-sctp packets we would
incorrectly send back a SACK that would renege improperly
on already received packets thus causing unneeded retransmissions.


# 5171328b 06-Mar-2009 Randall Stewart <rrs@FreeBSD.org>

Fixes for window probes:
1) WP should never be marked unless flight size is 0
2) When recovering from wp if the peer ack's it we don't mark for retran
3) When recovering, we must assure a timer is still running.


# dfb11ef8 04-Mar-2009 Randall Stewart <rrs@FreeBSD.org>

- PR-SCTP bug, where the CUM-ACK was not being updated
into the advance_peer_ack point so we would incorrectly
send a wrong value in the FWD-TSN
- PR-SCTP bug, where an PR packet is used for a window
probe which could incorrectly get the packet moved
back into the send_queue, which will cause major issues and
should not happen.
- Fix a trace to use the proper macro.


# 830d754d 06-Dec-2008 Randall Stewart <rrs@FreeBSD.org>

Code from the hack-session known as the IETF (and a
bit of debugging afterwards):
- Fix protection code for notification generation.
- Decouple associd from vtag
- Allow vtags to have less strigent requirements in non-uniqueness.
o don't pre-hash them when you issue one in a cookie.
o Allow duplicates and use addresses and ports to
discriminate amongst the duplicates during lookup.
- Add support for the NAT draft draft-ietf-behave-sctpnat-00, this
is still experimental and needs more extensive testing with the
Jason Butt ipfw changes.
- Support for the SENDER_DRY event to get DTLS in OpenSSL working
with a set of patches from Michael Tuexen (hopefully heading to OpenSSL soon).
- Update the support of SCTP-AUTH by Peter Lei.
- Use macros for refcounting.
- Fix MTU for UDP encapsulation.
- Fix reporting back of unsent data.
- Update assoc send counter handling to be consistent with endpoint sent counter.
- Fix a bug in PR-SCTP.
- Fix so we only send another FWD-TSN when a SACK arrives IF and only
if the adv-peer-ack point progressed. However we still make sure
a timer is running if we do have an adv_peer_ack point.
- Fix PR-SCTP bug where chunks were retransmitted if they are sent
unreliable but not abandoned yet.

With the help of: Michael Teuxen and Peter Lei :-)
MFC after: 4 weeks


# a1e13272 12-Nov-2008 Randall Stewart <rrs@FreeBSD.org>

-Improvement: Add '\n' on debug output in sctp_lower_sosend().
-Improvement: panic() on INVARIANTS kernels if memory allocation
fails for a tagblock in sctp_add_vtag_to_timewait().
-Bugfix: Protect code in sctp_is_in_timewait() by
SCTP_INP_INFO_WLOCK/SCTP_INP_INFO_WUNLOCK.
-Cleanup: Get rid of unused variable now in sctp_init_asoc().
-Bugfix: Reuse the correct vtag in sctp_add_vtag_to_timewait().
-Cleanup: Get rid of unused constant SCTP_TIME_WAIT_SHORT
in sctp_constants.h.
-Improvement: Use all hash buckets of the vtag hash table.
-Cleanup: Get rid of then unused constant SCTP_STACK_VTAG_HASH_SIZE_A.
-Bugfix: Handle SHUTDOWN;SACK packet correctly.
-Bugfix: Last TSN in a gap ack block was not being "ack'd"
in the internal scoreboard.
Obtained from: (with help from Michael Tuexen)


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# df6e0cc3 28-Aug-2008 Randall Stewart <rrs@FreeBSD.org>

- Make strict-sacks be the default.
- Change it so that without INVARIANTs there are
no panics in SCTP.
- sctp_timer changes so that we have a recovery mechanism
when the sent list is out of order.


# fc14de76 09-Jul-2008 Randall Stewart <rrs@FreeBSD.org>

1) Adds the rest of the VIMAGE change macros
2) Adds some __UserSpace__ on some of the common defines that
the user space code needs
3) Fixes a bug when we send up data to a user that failed. We
need to a) trim off the data chunk headers, if present, and
b) make sure the frag bit is communicated properly for the
msgs coming off the stream queues... i.e. we see if some
of the msg has been taken.

Obtained from: jeli contributed the VIMAGE changes on this pass Thanks Julain!


# b3f1ea41 14-Jun-2008 Randall Stewart <rrs@FreeBSD.org>

- Macro-izes the packed declaration in all headers.
- Vimage prep - these are major restructures to move
all global variables to be accessed via a macro or two.
The variables all go into a single structure.
- Asconf address addition tweaks (add_or_del Interfaces)
- Fix rwnd calcualtion to be more conservative.
- Support SACK_IMMEDIATE flag to skip delayed sack
by demand of peer.
- Comment updates in the sack mapping calculations
- Invarients panic added.
- Pre-support for UDP tunneling (we can do this on
MAC but will need added support from UDP to
get a "pipe" of UDP packets in.
- clear trace buffer sysctl added when local tracing on.

Note the majority of this huge patch is all the vimage prep stuff :-)


# c54a18d2 20-May-2008 Randall Stewart <rrs@FreeBSD.org>

- Adds support for the multi-asconf (From Kozuka-san)
- Adds some prepwork (Not all yet) for vimage in particular
support the delete the sctppcbinfo.xx structs. There is
still a leak in here if it were to be called plus we stil
need the regrouping (From Me and Michael Tuexen)
- Adds support for UDP tunneling. For BSD there is no
socket yet setup so its disabled, but major argument
changes are in here to emcompass the passing of the port
number (zero when you don't have a udp tunnel, the default
for BSD). Will add some hooks in UDP here shortly (discussed
with Robert) that will allow easy tunneling. (Mainly from
Peter Lei and Michael Tuexen with some BSD work from me :-D)
- Some ease for windows, evidently leave is reserved by their
compile move label leave: -> out:

MFC after: 1 week


# c40e9cf2 14-Apr-2008 Randall Stewart <rrs@FreeBSD.org>

Protection against errant sender sending a stream
seq number out of order with no missing TSN's (a
cisco box has this problem which will make a ssn
be held forever).
MFC after: 1 week


# f36d9806 28-Jan-2008 Randall Stewart <rrs@FreeBSD.org>

- Fixes a comparison wrap issue with sack gap ack blocks that
span the 32 bit roll over mark.


# 81aca91a 09-Nov-2007 Randall Stewart <rrs@FreeBSD.org>

- Fix a bug in sctp_calc_rwnd() which resulted in wrong rwnd predictions.
- Fix a signedness problem that shows up in some 64 bit platforms (macos).

MFC after: 1 week


# b201f536 16-Oct-2007 Randall Stewart <rrs@FreeBSD.org>

- fix sctp_ifn initial refcount issue (prevents deletion)
- fix a bug during cookie collision that prevented an
association from coming up in a specific restart case.
- Fix it so the shutdown-pending flag gets removed (this is
more for correctness then needed) when we enter shutdown-sent
or shutdown-ack-sent states.
- Fix a bug that caused the receiver to sometimes NOT send
a SACK when a duplicate TSN arrived. Without this fix
it was possible for the association to fall down if the
- Deleted primary destination is also stored when SCTP_MOBILITY_BASE.
(Previously, it is stored when only SCTP_MOBILITY_FASTHANDOFF)
- Fix a locking issue where we might call send_initiate_ack() and
incorrectly state the lock held/not held. Also fix it so that
when we release the lock the inp cannot be deleted on us.
- Add the debug option that can cause the stack to panic instead
of aborting an assoc. This does not and should never show up
in options but is useful for debugging unexpected aborts.
- Add cumack_log sent to track sending cumack information for
the debug case where we are running a special log per assoc.
- Added extra () aroudn sctp_sbspace macro to avoid compile warnings.
MFC after: 1 week


# d55b0b1b 30-Sep-2007 Randall Stewart <rrs@FreeBSD.org>

- Bug fix managing congestion parameter on immediate
retransmittion by handover event (fast mobility code)
- Fixed problem of mobility code which is caused by remaining
parameters in the deleted primary destination.
- Add a missing lock. When a peer sends an INIT, and while we
are processing it to send an INIT-ACK the socket is closed,
we did not hold a lock to keep the socket from going away.
Add protection for this case.
- Fix so that arwnd is alway uses the minimal rwnd if the user
has set the socket buffer smaller. Found this when the test
org decided to see what happens when you set in a rwnd of 10
bytes (which is not allowed per RFC .. 4k is minimum).
- Fixes so a cookie-echo ootb will NOT cause an abort to
be sent. This was happening in a MPI collision case.
- Examined all panics and unless there was no recovery, moved
any that were not already to INVARANTS.

Approved by: re@freebsd.org (gnn)


# 04ee05e8 13-Sep-2007 Randall Stewart <rrs@FreeBSD.org>

- Incorrect error EAGAIN returned for invalid send on a locked
stream (using EEOR mode). Changed to EINVAL (in sctp_output.c)
- Static analysis comments added
- fix in mobility code to return a value (static analysis found).
- sctp6_notify function made visible instead of
static (this is needed for Panda).

Approved by: re@freebsd.org (B Mah)


# 851b7298 08-Sep-2007 Randall Stewart <rrs@FreeBSD.org>

- send call has a reference to uio->uio_resid in
the recent send code, but uio may be NULL on sendfile
calls. Change to use sndlen variable.
- EMSGSIZE is not being returned in non-blocking mode
and needs a small tweak to look if the msg would
ever fit when returning EWOULDBLOCK.
- FWD-TSN has a bug in stream processing which could
cause a panic. This is a follow on to the codenomicon
fix.
- PDAPI level 1 and 2 do not work unless the reader
gets his returned buffer full. Fix so we can break
out when at level 1 or 2.
- Fix fast-handoff features to copy across properly on
accepted sockets
- Fix sctp_peeloff() system call when no true system call
exists to screen arguments for errors. In cases where a
real system call exists the system call itself does this.
- Fix raddr leak in recent add-ip code change for bundled
asconfs (even when non-bundled asconfs are received)
- Make sure ipi_addr lock is held when walking global addr
list. Need to change this lock type to a rwlock().
- Add don't wake flag on both input and output when the
socket is closing.
- When deleting an address verify the interface is correct
before allowing the delete to process. This protects panda
and unnumbered.
- Clean up old sysctl stuff and get rid of the old Open/Net
BSD structures.
- Add a function to watch the ranges in the sysctl sets.
- When appending in the reassembly queue, validate that
the assoc has not gone to about to be freed. If so
(in the middle) abort out. Note this especially effects
MAC I think due to the lock/unlock they do (or with
LOCK testing in place).
- Netstat patch to get rid of warnings.
- Make sure that no data gets queued to inactive/unconfirmed
destinations. This especially effect CMT but also makes a
impact on regular SCTP as well.
- During init collision when we detect seq number out
of sync we need to treat it like Case C and discard
the cookie (no invarient needed here).
- Atomic access to the random store.
- When we declare a vtag good, we need to shove it
into the time wait hash to prevent further use. When
the tag is put into the assoc hash, we need to remove it
from the twait hash (where it will surely be). This prevents
duplicate tag assignments.
- Move decr-ref count to better protect sysctl out of
data.
- ltrace error corrections in sctp6_usrreq.c
- Add hook for interface up/down to be sent to us.
- Make sysctl() exported structures independent of processor
architecture.
- Fix route and src addr cache clearing for delete address case.
- Make sure address marked SCTP_DEL_IP_ADDRESS is never selected
as src addr.
- in icmp handling fixed so we actually look at the icmp codes
to figure out what to do.
- Modified mobility code.
Reception of DELETE IP ADDRESS for a primary destination and
SET PRIMARY for a new primary destination is used for
retransmission trigger to the new primary destination.
Also, in this case, destination of chunks in send_queue are
changed to the new primary destination.
- Fix so that we disallow sending by mbuf to ever have EEOR
mode set upon it.

Approved by: re@freebsd.org (B Mah)


# ceaad40a 08-Sep-2007 Randall Stewart <rrs@FreeBSD.org>

- Locking compatiability changes. This involves adding
additional flags to many function calls. The flags only
get used in BSD when we compile with lock testing. These
flags allow apple to escape the "giant" lock it holds on
the socket and have more fine-grained locking in the NKE.
It also allows us to test (with witness) the locking used
by apple via a compile switch (manually applied).

Approved by: re@freebsd.org(B Mah)


# 2afb3e84 26-Aug-2007 Randall Stewart <rrs@FreeBSD.org>

- During shutdown pending, when the last sack came in and
the last message on the send stream was "null" but still
there, a state we allow, we could get hung and not clean
it up and wait for the shutdown guard timer to clear the
association without a graceful close. Fix this so that
that we properly clean up.
- Added support for Multiple ASCONF per new RFC. We only
(so far) accept input of these and cannot yet generate
a multi-asconf.
- Sysctl'd support for experimental Fast Handover feature. Always
disabled unless sysctl or socket option changes to enable.
- Error case in add-ip where the peer supports AUTH and ADD-IP
but does NOT require AUTH of ASCONF/ASCONF-ACK. We need to
ABORT in this case.
- According to the Kyoto summit of socket api developers
(Solaris, Linux, BSD). We need to have:
o non-eeor mode messages be atomic - Fixed
o Allow implicit setup of an assoc in 1-2-1 model if
using the sctp_**() send calls - Fixed
o Get rid of HAVE_XXX declarations - Done
o add a sctp_pr_policy in hole in sndrcvinfo structure - Done
o add a PR_SCTP_POLICY_VALID type flag - yet to-do in a future patch!
- Optimize sctp6 calls to reuse code in sctp_usrreq. Also optimize
when we close sending out the data and disabling Nagle.
- Change key concatenation order to match the auth RFC
- When sending OOTB shutdown_complete always do csum.
- Don't send PKT-DROP to a PKT-DROP
- For abort chunks just always checksums same for
shutdown-complete.
- inpcb_free front state had a bug where in queue
data could wedge an assoc. We need to just abandon
ones in front states (free_assoc).
- If a peer sends us a 64k abort, we would try to
assemble a response packet which may be larger than
64k. This then would be dropped by IP. Instead make
a "minimum" size for us 64k-2k (we want at least
2k for our initack). If we receive such an init
discard it early without all the processing.
- When we peel off we must increment the tcb ref count
to keep it from being freed from underneath us.
- handling fwd-tsn had bugs that caused memory overwrites
when given faulty data, fixed so can't happen and we
also stop at the first bad stream no.
- Fixed so comm-up generates the adaption indication.
- peeloff did not get the hmac params copied.
- fix it so we lock the addr list when doing src-addr selection
(in future we need to use a multi-reader/one writer lock here)
- During lowlevel output, we could end up with a _l_addr set
to null if the iterator is calling the output routine. This
means we would possibly crash when we gather the MTU info.
Fix so we only do the gather where we have a src address
cached.
- we need to be sure to set abort flag on conn state when
we receive an abort.
- peeloff could leak a socket. Moved code so the close will
find the socket if the peeloff fails (uipc_syscalls.c)

Approved by: re@freebsd.org(Ken Smith)


# c4739e2f 23-Aug-2007 Randall Stewart <rrs@FreeBSD.org>

- Fix address add handling to clear cached routes and source addresses
when peer acks the add in case the routing table changes.
- Fix sctp_lower_sosend to send shutdown chunk for mbuf send
case when sndlen = 0 and sinfoflag = SCTP_EOF
- Fix sctp_lower_sosend for SCTP_ABORT mbuf send case with null data,
So that it does not send the "null" data mbuf out and cause
it to get freed twice.
- Fix so auto-asconf sysctl actually effect the socket's asconf state.
- Do not allow SCTP_AUTO_ASCONF option to be used on subset bound sockets.
- Memset bug in sctp_output.c (arguments were reversed) submitted
found and reported by Dave Jones (davej@codemonkey.org.uk).
- PD-API point needs to be invoked >= not just > to conform to socket api
draft this fixes sctp_indata.c in the two places need to be >=.
- move M_NOTIFICATION to use M_PROTO5.
- PEER_ADDR_PARAMS did not fail properly if you specify an address
that is not in the association with a valid assoc_id. This meant
you got or set the stcb level values instead of the destination
you thought you were going to get/set. Now validate if the
stcb is non-null and the net is NULL that the sa_family is
set and the address is unspecified otherwise return an error.
- The thread based iterator could crash if associations were freed
at the exact time it was running. rework the worker thread to
use the increment/decrement to prevent this and no longer use
the markers that the timer based iterator uses.
- Fix the memleak in sctp_add_addr_to_vrf() for the case when it is
detected that ifa is already pointing to a ifn.
- Fix it so that if someone is so insane that they drop the
send window below the minimal add mark, they still can send.
- Changed all state for associations to use mask safe macro.
- During front states in association freeing in sctp_inpcbfree, we
had a locking problem where locks were not in place where they
should have been.
- Free association calls were not testing the return value in
sctp_inpcb_free() properly... others should be cast void returns
where we don't care about the return value.
- If a reference count is held on an assoc, even from the "force free"
we should not do the actual free.. but instead let the timer
free it.
- When we enter sctp_input(), if the SCTP_ASOC_ABOUT_TO_BE_FREED
flag is set, we must NOT process the packet but handle it like
ootb. This is because while freeing an assoc we release the
locks to get all the higher order locks so we can purge all
the hash tables. This leaves a hole if a packet comes in
just at that point. Now sctp_common_input_processing() will
call the ootb code in such a case.
- Change MBUF M_NOTIFICATION to use M_PROTO5 (per Sam L). This makes
it so we don't have a conflict (I think this is a covertity change).
We made this change AFTER some conversation and looking to make sure
that M_PROTO5 does not have a problem between SCTP and the 802.11
stuff (which is the only other place its used).
- Fixed lock order reversal and missing atomic protection around
locked_tcb during association lookup and the 1-2-1 model.
- Added debug to source address selection.
- V6 output must always do checksum even for loopback.
- Remove more locks around inp that are not needed for an atomically
added/subtracted ref count.
- slight optimization in the way we zero the array in sctp_sack_check()
- It was possible to respond to a ABORT() with bad checksum with
a PKT-DROP. This lead to a PKT-DROP/ABORT war. Add code to NOT
send a PKT-DROP to any ABORT().
- Add an option for local logging (useful for macintosh or when
you need better performing during debugging). Note no commands
are here to get the log info, you must just use kgdb.
- The timer code needs to be aware of if it needs to call
sctp_sack_check() to slide the maps and adjust the cum-ack.
This is because it may be out of sync cum-ack wise.
- Added threshold managment logging.
- If the user picked just the right size, that just filled the send
window minus one mtu, we would enter a forever loop not copying and
at the same time not blocking. Change from < to <= solves this.
- Sysctl added to control the fragment interleave level which defaults
to 1.
- My rwnd control was not being used to control the rwnd properly (we
did not add and subtract to it :-() this is now fixed so we handle
small messages (1 byte etc) better to bring our rwnd down more
slowly.

Approved by: re@freebsd.org (Bruce Mah)


# 52be287e 21-Jul-2007 Randall Stewart <rrs@FreeBSD.org>

- remove duplicate code from sctp_asconf.c
- remove duplicate #include <sys/priv.h> that is not under
#ifdef FreeBSD version to allow compile on 6.1
- static analysis changes per the cisco SA tool including:
o some SA_IGNORE comments
o some checks for NULL before unlock.
o type corrections int -> size_t
- Fix it so sctp_alloc_asoc takes a thread/proc argument. Without this
we pass a NULL in to bind on implicit assoc setup and crash :-(
Approved by: re@freebsd.org(Ken Smith)


# 18e198d3 17-Jul-2007 Randall Stewart <rrs@FreeBSD.org>

- added pre-checks to the bindx call.
- use proper tick gathering macro instead of ticks directly.
- Placed reasonable boundaries on sets that a user can do
that are converted to ticks from ms.
- Fix CMT_PF to always check to be sure CMT is on.
- Fix ticks use of CMT_PF.
- put back code to allow asconfs to be queued while INITs are in flight
and before the assoc is established.
- During window probes, an ack'd packet might be left with the window
probe mark on it causing it to be retransmitted. Change so that
the flight decrease macro clears the window_probe mark.
- Additional logging flight size/reading and ASOC LOG. This
is only enabled if you manually insert things into opt_sctp.h
since its a set of debug code only.
- Found an interesting SMP race in the way data was appended which
could cause a reader to lose a part of a message, had to
reorder when we marked the message was complete to after
the data was appended.
- bug in ADD-IP for the subset bound socket case when the peer has only
one address
- fix ASCONF implicit success/error handling case
- proper support of jails in Freebsd 6>
- copy out the timeval for the 64 bit sparc world on cookie-echo
alignment error crashes without this).
Approved by: re(Ken Smith)


# b54d3a6c 14-Jul-2007 Randall Stewart <rrs@FreeBSD.org>

- Modular congestion control, with RFC2581 being the default.
- CMT_PF states added (w/sysctl to turn the PF version on)
- sctp_input.c had a missing incr of cookie case when the
auth was bad. This meant a free was called without an
increment to refcnt, added increment like rest of code.
- There was a case, unlikely, when the scope of the destination
changed (this is a TSNH case). In that case, it would not free
the alloc'ed asoc (in sctp_input.c).
- When listed addresses found a colliding cookie/Init, then
the collided upon tcb was not unlocked in sctp_pcb.c
- Add error checking on arguments of sctp_sendx(3) to prevent it from
referencing a NULL pointer.
- Fix an error return of sctp_sendx(3), it was returing
ENOMEM not -1.
- Get assoc id was changed to use the sanctified socket api
method for getting a assoc id (PEER_ADDR_INFO instead of
PEER_ADDR_PARAMS).
- Fix it so a peeled off socket will get a proper error return
if it trys to send to a different address then it is connected to.
- Fix so that select_a_stream can avoid an endless loop that
could hang a caller.
- time_entered (state set time) was not being set in all cases
to the time we went established.
Approved by: re(ken smith)


# 5bead436 02-Jul-2007 Randall Stewart <rrs@FreeBSD.org>

- Consolidate the code that free's chunks to actually also
call the sctp_free_remote_address() function.
- Assure that when we allocate a chunk the whoTo is NULL,
also when we free it and place it into the cache we NULL
it (that way the consolidation code will always work).
- Fix a small race, when a empty data holder is left on the stream
out queue, and both sides do a shutdown, the empty data holder
would prevent us from sending a SHUTDOWN-ACK and at the same time we
never would cleanup the empty holder (since nothing was ever in queue).
We now add a utility function that a) cleans up empty holders and
b) properly determines if there are still pending data chunks on
the stream out wheel.
Approved by: re@freebsd.org (Ken Smith)


# 9ceab0fa 29-Jun-2007 Randall Stewart <rrs@FreeBSD.org>

- When a SCTP socket is closed, but the last data
SACK is lost, we would incorrectly abort the association
instead of retransmitting the SACK.
Approved by: re@freebsd.org (Ken Smith)


# 671d309c 22-Jun-2007 Randall Stewart <rrs@FreeBSD.org>

- Fix stream reset so it limits the number of streams that can be listed
- Fix fwd-tsn to use proper accessor so it does not overrun mbufs
- Fix stream reset error reporting to actually work (it has always been
broken if the peer rejects a stream reset)
- Some 64 bit friendly changes

Approved by: re(bmah@freebsd.org)


# eacc51c5 18-Jun-2007 Randall Stewart <rrs@FreeBSD.org>

- Fixes cstatic issues found by cisco sa tool (missing frees and such
on error legs)
- align sctp_sockstore to 64 bit boundary ..


# 72fb6fdb 15-Jun-2007 Randall Stewart <rrs@FreeBSD.org>

- Matthew's changes to get inlines out, plus a few of my own
to deal with the VRF inline function -> becomes a macro now.
Submitted by: Matthew Jacobs


# 458303da 15-Jun-2007 Randall Stewart <rrs@FreeBSD.org>

- Issue one, new stack reduction left packet_drop handling still
thinking it had the whole chunk. This could cause a crash if
a large packet drop came in. Fixed by adjusting the trunc length
down to the limit.
- Large sacks with lots of segments could also have same issue. Changed
duplicate and segment handling to use proper get_m_ptr function to
pull each block from mbuf chains.


# 80fefe0a 14-Jun-2007 Randall Stewart <rrs@FreeBSD.org>

- Fix so ifn's are properly deleted when the ref count goes to 0.
- Fix so VRF's will clean themselves up when no references are around.
- Allow sctp_ifa to be passed into inpcb_bind, addr_mgmt_ep_sa to bypass
normal validation checks.
- turn auto-asconf off for subset bound sockets
- Moves all logging to use KTR. This gets rid of most
of the logging #ifdef's with a few exceptions reducing
the number of config options for SCTP.


# f4c93d24 02-Jun-2007 Randall Stewart <rrs@FreeBSD.org>

- fix initial pcb vrf setting when the initial vrf is not the
default_vrf_id
- Missing lock/unlock of inp added as well in the v6 side.
- IFN hash table moves to sctppcbinfo since indexes are
unique across systems (including different VRFs) this makes it easier
to do ifn lookups.


# ad21a364 01-Jun-2007 Randall Stewart <rrs@FreeBSD.org>

- Take out the broken table-id concept. Panda Routers have a M-VRF
concept that is NOT well thought out for a multi-homed transport
protocol. So the useless table-id entries passed around need to
be removed.
- Add a event timer for the zero copy api.
- Fix a bug in sctp_timer.c when searching for an alternate
with the largest ssthresh (the compare was wrong).


# 0696e120 30-May-2007 Randall Stewart <rrs@FreeBSD.org>

- Fix a memory overwrite when the mapping array
is expanded, size of expansion was not taken int consideration.
- Fix so vtag hash is 1 bigger so that it modulo's out
correctly, avoids a panic when restart with right modulo happens.
- do not dereference stcb when control->do_not_ref_stcb is set
- Fix up packet logging to not often use a lock and also to
add to options.
- Fix some logging option duplication in the sctputil.h


# 207304d4 29-May-2007 Randall Stewart <rrs@FreeBSD.org>

- Fixes so we won't try to start a timer when we
hold a wq lock for the iterator. Panda uses a
silly recursive lock they hold through the timer.
- Add poor mans wireshark compile option..
- Allocate and start using SCTP_M_XXX for all SCTP_MALLOC() calls.
- sysctl now will get back the refcnt for viewing by onlookers.

Reviewed by: gnn


# d61a0ae0 28-May-2007 Randall Stewart <rrs@FreeBSD.org>

- fixed autclose to not allow setting on 1-2-1 model.
- bounded cookie-life to 1 second minimum in socket option set.
- Delayed_ack_time becomes delayed_ack per new socket api document.
- Improve port number selection, we now use low/high bounds and
no chance of a endless loop. Only one call to random per bind
as well.
- fixes so set_peer_primary pre-screens addresses to be
valid to this host.
- maxseg did not allow setting on an assoc basis. We needed
to thus track and use an association value instead of a inp value.
- Fixed ep get of HB status to report back properly.
- use settings flag to tell if assoc level hb is on off not
the timer.. since the timer may still run if unconf address
are present.
- check for crazy ENABLE/DISABLE conditions.
- set and get of pmtud (fixed path mtu) not always taking into account ovh.
- Getting PMTU info on stcb only needs to return PMTUD_ENABLED if
any net is doing PMTU discovery.
- Panic or warning fixed to not do so when a valid ip frag is
taking place.
- sndrcvinfo appearing in both inp and stcb was full size, instead
of the non-pad version. This saves about 92 bytes from each struct
by carefully converting to use the smaller version.
- one-2-one model get(maxseg) would always get ep value, never the
tcb's value.
- The delayed ack time could be under a tick, this fixes so
it bounds it to at least 1 tick for platforms whos tick
is more than a ms.
- Fragment interleave level set to wrong default value.
- Fragment interleave could not set level 0.
- Defered stream reset was broken due to a guard check and ntohl issue.
- Found two lock order reversals and fixed.
- Tighten up address checking, if the user gives an address the sa_len
had better be set properly.
- Get asoc by assoc-id would return a locked tcb when it was asked
not to if the tcb was in the restart hash.
- sysctl to dig down and get more association details

Reviewed by: gnn


# 3c503c28 16-May-2007 Randall Stewart <rrs@FreeBSD.org>

- Fixed 1-2-1 model to not worry about associd in sockopts
- Fixed RTOinfo for bounding.
- Fixed connect() to return ECONNREFUSED when an ABORT is received.
- Added comments to direct Static Analysis not to look at some things
it does not understand (comments are /* sa_ignore XXXXX */)
- Bind when colliding was broken, missing not_found = 1 before
checking to see if the port was in use caused endless bind loop.
- Cookie life needs to be in milliseconds to conform to socket api.
- Cookie life is not supposed to change if its 0, On the assoc
level set we changed it to 0 opps.
- Two more static analysis issues identified by the cisco
tool. Null checks needed.
- An issue for sendfile(). Need to validate the correct
input argument.
- When sending failed due to a no route to host, we leaked
the mbuf chain failing to call m_freem().
- Fix #ifdef issue for getting hash block len when HAVE_SHA2 is NOT defined
Reviewed by: gnn


# ad81507e 09-May-2007 Randall Stewart <rrs@FreeBSD.org>

Two major items here:
- All printf that was surrounded by #ifdef SCTP_DEBUG moves to
a macro that does all of this. This removes all printfs from
the code and makes the code more portable and easier to
read.
- Static Analysis (cisco) - found a few bugs, but mostly we
add checks for NULL pointers and such to make the tool
happy. We now pass the Cisco SA tools checks except for
where it does not understand tailq/lists. We still need
to look at the coverity tools output too (this is like
the cisco SA tool) and see if it wants us to fix any other
items. Hopefully this will be the last major churn in the
code other than bug fixes.


# b1006367 08-May-2007 Randall Stewart <rrs@FreeBSD.org>

- Copyright change, cisco's silly tool wants it to say:
"Copyright (c) 2001-2007, by Cisco Systems,"
instead of
*Copyright (c) 2001-2007, Cisco Systems,"

- Also fix a few straglers that were still in 2006.


# 6e55db54 08-May-2007 Randall Stewart <rrs@FreeBSD.org>

- Static analyisis fixes for cisco's commit (this is equivilant
to the coverity tool.. may even be the same one.. not sure).
- A bug in the way sctp_abort() and friends were
setting the IP_CLOSE flag.. and NOT passing the
last argument as a (,1)... so that things would
get freed..


# 17205ecc 07-May-2007 Randall Stewart <rrs@FreeBSD.org>

- More macros for OS compatabilty
- PR-SCTP would ignore FWD-TSN's above a rwnd's worth
of TSN's (1 byte msgs).. this left the peer hopelessly
out of sync.. or an attacker. So now we abort the assoc.
- New IFN hash, also rename hashes to match addr/ifn now
that the vrf has multiple.
- Do not enable SCTP_PCB_FLAGS_RECVDATAIOEVNT per default
as defined in the Socket API ID.
- Export MTU information via sysctl.
- Vrf's need table id's. This is default for
BSD, but may be other things later when BSD
fully supports VRFs.
- Additional stream reset bug (caught by cisco dev-test).
- Additional validations for the address in sending a message (socket api).
-------- and -----
- Fix association notifications not to give the active open
side false notifications.
- Fix so sendfile and SENDALL will work properly (missing
flag to say socket sender is done).
- Fix Bug that prevented COOKIES from being retransmitted.
- Break out connectx into helper sub-models so that iox routines can
reuse the helpers.
- When an address is added during system init (non-dynamic mode) make
sure that the "defer use" flag is not set.
** its compiling on XR now :-D **

Reviewed by: gnn


# d06c82f1 01-May-2007 Randall Stewart <rrs@FreeBSD.org>

- Somehow the disable fragment option got lost. We could
set/clear it but would not do it. Now we will.
- Moved to latest socket api for extended sndrcv info struct.
- Moved to support all new levels of fragment interleave (0-2).
- Codenomicon security test updates - length checks and such.
- Bug in stream reset (2 actually).
- setpeerprimary could unlock a null pointer, fixed.
- Added a flag in the pcb so netstat can see if we are listening easier.

Obtained from: (some of the Listen changes from Weongyo Jeong)


# 9a6142d8 22-Apr-2007 Randall Stewart <rrs@FreeBSD.org>

- Somehow the disable fragment option got lost. We could
set/clear it but would not do it. Now we will.
- Moved to latest socket api for extended sndrcv info struct.
- Moved to support all new levels of fragment interleave.


# f1f73e57 19-Apr-2007 Randall Stewart <rrs@FreeBSD.org>

- More work on making send lock contention.
- Removed free-oqueue cache.
- Fix counter for sq entries
- Increased the amount of information retained
on ASOC_TSN logging on the association.
- Made it so with the ASOC_TSN logging on
sending or recieving an abort we dump the log.
- Went through and added invariant's around some
panic's that needed them.
- decrements went to atomic_subtact_int instead of add -1
- Removed residual count increment that threw off a
strm oq count.
- Tracks and complaints if we don't have a LAST fragment and
clean up the sp structure.
- Track a new stat that counts number of abandoned msgs that
happen if you close without reading.
- Fix lookup of frag point to be aware of a 0 assoc-id.
Reviewed by: gnn


# d0cf96b4 14-Apr-2007 Max Laier <mlaier@FreeBSD.org>

Fix a typeo - unbreak the build.


# c105859e 14-Apr-2007 Randall Stewart <rrs@FreeBSD.org>

- fix source address selection when picking an acceptable address
- name change of prefered -> preferred
- CMT fast recover code added.
- Comment fixes in CMT.
- We were not giving a reason of cant_start_asoc per socket api
if we failed to get init/or/cookie to bring up an assoc. Change
so we don't just give a generic "comm lost" but look at actual
states of dying assoc.
- change "crc32" arguments to "crc32c" to silence strict/noisy
compiler warnings when crc32() is also declared
- A few minor tweaks to get the portable stuff truely portable
for sctp6_usrreq.c :-D
- one-2-one style vrf match problem.
- window recovery would leave chks marked for retran
during window probes on the sent queue. This would then
cause an out-of-order problem and assure that the flight
size "problem" would occur.
- Solves a flight size logging issue that caused rwnd
overruns, flight size off as well as false retransmissions.g
- Macroize the up and down of flight size.
- Fix a ECNE bug in its counting.
- The strict_sacks options was causing aborts when window probing
was active, fix to make strict sacks a bit smarter about what
the next unsent TSN is.
- Fixes a one-2-one wakeup bug found by Martin Kulas.
- If-defed out form, Andre's copy routines pending his
commit of at least m_last().. need to adjust for 6.2 as
well.. since m_last won't exist.
Reviewed by: gnn


# bff64a4d 03-Apr-2007 Randall Stewart <rrs@FreeBSD.org>

- fixed several places where we did not release INP locks.
- fixed a refcount bug in the new ifa structures.
- use vrf's from default stcb or inp whenever possible.
- Address limits raised to account for a full IP fragmented
packet (1000 addresses).
- flight size correcting updated to include one message only
and to handle case where the peer does not cumack the
next segment aka lists 1/1 in sack blocks..
- Various bad init/init-ack handling could cause a panic
since we tried to unlock the destroyed mutex. Fixes
so we properly exit when we need to destroy an assoc.
(Found by Cisco DevTest team :D)
- name rename in src-addr-selection from pass to sifa.
- route structure typedef'd to allow different platforms
and updated into sctp_os_bsd file.
- Max retransmissions a chunk can be made added.
Reviewed by: gnn


# 5e54f665 31-Mar-2007 Randall Stewart <rrs@FreeBSD.org>

- Found bug in min split point bundling which caused
incorrect, non-bundlable fragmentation.
- Added min residual to better control split points for
both how big a msg must be as well as how much needs
to be left over.
- With our new algo in place, we need to implicitly
set "end of msg" on the sp-> structure otherwise we
end up with "hung" associations.
- Room reserved up front in IP header by pushing IP
header to back of mbuf.
- Fix so FR's peg count of retransmissions needed.
- Fix so an unlucky chunk that never gets across
will kill the assoc via the kill timer and send an
abort too.
- Fix bug in sctp_input which can result in a crash.
- Do not strip off IP options anymore.
- Clean up sctp_calculate_rto().
- Get rid of unused sysctl.
- Fixed so we discard all M-Cast
- Fixed so port check done AFTER checksum
- Fixed bug in fragmentation code that prevented
us from fragmenting a small complete message when
we needed to.
- Window probes were not marked back to unsent and
flight adjusted when a sack came in with no
window change or accepting of the probe data.
We now fix this with having a mark on the net and
the chunk so we can clear it out when the sack arrives
forcing it to retran just like it was "new" this
improves the handling of window probes, which were
dropped by the receiver.
- Tighten AUTH protocol error checks during INIT/INIT-ACK exchange


# 62c1ff9c 20-Mar-2007 Randall Stewart <rrs@FreeBSD.org>

- window update sacks sent incorrectly after
shutdown which caused extra abort from peer.
- RTT time calculation was not being done in
express sack handling since it refered to an unused
variable (rto_pending). Removed variable.
- socket buffer high water access macro-ized.


# 132dea7d 19-Mar-2007 Randall Stewart <rrs@FreeBSD.org>

- errno -> becomes error in sctp_output.c and sctputil.c
- SB_CLEAR macro defined and used for sb clearing.
- Fix for CMT express_sack_handling did not do proper
pseudo-cumack updates.
- Get rid of extraneous function that was never used ip_2_ip6_hdr()
- Fixed source address selection bug (initialization problem).
- Source address selection debug added.


# 42551e99 15-Mar-2007 Randall Stewart <rrs@FreeBSD.org>

- Sysctl's move to seperate file
- moved away from ifn/ifa access to sctp_ifa/sctp_ifn
built and managed by the add-ip code.
- cleaned up add-ip code to use the iterator
- made iterator be a thread, which enables auto-asconf now.
- rewrote and cleaned up source address selection (also
made it use new structures).
- Fixed a couple of memory leaks.
- DACK now settable as to how many packets to delay as
well as time.
- connectx() to latest socket API, new associd arg.
- Fixed issue with revoking and loosing potential to
send when we inflate the flight size. We now inflate
the cwnd too and deflate it later when the revoked
chunk is sent or acked.
- Got rid of some temp debug code
- src addr selection moved to a common file (sctp_output.c)
- Support for simple VRF's (we have support for multi-vfr
via compile switch that is scrubbed from BSD but we won't
need multi-vrf until we first get VRF :-D)
- Rest of mib work for address information now done
- Limit number of addresses in INIT/INIT-ACK to
a #def (30).

Reviewed by: gnn


# f42a358a 12-Feb-2007 Randall Stewart <rrs@FreeBSD.org>

- Copyright updates (aka 2007)
- ZONE get now also take a type cast so it does the
cast like mtod does.
- New macro SCTP_LIST_EMPTY, which in bsd is just
LIST_EMPTY
- Removal of const in some of the static hmac functions
(not needed)
- Store length changes to allow for new fields in auth
- Auth code updated to current draft (this should be the
RFC version we think).
- use uint8_t instead of u_char in LOOPBACK address comparison
- Some u_int32_t converted to uint32_t (in crc code)
- A bug was found in the mib counts for ordered/unordered
count, this was fixed (was referencing a freed mbuf).
- SCTP_ASOCLOG_OF_TSNS added (code will probably disappear
after my testing completes. It allows us to keep a
small log on each assoc of the last 40 TSN's in/out and
stream assignment. It is NOT in options and so is only
good for private builds.
- Some CMT changes in prep for Jana fixing his problem
with reneging when CMT is enabled (Concurrent Multipath
Transfer = CMT).
- Some missing mib stats added.
- Correction to number of open assoc's count in mib
- Correction to os_bsd.h to get right sha2 macros
- Add of special AUTH_04 flags so you can compile the code
with the old format (in case the peer does not yet support
the latest auth code).
- Nonce sum was incorrectly being set in when ecn_nonce was
NOT on.
- LOR in listen with implicit bind found and fixed.
- Moved away from using mbuf's for socket options to using
just data pointers. The mbufs were used to harmonize
NetBSD code since both Net and Open used this method. We
have decided to move away from that and more conform to
FreeBSD style (which makes more sense).
- Very very nasty bug found in some of my "debug" code. The
cookie_how collision case tracking had an endless loop in
it if you got a second retransmission of a cookie collision
case. This would lock up a CPU .. ugly..
- auth function goes to using size_t instead of int which
conforms to socketapi better
- Found the nasty bug that happens after 9 days of testing.. you
get the data chunk, deliver it and due to the reference to a ch->
that every now and then has been deleted (depending on the postion
in the mbuf) you have an invalid ch->ch.flags.. and thus you don't
advance the stream sequence number.. so you block the stream
permanently. The fix is to make local variables of these guys
and set them up before you have any chance of trimming the
mbuf.
- style fix in sctp_util.h, not sure how this got bad maybe in
the last patch? (aka it may not be in the real source).
- Found interesting bug when using the extended snd/rcv info where
we would get an error on receiving with this. Thats because
it was NOT padded to the same size as the snd_rcv info. We
increase (add the pad) so the two structs are the same size
in sctp_uio.h
- In sctp_usrreq.c one of the most common things we did for
socket options was to cast the pointer and validate the size.
This as been macro-ized to help make the code more readable.
- in sctputil.c two things, the socketapi class found a missing
flag type (the next msg is a notification) and a missing
scope recovery was also fixed.

Reviewed by: gnn


# 93164cf9 18-Jan-2007 Randall Stewart <rrs@FreeBSD.org>

- most all includes (#include <>) migrate to the sctp_os_bsd.h file
- Finally all splxx() are removed
- Count error fixed in mapping array which might
cause a wrong cumack generation.
- Invariants around panic for case D + printf when no invariants.
- one-to-one model race condition fixed by using
a pre-formed connection and then completing the
work so accept won't happen on a non-formed
association.
- Some additional paranoia checks in sctp_output.
- Locks that were missing in the accept code.

Approved by: gnn


# 44b7479b 15-Jan-2007 Randall Stewart <rrs@FreeBSD.org>

- Macroizes the V6ONLY flag check.
- Added a short time wait (not used yet) constant
- Corrected the type of the crc32c table (it was
unsigned long and really is a uint32_t
- Got rid of the user of MHeaders until they
are truely needed by lower layers.
- Fixed an initialization problem in the readq structure
(ordering was off).
- Found yet another collision bug when the random number
generator returns two numbers on one side (during a collision)
that are the same. Also added some tracking of cookies
that will go away when we know that we have the last collision
bug gone.
- Fixed an init bug for book_size_scale, that was causing
Early FR code to run when it should not.
- Fixed a flight size tracking bug that was associated with
Early FR but due to above bug also effected all FR's
- Fixed it so Max Burst also will apply to Fast Retransmit.
- Fixed a bug in the temporary logging code that allowed a
static log array overflow
- hashinit_flags is now used.
- Two last mcopym's were converted to the macro sctp_m_copym that
has always been used by all other places
- macro sctp_m_copym was converted to upper case.
- We now validate sinfo_flags on input (we did not before).
- Fixed a bug that prevented a user from sending data and immediately
shuting down with one send operation.
- Moved to use hashdestroy instead of free() in our macros.
- Fixed an init problem in our timed_wait vtag where we
did not fully initialize our time-wait blocks.
- Timer stops were re-positioned.
- A pcb cleanup method was added, however this probably will
not be used in BSD.. unless we make module loadable protocols
- I think this fixes the mysterious timer bug.. it was a
ordering of locks problem in the way we did timers. It
now conforms to the timeout(9) manual (except for the
_drain part, we had to do this a different way due
to locks).
- Fixed error return code so we get either CONNREUSED or CONNRESET
depending on where one is in progression
- Purged an unused clone macro.
- Fixed a read erro code issue where we were NOT getting the proper
error when the connection was reset.
- Purged an unused clone macro.
- Fixed a read erro code issue where we were NOT getting the proper
error when the connection was reset.
Approved by: gnn


# 139bc87f 29-Dec-2006 Randall Stewart <rrs@FreeBSD.org>

a) macro-ization of all mbuf and random number
access plus timers. This makes the code
more portable and able to change out the
mbuf or timer system used more easily ;-)
b) removal of all use of pkt-hdr's until only
the places we need them (before ip_output routines).
c) remove a bunch of code not needed due to <b> aka
worrying about pkthdr's :-)
d) There was one last reorder problem it looks where
if a restart occur's and we release and relock (at
the point where we setup our alias vtag) we would
end up possibly getting the wrong TSN in place. The
code that fixed the TSN's just needed to be shifted
around BEFORE the release of the lock.. also code that
set the state (since this also could contribute).
Approved by: gnn


# a5d547ad 14-Dec-2006 Randall Stewart <rrs@FreeBSD.org>

1) Fixes on a number of different collision case LOR's.
2) Fix all "magic numbers" to be constants.
3) A collision case that would generate two associations to
the same peer due to a missing lock is fixed.
4) Added tracking of where timers are stopped.
Approved by: gnn


# 6a91f103 11-Nov-2006 Randall Stewart <rrs@FreeBSD.org>

Turns out we would reset the TSN seq counter during
a colliding INIT. This if fine except when we have
data outstanding... we basically reset it to the
previous value it was.. so then we end up assigning
the same TSN to two different data chunks.
This patch:

1) Finds a missing lock for when we change the stream
numbers during COOKIE and INIT-ACK processing.. we
were NOT locking the send_buffer.. which COULD cause
problems (found by inspection looking for <2>)

2) Fixes a case during a colliding INIT where we incorrectly
reset the sending Sequence thus in some cases duplicately
assigning a TSN.

3) Additional enhancments to logging so we can see strm/tsn in
the receiver AND new tracking to watch what the sender
is doing with TSN and STRM seq's.

Approved by: gnn


# 03b0b021 07-Nov-2006 Randall Stewart <rrs@FreeBSD.org>

-Fixes first of all the getcred on IPv6 and V4. The
copy's were incorrect and so was the locking.
-A bug was also found that would create a race and
panic when an abort arrived on a socket being read
from.
-Also fix the reader to get MSG_TRUNC when a partial
delivery is aborted.
-Also addresses a couple of coverity caught error path
memory leaks and a couple of other valid complaints
Approved by: gnn


# 50cec919 05-Nov-2006 Randall Stewart <rrs@FreeBSD.org>

Tons of fixes to get all the 64bit issues removed.
This also moves two 16 bit int's to become 32 bit
values so we do not have to use atomic_add_16.
Most of the changes are %p, casts and other various
nasty's that were in the orignal code base. With this
commit my machine will now do a build universe.. however
I as yet have not tested on a 64bit machine .. it may not work :-(


# f8829a4a 03-Nov-2006 Randall Stewart <rrs@FreeBSD.org>

Ok, here it is, we finally add SCTP to current. Note that this
work is not just mine, but it is also the works of Peter Lei
and Michael Tuexen. They both are my two key other developers
working on the project.. and they need ata-boy's too:
****
peterlei@cisco.com
tuexen@fh-muenster.de
****
I did do a make sysent which updated the
syscall's and sysproto.. I hope that is correct... without
it you don't build since we have new syscalls for SCTP :-0

So go out and look at the NOTES, add
option SCTP (make sure inet and inet6 are present too)
and play with SCTP.

I will see about comitting some test tools I have after I
figure out where I should place them. I also have a
lib (libsctp.a) that adds some of the missing socketapi
functions that I need to put into lib's.. I will talk
to George about this :-)

There may still be some 64 bit issues in here, none of
us have a 64 bit processor to test with yet.. Michael
may have a MAC but thats another beast too..

If you have a mac and want to use SCTP contact Michael
he maintains a web site with a loadable module with
this code :-)

Reviewed by: gnn
Approved by: gnn