mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
tcp: improve inp locking in setsockopt
Ensure that the inp is not dropped when starting a stack switch.
While there, clean-up the code by using INP_WLOCK_RECHECK, which
also re-assigns tp.
Reviewed by: glebius
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D45241
(cherry picked from commit fe136aecc2)
This commit is contained in:
parent
e4a4ca83df
commit
d48fcf99c4
1 changed files with 2 additions and 7 deletions
|
|
@ -1696,11 +1696,7 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt)
|
|||
default:
|
||||
return (error);
|
||||
}
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_flags & INP_DROPPED) {
|
||||
INP_WUNLOCK(inp);
|
||||
return (ECONNRESET);
|
||||
}
|
||||
INP_WLOCK_RECHECK(inp);
|
||||
} else if (sopt->sopt_name == TCP_FUNCTION_BLK) {
|
||||
/*
|
||||
* Protect the TCP option TCP_FUNCTION_BLK so
|
||||
|
|
@ -1715,8 +1711,7 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt)
|
|||
if (error)
|
||||
return (error);
|
||||
|
||||
INP_WLOCK(inp);
|
||||
tp = intotcpcb(inp);
|
||||
INP_WLOCK_RECHECK(inp);
|
||||
|
||||
blk = find_and_ref_tcp_functions(&fsn);
|
||||
if (blk == NULL) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue