mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-17 05:43:59 +00:00
Add INP_INHASHLIST flag for inpcb->inp_flags to indicate whether
or not the inpcb is currenty on various hash lookup lists, rather than using (lport != 0) to detect this. This means that the full 4-tuple of a connection can be retained after close, which should lead to more sensible netstat output in the window between TCP close and socket close. MFC after: 2 weeks
This commit is contained in:
parent
b993cf2e76
commit
111d57a69c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=189657
|
@ -1,7 +1,7 @@
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1982, 1986, 1991, 1993, 1995
|
* Copyright (c) 1982, 1986, 1991, 1993, 1995
|
||||||
* The Regents of the University of California.
|
* The Regents of the University of California.
|
||||||
* Copyright (c) 2007-2008 Robert N. M. Watson
|
* Copyright (c) 2007-2009 Robert N. M. Watson
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -1032,7 +1032,7 @@ in_pcbdrop(struct inpcb *inp)
|
||||||
INP_WLOCK_ASSERT(inp);
|
INP_WLOCK_ASSERT(inp);
|
||||||
|
|
||||||
inp->inp_vflag |= INP_DROPPED;
|
inp->inp_vflag |= INP_DROPPED;
|
||||||
if (inp->inp_lport) {
|
if (inp->inp_flags & INP_INHASHLIST) {
|
||||||
struct inpcbport *phd = inp->inp_phd;
|
struct inpcbport *phd = inp->inp_phd;
|
||||||
|
|
||||||
LIST_REMOVE(inp, inp_hash);
|
LIST_REMOVE(inp, inp_hash);
|
||||||
|
@ -1041,7 +1041,7 @@ in_pcbdrop(struct inpcb *inp)
|
||||||
LIST_REMOVE(phd, phd_hash);
|
LIST_REMOVE(phd, phd_hash);
|
||||||
free(phd, M_PCB);
|
free(phd, M_PCB);
|
||||||
}
|
}
|
||||||
inp->inp_lport = 0;
|
inp->inp_flags &= ~INP_INHASHLIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1421,6 +1421,8 @@ in_pcbinshash(struct inpcb *inp)
|
||||||
|
|
||||||
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
||||||
INP_WLOCK_ASSERT(inp);
|
INP_WLOCK_ASSERT(inp);
|
||||||
|
KASSERT((inp->inp_flags & INP_INHASHLIST) == 0,
|
||||||
|
("in_pcbinshash: INP_INHASHLIST"));
|
||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
if (inp->inp_vflag & INP_IPV6)
|
if (inp->inp_vflag & INP_IPV6)
|
||||||
|
@ -1457,6 +1459,7 @@ in_pcbinshash(struct inpcb *inp)
|
||||||
inp->inp_phd = phd;
|
inp->inp_phd = phd;
|
||||||
LIST_INSERT_HEAD(&phd->phd_pcblist, inp, inp_portlist);
|
LIST_INSERT_HEAD(&phd->phd_pcblist, inp, inp_portlist);
|
||||||
LIST_INSERT_HEAD(pcbhash, inp, inp_hash);
|
LIST_INSERT_HEAD(pcbhash, inp, inp_hash);
|
||||||
|
inp->inp_flags |= INP_INHASHLIST;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1475,6 +1478,8 @@ in_pcbrehash(struct inpcb *inp)
|
||||||
|
|
||||||
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
||||||
INP_WLOCK_ASSERT(inp);
|
INP_WLOCK_ASSERT(inp);
|
||||||
|
KASSERT(inp->inp_flags & INP_INHASHLIST,
|
||||||
|
("in_pcbrehash: !INP_INHASHLIST"));
|
||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
if (inp->inp_vflag & INP_IPV6)
|
if (inp->inp_vflag & INP_IPV6)
|
||||||
|
@ -1502,7 +1507,7 @@ in_pcbremlists(struct inpcb *inp)
|
||||||
INP_WLOCK_ASSERT(inp);
|
INP_WLOCK_ASSERT(inp);
|
||||||
|
|
||||||
inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
|
inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
|
||||||
if (inp->inp_lport) {
|
if (inp->inp_flags & INP_INHASHLIST) {
|
||||||
struct inpcbport *phd = inp->inp_phd;
|
struct inpcbport *phd = inp->inp_phd;
|
||||||
|
|
||||||
LIST_REMOVE(inp, inp_hash);
|
LIST_REMOVE(inp, inp_hash);
|
||||||
|
@ -1511,6 +1516,7 @@ in_pcbremlists(struct inpcb *inp)
|
||||||
LIST_REMOVE(phd, phd_hash);
|
LIST_REMOVE(phd, phd_hash);
|
||||||
free(phd, M_PCB);
|
free(phd, M_PCB);
|
||||||
}
|
}
|
||||||
|
inp->inp_flags &= ~INP_INHASHLIST;
|
||||||
}
|
}
|
||||||
LIST_REMOVE(inp, inp_list);
|
LIST_REMOVE(inp, inp_list);
|
||||||
pcbinfo->ipi_count--;
|
pcbinfo->ipi_count--;
|
||||||
|
|
|
@ -406,6 +406,7 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
|
||||||
#define INP_DONTFRAG 0x800 /* don't fragment packet */
|
#define INP_DONTFRAG 0x800 /* don't fragment packet */
|
||||||
#define INP_NONLOCALOK 0x1000 /* Allow bind to spoof any address */
|
#define INP_NONLOCALOK 0x1000 /* Allow bind to spoof any address */
|
||||||
/* - requires options IP_NONLOCALBIND */
|
/* - requires options IP_NONLOCALBIND */
|
||||||
|
#define INP_INHASHLIST 0x2000 /* in_pcbinshash() has been called */
|
||||||
|
|
||||||
#define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */
|
#define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue