From root@gw.alfabank.kiev.ua  Mon Nov 28 14:05:14 2005
Return-Path: <root@gw.alfabank.kiev.ua>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3138716A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 28 Nov 2005 14:05:14 +0000 (GMT)
	(envelope-from root@gw.alfabank.kiev.ua)
Received: from gw.alfabank.kiev.ua (pajaro.alfabank.kiev.ua [80.91.172.227])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A09E443D5A
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 28 Nov 2005 14:05:13 +0000 (GMT)
	(envelope-from root@gw.alfabank.kiev.ua)
Received: by gw.alfabank.kiev.ua (Postfix, from userid 0)
	id DA11E4512AD; Mon, 28 Nov 2005 16:05:10 +0200 (EET)
Message-Id: <20051128140510.DA11E4512AD@gw.alfabank.kiev.ua>
Date: Mon, 28 Nov 2005 16:05:10 +0200 (EET)
From: don_oles@able.com.ua
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: tcpflow port not working with local interface, patch provided
X-Send-Pr-Version: 3.113
X-GNATS-Notify: jose@we.lc.ehu.es

>Number:         89672
>Category:       ports
>Synopsis:       tcpflow port not working with local interface, patch provided
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lawrance
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 28 14:10:05 GMT 2005
>Closed-Date:    Tue Dec 13 05:49:36 GMT 2005
>Last-Modified:  Tue Dec 13 05:49:36 GMT 2005
>Originator:     Oles Hnatkevych
>Release:        FreeBSD 4.11-STABLE i386
>Organization:
>Environment:
System: FreeBSD pajaro.kiev.ua.alfa 4.11-STABLE FreeBSD 4.11-STABLE #17: Thu Jun 30 17:56:26 EEST 2005 root@pajaro.kiev.ua.alfa:/usr/src/sys/compile/PAJARO i386


>Description:
	The tcpflow-0.21 port (the latest) does not work with packets going through local interface, it treats them as invalid packets.
>How-To-Repeat:
	Just do it. tcpflow -c -i lo0 won't show anything.
>Fix:
	The file datalink patch below. The patch code is derived from tcpdump sources coming with the system.
	(I'm afraid the removing &lt; &gt; comments also will patch the patch code below, the SWAPLONG definition)


--------------------- cut ------------------------------------------------
--- datalink.c.orig     Mon May  9 12:00:38 2005
+++ datalink.c  Mon May  9 12:23:47 2005
@@ -42,6 +42,13 @@

 #include "tcpflow.h"

+/*
+ * Byte-swap a 32-bit number.
+ * ("htonl()" or "ntohl()" won't work - we want to byte-swap even on
+ * big-endian platforms.)
+ */
+#define SWAPLONG(y) \
+((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))


 /* The DLT_NULL packet header is 4 bytes long. It contains a network
@@ -71,7 +78,8 @@
 #ifndef DLT_NULL_BROKEN
   /* make sure this is AF_INET */
   memcpy((char *)&family, (char *)p, sizeof(family));
-  family = ntohl(family);
+  // family = ntohl(family);
+  if ((family & 0xFFFF0000) != 0) family = SWAPLONG(family);
   if (family != AF_INET) {
     DEBUG(6) ("warning: received non-AF_INET null frame (type %d)", family);
     return;
--------------------- cut ------------------------------------------------
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Mon Nov 28 22:43:10 GMT 2005 
State-Changed-Why:  
Awaiting maintainers feedback 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89672 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: jose@we.lc.ehu.es
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/89672: net/tcpflow port not working with local interface, patch provided
Date: Mon, 28 Nov 2005 22:43:05 UT

 Maintainer of net/tcpflow,
 
 Please note that PR ports/89672 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/89672
 
 -- 
 Edwin Groothuis
 edwin@FreeBSD.org
Responsible-Changed-From-To: freebsd-ports-bugs->lawrance 
Responsible-Changed-By: lawrance 
Responsible-Changed-When: Mon Dec 12 04:53:09 UTC 2005 
Responsible-Changed-Why:  
Take 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89672 

From: Sam Lawrance <lawrance@FreeBSD.org>
To: bug-followup@FreeBSD.org, don_oles@able.com.ua
Cc:  
Subject: Re: ports/89672: tcpflow port not working with local interface, patch provided
Date: Mon, 12 Dec 2005 15:56:10 +1100

 On a 6.0 system, tcpflow doesn't show any traffic on lo0 - even with  
 the patch.  I haven't got a 4.x system to test on.
 
 Any ideas?
 
State-Changed-From-To: feedback->analyzed 
State-Changed-By: lawrance 
State-Changed-When: Tue Dec 13 05:37:19 UTC 2005 
State-Changed-Why:  
Never mind, it was pilot error!  Works great. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89672 
State-Changed-From-To: analyzed->closed 
State-Changed-By: lawrance 
State-Changed-When: Tue Dec 13 05:49:35 UTC 2005 
State-Changed-Why:  
Committed, thanks for the patch! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89672 
>Unformatted:
