Skip to content

Commit

Permalink
Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
tuexen committed Aug 8, 2023
1 parent be1d96f commit 9a8fc34
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 76 deletions.
10 changes: 4 additions & 6 deletions usrsctplib/netinet/sctp_usrreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,10 @@ SYSCTL_PROC(_net_inet_sctp, OID_AUTO, getcred,
"Get the ucred of a SCTP connection");
#endif

#ifdef INET
#if defined(_WIN32) || defined(__Userspace__)
int
#elif defined(__FreeBSD__)
static void
#if defined(__FreeBSD__) && !defined(__Userspace__)
void
#else
static int
int
#endif
sctp_abort(struct socket *so)
{
Expand Down Expand Up @@ -725,6 +722,7 @@ sctp_abort(struct socket *so)
#endif
}

#ifdef INET
#if defined(__Userspace__)
int
#else
Expand Down
5 changes: 5 additions & 0 deletions usrsctplib/netinet/sctp_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ void sctp_close(struct socket *so);
#else
int sctp_detach(struct socket *so);
#endif
#if defined(__FreeBSD__) && !defined(__Userspace__)
void sctp_abort(struct socket *so);
#else
int sctp_abort(struct socket *so);
#endif
int sctp_disconnect(struct socket *so);
#if !defined(__Userspace__)
#if defined(__APPLE__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN)
Expand Down
73 changes: 3 additions & 70 deletions usrsctplib/netinet6/sctp6_usrreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,73 +732,6 @@ SYSCTL_PROC(_net_inet6_sctp6, OID_AUTO, getcred,
"Get the ucred of a SCTP6 connection");
#endif

/* This is the same as the sctp_abort() could be made common */
#if defined(__Userspace__)
int
#elif defined(__FreeBSD__) || defined(_WIN32)
static void
#else
static int
#endif
sctp6_abort(struct socket *so)
{
#if defined(__FreeBSD__) && !defined(__Userspace__)
struct epoch_tracker et;
#endif
struct sctp_inpcb *inp;
uint32_t flags;

inp = (struct sctp_inpcb *)so->so_pcb;
if (inp == NULL) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
#if (defined(__FreeBSD__) || defined(_WIN32)) && !defined(__Userspace__)
return;
#else
return (EINVAL);
#endif
}
#if defined(__FreeBSD__) && !defined(__Userspace__)
NET_EPOCH_ENTER(et);
#endif
sctp_must_try_again:
flags = inp->sctp_flags;
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 17);
#endif
if (((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) &&
(atomic_cmpset_int(&inp->sctp_flags, flags, (flags | SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP)))) {
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 16);
#endif
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_AFTER_CMPSET_OFCLOSE);
SOCK_LOCK(so);
SCTP_SB_CLEAR(so->so_snd);
/* same for the rcv ones, they are only
* here for the accounting/select.
*/
SCTP_SB_CLEAR(so->so_rcv);
#if defined(__APPLE__) && !defined(__Userspace__)
so->so_usecount--;
#else
/* Now null out the reference, we are completely detached. */
so->so_pcb = NULL;
#endif
SOCK_UNLOCK(so);
} else {
flags = inp->sctp_flags;
if ((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) {
goto sctp_must_try_again;
}
}
#if defined(__FreeBSD__) && !defined(__Userspace__)
NET_EPOCH_EXIT(et);
return;
#else
return (0);
#endif
}

#if defined(__Userspace__)
int
sctp6_attach(struct socket *so, int proto SCTP_UNUSED, uint32_t vrf_id)
Expand Down Expand Up @@ -1733,7 +1666,7 @@ sctp6_getpeeraddr(struct socket *so, struct mbuf *nam)
#define SCTP6_PROTOSW \
.pr_protocol = IPPROTO_SCTP, \
.pr_ctloutput = sctp_ctloutput, \
.pr_abort = sctp6_abort, \
.pr_abort = sctp_abort, \
.pr_accept = sctp_accept, \
.pr_attach = sctp6_attach, \
.pr_bind = sctp6_bind, \
Expand Down Expand Up @@ -1766,7 +1699,7 @@ struct protosw sctp6_stream_protosw = {
#else
struct pr_usrreqs sctp6_usrreqs = {
#if defined(__APPLE__) && !defined(__Userspace__)
.pru_abort = sctp6_abort,
.pru_abort = sctp_abort,
.pru_accept = sctp_accept,
.pru_attach = sctp6_attach,
.pru_bind = sctp6_bind,
Expand All @@ -1787,7 +1720,7 @@ struct pr_usrreqs sctp6_usrreqs = {
.pru_soreceive = sctp_soreceive,
.pru_sopoll = sopoll
#elif defined(_WIN32) && !defined(__Userspace__)
sctp6_abort,
sctp_abort,
sctp_accept,
sctp6_attach,
sctp6_bind,
Expand Down

0 comments on commit 9a8fc34

Please sign in to comment.