Changeset View
Standalone View
sys/netinet/tcp_syncache.c
Context not available. | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/hash.h> | #include <sys/hash.h> | ||||
#include <sys/refcount.h> | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
Context not available. | |||||
tp->irs = sc->sc_irs; | tp->irs = sc->sc_irs; | ||||
tcp_rcvseqinit(tp); | tcp_rcvseqinit(tp); | ||||
tcp_sendseqinit(tp); | tcp_sendseqinit(tp); | ||||
if (sc->sc_t_fb && (sc->sc_t_fb != tp->t_fb)) { | |||||
jtl: Why track this at the time the syncache entry is created?
Because we currently will require a… | |||||
rrsAuthorUnsubmitted Not Done Inline ActionsHmm I did not see that the the sync-cache expansion code had a easy If I can access the listening socket at expansion then yes, thats where rrs: Hmm I did not see that the the sync-cache expansion code had a easy
reference back to the… | |||||
/* | |||||
* Our parents t_fb was not the default, | |||||
* is it still valid, if so we need to | |||||
Not Done Inline ActionsIf the listen socket is using a custom stack and the custom stack is removed, this code will effectively switch all new sessions for the listen socket to use the default TCP stack. However, the refcount for the custom TCP stack won't drop to 0 until the listen socket itself is closed. I think it probably is better to keep using the same (custom) TCP stack until the listen socket itself is closed. That seems more predictable. jtl: If the listen socket is using a custom stack and the custom stack is removed, this code will… | |||||
Not Done Inline ActionsWhich is fine but it means you extend it so it continues to be used.. which is rrs: Which is fine but it means you extend it so it continues to be used.. which is
why I did it… | |||||
* release our ref on tp->t_fb and pickup | |||||
* one on the new entry. | |||||
*/ | |||||
struct tcp_function_block *blk; | |||||
blk = find_and_ref_tcp_fb(sc->sc_t_fb); | |||||
if (blk) { | |||||
if (tp->t_fb->tcp_fb_fini) | |||||
(*tp->t_fb->tcp_fb_fini)(tp); | |||||
refcount_release(&tp->t_fb->refcnt); | |||||
Not Done Inline ActionsWe should always find the block, so there should probably be a KASSERT here. jtl: We should always find the block, so there should probably be a KASSERT here. | |||||
Not Done Inline Actionsok rrs: ok | |||||
tp->t_fb = blk; | |||||
if (tp->t_fb->tcp_fb_init) { | |||||
(*tp->t_fb->tcp_fb_init)(tp); | |||||
} | |||||
} | |||||
} | |||||
tp->snd_wl1 = sc->sc_irs; | tp->snd_wl1 = sc->sc_irs; | ||||
tp->snd_max = tp->iss + 1; | tp->snd_max = tp->iss + 1; | ||||
tp->snd_nxt = tp->iss + 1; | tp->snd_nxt = tp->iss + 1; | ||||
Context not available. | |||||
tp->t_keepidle = sototcpcb(lso)->t_keepidle; | tp->t_keepidle = sototcpcb(lso)->t_keepidle; | ||||
tp->t_keepintvl = sototcpcb(lso)->t_keepintvl; | tp->t_keepintvl = sototcpcb(lso)->t_keepintvl; | ||||
tp->t_keepcnt = sototcpcb(lso)->t_keepcnt; | tp->t_keepcnt = sototcpcb(lso)->t_keepcnt; | ||||
tcp_timer_activate(tp, TT_KEEP, TP_KEEPINIT(tp)); | tp->t_fb->tcp_timer_activate(tp, TT_KEEP, TP_KEEPINIT(tp)); | ||||
soisconnected(so); | soisconnected(so); | ||||
Context not available. | |||||
struct label *maclabel; | struct label *maclabel; | ||||
#endif | #endif | ||||
struct syncache scs; | struct syncache scs; | ||||
struct tcp_function_block *blk; | |||||
struct ucred *cred; | struct ucred *cred; | ||||
INP_WLOCK_ASSERT(inp); /* listen socket */ | INP_WLOCK_ASSERT(inp); /* listen socket */ | ||||
Context not available. | |||||
win = sbspace(&so->so_rcv); | win = sbspace(&so->so_rcv); | ||||
sb_hiwat = so->so_rcv.sb_hiwat; | sb_hiwat = so->so_rcv.sb_hiwat; | ||||
ltflags = (tp->t_flags & (TF_NOOPT | TF_SIGNATURE)); | ltflags = (tp->t_flags & (TF_NOOPT | TF_SIGNATURE)); | ||||
blk = tp->t_fb; | |||||
/* By the time we drop the lock these should no longer be used. */ | /* By the time we drop the lock these should no longer be used. */ | ||||
so = NULL; | so = NULL; | ||||
tp = NULL; | tp = NULL; | ||||
Context not available. | |||||
#endif | #endif | ||||
sc->sc_irs = th->th_seq; | sc->sc_irs = th->th_seq; | ||||
sc->sc_iss = arc4random(); | sc->sc_iss = arc4random(); | ||||
sc->sc_t_fb = blk; | |||||
sc->sc_flags = 0; | sc->sc_flags = 0; | ||||
sc->sc_flowlabel = 0; | sc->sc_flowlabel = 0; | ||||
Context not available. |
Why track this at the time the syncache entry is created?
Because we currently will require a common code path through the syncache, we shouldn't need to care which TCP stack is in use until we expand the syncache entry. And, the user can't change the TCP stack once the socket enters the listen state.
If it isn't the default TCP stack, we *do* need to go through the initialization, which this code does.