]> Pileus Git - ~andy/linux/commitdiff
net: sctp: sctp_verify_init: clean up mandatory checks and add comment
authorDaniel Borkmann <dborkman@redhat.com>
Tue, 27 Aug 2013 14:53:52 +0000 (16:53 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 29 Aug 2013 19:54:48 +0000 (15:54 -0400)
Add a comment related to RFC4960 explaning why we do not check for initial
TSN, and while at it, remove yoda notation checks and clean up code from
checks of mandatory conditions. That's probably just really minor, but makes
reviewing easier.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/sm_make_chunk.c

index 01e97836ca6c95ddd378dbd4c9fec09041c4fc26..d244a23ab8d33c95e0b8133e212c35bc4a47875a 100644 (file)
@@ -2240,25 +2240,23 @@ int sctp_verify_init(struct net *net, const struct sctp_association *asoc,
                     struct sctp_chunk **errp)
 {
        union sctp_params param;
-       int has_cookie = 0;
+       bool has_cookie = false;
        int result;
 
-       /* Verify stream values are non-zero. */
-       if ((0 == peer_init->init_hdr.num_outbound_streams) ||
-           (0 == peer_init->init_hdr.num_inbound_streams) ||
-           (0 == peer_init->init_hdr.init_tag) ||
-           (SCTP_DEFAULT_MINWINDOW > ntohl(peer_init->init_hdr.a_rwnd))) {
-
+       /* Check for missing mandatory parameters. Note: Initial TSN is
+        * also mandatory, but is not checked here since the valid range
+        * is 0..2**32-1. RFC4960, section 3.3.3.
+        */
+       if (peer_init->init_hdr.num_outbound_streams == 0 ||
+           peer_init->init_hdr.num_inbound_streams == 0 ||
+           peer_init->init_hdr.init_tag == 0 ||
+           ntohl(peer_init->init_hdr.a_rwnd) < SCTP_DEFAULT_MINWINDOW)
                return sctp_process_inv_mandatory(asoc, chunk, errp);
-       }
 
-       /* Check for missing mandatory parameters.  */
        sctp_walk_params(param, peer_init, init_hdr.params) {
-
-               if (SCTP_PARAM_STATE_COOKIE == param.p->type)
-                       has_cookie = 1;
-
-       } /* for (loop through all parameters) */
+               if (param.p->type == SCTP_PARAM_STATE_COOKIE)
+                       has_cookie = true;
+       }
 
        /* There is a possibility that a parameter length was bad and
         * in that case we would have stoped walking the parameters.