Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Improve compliance to RFC 6458.



details:   https://anonhg.NetBSD.org/src/rev/97f9ef3fc50e
branches:  trunk
changeset: 828372:97f9ef3fc50e
user:      rjs <rjs%NetBSD.org@localhost>
date:      Sun Dec 10 11:52:14 2017 +0000

description:
Improve compliance to RFC 6458.

diffstat:

 sys/netinet/sctp_indata.c |    8 +-
 sys/netinet/sctp_output.c |   63 ++++++++---------
 sys/netinet/sctp_uio.h    |  162 ++++++++++++++++++++++++++++++++++++++-------
 sys/netinet/sctp_usrreq.c |   14 +--
 4 files changed, 172 insertions(+), 75 deletions(-)

diffs (truncated from 647 to 300 lines):

diff -r 7793d06fef4a -r 97f9ef3fc50e sys/netinet/sctp_indata.c
--- a/sys/netinet/sctp_indata.c Sun Dec 10 11:03:58 2017 +0000
+++ b/sys/netinet/sctp_indata.c Sun Dec 10 11:52:14 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sctp_indata.c,v 1.4 2016/04/25 21:21:02 rjs Exp $ */
+/*     $NetBSD: sctp_indata.c,v 1.5 2017/12/10 11:52:14 rjs Exp $ */
 /*     $KAME: sctp_indata.c,v 1.36 2005/03/06 16:04:17 itojun Exp $    */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctp_indata.c,v 1.4 2016/04/25 21:21:02 rjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctp_indata.c,v 1.5 2017/12/10 11:52:14 rjs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -205,7 +205,7 @@
        outinfo->sinfo_stream = stream_no;
        outinfo->sinfo_ssn = stream_seq;
        if (flags & SCTP_DATA_UNORDERED) {
-               outinfo->sinfo_flags = MSG_UNORDERED;
+               outinfo->sinfo_flags = SCTP_UNORDERED;
        } else {
                outinfo->sinfo_flags = 0;
        }
@@ -256,7 +256,7 @@
        outinfo->sinfo_stream = chk->rec.data.stream_number;
        outinfo->sinfo_ssn = chk->rec.data.stream_seq;
        if (chk->rec.data.rcv_flags & SCTP_DATA_UNORDERED) {
-               outinfo->sinfo_flags = MSG_UNORDERED;
+               outinfo->sinfo_flags = SCTP_UNORDERED;
        } else {
                outinfo->sinfo_flags = 0;
        }
diff -r 7793d06fef4a -r 97f9ef3fc50e sys/netinet/sctp_output.c
--- a/sys/netinet/sctp_output.c Sun Dec 10 11:03:58 2017 +0000
+++ b/sys/netinet/sctp_output.c Sun Dec 10 11:52:14 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sctp_output.c,v 1.11 2017/06/27 13:54:56 rjs Exp $ */
+/*     $NetBSD: sctp_output.c,v 1.12 2017/12/10 11:52:14 rjs Exp $ */
 /*     $KAME: sctp_output.c,v 1.48 2005/06/16 18:29:24 jinmei Exp $    */
 
 /*
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctp_output.c,v 1.11 2017/06/27 13:54:56 rjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctp_output.c,v 1.12 2017/12/10 11:52:14 rjs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -4006,7 +4006,7 @@
        memset(template, 0, sizeof(struct sctp_tmit_chunk));
        template->sent = SCTP_DATAGRAM_UNSENT;
        if ((stcb->asoc.peer_supports_prsctp) &&
-           (srcv->sinfo_flags & (MSG_PR_SCTP_TTL|MSG_PR_SCTP_BUF)) &&
+           (srcv->sinfo_flags & (SCTP_PR_SCTP_TTL|SCTP_PR_SCTP_BUF)) &&
            (srcv->sinfo_timetolive > 0)
                ) {
                /* If:
@@ -4016,7 +4016,7 @@
                 *     to mean a reliable send for both buffer/time
                 *     related one.
                 */
-               if (srcv->sinfo_flags & MSG_PR_SCTP_BUF) {
+               if (srcv->sinfo_flags & SCTP_PR_SCTP_BUF) {
                        /*
                         * Time to live is a priority stored in tv_sec
                         * when doing the buffer drop thing.
@@ -4036,7 +4036,7 @@
 #endif
                }
        }
-       if ((srcv->sinfo_flags & MSG_UNORDERED) == 0) {
+       if ((srcv->sinfo_flags & SCTP_UNORDERED) == 0) {
                template->rec.data.stream_seq = strq->next_sequence_sent;
        } else {
                template->rec.data.stream_seq = 0;
@@ -4049,7 +4049,7 @@
        template->rec.data.doing_fast_retransmit = 0;
        template->rec.data.ect_nonce = 0;   /* ECN Nonce */
 
-       if (srcv->sinfo_flags & MSG_ADDR_OVER) {
+       if (srcv->sinfo_flags & SCTP_ADDR_OVER) {
                template->whoTo = net;
        } else {
                if (stcb->asoc.primary_destination)
@@ -4060,7 +4060,7 @@
                }
        }
        /* the actual chunk flags */
-       if (srcv->sinfo_flags & MSG_UNORDERED) {
+       if (srcv->sinfo_flags & SCTP_UNORDERED) {
                template->rec.data.rcv_flags = SCTP_DATA_UNORDERED;
        } else {
                template->rec.data.rcv_flags = 0;
@@ -4076,10 +4076,10 @@
                         * Zero is reserved specifically to be
                         * EXCLUDED and sent reliable.
                         */
-                       if (srcv->sinfo_flags & MSG_PR_SCTP_TTL) {
+                       if (srcv->sinfo_flags & SCTP_PR_SCTP_TTL) {
                                template->flags |= SCTP_PR_SCTP_ENABLED;
                        }
-                       if (srcv->sinfo_flags & MSG_PR_SCTP_BUF) {
+                       if (srcv->sinfo_flags & SCTP_PR_SCTP_BUF) {
                                template->flags |= SCTP_PR_SCTP_BUFFER;
                        }
                }
@@ -4160,7 +4160,7 @@
        }
        so = stcb->sctp_socket;
        asoc = &stcb->asoc;
-       if (srcv->sinfo_flags & MSG_ABORT) {
+       if (srcv->sinfo_flags & SCTP_ABORT) {
                if ((SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT) &&
                    (SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_ECHOED)) {
                        /* It has to be up before we abort */
@@ -4242,7 +4242,7 @@
                error = EMSGSIZE;
                goto release;
        }
-       if ((srcv->sinfo_flags & MSG_EOF) &&
+       if ((srcv->sinfo_flags & SCTP_EOF) &&
            (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
            (dataout == 0)
                ) {
@@ -4365,7 +4365,7 @@
                chk->book_size = chk->send_size;
                chk->mbcnt = mbcnt;
                /* ok, we are commited */
-               if ((srcv->sinfo_flags & MSG_UNORDERED) == 0) {
+               if ((srcv->sinfo_flags & SCTP_UNORDERED) == 0) {
                        /* bump the ssn if we are unordered. */
                        strq->next_sequence_sent++;
                }
@@ -4480,7 +4480,7 @@
                 * and breaking the pointers.
                 */
                /* ok, we are commited */
-               if ((srcv->sinfo_flags & MSG_UNORDERED) == 0) {
+               if ((srcv->sinfo_flags & SCTP_UNORDERED) == 0) {
                        /* bump the ssn if we are unordered. */
                        strq->next_sequence_sent++;
                }
@@ -4514,7 +4514,7 @@
        /* has a SHUTDOWN been (also) requested by the user on this asoc? */
 zap_by_it_all:
 
-       if ((srcv->sinfo_flags & MSG_EOF) &&
+       if ((srcv->sinfo_flags & SCTP_EOF) &&
            (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE)) {
 
                int some_on_streamwheel = 0;
@@ -4557,11 +4557,6 @@
                         * we still got (or just got) data to send, so set
                         * SHUTDOWN_PENDING
                         */
-                       /*
-                        * XXX sockets draft says that MSG_EOF should be sent
-                        * with no data.  currently, we will allow user data
-                        * to be sent first and move to SHUTDOWN-PENDING
-                        */
                        asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
                }
        }
@@ -4800,7 +4795,7 @@
        /* take off the sendall flag, it would
         * be bad if we failed to do this  :-0
         */
-       ca->sndrcv.sinfo_flags &= ~MSG_SENDALL;
+       ca->sndrcv.sinfo_flags &= ~SCTP_SENDALL;
 
        /* get length and mbuf chain */
        if (uio) {
@@ -7171,7 +7166,7 @@
                sctppcbinfo.mbuf_track++;
                if (sctp_find_cmsg(SCTP_SNDRCV, (void *)&srcv, control,
                                   sizeof(srcv))) {
-                       if (srcv.sinfo_flags & MSG_SENDALL) {
+                       if (srcv.sinfo_flags & SCTP_SENDALL) {
                                /* its a sendall */
                                sctppcbinfo.mbuf_track--;
                                sctp_m_freem(control);
@@ -7293,7 +7288,7 @@
                return (ENOENT);
        } else if (stcb == NULL) {
                /* UDP mode, we must go ahead and start the INIT process */
-               if ((use_rcvinfo) && (srcv.sinfo_flags & MSG_ABORT)) {
+               if ((use_rcvinfo) && (srcv.sinfo_flags & SCTP_ABORT)) {
                        /* Strange user to do this */
                        if (control) {
                                sctppcbinfo.mbuf_track--;
@@ -7409,7 +7404,7 @@
                                control = NULL;
                        }
                        if ((use_rcvinfo) &&
-                           (srcv.sinfo_flags & MSG_ABORT)) {
+                           (srcv.sinfo_flags & SCTP_ABORT)) {
                                sctp_msg_append(stcb, net, m, &srcv, flags);
                                error = 0;
                        } else {
@@ -7448,7 +7443,7 @@
                sctp_m_freem(control);
                control = NULL;
        }
-       if (net && ((srcv.sinfo_flags & MSG_ADDR_OVER))) {
+       if (net && ((srcv.sinfo_flags & SCTP_ADDR_OVER))) {
                /* we take the override or the unconfirmed */
                ;
        } else {
@@ -9455,7 +9450,7 @@
        }
 
        /* Are we aborting? */
-       if (srcv->sinfo_flags & MSG_ABORT) {
+       if (srcv->sinfo_flags & SCTP_ABORT) {
                if ((SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT) &&
                    (SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_ECHOED)) {
                        /* It has to be up before we abort */
@@ -9536,7 +9531,7 @@
                error = EFAULT;
                goto release;
        }
-       if ((srcv->sinfo_flags & MSG_EOF) &&
+       if ((srcv->sinfo_flags & SCTP_EOF) &&
            (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
            (tot_out == 0)) {
                sounlock(so);
@@ -9591,7 +9586,7 @@
                chk->send_size = tot_out;
                chk->book_size = chk->send_size;
                /* ok, we are commited */
-               if ((srcv->sinfo_flags & MSG_UNORDERED) == 0) {
+               if ((srcv->sinfo_flags & SCTP_UNORDERED) == 0) {
                        /* bump the ssn if we are unordered. */
                        strq->next_sequence_sent++;
                }
@@ -9680,7 +9675,7 @@
                        tot_out -= tot_demand;
                }
                /* Now the tmp list holds all chunks and data */
-               if ((srcv->sinfo_flags & MSG_UNORDERED) == 0) {
+               if ((srcv->sinfo_flags & SCTP_UNORDERED) == 0) {
                        /* bump the ssn if we are unordered. */
                        strq->next_sequence_sent++;
                }
@@ -9759,7 +9754,7 @@
                so->so_snd.sb_cc += dataout;
                so->so_snd.sb_mbcnt += mbcnt;
        }
-       if ((srcv->sinfo_flags & MSG_EOF) &&
+       if ((srcv->sinfo_flags & SCTP_EOF) &&
            (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE)
                ) {
                int some_on_streamwheel = 0;
@@ -9802,7 +9797,7 @@
                         * SHUTDOWN_PENDING
                         */
                        /*
-                        * XXX sockets draft says that MSG_EOF should be sent
+                        * XXX sockets draft says that SCTP_EOF should be sent
                         * with no data.  currently, we will allow user data
                         * to be sent first and move to SHUTDOWN-PENDING
                         */
@@ -9900,7 +9895,7 @@
                if (sctp_find_cmsg(SCTP_SNDRCV, (void *)&srcv, control,
                                   sizeof(srcv))) {
                        /* got one */
-                       if (srcv.sinfo_flags & MSG_SENDALL) {
+                       if (srcv.sinfo_flags & SCTP_SENDALL) {
                                /* its a sendall */
                                sctppcbinfo.mbuf_track--;
                                sctp_m_freem(control);
@@ -9961,7 +9956,7 @@
        } else if (stcb == NULL) {
                /* UDP style, we must go ahead and start the INIT process */
                if ((use_rcvinfo) &&
-                   (srcv.sinfo_flags & MSG_ABORT)) {
+                   (srcv.sinfo_flags & SCTP_ABORT)) {
                        /* User asks to abort a non-existant asoc */
                        error = ENOENT;
                        sounlock(so);
@@ -10075,7 +10070,7 @@
            (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) ||
            (asoc->state & SCTP_STATE_SHUTDOWN_PENDING)) {
                if ((use_rcvinfo) &&
-                   (srcv.sinfo_flags & MSG_ABORT)) {
+                   (srcv.sinfo_flags & SCTP_ABORT)) {
                        ;
                } else {
                        error = ECONNRESET;
@@ -10090,7 +10085,7 @@
 #endif
 
        if (stcb) {
-               if (net && ((srcv.sinfo_flags & MSG_ADDR_OVER))) {



Home | Main Index | Thread Index | Old Index