summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_subr.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2010-08-18 17:39:47 +0000
committerandre <andre@FreeBSD.org>2010-08-18 17:39:47 +0000
commit82e4bb536ac304054c6d49d74651f89b7846106d (patch)
tree1891fe16b73f945b8252ca062e79b5342b435c56 /sys/netinet/tcp_subr.c
parent95a3f24d1676e8b4016f4dbc0ee2eb63af12ac2f (diff)
downloadFreeBSD-src-82e4bb536ac304054c6d49d74651f89b7846106d.zip
FreeBSD-src-82e4bb536ac304054c6d49d74651f89b7846106d.tar.gz
Untangle the net.inet.tcp.log_in_vain and net.inet.tcp.log_debug
sysctl's and remove any side effects. Both sysctl's share the same backend infrastructure and due to the way it was implemented enabling net.inet.tcp.log_in_vain would also cause log_debug output to be generated. This was surprising and eventually annoying to the user. The log output backend is kept the same but a little shim is inserted to properly separate log_in_vain and log_debug and to remove any side effects. PR: kern/137317 MFC after: 1 week
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r--sys/netinet/tcp_subr.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index f23a540..fe8f79a 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -268,6 +268,8 @@ VNET_DEFINE(uma_zone_t, sack_hole_zone);
static struct inpcb *tcp_notify(struct inpcb *, int);
static void tcp_isn_tick(void *);
+static char * tcp_log_addr(struct in_conninfo *inc, struct tcphdr *th,
+ void *ip4hdr, const void *ip6hdr);
/*
* Target size of TCP PCB hash tables. Must be a power of two.
@@ -2234,9 +2236,33 @@ SYSCTL_PROC(_net_inet_tcp, TCPCTL_DROP, drop,
* and ip6_hdr pointers have to be passed as void pointers.
*/
char *
+tcp_log_vain(struct in_conninfo *inc, struct tcphdr *th, void *ip4hdr,
+ const void *ip6hdr)
+{
+
+ /* Is logging enabled? */
+ if (tcp_log_in_vain == 0)
+ return (NULL);
+
+ return (tcp_log_addr(inc, th, ip4hdr, ip6hdr));
+}
+
+char *
tcp_log_addrs(struct in_conninfo *inc, struct tcphdr *th, void *ip4hdr,
const void *ip6hdr)
{
+
+ /* Is logging enabled? */
+ if (tcp_log_debug == 0)
+ return (NULL);
+
+ return (tcp_log_addr(inc, th, ip4hdr, ip6hdr));
+}
+
+static char *
+tcp_log_addr(struct in_conninfo *inc, struct tcphdr *th, void *ip4hdr,
+ const void *ip6hdr)
+{
char *s, *sp;
size_t size;
struct ip *ip;
@@ -2259,10 +2285,6 @@ tcp_log_addrs(struct in_conninfo *inc, struct tcphdr *th, void *ip4hdr,
2 * INET_ADDRSTRLEN;
#endif /* INET6 */
- /* Is logging enabled? */
- if (tcp_log_debug == 0 && tcp_log_in_vain == 0)
- return (NULL);
-
s = malloc(size, M_TCPLOG, M_ZERO|M_NOWAIT);
if (s == NULL)
return (NULL);
OpenPOWER on IntegriCloud