From nobody@FreeBSD.org  Tue Feb  5 21:19:00 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3A17B16A41B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  5 Feb 2008 21:19:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 2975913C45B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  5 Feb 2008 21:19:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m15LGwMR016592
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 5 Feb 2008 21:16:58 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m15LGwZB016590;
	Tue, 5 Feb 2008 21:16:58 GMT
	(envelope-from nobody)
Message-Id: <200802052116.m15LGwZB016590@www.freebsd.org>
Date: Tue, 5 Feb 2008 21:16:58 GMT
From: Mike Neuman <mcn@EnGarde.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Netgraph Source assumes 32-bit timeval on AMD64
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         120304
>Category:       kern
>Synopsis:       [netgraph] [patch] netgraph source assumes 32-bit timeval on AMD64
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-net
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 05 21:20:02 UTC 2008
>Closed-Date:    
>Last-Modified:  Mon May 13 08:40:00 UTC 2013
>Originator:     Mike Neuman
>Release:        6.3-RELEASE
>Organization:
En Garde Systems
>Environment:
FreeBSD xeonpm.engarde.com 6.3-RELEASE FreeBSD 6.3-RELEASE #0: Tue Feb  5 10:54:16 PST 2008     mcn@xeonpm.engarde.com:/usr/src/sys/amd64/compile/PRIVATE  amd64
>Description:
The ng_source module assumes that struct timevals contain 32-bit fields,
which is not the case on amd64 machines.
>How-To-Repeat:
kldload ng_ether
ngctl mkpeer em0: source orphans output
nghook em0:orphans input <raw-packet.cap
ngctl msg em0:orphans start 16
ngctl msg em0:orphans getstats

Note the stats show the various timevals precessing based upon word length.
>Fix:
The fix for amd64 is simple, however the patch is not suitable because
it should handle both 32-bit and 64-bit timeval lengths. I did not readily
find the proper way to do this.

Patch attached with submission follows:

*** sys/netgraph/ng_source.c.orig	Tue Feb  5 13:00:47 2008
--- sys/netgraph/ng_source.c	Tue Feb  5 12:17:36 2008
***************
*** 113,120 ****
  
  /* Parse type for timeval */
  static const struct ng_parse_struct_field ng_source_timeval_type_fields[] = {
! 	{ "tv_sec",		&ng_parse_int32_type	},
! 	{ "tv_usec",		&ng_parse_int32_type	},
  	{ NULL }
  };
  const struct ng_parse_type ng_source_timeval_type = {
--- 113,120 ----
  
  /* Parse type for timeval */
  static const struct ng_parse_struct_field ng_source_timeval_type_fields[] = {
! 	{ "tv_sec",		&ng_parse_int64_type	},
! 	{ "tv_usec",		&ng_parse_int64_type	},
  	{ NULL }
  };
  const struct ng_parse_type ng_source_timeval_type = {


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Feb 5 22:29:47 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer(s). 

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

From: Eugene Grosbein <egrosbein@rdtc.ru>
To: bug-followup@FreeBSD.ORG, "net@freebsd.org" <net@FreeBSD.ORG>
Cc:  
Subject: Re: kern/120304: [netgraph] [patch] netgraph source assumes 32-bit
 timeval on AMD64
Date: Tue, 07 Aug 2012 19:38:08 +0700

 Hi!
 
 This is still the problem for 9.1-PRERELEASE: ng_source is unusable for 64bit systems.
 The patch really helps and fixes the problem for 64bit (and breaks for 32bit :-)
 
 Perhaps, it may be improved with some #ifdef's
 
 Eugene Grosbein

From: Mitya <mitya@cabletv.dp.ua>
To: bug-followup@FreeBSD.org, mcn@EnGarde.com
Cc:  
Subject: Re: kern/120304: [netgraph] [patch] netgraph source assumes 32-bit
 timeval on AMD64
Date: Mon, 13 May 2013 11:01:20 +0300

 This is a multi-part message in MIME format.
 --------------000802080404020703030804
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 7bit
 
 This is a more accuracy patch
 
 --------------000802080404020703030804
 Content-Type: text/plain; charset=UTF-8;
  name="ng_source.c.diff"
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment;
  filename="ng_source.c.diff"
 
 LS0tIG5nX3NvdXJjZS5jLm9yaWcJMjAxMS0wOS0yMyAwMzo1MTozNy4wMDAwMDAwMDAgKzAz
 MDAKKysrIG5nX3NvdXJjZS5jCTIwMTMtMDUtMDMgMTQ6MTg6MTguMDAwMDAwMDAwICswMzAw
 CkBAIC0xMjYsOCArMTI2LDE2IEBACiAKIC8qIFBhcnNlIHR5cGUgZm9yIHRpbWV2YWwgKi8K
 IHN0YXRpYyBjb25zdCBzdHJ1Y3QgbmdfcGFyc2Vfc3RydWN0X2ZpZWxkIG5nX3NvdXJjZV90
 aW1ldmFsX3R5cGVfZmllbGRzW10gPSB7CisjaWYgZGVmaW5lZChfX0xQNjRfXykgfHwgZGVm
 aW5lZChfX2FybV9fKSB8fCBkZWZpbmVkKF9fbWlwc19fKQorCXsgInR2X3NlYyIsCQkmbmdf
 cGFyc2VfaW50NjRfdHlwZQl9LAorI2Vsc2UKIAl7ICJ0dl9zZWMiLAkJJm5nX3BhcnNlX2lu
 dDMyX3R5cGUJfSwKKyNlbmRpZgorI2lmIGRlZmluZWQoX19MUDY0X18pCisJeyAidHZfdXNl
 YyIsCQkmbmdfcGFyc2VfaW50NjRfdHlwZQl9LAorI2Vsc2UKIAl7ICJ0dl91c2VjIiwJCSZu
 Z19wYXJzZV9pbnQzMl90eXBlCX0sCisjZW5kaWYKIAl7IE5VTEwgfQogfTsKIGNvbnN0IHN0
 cnVjdCBuZ19wYXJzZV90eXBlIG5nX3NvdXJjZV90aW1ldmFsX3R5cGUgPSB7Cg==
 --------------000802080404020703030804--
>Unformatted:
