From root@ns.palladant.ru  Mon Jan 12 23:25:58 2004
Return-Path: <root@ns.palladant.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3912016A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 12 Jan 2004 23:25:58 -0800 (PST)
Received: from ns.palladant.ru (c2950post-fe-0-6.tagnet.ru [80.78.104.38])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A6B3F43D53
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 12 Jan 2004 23:25:56 -0800 (PST)
	(envelope-from root@ns.palladant.ru)
Received: from root by ns.palladant.ru with local (Exim 4.24; FreeBSD)
	id 1AgIvy-0006Ph-J7
	for FreeBSD-gnats-submit@freebsd.org; Tue, 13 Jan 2004 12:25:54 +0500
Message-Id: <E1AgIvy-0006Ph-J7@ns.palladant.ru>
Date: Tue, 13 Jan 2004 12:25:54 +0500
From: boris@tagnet.ru
Reply-To: boris@tagnet.ru
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] PPP sends incorrect data to RADIUS where OctetsIn or OctetsOut are going over UINT32_MAX
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         61294
>Category:       bin
>Synopsis:       [patch] PPP sends incorrect data to RADIUS where OctetsIn or OctetsOut are going over UINT32_MAX
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    dds
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 12 23:30:18 PST 2004
>Closed-Date:    Tue Jun 15 20:41:54 EEST 2004
>Last-Modified:  Tue Jun 15 20:41:54 EEST 2004
>Originator:     Boris Kovalenko
>Release:        FreeBSD 5.1-RELEASE-p10 i386
>Organization:
JSC Tagnet
>Environment:
System: FreeBSD ns.palladant.ru 5.1-RELEASE-p10 FreeBSD 5.1-RELEASE-p10 #3: Thu Nov 20 09:50:51 YEKT 2003 root@ns.palladant.ru:/usr/src/sys/i386/compile/PALLADA i386


	
>Description:
    When RADIUS is enabled in PPP it send its accounting data to RADIUS. 
    OctetsIn and OctetsOut are defined as unsigned long long (UINT64) values,
    but RADIUS allows only UINT32 values, so we are loosing information when
    values goes over UINT32_MAX limit. RFC2869 defines two new RADIUS attributes
    Acct-Input-Gigawords and Acct-Output-Gigawords to tell the RADIUS how many
    times Acct-Input-Octets and Acct-Output-Octets has wrapped around UINT32_MAX.
    So we need to put this attributes in RADIUS request and also modify OctetsIn
    and OctetsOut as needed.
>How-To-Repeat:
    Try to download more then 4G with PPP connection. This is really possible
    if use PPPoE.
>Fix:
    Patches attached.
    
--- radlib.h.diff begins here ---
--- radlib.h.orig	Tue Jan 13 09:01:15 2004
+++ radlib.h	Tue Jan 13 11:29:44 2004
@@ -168,6 +168,9 @@
         #define RAD_TERM_HOST_REQUEST		18
 #define	RAD_ACCT_MULTI_SESSION_ID	50	/* String */
 #define	RAD_ACCT_LINK_COUNT		51	/* Integer */
+/* RFC 2869 */
+#define	RAD_ACCT_INPUT_GIGAWORDS	52
+#define	RAD_ACCT_OUTPUT_GIGAWORDS	53
 
 struct rad_handle;
 struct timeval;
--- radlib.h.diff ends here ---

--- radius.c.diff begins here ---
--- radius.c.orig	Sat Jun 28 21:37:04 2003
+++ radius.c	Tue Jan 13 11:40:37 2004
@@ -27,6 +27,7 @@
  *
  */
 
+#include <stdint.h>
 #include <sys/param.h>
 
 #include <sys/socket.h>
@@ -1144,9 +1145,11 @@
 
   if (acct_type == RAD_STOP)
   /* Show some statistics */
-    if (rad_put_int(r->cx.rad, RAD_ACCT_INPUT_OCTETS, stats->OctetsIn) != 0 ||
+    if (rad_put_int(r->cx.rad, RAD_ACCT_INPUT_OCTETS, stats->OctetsIn % UINT32_MAX) != 0 ||
         rad_put_int(r->cx.rad, RAD_ACCT_INPUT_PACKETS, stats->PacketsIn) != 0 ||
-        rad_put_int(r->cx.rad, RAD_ACCT_OUTPUT_OCTETS, stats->OctetsOut) != 0 ||
+        rad_put_int(r->cx.rad, RAD_ACCT_OUTPUT_OCTETS, stats->OctetsOut % UINT32_MAX) != 0 ||
+        rad_put_int(r->cx.rad, RAD_ACCT_INPUT_GIGAWORDS, stats->OctetsIn / UINT32_MAX) != 0 ||
+        rad_put_int(r->cx.rad, RAD_ACCT_OUTPUT_GIGAWORDS, stats->OctetsOut / UINT32_MAX) != 0 ||
         rad_put_int(r->cx.rad, RAD_ACCT_OUTPUT_PACKETS, stats->PacketsOut)
         != 0 ||
         rad_put_int(r->cx.rad, RAD_ACCT_SESSION_TIME, throughput_uptime(stats))
--- radius.c.diff ends here ---


>Release-Note:
>Audit-Trail:
Submitter was asked to examine whether sending RAD_ACCT_INPUT_GIGAWORDS
could cause problems in applications that do not expect such messages?

Submitter responds:
Yes, I have tested it with ICRadius, which does not suport
GIGAWORDS. ICRadius simply ignores this attribute as per RFC.
Regarding to RFC 2865 - "A RADIUS server MAY ignore Attributes
with an unknown Type." All known to me RADIUS servers: ICRadius,
FreeRADIUS, XtRADIUS, OpenRadius, Equant RADIUS (commercial) do
so, or have a configuration command like IgnoreUnknownAttributes.
GIGAWORDS are implemented in MPD, and I heard no complains from
users useing various RADIUS servers.

State-Changed-From-To: open->analyzed 
State-Changed-By: dds 
State-Changed-When: Wed May 19 09:34:19 GMT 2004 
State-Changed-Why:  
Contact by original submitter to ask for a commit following another 
recent ppp commit. 
The proposed patch appears to be ok. 



Responsible-Changed-From-To: freebsd-bugs->dds 
Responsible-Changed-By: dds 
Responsible-Changed-When: Wed May 19 09:34:19 GMT 2004 
Responsible-Changed-Why:  
Contact by original submitter to ask for a commit following another 
recent ppp commit. 
The proposed patch appears to be ok. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=61294 
State-Changed-From-To: analyzed->patched 
State-Changed-By: dds 
State-Changed-When: Wed May 19 21:04:22 GMT 2004 
State-Changed-Why:  
cvs commit: src/usr.sbin/ppp radius.c 


http://www.freebsd.org/cgi/query-pr.cgi?pr=61294 
State-Changed-From-To: patched->feedback 
State-Changed-By: dds 
State-Changed-When: Sun May 23 20:35:59 GMT 2004 
State-Changed-Why:  
Asked originator for testing feedback. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=61294 
State-Changed-From-To: feedback->patched 
State-Changed-By: dds 
State-Changed-When: Sun May 23 20:36:31 GMT 2004 
State-Changed-Why:  
Originator replies: 
"Have tested the latest PPP code due this hollydays and found no problems." 


http://www.freebsd.org/cgi/query-pr.cgi?pr=61294 
State-Changed-From-To: patched->closed 
State-Changed-By: dds 
State-Changed-When: Tue Jun 15 17:40:36 GMT 2004 
State-Changed-Why:  
Fix MFCed to RELENG_4 

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