syncache: simplify syncache_add() KPI to return struct socket pointer
directly, not overwriting the listen socket pointer argument. Not a functional change.
This commit is contained in:
parent
08d9c92027
commit
8d5719aa74
@ -1341,7 +1341,8 @@ tcp_input(struct mbuf **mp, int *offp, int proto)
|
|||||||
#endif
|
#endif
|
||||||
TCP_PROBE3(debug__input, tp, th, m);
|
TCP_PROBE3(debug__input, tp, th, m);
|
||||||
tcp_dooptions(&to, optp, optlen, TO_SYN);
|
tcp_dooptions(&to, optp, optlen, TO_SYN);
|
||||||
if (syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL, iptos))
|
if ((so = syncache_add(&inc, &to, th, inp, so, m, NULL, NULL,
|
||||||
|
iptos)) != NULL)
|
||||||
goto tfo_socket_result;
|
goto tfo_socket_result;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1322,24 +1322,25 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static struct socket *
|
||||||
syncache_tfo_expand(struct syncache *sc, struct socket **lsop, struct mbuf *m,
|
syncache_tfo_expand(struct syncache *sc, struct socket *lso, struct mbuf *m,
|
||||||
uint64_t response_cookie)
|
uint64_t response_cookie)
|
||||||
{
|
{
|
||||||
struct inpcb *inp;
|
struct inpcb *inp;
|
||||||
struct tcpcb *tp;
|
struct tcpcb *tp;
|
||||||
unsigned int *pending_counter;
|
unsigned int *pending_counter;
|
||||||
|
struct socket *so;
|
||||||
|
|
||||||
NET_EPOCH_ASSERT();
|
NET_EPOCH_ASSERT();
|
||||||
|
|
||||||
pending_counter = intotcpcb(sotoinpcb(*lsop))->t_tfo_pending;
|
pending_counter = intotcpcb(sotoinpcb(lso))->t_tfo_pending;
|
||||||
*lsop = syncache_socket(sc, *lsop, m);
|
so = syncache_socket(sc, lso, m);
|
||||||
if (*lsop == NULL) {
|
if (so == NULL) {
|
||||||
TCPSTAT_INC(tcps_sc_aborted);
|
TCPSTAT_INC(tcps_sc_aborted);
|
||||||
atomic_subtract_int(pending_counter, 1);
|
atomic_subtract_int(pending_counter, 1);
|
||||||
} else {
|
} else {
|
||||||
soisconnected(*lsop);
|
soisconnected(so);
|
||||||
inp = sotoinpcb(*lsop);
|
inp = sotoinpcb(so);
|
||||||
tp = intotcpcb(inp);
|
tp = intotcpcb(inp);
|
||||||
tp->t_flags |= TF_FASTOPEN;
|
tp->t_flags |= TF_FASTOPEN;
|
||||||
tp->t_tfo_cookie.server = response_cookie;
|
tp->t_tfo_cookie.server = response_cookie;
|
||||||
@ -1348,6 +1349,8 @@ syncache_tfo_expand(struct syncache *sc, struct socket **lsop, struct mbuf *m,
|
|||||||
tp->t_tfo_pending = pending_counter;
|
tp->t_tfo_pending = pending_counter;
|
||||||
TCPSTAT_INC(tcps_sc_completed);
|
TCPSTAT_INC(tcps_sc_completed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (so);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1369,20 +1372,19 @@ syncache_tfo_expand(struct syncache *sc, struct socket **lsop, struct mbuf *m,
|
|||||||
* be ACKed either when the application sends response data or the delayed
|
* be ACKed either when the application sends response data or the delayed
|
||||||
* ACK timer expires, whichever comes first.
|
* ACK timer expires, whichever comes first.
|
||||||
*/
|
*/
|
||||||
int
|
struct socket *
|
||||||
syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
||||||
struct inpcb *inp, struct socket **lsop, struct mbuf *m, void *tod,
|
struct inpcb *inp, struct socket *so, struct mbuf *m, void *tod,
|
||||||
void *todctx, uint8_t iptos)
|
void *todctx, uint8_t iptos)
|
||||||
{
|
{
|
||||||
struct tcpcb *tp;
|
struct tcpcb *tp;
|
||||||
struct socket *so;
|
struct socket *rv = NULL;
|
||||||
struct syncache *sc = NULL;
|
struct syncache *sc = NULL;
|
||||||
struct syncache_head *sch;
|
struct syncache_head *sch;
|
||||||
struct mbuf *ipopts = NULL;
|
struct mbuf *ipopts = NULL;
|
||||||
u_int ltflags;
|
u_int ltflags;
|
||||||
int win, ip_ttl, ip_tos;
|
int win, ip_ttl, ip_tos;
|
||||||
char *s;
|
char *s;
|
||||||
int rv = 0;
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
int autoflowlabel = 0;
|
int autoflowlabel = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -1405,7 +1407,6 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
|||||||
* Combine all so/tp operations very early to drop the INP lock as
|
* Combine all so/tp operations very early to drop the INP lock as
|
||||||
* soon as possible.
|
* soon as possible.
|
||||||
*/
|
*/
|
||||||
so = *lsop;
|
|
||||||
KASSERT(SOLISTENING(so), ("%s: %p not listening", __func__, so));
|
KASSERT(SOLISTENING(so), ("%s: %p not listening", __func__, so));
|
||||||
tp = sototcpcb(so);
|
tp = sototcpcb(so);
|
||||||
cred = crhold(so->so_cred);
|
cred = crhold(so->so_cred);
|
||||||
@ -1734,9 +1735,8 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
|||||||
SCH_UNLOCK(sch);
|
SCH_UNLOCK(sch);
|
||||||
|
|
||||||
if (tfo_cookie_valid) {
|
if (tfo_cookie_valid) {
|
||||||
syncache_tfo_expand(sc, lsop, m, tfo_response_cookie);
|
rv = syncache_tfo_expand(sc, so, m, tfo_response_cookie);
|
||||||
/* INP_RUNLOCK(inp) will be performed by the caller */
|
/* INP_RUNLOCK(inp) will be performed by the caller */
|
||||||
rv = 1;
|
|
||||||
goto tfo_expanded;
|
goto tfo_expanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1761,10 +1761,8 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
|||||||
done:
|
done:
|
||||||
TCP_PROBE5(receive, NULL, NULL, m, NULL, th);
|
TCP_PROBE5(receive, NULL, NULL, m, NULL, th);
|
||||||
donenoprobe:
|
donenoprobe:
|
||||||
if (m) {
|
if (m)
|
||||||
*lsop = NULL;
|
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* If tfo_pending is not NULL here, then a TFO SYN that did not
|
* If tfo_pending is not NULL here, then a TFO SYN that did not
|
||||||
* result in a new socket was processed and the associated pending
|
* result in a new socket was processed and the associated pending
|
||||||
|
@ -43,8 +43,8 @@ void syncache_destroy(void);
|
|||||||
void syncache_unreach(struct in_conninfo *, tcp_seq);
|
void syncache_unreach(struct in_conninfo *, tcp_seq);
|
||||||
int syncache_expand(struct in_conninfo *, struct tcpopt *,
|
int syncache_expand(struct in_conninfo *, struct tcpopt *,
|
||||||
struct tcphdr *, struct socket **, struct mbuf *);
|
struct tcphdr *, struct socket **, struct mbuf *);
|
||||||
int syncache_add(struct in_conninfo *, struct tcpopt *,
|
struct socket * syncache_add(struct in_conninfo *, struct tcpopt *,
|
||||||
struct tcphdr *, struct inpcb *, struct socket **, struct mbuf *,
|
struct tcphdr *, struct inpcb *, struct socket *, struct mbuf *,
|
||||||
void *, void *, uint8_t);
|
void *, void *, uint8_t);
|
||||||
void syncache_chkrst(struct in_conninfo *, struct tcphdr *, struct mbuf *);
|
void syncache_chkrst(struct in_conninfo *, struct tcphdr *, struct mbuf *);
|
||||||
void syncache_badack(struct in_conninfo *);
|
void syncache_badack(struct in_conninfo *);
|
||||||
|
@ -348,11 +348,11 @@ void
|
|||||||
toe_syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
toe_syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
||||||
struct inpcb *inp, void *tod, void *todctx, uint8_t iptos)
|
struct inpcb *inp, void *tod, void *todctx, uint8_t iptos)
|
||||||
{
|
{
|
||||||
struct socket *lso = inp->inp_socket;
|
|
||||||
|
|
||||||
INP_WLOCK_ASSERT(inp);
|
INP_WLOCK_ASSERT(inp);
|
||||||
|
|
||||||
syncache_add(inc, to, th, inp, &lso, NULL, tod, todctx, iptos);
|
(void )syncache_add(inc, to, th, inp, inp->inp_socket, NULL, tod,
|
||||||
|
todctx, iptos);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user