Skip to content

Commit

Permalink
Fix FreeBSD kernel specific bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
tuexen committed Jul 28, 2023
1 parent 130ddb1 commit b096653
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
10 changes: 9 additions & 1 deletion usrsctplib/netinet/sctp_os_userspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,15 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index);
#define SCTP_SOWAKEUP(so) wakeup(&(so)->so_timeo, so)
/* number of bytes ready to read */
#define SCTP_SBAVAIL(sb) (sb)->sb_cc
/* clear the socket buffer state */
#define SCTP_SB_INCR(sb, incr) \
{ \
atomic_add_int(&(sb)->sb_cc, incr); \
}
#define SCTP_SB_DECR(sb, decr) \
{ \
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, incr); \
}
s/* clear the socket buffer state */

This comment has been minimized.

Copy link
@fleetwoodstack

fleetwoodstack Jul 31, 2023

This is a typo that is causing build errors downstream

This comment has been minimized.

Copy link
@fleetwoodstack

fleetwoodstack Jul 31, 2023

I've fixed this here
#684

#define SCTP_SB_CLEAR(sb) \
(sb).sb_cc = 0; \
(sb).sb_mb = NULL; \
Expand Down
2 changes: 1 addition & 1 deletion usrsctplib/netinet/sctp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -7874,7 +7874,7 @@ sctp_move_to_outqueue(struct sctp_tcb *stcb,
if ((stcb->sctp_socket != NULL) &&
((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) {
atomic_subtract_int(&stcb->sctp_socket->so_snd.sb_cc, sp->length);
SCTP_SB_DECR(&stcb->sctp_socket->so_snd, sp->length);
}
if (sp->data) {
sctp_m_freem(sp->data);
Expand Down
2 changes: 1 addition & 1 deletion usrsctplib/netinet/sctp_pcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4184,7 +4184,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
TAILQ_REMOVE(&inp->read_queue, sq, next);
sctp_free_remote_addr(sq->whoFrom);
if (so)
so->so_rcv.sb_cc -= sq->length;
SCTP_SB_DECR(&so->so_rcv, sq->length);
if (sq->data) {
sctp_m_freem(sq->data);
sq->data = NULL;
Expand Down
8 changes: 4 additions & 4 deletions usrsctplib/netinet/sctp_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ extern struct pr_usrreqs sctp_usrreqs;
}

#define sctp_sbfree(ctl, stcb, sb, m) { \
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
SCTP_SB_DECR(sb, SCTP_BUF_LEN((m))); \
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \
if (((ctl)->do_not_ref_stcb == 0) && stcb) {\
SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
Expand All @@ -219,7 +219,7 @@ extern struct pr_usrreqs sctp_usrreqs;
}

#define sctp_sballoc(stcb, sb, m) { \
atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \
SCTP_SB_INCR(sb, SCTP_BUF_LEN((m))); \
atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \
if (stcb) { \
atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
Expand Down Expand Up @@ -250,7 +250,7 @@ extern struct pr_usrreqs sctp_usrreqs;
}

#define sctp_sbfree(ctl, stcb, sb, m) { \
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
SCTP_SB_DECR(sb, SCTP_BUF_LEN((m))); \
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \
if (((ctl)->do_not_ref_stcb == 0) && stcb) { \
SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
Expand All @@ -259,7 +259,7 @@ extern struct pr_usrreqs sctp_usrreqs;
}

#define sctp_sballoc(stcb, sb, m) { \
atomic_add_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
SCTP_SB_INCR(sb, SCTP_BUF_LEN((m))); \
atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \
if (stcb) { \
atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
Expand Down
4 changes: 2 additions & 2 deletions usrsctplib/netinet/sctputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -5544,7 +5544,7 @@ sctp_free_bufspace(struct sctp_tcb *stcb, struct sctp_association *asoc,
if ((stcb->sctp_socket != NULL) &&
(((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) ||
((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)))) {
SCTP_SAVE_ATOMIC_DECREMENT(&stcb->sctp_socket->so_snd.sb_cc, tp1->book_size);
SCTP_SB_DECR(&stcb->sctp_socket->so_snd, tp1->book_size);
}
}

Expand Down Expand Up @@ -6754,7 +6754,7 @@ sctp_sorecvmsg(struct socket *so,
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SB_LOGGING_ENABLE) {
sctp_sblog(&so->so_rcv, control->do_not_ref_stcb?NULL:stcb, SCTP_LOG_SBFREE, (int)cp_len);
}
SCTP_SAVE_ATOMIC_DECREMENT(&so->so_rcv.sb_cc, (int)cp_len);
SCTP_SB_DECR(&so->so_rcv, (int)cp_len);
if ((control->do_not_ref_stcb == 0) &&
stcb) {
atomic_subtract_int(&stcb->asoc.sb_cc, (int)cp_len);
Expand Down
4 changes: 2 additions & 2 deletions usrsctplib/netinet/sctputil.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ do { \
} \
if (stcb->sctp_socket && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \
SCTP_SAVE_ATOMIC_DECREMENT(&stcb->sctp_socket->so_snd.sb_cc, sp->length); \
SCTP_SB_DECR(&stcb->sctp_socket->so_snd, sp->length); \
} \
} \
} while (0)
Expand All @@ -299,7 +299,7 @@ do { \
if ((stcb->sctp_socket != NULL) && \
((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \
atomic_add_int(&stcb->sctp_socket->so_snd.sb_cc,sz); \
SCTP_SB_INCR(&stcb->sctp_socket->so_snd, sz); \
} \
} while (0)

Expand Down

0 comments on commit b096653

Please sign in to comment.