inpcb: apply smr_advance(9)/smr_wait(9) trick only to reusable sockets
The protocols marked with PR_CONNREQUIRED can never go through pr_connect
after being disconnected. This is a tiny improvement of fdb987bebd.
While here push clearing of the addresses under the same condition.
Although this clearing originates from pre-FreeBSD times, it actually
makes sense only for protocols that can reconnect.
Reviewed by: pouria, markj
Differential Revision: https://reviews.freebsd.org/D55661
This commit is contained in:
@@ -1433,11 +1433,13 @@ in_pcbdisconnect(struct inpcb *inp)
|
||||
|
||||
in_pcbremhash_locked(inp);
|
||||
|
||||
/* See the comment in in_pcbinshash(). */
|
||||
inp->inp_smr = smr_advance(inp->inp_pcbinfo->ipi_smr);
|
||||
inp->inp_laddr.s_addr = INADDR_ANY;
|
||||
inp->inp_faddr.s_addr = INADDR_ANY;
|
||||
inp->inp_fport = 0;
|
||||
if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) {
|
||||
/* See the comment in in_pcbinshash(). */
|
||||
inp->inp_smr = smr_advance(inp->inp_pcbinfo->ipi_smr);
|
||||
inp->inp_laddr.s_addr = INADDR_ANY;
|
||||
inp->inp_faddr.s_addr = INADDR_ANY;
|
||||
inp->inp_fport = 0;
|
||||
}
|
||||
}
|
||||
#endif /* INET */
|
||||
|
||||
|
||||
@@ -510,13 +510,14 @@ in6_pcbdisconnect(struct inpcb *inp)
|
||||
|
||||
in_pcbremhash_locked(inp);
|
||||
|
||||
/* See the comment in in_pcbinshash(). */
|
||||
inp->inp_smr = smr_advance(inp->inp_pcbinfo->ipi_smr);
|
||||
|
||||
/* XXX-MJ torn writes are visible to SMR lookup */
|
||||
memset(&inp->in6p_laddr, 0, sizeof(inp->in6p_laddr));
|
||||
memset(&inp->in6p_faddr, 0, sizeof(inp->in6p_faddr));
|
||||
inp->inp_fport = 0;
|
||||
if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) {
|
||||
/* See the comment in in_pcbinshash(). */
|
||||
inp->inp_smr = smr_advance(inp->inp_pcbinfo->ipi_smr);
|
||||
/* XXX-MJ torn writes are visible to SMR lookup */
|
||||
memset(&inp->in6p_laddr, 0, sizeof(inp->in6p_laddr));
|
||||
memset(&inp->in6p_faddr, 0, sizeof(inp->in6p_faddr));
|
||||
inp->inp_fport = 0;
|
||||
}
|
||||
/* clear flowinfo - draft-itojun-ipv6-flowlabel-api-00 */
|
||||
inp->inp_flow &= ~IPV6_FLOWLABEL_MASK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user