NetBSD Problem Report #18669

Received: (qmail 6443 invoked by uid 605); 16 Oct 2002 13:10:45 -0000
Message-Id: <20021016130817.BADCC46B0@stasis.kittenz.org>
Date: Wed, 16 Oct 2002 14:08:17 +0100 (BST)
From: xs@kittenz.org
Sender: gnats-bugs-owner@netbsd.org
Reply-To: xs@kittenz.org
To: gnats-bugs@gnats.netbsd.org
Subject: net.inet.tcp.log_refused may give misleading results
X-Send-Pr-Version: 3.95

>Number:         18669
>Category:       kern
>Synopsis:       net.inet.tcp.log_refused may give misleading results
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 16 13:11:01 +0000 2002
>Closed-Date:    Wed Oct 16 15:16:08 +0000 2002
>Last-Modified:  Mon Oct 21 02:24:01 +0000 2002
>Originator:     
>Release:        NetBSD 1.6I
>Organization:
>Environment:
System: NetBSD stasis 1.6I NetBSD 1.6I (STASIS) #8: Thu Oct 10 13:02:47 BST 2002 xs@stasis:/usr/src/sys/arch/i386/compile/STASIS i386
Architecture: i386
Machine: i386
/sys/netinet/tcp_input.c:
     $NetBSD: tcp_input.c,v 1.155 2002/09/11 02:41:21 itojun Exp $
>Description:
	With net.inet.tcp.log_refused enabled, seemingly impossible
	connection attempts are logged. It turns out that this is
	because only TH_SYN is checked in the header, so, for example,
	TH_SYN|TH_ACK packets are considered connection attempts.

>How-To-Repeat:
	Change tcp4_log_refused to display flags:

Index: tcp_input.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netinet/tcp_input.c,v
retrieving revision 1.155
diff -u -r1.155 tcp_input.c
--- tcp_input.c	2002/09/11 02:41:21	1.155
+++ tcp_input.c	2002/10/13 15:19:44
@@ -729,10 +729,24 @@
 		strcpy(src, "(unknown)");
 		strcpy(dst, "(unknown)");
 	}
+#ifndef TH_ECN
+#define	TH_ECN	0x40
+#endif
+#ifndef TH_CWR
+#define	TH_CWR	0x80
+#endif
 	log(LOG_INFO,
-	    "Connection attempt to TCP %s:%d from %s:%d\n",
+	    "Connection attempt to TCP %s:%d from %s:%d (%c%c%c%c%c%c%c%c)\n",
 	    dst, ntohs(th->th_dport),
-	    src, ntohs(th->th_sport));
+	    src, ntohs(th->th_sport),
+	    (th->th_flags & TH_FIN? 'F': '-'),
+	    (th->th_flags & TH_SYN? 'S': '-'),
+	    (th->th_flags & TH_RST? 'R': '-'),
+	    (th->th_flags & TH_PUSH?'P': '-'),
+	    (th->th_flags & TH_ACK? 'A': '-'),
+	    (th->th_flags & TH_URG? 'U': '-'),
+	    (th->th_flags & TH_ECN? 'E': '-'),
+	    (th->th_flags & TH_CWR? 'C': '-'));
 }
 #endif

	visit various websites. over time, it sometimes yields:

Connection attempt to TCP 10.2.0.2:64785 from 129.128.5.191:80 (-S--A---)

>Fix:
	perhaps check TH_SYN and not TH_ACK and/or display th_flags.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: itojun 
State-Changed-When: Wed Oct 16 08:15:45 PDT 2002 
State-Changed-Why:  
fixed in current, thanks. 

From: Jun-ichiro itojun Hagino <itojun@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/18669 CVS commit: syssrc/sys/netinet
Date: Wed, 16 Oct 2002 18:15:30 +0300 (EEST)

 Module Name:	syssrc
 Committed By:	itojun
 Date:		Wed Oct 16 15:15:30 UTC 2002

 Modified Files:
 	syssrc/sys/netinet: tcp_input.c

 Log Message:
 correct log_refused check (TH_SYN, !TH_RST and !TH_ACK).  PR 18669


 To generate a diff of this commit:
 cvs rdiff -r1.155 -r1.156 syssrc/sys/netinet/tcp_input.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Jun-ichiro itojun Hagino <itojun@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/18669 CVS commit: [netbsd-1-5] syssrc/sys/netinet
Date: Fri, 18 Oct 2002 13:24:43 +0300 (EEST)

 Module Name:	syssrc
 Committed By:	itojun
 Date:		Fri Oct 18 10:24:43 UTC 2002

 Modified Files:
 	basesrc [netbsd-1-5]: CHANGES-1.5.4
 	syssrc/sys/netinet [netbsd-1-5]: tcp_input.c

 Log Message:
 sys/netinet/tcp_input.c				1.156 via patch

   Correct log_refused check (TH_SYN, !TH_RST and !TH_ACK).  Fixes PR#18669.

 (itojun)


 To generate a diff of this commit:
 cvs rdiff -r1.1.2.68 -r1.1.2.69 basesrc/CHANGES-1.5.4
 cvs rdiff -r1.108.4.13 -r1.108.4.14 syssrc/sys/netinet/tcp_input.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Luke Mewburn <lukem@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/18669 CVS commit: [netbsd-1-6] syssrc/sys/netinet
Date: Mon, 21 Oct 2002 05:22:28 +0300 (EEST)

 Module Name:	syssrc
 Committed By:	lukem
 Date:		Mon Oct 21 02:22:27 UTC 2002

 Modified Files:
 	syssrc/sys/netinet [netbsd-1-6]: tcp_input.c

 Log Message:
 Pull up revision 1.156 via patch (requested by itojun in ticket #915):
 correct log_refused check (TH_SYN, !TH_RST and !TH_ACK).  PR 18669


 To generate a diff of this commit:
 cvs rdiff -r1.141.4.3 -r1.141.4.4 syssrc/sys/netinet/tcp_input.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.