- Get rid of the sctp_inpcb_free() "magic numbers", now they

are sensible defines that tell what you are directing
   the function to do.
This commit is contained in:
Randall Stewart 2007-05-08 15:53:03 +00:00
parent 6a955a7506
commit b0552ae214
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=169380
5 changed files with 37 additions and 14 deletions

View File

@ -898,6 +898,16 @@ __FBSDID("$FreeBSD$");
* detracts a small amount for ipv4 but it
* simplifies the ipv6 addition */
/* Argument magic number for sctp_inpcb_free() */
/* third argument */
#define SCTP_CALLED_DIRECTLY_NOCMPSET 0
#define SCTP_CALLED_AFTER_CMPSET_OFCLOSE 1
/* second argument */
#define SCTP_FREE_SHOULD_USE_ABORT 1
#define SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE 0
#ifndef IPPROTO_SCTP
#define IPPROTO_SCTP 132 /* the Official IANA number :-) */
#endif /* !IPPROTO_SCTP */

View File

@ -2533,7 +2533,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
/*
* First time through we have the socket lock, after that no more.
*/
if (from == 1) {
if (from == SCTP_CALLED_AFTER_CMPSET_OFCLOSE) {
/*
* Once we are in we can remove the flag from = 1 is only
* passed from the actual closing routines that are called
@ -2556,7 +2556,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
ip_pcb = &inp->ip_inp.inp; /* we could just cast the main pointer
* here but I will be nice :> (i.e.
* ip_pcb = ep;) */
if (immediate == 0) {
if (immediate == SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE) {
int cnt_in_sd;
cnt_in_sd = 0;
@ -4192,7 +4192,9 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
* if the socket closes at the same time we are here
* we might collide in the cleanup.
*/
sctp_inpcb_free(inp, 0, 0);
sctp_inpcb_free(inp,
SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE,
SCTP_CALLED_DIRECTLY_NOCMPSET);
SCTP_INP_DECR_REF(inp);
goto out_of;
} else {

View File

@ -456,7 +456,8 @@ sctp_abort(struct socket *so)
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 16);
#endif
sctp_inpcb_free(inp, 1, 1);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_AFTER_CMPSET_OFCLOSE);
SOCK_LOCK(so);
SCTP_SB_CLEAR(so->so_snd);
/*
@ -521,7 +522,8 @@ sctp_attach(struct socket *so, int proto, struct thread *p)
sctp_log_closing(inp, NULL, 15);
#endif
SCTP_INP_WUNLOCK(inp);
sctp_inpcb_free(inp, 1, 1);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_AFTER_CMPSET_OFCLOSE);
} else {
SCTP_INP_WUNLOCK(inp);
}
@ -577,12 +579,14 @@ sctp_close(struct socket *so)
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 13);
#endif
sctp_inpcb_free(inp, 1, 1);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_AFTER_CMPSET_OFCLOSE);
} else {
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 14);
#endif
sctp_inpcb_free(inp, 0, 1);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE,
SCTP_CALLED_AFTER_CMPSET_OFCLOSE);
}
/*
* The socket is now detached, no matter what the state of

View File

@ -1669,7 +1669,8 @@ sctp_timeout_handler(void *t)
*/
SCTP_INP_DECR_REF(inp);
sctp_timer_stop(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL, SCTP_FROM_SCTPUTIL + SCTP_LOC_3);
sctp_inpcb_free(inp, 1, 0);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_DIRECTLY_NOCMPSET);
goto out_no_decr;
break;
default:
@ -3515,7 +3516,8 @@ sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
} else {
if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
if (LIST_FIRST(&inp->sctp_asoc_list) == NULL) {
sctp_inpcb_free(inp, 1, 0);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_DIRECTLY_NOCMPSET);
}
}
}
@ -3592,7 +3594,8 @@ sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
/* Got to have a TCB */
if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
if (LIST_FIRST(&inp->sctp_asoc_list) == NULL) {
sctp_inpcb_free(inp, 1, 0);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_DIRECTLY_NOCMPSET);
}
}
return;
@ -3627,7 +3630,8 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh,
/* Generate a TO address for future reference */
if (inp && (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
if (LIST_FIRST(&inp->sctp_asoc_list) == NULL) {
sctp_inpcb_free(inp, 1, 0);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_DIRECTLY_NOCMPSET);
}
}
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset,

View File

@ -522,7 +522,8 @@ sctp6_abort(struct socket *so)
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 16);
#endif
sctp_inpcb_free(inp, 1, 0);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
SCTP_CALLED_AFTER_CMPSET_OFCLOSE);
SOCK_LOCK(so);
SCTP_SB_CLEAR(so->so_snd);
/*
@ -665,12 +666,14 @@ sctp6_close(struct socket *so)
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 13);
#endif
sctp_inpcb_free(inp, 1, 1);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT
,SCTP_CALLED_AFTER_CMPSET_OFCLOSE);
} else {
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 14);
#endif
sctp_inpcb_free(inp, 0, 1);
sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE,
SCTP_CALLED_AFTER_CMPSET_OFCLOSE);
}
/*
* The socket is now detached, no matter what the state of