summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authortuexen <tuexen@FreeBSD.org>2014-09-18 09:49:49 +0000
committertuexen <tuexen@FreeBSD.org>2014-09-18 09:49:49 +0000
commita2c29a6744004bbb52691c07a95730b1fdfb6861 (patch)
treef971ea84100168b96bbd86ef8779eb6065155168 /sys/netinet
parent30b741cb6cc4d4e580e6d52448dc1d40b34c4c93 (diff)
downloadFreeBSD-src-a2c29a6744004bbb52691c07a95730b1fdfb6861.zip
FreeBSD-src-a2c29a6744004bbb52691c07a95730b1fdfb6861.tar.gz
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)
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/sctp_auth.c6
-rw-r--r--sys/netinet/sctp_auth.h2
-rw-r--r--sys/netinet/sctp_cc_functions.c11
-rw-r--r--sys/netinet/sctp_os_bsd.h2
-rw-r--r--sys/netinet/sctp_output.c2
-rw-r--r--sys/netinet/sctp_pcb.c4
-rw-r--r--sys/netinet/sctp_structs.h4
-rw-r--r--sys/netinet/sctp_usrreq.c5
-rw-r--r--sys/netinet/sctputil.c4
9 files changed, 19 insertions, 21 deletions
diff --git a/sys/netinet/sctp_auth.c b/sys/netinet/sctp_auth.c
index 1f30103..8ce2aab 100644
--- a/sys/netinet/sctp_auth.c
+++ b/sys/netinet/sctp_auth.c
@@ -631,7 +631,7 @@ sctp_copy_skeylist(const struct sctp_keyhead *src, struct sctp_keyhead *dest)
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_tcb *stcb, struct mbuf *m,
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;
diff --git a/sys/netinet/sctp_auth.h b/sys/netinet/sctp_auth.h
index 423a5cc..b98764e 100644
--- a/sys/netinet/sctp_auth.h
+++ b/sys/netinet/sctp_auth.h
@@ -154,7 +154,7 @@ sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t keyid,
/* 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);
diff --git a/sys/netinet/sctp_cc_functions.c b/sys/netinet/sctp_cc_functions.c
index d788ff2..e32faf9 100644
--- a/sys/netinet/sctp_cc_functions.c
+++ b/sys/netinet/sctp_cc_functions.c
@@ -1130,12 +1130,9 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb,
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(struct sctp_tcb *stcb,
* 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(struct sctp_tcb *stcb,
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) {
diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h
index ea79dd4..e926808 100644
--- a/sys/netinet/sctp_os_bsd.h
+++ b/sys/netinet/sctp_os_bsd.h
@@ -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) \
diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index 6dfc5cf..c9b7722 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -11301,7 +11301,7 @@ sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net, int so_locked
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) {
/*
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index 58945f7..6b74968 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -6513,8 +6513,8 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
}
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;
diff --git a/sys/netinet/sctp_structs.h b/sys/netinet/sctp_structs.h
index 24c456c..3f6d935 100644
--- a/sys/netinet/sctp_structs.h
+++ b/sys/netinet/sctp_structs.h
@@ -418,8 +418,8 @@ TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk);
#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;
};
diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c
index be1831b..e1fa351 100644
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -4208,12 +4208,13 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
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;
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index d99fa45..fde23ef 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -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
OpenPOWER on IntegriCloud