Change inp_ppcb from caddr_t to void *, fix/remove associated related
casts. Consistently use intotw() to cast inp_ppcb pointers to struct tcptw * pointers. Consistently use intotcpcb() to cast inp_ppcb pointers to struct tcpcb * pointers. Don't assign tp to the results to intotcpcb() during variable declation at the top of functions, as that is before the asserts relating to locking have been performed. Do this later in the function after appropriate assertions have run to allow that operation to be conisdered safe. MFC after: 3 months
This commit is contained in:
parent
4586157b3a
commit
d67aff8ec4
@ -865,6 +865,7 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr,
|
||||
u_int lport_arg, int wild_okay)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
struct tcptw *tw;
|
||||
#ifdef INET6
|
||||
int matchwild = 3 + INP_LOOKUP_MAPPED_PCB_COST;
|
||||
#else
|
||||
@ -948,9 +949,10 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr,
|
||||
* are clogging up needed local ports.
|
||||
*/
|
||||
if ((inp->inp_vflag & INP_TIMEWAIT) != 0) {
|
||||
if (tcp_twrecycleable((struct tcptw *)inp->inp_ppcb)) {
|
||||
tw = intotw(inp);
|
||||
if (tcp_twrecycleable(tw)) {
|
||||
INP_LOCK(inp);
|
||||
tcp_twclose((struct tcptw *)inp->inp_ppcb, 0);
|
||||
tcp_twclose(tw, 0);
|
||||
match = NULL;
|
||||
goto retrylookup;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ struct inpcb {
|
||||
/* local and foreign ports, local and foreign addr */
|
||||
struct in_conninfo inp_inc;
|
||||
|
||||
caddr_t inp_ppcb; /* pointer to per-protocol pcb */
|
||||
void *inp_ppcb; /* pointer to per-protocol pcb */
|
||||
struct inpcbinfo *inp_pcbinfo; /* PCB list info */
|
||||
struct socket *inp_socket; /* back pointer to socket */
|
||||
/* list for this PCB's local port */
|
||||
|
@ -760,8 +760,7 @@ tcp_input(m, off0)
|
||||
*/
|
||||
if (thflags & TH_SYN)
|
||||
tcp_dooptions(&to, optp, optlen, 1);
|
||||
if (tcp_timewait((struct tcptw *)inp->inp_ppcb,
|
||||
&to, th, m, tlen))
|
||||
if (tcp_timewait(intotw(inp), &to, th, m, tlen))
|
||||
goto findpcb;
|
||||
/*
|
||||
* tcp_timewait unlocks inp.
|
||||
|
@ -760,8 +760,7 @@ tcp_input(m, off0)
|
||||
*/
|
||||
if (thflags & TH_SYN)
|
||||
tcp_dooptions(&to, optp, optlen, 1);
|
||||
if (tcp_timewait((struct tcptw *)inp->inp_ppcb,
|
||||
&to, th, m, tlen))
|
||||
if (tcp_timewait(intotw(inp), &to, th, m, tlen))
|
||||
goto findpcb;
|
||||
/*
|
||||
* tcp_timewait unlocks inp.
|
||||
|
@ -622,7 +622,7 @@ tcp_newtcpcb(struct inpcb *inp)
|
||||
* which may match an IPv4-mapped IPv6 address.
|
||||
*/
|
||||
inp->inp_ip_ttl = ip_defttl;
|
||||
inp->inp_ppcb = (caddr_t)tp;
|
||||
inp->inp_ppcb = tp;
|
||||
return (tp); /* XXX */
|
||||
}
|
||||
|
||||
@ -848,10 +848,11 @@ tcp_drain(void)
|
||||
static struct inpcb *
|
||||
tcp_notify(struct inpcb *inp, int error)
|
||||
{
|
||||
struct tcpcb *tp = (struct tcpcb *)inp->inp_ppcb;
|
||||
struct tcpcb *tp;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
tp = intotcpcb(inp);
|
||||
|
||||
/*
|
||||
* Ignore some errors if we are hooked up.
|
||||
@ -958,7 +959,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
inp = inp_list[i];
|
||||
if (inp->inp_gencnt <= gencnt) {
|
||||
struct xtcpcb xt;
|
||||
caddr_t inp_ppcb;
|
||||
void *inp_ppcb;
|
||||
|
||||
bzero(&xt, sizeof(xt));
|
||||
xt.xt_len = sizeof xt;
|
||||
@ -1429,10 +1430,11 @@ tcp_isn_tick(void *xtp)
|
||||
struct inpcb *
|
||||
tcp_drop_syn_sent(struct inpcb *inp, int errno)
|
||||
{
|
||||
struct tcpcb *tp = intotcpcb(inp);
|
||||
struct tcpcb *tp;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
tp = intotcpcb(inp);
|
||||
|
||||
if (tp != NULL && tp->t_state == TCPS_SYN_SENT) {
|
||||
tp = tcp_drop(tp, errno);
|
||||
@ -1453,7 +1455,7 @@ tcp_drop_syn_sent(struct inpcb *inp, int errno)
|
||||
struct inpcb *
|
||||
tcp_mtudisc(struct inpcb *inp, int errno)
|
||||
{
|
||||
struct tcpcb *tp = intotcpcb(inp);
|
||||
struct tcpcb *tp;
|
||||
struct socket *so = inp->inp_socket;
|
||||
u_int maxmtu;
|
||||
u_int romtu;
|
||||
@ -1463,6 +1465,7 @@ tcp_mtudisc(struct inpcb *inp, int errno)
|
||||
#endif /* INET6 */
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
tp = intotcpcb(inp);
|
||||
if (tp != NULL) {
|
||||
#ifdef INET6
|
||||
isipv6 = (tp->t_inpcb->inp_vflag & INP_IPV6) != 0;
|
||||
@ -1720,7 +1723,7 @@ tcp_twstart(struct tcpcb *tp)
|
||||
SOCK_UNLOCK(so);
|
||||
if (acknow)
|
||||
tcp_twrespond(tw, TH_ACK);
|
||||
inp->inp_ppcb = (caddr_t)tw;
|
||||
inp->inp_ppcb = tw;
|
||||
inp->inp_vflag |= INP_TIMEWAIT;
|
||||
tcp_timer_2msl_reset(tw, tw_time);
|
||||
|
||||
@ -1799,7 +1802,7 @@ tcp_twclose(struct tcptw *tw, int reuse)
|
||||
*/
|
||||
inp = tw->tw_inpcb;
|
||||
KASSERT((inp->inp_vflag & INP_TIMEWAIT), ("tcp_twclose: !timewait"));
|
||||
KASSERT(inp->inp_ppcb == (void *)tw, ("tcp_twclose: inp_ppcb != tw"));
|
||||
KASSERT(intotw(inp) == tw, ("tcp_twclose: inp_ppcb != tw"));
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo); /* tcp_timer_2msl_stop(). */
|
||||
INP_LOCK_ASSERT(inp);
|
||||
|
||||
|
@ -622,7 +622,7 @@ tcp_newtcpcb(struct inpcb *inp)
|
||||
* which may match an IPv4-mapped IPv6 address.
|
||||
*/
|
||||
inp->inp_ip_ttl = ip_defttl;
|
||||
inp->inp_ppcb = (caddr_t)tp;
|
||||
inp->inp_ppcb = tp;
|
||||
return (tp); /* XXX */
|
||||
}
|
||||
|
||||
@ -848,10 +848,11 @@ tcp_drain(void)
|
||||
static struct inpcb *
|
||||
tcp_notify(struct inpcb *inp, int error)
|
||||
{
|
||||
struct tcpcb *tp = (struct tcpcb *)inp->inp_ppcb;
|
||||
struct tcpcb *tp;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
tp = intotcpcb(inp);
|
||||
|
||||
/*
|
||||
* Ignore some errors if we are hooked up.
|
||||
@ -958,7 +959,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
inp = inp_list[i];
|
||||
if (inp->inp_gencnt <= gencnt) {
|
||||
struct xtcpcb xt;
|
||||
caddr_t inp_ppcb;
|
||||
void *inp_ppcb;
|
||||
|
||||
bzero(&xt, sizeof(xt));
|
||||
xt.xt_len = sizeof xt;
|
||||
@ -1429,10 +1430,11 @@ tcp_isn_tick(void *xtp)
|
||||
struct inpcb *
|
||||
tcp_drop_syn_sent(struct inpcb *inp, int errno)
|
||||
{
|
||||
struct tcpcb *tp = intotcpcb(inp);
|
||||
struct tcpcb *tp;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
tp = intotcpcb(inp);
|
||||
|
||||
if (tp != NULL && tp->t_state == TCPS_SYN_SENT) {
|
||||
tp = tcp_drop(tp, errno);
|
||||
@ -1453,7 +1455,7 @@ tcp_drop_syn_sent(struct inpcb *inp, int errno)
|
||||
struct inpcb *
|
||||
tcp_mtudisc(struct inpcb *inp, int errno)
|
||||
{
|
||||
struct tcpcb *tp = intotcpcb(inp);
|
||||
struct tcpcb *tp;
|
||||
struct socket *so = inp->inp_socket;
|
||||
u_int maxmtu;
|
||||
u_int romtu;
|
||||
@ -1463,6 +1465,7 @@ tcp_mtudisc(struct inpcb *inp, int errno)
|
||||
#endif /* INET6 */
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
tp = intotcpcb(inp);
|
||||
if (tp != NULL) {
|
||||
#ifdef INET6
|
||||
isipv6 = (tp->t_inpcb->inp_vflag & INP_IPV6) != 0;
|
||||
@ -1720,7 +1723,7 @@ tcp_twstart(struct tcpcb *tp)
|
||||
SOCK_UNLOCK(so);
|
||||
if (acknow)
|
||||
tcp_twrespond(tw, TH_ACK);
|
||||
inp->inp_ppcb = (caddr_t)tw;
|
||||
inp->inp_ppcb = tw;
|
||||
inp->inp_vflag |= INP_TIMEWAIT;
|
||||
tcp_timer_2msl_reset(tw, tw_time);
|
||||
|
||||
@ -1799,7 +1802,7 @@ tcp_twclose(struct tcptw *tw, int reuse)
|
||||
*/
|
||||
inp = tw->tw_inpcb;
|
||||
KASSERT((inp->inp_vflag & INP_TIMEWAIT), ("tcp_twclose: !timewait"));
|
||||
KASSERT(inp->inp_ppcb == (void *)tw, ("tcp_twclose: inp_ppcb != tw"));
|
||||
KASSERT(intotw(inp) == tw, ("tcp_twclose: inp_ppcb != tw"));
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo); /* tcp_timer_2msl_stop(). */
|
||||
INP_LOCK_ASSERT(inp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user