diff options
| author | ad <ad@NetBSD.org> | 1999-05-23 20:33:50 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 1999-05-23 20:33:50 +0000 |
| commit | ccc7e59e1f495ae0a900e76459858ff8a10cb953 (patch) | |
| tree | a36f8468e9728eccfb9cc60f275f3fce97e874ec /sys | |
| parent | bdf1938edd2f5dfdac486821e6505c40a724e6b5 (diff) | |
Add new sysctl (net.inet.tcp.log_refused) that when set, causes refused TCP
connections to be logged.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/netinet/tcp_input.c | 11 | ||||
| -rw-r--r-- | sys/netinet/tcp_var.h | 8 |
2 files changed, 16 insertions, 3 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 13f33b3cace..0071f5f2f81 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_input.c,v 1.81 1999/05/03 23:30:27 thorpej Exp $ */ +/* $NetBSD: tcp_input.c,v 1.82 1999/05/23 20:33:50 ad Exp $ */ /*- * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. @@ -112,6 +112,7 @@ #include <machine/stdarg.h> int tcprexmtthresh = 3; +int tcp_log_refused; struct tcpiphdr tcp_saveti; #define TCP_PAWS_IDLE (24 * 24 * 60 * 60 * PR_SLOWHZ) @@ -549,6 +550,14 @@ findpcb: inp = in_pcblookup_bind(&tcbtable, ti->ti_dst, ti->ti_dport); if (inp == 0) { ++tcpstat.tcps_noport; + if (tcp_log_refused && (tiflags & TH_SYN)) { + char buf[4*sizeof "123"]; + strcpy(buf, inet_ntoa(ti->ti_dst)); + log(LOG_INFO, + "Connection attempt to TCP %s:%d from %s:%d\n", + buf, ntohs(ti->ti_dport), inet_ntoa(ti->ti_src), + ntohs(ti->ti_sport)); + } goto dropwithreset; } } diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 5e8c125c93a..040d4e9c029 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_var.h,v 1.59 1999/04/29 03:54:23 thorpej Exp $ */ +/* $NetBSD: tcp_var.h,v 1.60 1999/05/23 20:33:51 ad Exp $ */ /*- * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. @@ -455,7 +455,8 @@ struct tcpstat { #define TCPCTL_KEEPCNT 19 /* keepalive count */ #define TCPCTL_SLOWHZ 20 /* PR_SLOWHZ (read-only) */ #define TCPCTL_NEWRENO 21 /* NewReno Congestion Control */ -#define TCPCTL_MAXID 22 +#define TCPCTL_LOG_REFUSED 22 /* Log refused connections */ +#define TCPCTL_MAXID 23 #define TCPCTL_NAMES { \ { 0, 0 }, \ @@ -480,6 +481,7 @@ struct tcpstat { { "keepcnt", CTLTYPE_INT }, \ { "slowhz", CTLTYPE_INT }, \ { "newreno", CTLTYPE_INT }, \ + { "log_refused",CTLTYPE_INT }, \ } #ifdef _KERNEL @@ -501,6 +503,7 @@ extern int tcp_ack_on_push; /* ACK immediately on PUSH */ extern int tcp_syn_cache_limit; /* max entries for compressed state engine */ extern int tcp_syn_bucket_limit;/* max entries per hash bucket */ extern int tcp_syn_cache_interval; /* compressed state timer */ +extern int tcp_log_refused; /* log refused connections */ extern int tcp_syn_cache_size; extern struct syn_cache_head tcp_syn_cache[]; @@ -529,6 +532,7 @@ extern u_long syn_cache_count; { 1, 0, &tcp_keepcnt }, \ { 1, 1, 0, PR_SLOWHZ }, \ { 1, 0, &tcp_do_newreno }, \ + { 1, 0, &tcp_log_refused }, \ } int tcp_attach __P((struct socket *)); |
