Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netipsec/xform_tcp.c
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
#define TCP_KEYLEN_MAX 80 /* maximum length of TCP-MD5 key */ | #define TCP_KEYLEN_MAX 80 /* maximum length of TCP-MD5 key */ | ||||
static int | static int | ||||
tcp_ipsec_pcbctl(struct inpcb *inp, struct sockopt *sopt) | tcp_ipsec_pcbctl(struct inpcb *inp, struct sockopt *sopt) | ||||
{ | { | ||||
struct tcpcb *tp; | struct tcpcb *tp; | ||||
int error, optval; | int error, optval; | ||||
INP_WLOCK_ASSERT(inp); | |||||
if (sopt->sopt_name != TCP_MD5SIG) { | if (sopt->sopt_name != TCP_MD5SIG) { | ||||
INP_WUNLOCK(inp); | |||||
return (ENOPROTOOPT); | return (ENOPROTOOPT); | ||||
} | } | ||||
tp = intotcpcb(inp); | |||||
if (sopt->sopt_dir == SOPT_GET) { | if (sopt->sopt_dir == SOPT_GET) { | ||||
INP_RLOCK(inp); | |||||
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | |||||
INP_RUNLOCK(inp); | |||||
return (ECONNRESET); | |||||
} | |||||
tp = intotcpcb(inp); | |||||
optval = (tp->t_flags & TF_SIGNATURE) ? 1 : 0; | optval = (tp->t_flags & TF_SIGNATURE) ? 1 : 0; | ||||
INP_WUNLOCK(inp); | INP_RUNLOCK(inp); | ||||
/* On success return with released INP_WLOCK */ | /* On success return with released INP_WLOCK */ | ||||
return (sooptcopyout(sopt, &optval, sizeof(optval))); | return (sooptcopyout(sopt, &optval, sizeof(optval))); | ||||
} | } | ||||
INP_WUNLOCK(inp); | |||||
error = sooptcopyin(sopt, &optval, sizeof(optval), sizeof(optval)); | error = sooptcopyin(sopt, &optval, sizeof(optval), sizeof(optval)); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
/* INP_WLOCK_RECHECK */ | /* INP_WLOCK_RECHECK */ | ||||
INP_WLOCK(inp); | INP_WLOCK(inp); | ||||
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
return (ECONNRESET); | return (ECONNRESET); | ||||
} | } | ||||
tp = intotcpcb(inp); | |||||
if (optval > 0) | if (optval > 0) | ||||
tp->t_flags |= TF_SIGNATURE; | tp->t_flags |= TF_SIGNATURE; | ||||
else | else | ||||
tp->t_flags &= ~TF_SIGNATURE; | tp->t_flags &= ~TF_SIGNATURE; | ||||
/* On success return with acquired INP_WLOCK */ | INP_WUNLOCK(inp); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* Callback function invoked by m_apply() to digest TCP segment data | * Callback function invoked by m_apply() to digest TCP segment data | ||||
* contained within an mbuf chain. | * contained within an mbuf chain. | ||||
*/ | */ | ||||
static int | static int | ||||
▲ Show 20 Lines • Show All 304 Lines • Show Last 20 Lines |