summaryrefslogtreecommitdiffstats
path: root/sys/netinet/sctputil.c
diff options
context:
space:
mode:
authorrrs <rrs@FreeBSD.org>2006-11-05 13:25:18 +0000
committerrrs <rrs@FreeBSD.org>2006-11-05 13:25:18 +0000
commit20dc61d3a46238522e738dd8dde26965d5ce46dd (patch)
tree0917b677ec5366916adb9fc52ff977feb016deb1 /sys/netinet/sctputil.c
parent21ab4f8a250dc1903e52406d7a88f2bc912fb733 (diff)
downloadFreeBSD-src-20dc61d3a46238522e738dd8dde26965d5ce46dd.zip
FreeBSD-src-20dc61d3a46238522e738dd8dde26965d5ce46dd.tar.gz
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 :-(
Diffstat (limited to 'sys/netinet/sctputil.c')
-rw-r--r--sys/netinet/sctputil.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index bcd7c45..45ebbe5 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -164,7 +164,7 @@ sctp_sblog(struct sockbuf *sb,
sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_SB;
- sctp_clog[sctp_cwnd_log_at].x.sb.stcb = (uint32_t) stcb;
+ sctp_clog[sctp_cwnd_log_at].x.sb.stcb = stcb;
sctp_clog[sctp_cwnd_log_at].x.sb.so_sbcc = sb->sb_cc;
if (stcb)
sctp_clog[sctp_cwnd_log_at].x.sb.stcb_sbcc = stcb->asoc.sb_cc;
@@ -182,10 +182,10 @@ sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc)
sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
sctp_clog[sctp_cwnd_log_at].from = 0;
sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_CLOSE;
- sctp_clog[sctp_cwnd_log_at].x.close.inp = (uint32_t) inp;
+ sctp_clog[sctp_cwnd_log_at].x.close.inp = (void *)inp;
sctp_clog[sctp_cwnd_log_at].x.close.sctp_flags = inp->sctp_flags;
if (stcb) {
- sctp_clog[sctp_cwnd_log_at].x.close.stcb = (uint32_t) stcb;
+ sctp_clog[sctp_cwnd_log_at].x.close.stcb = (void *)stcb;
sctp_clog[sctp_cwnd_log_at].x.close.state = (uint16_t) stcb->asoc.state;
} else {
sctp_clog[sctp_cwnd_log_at].x.close.stcb = 0;
@@ -204,7 +204,7 @@ rto_logging(struct sctp_nets *net, int from)
sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_RTT;
- sctp_clog[sctp_cwnd_log_at].x.rto.net = (uint32_t) net;
+ sctp_clog[sctp_cwnd_log_at].x.rto.net = (void *)net;
sctp_clog[sctp_cwnd_log_at].x.rto.rtt = net->prev_rtt;
sctp_clog[sctp_cwnd_log_at].x.rto.rttvar = net->rtt_variance;
sctp_clog[sctp_cwnd_log_at].x.rto.direction = net->rto_variance_dir;
@@ -234,7 +234,7 @@ sctp_log_nagle_event(struct sctp_tcb *stcb, int action)
sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
sctp_clog[sctp_cwnd_log_at].from = (uint8_t) action;
sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_NAGLE;
- sctp_clog[sctp_cwnd_log_at].x.nagle.stcb = (uint32_t) stcb;
+ sctp_clog[sctp_cwnd_log_at].x.nagle.stcb = (void *)stcb;
sctp_clog[sctp_cwnd_log_at].x.nagle.total_flight = stcb->asoc.total_flight;
sctp_clog[sctp_cwnd_log_at].x.nagle.total_in_queue = stcb->asoc.total_output_queue_size;
sctp_clog[sctp_cwnd_log_at].x.nagle.count_in_queue = stcb->asoc.chunks_on_out_queue;
@@ -377,8 +377,8 @@ sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from)
sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_LOCK_EVENT;
- sctp_clog[sctp_cwnd_log_at].x.lock.sock = (uint32_t) inp->sctp_socket;
- sctp_clog[sctp_cwnd_log_at].x.lock.inp = (uint32_t) inp;
+ sctp_clog[sctp_cwnd_log_at].x.lock.sock = (void *)inp->sctp_socket;
+ sctp_clog[sctp_cwnd_log_at].x.lock.inp = (void *)inp;
if (stcb) {
sctp_clog[sctp_cwnd_log_at].x.lock.tcb_lock = mtx_owned(&stcb->tcb_mtx);
} else {
@@ -495,7 +495,7 @@ sctp_wakeup_log(struct sctp_tcb *stcb, uint32_t cumtsn, uint32_t wake_cnt, int f
sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_WAKE;
- sctp_clog[sctp_cwnd_log_at].x.wake.stcb = (uint32_t) stcb;
+ sctp_clog[sctp_cwnd_log_at].x.wake.stcb = (void *)stcb;
sctp_clog[sctp_cwnd_log_at].x.wake.wake_cnt = wake_cnt;
sctp_clog[sctp_cwnd_log_at].x.wake.flight = stcb->asoc.total_flight_count;
sctp_clog[sctp_cwnd_log_at].x.wake.send_q = stcb->asoc.send_queue_cnt;
@@ -1309,9 +1309,9 @@ sctp_timeout_handler(void *t)
return;
}
if (stcb) {
- atomic_add_16(&stcb->asoc.refcnt, 1);
+ atomic_add_int(&stcb->asoc.refcnt, 1);
SCTP_TCB_LOCK(stcb);
- atomic_add_16(&stcb->asoc.refcnt, -1);
+ atomic_add_int(&stcb->asoc.refcnt, -1);
}
/* mark as being serviced now */
callout_deactivate(&tmr->timer);
@@ -3003,6 +3003,7 @@ sctp_notify_partial_delivery_indication(struct sctp_tcb *stcb,
}
if (no_lock == 0)
SCTP_INP_READ_UNLOCK(stcb->sctp_ep);
+ sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket);
} else {
/* append to socket */
add_to_end:
@@ -4198,15 +4199,13 @@ sctp_user_rcvd(struct sctp_tcb *stcb, int *freed_so_far, int hold_rlock,
{
/* User pulled some data, do we need a rwnd update? */
int r_unlocked = 0;
- int tcb_incr_up = 0;
uint32_t dif, rwnd;
struct socket *so = NULL;
if (stcb == NULL)
return;
- atomic_add_16(&stcb->asoc.refcnt, 1);
- tcb_incr_up = 1;
+ atomic_add_int(&stcb->asoc.refcnt, 1);
if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
/* Pre-check If we are freeing no update */
@@ -4291,9 +4290,7 @@ out:
}
SCTP_INP_DECR_REF(stcb->sctp_ep);
no_lock:
- if (tcb_incr_up) {
- atomic_add_16(&stcb->asoc.refcnt, -1);
- }
+ atomic_add_int(&stcb->asoc.refcnt, -1);
return;
}
@@ -4571,7 +4568,8 @@ found_one:
if (stcb) {
if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) &&
(control->do_not_ref_stcb == 0)) {
- stcb = NULL;
+ if (freecnt_applied == 0)
+ stcb = NULL;
} else if (control->do_not_ref_stcb == 0) {
/* you can't free it on me please */
/*
@@ -4581,7 +4579,7 @@ found_one:
* to increment, we need to use the atomic add to
* the refcnt
*/
- atomic_add_16(&stcb->asoc.refcnt, 1);
+ atomic_add_int(&stcb->asoc.refcnt, 1);
freecnt_applied = 1;
/*
* Setup to remember how much we have not yet told
@@ -5043,7 +5041,20 @@ wait_some_more:
}
goto wait_some_more;
} else if (control->data == NULL) {
- panic("Impossible data==NULL length !=0");
+ /*
+ * we must re-sync since data is probably being
+ * added
+ */
+ SCTP_INP_READ_LOCK(inp);
+ if ((control->length > 0) && (control->data == NULL)) {
+ /*
+ * big trouble.. we have the lock and its
+ * corrupt?
+ */
+ panic("Impossible data==NULL length !=0");
+ }
+ SCTP_INP_READ_UNLOCK(inp);
+ /* We will fall around to get more data */
}
goto get_more_data;
} else {
@@ -5277,14 +5288,17 @@ out:
SOCKBUF_UNLOCK(&so->so_rcv);
hold_sblock = 0;
}
- if ((stcb) && freecnt_applied) {
+ if (freecnt_applied) {
/*
* The lock on the socket buffer protects us so the free
* code will stop. But since we used the socketbuf lock and
* the sender uses the tcb_lock to increment, we need to use
* the atomic add to the refcnt.
*/
- atomic_add_16(&stcb->asoc.refcnt, -1);
+ if (stcb == NULL) {
+ panic("stcb for refcnt has gone NULL?");
+ }
+ atomic_add_int(&stcb->asoc.refcnt, -1);
freecnt_applied = 0;
/* Save the value back for next time */
stcb->freed_by_sorcv_sincelast = freed_so_far;
OpenPOWER on IntegriCloud