Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/uipc_ktls.c
Show First 20 Lines • Show All 803 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
ktls_try_toe(struct socket *so, struct ktls_session *tls, int direction) | ktls_try_toe(struct socket *so, struct ktls_session *tls, int direction) | ||||
{ | { | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
struct tcpcb *tp; | struct tcpcb *tp; | ||||
int error; | int error; | ||||
inp = so->so_pcb; | inp = so->so_pcb; | ||||
INP_WLOCK(inp); | INP_WLOCK(inp); | ||||
if (inp->inp_flags2 & INP_FREED) { | |||||
INP_WUNLOCK(inp); | |||||
return (ECONNRESET); | |||||
} | |||||
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | ||||
rrs: Your comment above
"SMR section makes it safe to access a pcb after it went through uma_zfree… | |||||
Done Inline ActionsThe comment belongs to in_pcb.c only. When we came to a pcb via a CK list pointer, then we must check this flag, and this is what inp_smr_lock() or inp_list_next() do. Nobody outside in_pcb.c shall come to a pcb via CK list pointers. glebius: The comment belongs to in_pcb.c only. When we came to a pcb via a CK list pointer, then we must… | |||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
return (ECONNRESET); | return (ECONNRESET); | ||||
} | } | ||||
if (inp->inp_socket == NULL) { | if (inp->inp_socket == NULL) { | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
return (ECONNRESET); | return (ECONNRESET); | ||||
} | } | ||||
tp = intotcpcb(inp); | tp = intotcpcb(inp); | ||||
Show All 34 Lines | |||||
{ | { | ||||
union if_snd_tag_alloc_params params; | union if_snd_tag_alloc_params params; | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
struct nhop_object *nh; | struct nhop_object *nh; | ||||
struct tcpcb *tp; | struct tcpcb *tp; | ||||
int error; | int error; | ||||
INP_RLOCK(inp); | INP_RLOCK(inp); | ||||
if (inp->inp_flags2 & INP_FREED) { | |||||
INP_RUNLOCK(inp); | |||||
return (ECONNRESET); | |||||
} | |||||
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | ||||
INP_RUNLOCK(inp); | INP_RUNLOCK(inp); | ||||
return (ECONNRESET); | return (ECONNRESET); | ||||
} | } | ||||
if (inp->inp_socket == NULL) { | if (inp->inp_socket == NULL) { | ||||
INP_RUNLOCK(inp); | INP_RUNLOCK(inp); | ||||
return (ECONNRESET); | return (ECONNRESET); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,591 Lines • ▼ Show 20 Lines | ktls_disable_ifnet_help(void *context, int pending __unused) | ||||
tls = context; | tls = context; | ||||
inp = tls->inp; | inp = tls->inp; | ||||
if (inp == NULL) | if (inp == NULL) | ||||
return; | return; | ||||
INP_WLOCK(inp); | INP_WLOCK(inp); | ||||
so = inp->inp_socket; | so = inp->inp_socket; | ||||
MPASS(so != NULL); | MPASS(so != NULL); | ||||
if ((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) || | if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | ||||
(inp->inp_flags2 & INP_FREED)) { | |||||
goto out; | goto out; | ||||
} | } | ||||
if (so->so_snd.sb_tls_info != NULL) | if (so->so_snd.sb_tls_info != NULL) | ||||
err = ktls_set_tx_mode(so, TCP_TLS_MODE_SW); | err = ktls_set_tx_mode(so, TCP_TLS_MODE_SW); | ||||
else | else | ||||
err = ENXIO; | err = ENXIO; | ||||
if (err == 0) { | if (err == 0) { | ||||
counter_u64_add(ktls_ifnet_disable_ok, 1); | counter_u64_add(ktls_ifnet_disable_ok, 1); | ||||
/* ktls_set_tx_mode() drops inp wlock, so recheck flags */ | /* ktls_set_tx_mode() drops inp wlock, so recheck flags */ | ||||
if ((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0 && | if ((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0 && | ||||
(inp->inp_flags2 & INP_FREED) == 0 && | |||||
(tp = intotcpcb(inp)) != NULL && | (tp = intotcpcb(inp)) != NULL && | ||||
tp->t_fb->tfb_hwtls_change != NULL) | tp->t_fb->tfb_hwtls_change != NULL) | ||||
(*tp->t_fb->tfb_hwtls_change)(tp, 0); | (*tp->t_fb->tfb_hwtls_change)(tp, 0); | ||||
} else { | } else { | ||||
counter_u64_add(ktls_ifnet_disable_fail, 1); | counter_u64_add(ktls_ifnet_disable_fail, 1); | ||||
} | } | ||||
out: | out: | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |
Your comment above
"SMR section makes it safe to access a pcb after it went through uma_zfree(). We always want a particular pcb locked, so after successful lookup and lock we just check INP_FREED."
confuses me here. The comment implies that we need to check INP_FREED, but yet here you remove that. Is the comment wrong or misleading? Did you mean we no-longer check INP_FREED maybe??