Author: tuexen
Date: Thu Sep 18 09:49:49 2014
New Revision: 271750
URL: http://svnweb.freebsd.org/changeset/base/271750

Log:
  MFC r271643:
  Chunk IDs are 8 bit entities, not 16 bit.
  Thanks to Peter Kasting from Google for drawing
  my attention to it.
  
  MFC r271665:
  The MTU is handled as a 32-bit entity within the SCTP stack.
  This was reported by Peter Kasting from Google.
  
  MFC r271670:
  Make a type conversion explicit. When compiling this code on
  Windows as part of the SCTP userland stack, this fixes a
  warning reported by Peter Kasting from Google.
  
  MFC r271672:
  Small cleanup which addresses a warning regaring the truncation
  of a 64-bit entity to a 32-bit entity. This issue was reported by
  Peter Kasting from Google.
  
  MFC r271673:
  Use a consistent type for the number of HMAC algorithms.
  This fixes a bug which resulted in a warning on the userland
  stack, when compiled on Windows.
  Thanks to Peter Kasting from Google for reporting the issue and
  provinding a potential fix.
  
  MFC r271674:
  Add a explict cast to silence a warning when building
  the userland stack on Windows.
  This issue was reported by Peter Kasting from Google.
  
  Approved by: re (kib)

Modified:
  stable/10/sys/netinet/sctp_auth.c
  stable/10/sys/netinet/sctp_auth.h
  stable/10/sys/netinet/sctp_cc_functions.c
  stable/10/sys/netinet/sctp_os_bsd.h
  stable/10/sys/netinet/sctp_output.c
  stable/10/sys/netinet/sctp_pcb.c
  stable/10/sys/netinet/sctp_structs.h
  stable/10/sys/netinet/sctp_usrreq.c
  stable/10/sys/netinet/sctputil.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet/sctp_auth.c
==============================================================================
--- stable/10/sys/netinet/sctp_auth.c   Thu Sep 18 09:22:37 2014        
(r271749)
+++ stable/10/sys/netinet/sctp_auth.c   Thu Sep 18 09:49:49 2014        
(r271750)
@@ -631,7 +631,7 @@ sctp_copy_skeylist(const struct sctp_key
 
 
 sctp_hmaclist_t *
-sctp_alloc_hmaclist(uint8_t num_hmacs)
+sctp_alloc_hmaclist(uint16_t num_hmacs)
 {
        sctp_hmaclist_t *new_list;
        int alloc_size;
@@ -1438,8 +1438,8 @@ sctp_auth_get_cookie_params(struct sctp_
                        p_random = (struct sctp_auth_random *)phdr;
                        random_len = plen - sizeof(*p_random);
                } else if (ptype == SCTP_HMAC_LIST) {
-                       int num_hmacs;
-                       int i;
+                       uint16_t num_hmacs;
+                       uint16_t i;
 
                        if (plen > sizeof(hmacs_store))
                                break;

Modified: stable/10/sys/netinet/sctp_auth.h
==============================================================================
--- stable/10/sys/netinet/sctp_auth.h   Thu Sep 18 09:22:37 2014        
(r271749)
+++ stable/10/sys/netinet/sctp_auth.h   Thu Sep 18 09:49:49 2014        
(r271750)
@@ -154,7 +154,7 @@ sctp_auth_key_release(struct sctp_tcb *s
 
 
 /* hmac list handling */
-extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint8_t num_hmacs);
+extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint16_t num_hmacs);
 extern void sctp_free_hmaclist(sctp_hmaclist_t * list);
 extern int sctp_auth_add_hmacid(sctp_hmaclist_t * list, uint16_t hmac_id);
 extern sctp_hmaclist_t *sctp_copy_hmaclist(sctp_hmaclist_t * list);

Modified: stable/10/sys/netinet/sctp_cc_functions.c
==============================================================================
--- stable/10/sys/netinet/sctp_cc_functions.c   Thu Sep 18 09:22:37 2014        
(r271749)
+++ stable/10/sys/netinet/sctp_cc_functions.c   Thu Sep 18 09:49:49 2014        
(r271750)
@@ -1130,12 +1130,9 @@ sctp_cwnd_update_after_packet_dropped(st
     uint32_t * bottle_bw, uint32_t * on_queue)
 {
        uint32_t bw_avail;
-       int rtt;
        unsigned int incr;
        int old_cwnd = net->cwnd;
 
-       /* need real RTT in msd for this calc */
-       rtt = net->rtt / 1000;
        /* get bottle neck bw */
        *bottle_bw = ntohl(cp->bottle_bw);
        /* and whats on queue */
@@ -1144,10 +1141,11 @@ sctp_cwnd_update_after_packet_dropped(st
         * adjust the on-queue if our flight is more it could be that the
         * router has not yet gotten data "in-flight" to it
         */
-       if (*on_queue < net->flight_size)
+       if (*on_queue < net->flight_size) {
                *on_queue = net->flight_size;
-       /* calculate the available space */
-       bw_avail = (*bottle_bw * rtt) / 1000;
+       }
+       /* rtt is measured in micro seconds, bottle_bw in bytes per second */
+       bw_avail = (uint32_t) (((uint64_t) (*bottle_bw) * net->rtt) / 
(uint64_t) 1000000);
        if (bw_avail > *bottle_bw) {
                /*
                 * Cap the growth to no more than the bottle neck. This can
@@ -1167,7 +1165,6 @@ sctp_cwnd_update_after_packet_dropped(st
                int seg_inflight, seg_onqueue, my_portion;
 
                net->partial_bytes_acked = 0;
-
                /* how much are we over queue size? */
                incr = *on_queue - bw_avail;
                if (stcb->asoc.seen_a_sack_this_pkt) {

Modified: stable/10/sys/netinet/sctp_os_bsd.h
==============================================================================
--- stable/10/sys/netinet/sctp_os_bsd.h Thu Sep 18 09:22:37 2014        
(r271749)
+++ stable/10/sys/netinet/sctp_os_bsd.h Thu Sep 18 09:49:49 2014        
(r271750)
@@ -322,7 +322,7 @@ typedef struct callout sctp_os_timer_t;
 /*      MTU              */
 /*************************/
 #define SCTP_GATHER_MTU_FROM_IFN_INFO(ifn, ifn_index, af) ((struct ifnet 
*)ifn)->if_mtu
-#define SCTP_GATHER_MTU_FROM_ROUTE(sctp_ifa, sa, rt) ((rt != NULL) ? 
rt->rt_mtu : 0)
+#define SCTP_GATHER_MTU_FROM_ROUTE(sctp_ifa, sa, rt) ((uint32_t)((rt != NULL) 
? rt->rt_mtu : 0))
 #define SCTP_GATHER_MTU_FROM_INTFC(sctp_ifn) ((sctp_ifn->ifn_p != NULL) ? 
((struct ifnet *)(sctp_ifn->ifn_p))->if_mtu : 0)
 #define SCTP_SET_MTU_OF_ROUTE(sa, rt, mtu) do { \
                                               if (rt != NULL) \

Modified: stable/10/sys/netinet/sctp_output.c
==============================================================================
--- stable/10/sys/netinet/sctp_output.c Thu Sep 18 09:22:37 2014        
(r271749)
+++ stable/10/sys/netinet/sctp_output.c Thu Sep 18 09:49:49 2014        
(r271750)
@@ -11301,7 +11301,7 @@ sctp_send_hb(struct sctp_tcb *stcb, stru
        hb->heartbeat.hb_info.time_value_1 = now.tv_sec;
        hb->heartbeat.hb_info.time_value_2 = now.tv_usec;
        /* Did our user request this one, put it in */
-       hb->heartbeat.hb_info.addr_family = net->ro._l_addr.sa.sa_family;
+       hb->heartbeat.hb_info.addr_family = (uint8_t) 
net->ro._l_addr.sa.sa_family;
        hb->heartbeat.hb_info.addr_len = net->ro._l_addr.sa.sa_len;
        if (net->dest_state & SCTP_ADDR_UNCONFIRMED) {
                /*

Modified: stable/10/sys/netinet/sctp_pcb.c
==============================================================================
--- stable/10/sys/netinet/sctp_pcb.c    Thu Sep 18 09:22:37 2014        
(r271749)
+++ stable/10/sys/netinet/sctp_pcb.c    Thu Sep 18 09:49:49 2014        
(r271750)
@@ -6513,8 +6513,8 @@ sctp_load_addresses_from_init(struct sct
                        }
                        got_random = 1;
                } else if (ptype == SCTP_HMAC_LIST) {
-                       int num_hmacs;
-                       int i;
+                       uint16_t num_hmacs;
+                       uint16_t i;
 
                        if (plen > sizeof(hmacs_store))
                                break;

Modified: stable/10/sys/netinet/sctp_structs.h
==============================================================================
--- stable/10/sys/netinet/sctp_structs.h        Thu Sep 18 09:22:37 2014        
(r271749)
+++ stable/10/sys/netinet/sctp_structs.h        Thu Sep 18 09:49:49 2014        
(r271750)
@@ -418,8 +418,8 @@ TAILQ_HEAD(sctpchunk_listhead, sctp_tmit
 #define CHUNK_FLAGS_FRAGMENT_OK                0x0100
 
 struct chk_id {
-       uint16_t id;
-       uint16_t can_take_data;
+       uint8_t id;
+       uint8_t can_take_data;
 };
 
 

Modified: stable/10/sys/netinet/sctp_usrreq.c
==============================================================================
--- stable/10/sys/netinet/sctp_usrreq.c Thu Sep 18 09:22:37 2014        
(r271749)
+++ stable/10/sys/netinet/sctp_usrreq.c Thu Sep 18 09:49:49 2014        
(r271750)
@@ -4208,12 +4208,13 @@ sctp_setopt(struct socket *so, int optna
                        uint32_t i;
 
                        SCTP_CHECK_AND_CAST(shmac, optval, struct 
sctp_hmacalgo, optsize);
-                       if (optsize < sizeof(struct sctp_hmacalgo) + 
shmac->shmac_number_of_idents * sizeof(uint16_t)) {
+                       if ((optsize < sizeof(struct sctp_hmacalgo) + 
shmac->shmac_number_of_idents * sizeof(uint16_t)) ||
+                           (shmac->shmac_number_of_idents > 0xffff)) {
                                SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_USRREQ, EINVAL);
                                error = EINVAL;
                                break;
                        }
-                       hmaclist = 
sctp_alloc_hmaclist(shmac->shmac_number_of_idents);
+                       hmaclist = sctp_alloc_hmaclist((uint16_t) 
shmac->shmac_number_of_idents);
                        if (hmaclist == NULL) {
                                SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_USRREQ, ENOMEM);
                                error = ENOMEM;

Modified: stable/10/sys/netinet/sctputil.c
==============================================================================
--- stable/10/sys/netinet/sctputil.c    Thu Sep 18 09:22:37 2014        
(r271749)
+++ stable/10/sys/netinet/sctputil.c    Thu Sep 18 09:49:49 2014        
(r271750)
@@ -2403,8 +2403,8 @@ sctp_calculate_rto(struct sctp_tcb *stcb
        net->rtt = (uint64_t) 1000000 *(uint64_t) now.tv_sec +
                (uint64_t) now.tv_usec;
 
-       /* computer rtt in ms */
-       rtt = net->rtt / 1000;
+       /* compute rtt in ms */
+       rtt = (int32_t) (net->rtt / 1000);
        if ((asoc->cc_functions.sctp_rtt_calculated) && (rtt_from_sack == 
SCTP_RTT_FROM_DATA)) {
                /*
                 * Tell the CC module that a new update has just occurred
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to