rpms/ppp/F-11 ppp-2.4.4-gigaword.patch, NONE, 1.1 ppp.spec, 1.50, 1.51 sources, 1.7, 1.8

Jiri Skala jskala at fedoraproject.org
Mon May 10 19:58:13 UTC 2010


Author: jskala

Update of /cvs/extras/rpms/ppp/F-11
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv25489

Modified Files:
	ppp.spec sources 
Added Files:
	ppp-2.4.4-gigaword.patch 
Log Message:
* Mon May 10 2010 - Jiri Skala <jskala at redhat.com> 2.4.4-13
- removed ppp-2.4.3 from sources
- fixes #521167 - RFE: Gigawords support in ppp


ppp-2.4.4-gigaword.patch:
 main.c                        |    4 +-
 plugins/radius/avpair.c       |   16 ++++++++---
 plugins/radius/etc/dictionary |    2 +
 plugins/radius/radius.c       |   61 ++++++++++++++++++++++++++++++++++++++----
 plugins/radius/radiusclient.h |    3 ++
 plugins/radius/sendserver.c   |   18 +++++++++++-
 pppd.h                        |    8 ++---
 sys-linux.c                   |   27 +++++++++++++++---
 8 files changed, 119 insertions(+), 20 deletions(-)

--- NEW FILE ppp-2.4.4-gigaword.patch ---
diff -Npru ppp/pppd/main.c ppp-2.4.4b1/pppd/main.c
--- ppp/pppd/main.c	2005-08-26 01:59:34.000000000 +0200
+++ ppp-2.4.4b1/pppd/main.c	2006-11-28 17:07:23.000000000 +0100
@@ -1345,9 +1345,9 @@ update_link_stats(u)
 
     slprintf(numbuf, sizeof(numbuf), "%u", link_connect_time);
     script_setenv("CONNECT_TIME", numbuf, 0);
-    slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_out);
+    snprintf(numbuf, sizeof(numbuf), "%llu", link_stats.bytes_out);
     script_setenv("BYTES_SENT", numbuf, 0);
-    slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_in);
+    snprintf(numbuf, sizeof(numbuf), "%llu", link_stats.bytes_in);
     script_setenv("BYTES_RCVD", numbuf, 0);
 }
 
diff -Npru ppp/pppd/plugins/radius/avpair.c ppp-2.4.4b1/pppd/plugins/radius/avpair.c
--- ppp/pppd/plugins/radius/avpair.c	2004-11-14 08:26:26.000000000 +0100
+++ ppp-2.4.4b1/pppd/plugins/radius/avpair.c	2006-11-28 17:10:04.000000000 +0100
@@ -291,9 +291,19 @@ static void rc_extract_vendor_specific_a
     /* Set attrlen to length of data */
     attrlen -= 4;
     for (; attrlen; attrlen -= vlen+2, ptr += vlen) {
-	vtype = *ptr++;
-	vlen = *ptr++;
-	vlen -= 2;
+
+	if ( vendor_id == VENDOR_USR ) {
+		vlen = attrlen - 4;
+	        vtype = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
+	        ptr += 4;
+	        /* fixup */ 
+	        attrlen -= 2;
+	} else {
+	        vtype = *ptr++;
+	        vlen = *ptr++;
+	        vlen -= 2;
+	}
+
 	if (vlen < 0 || vlen > attrlen - 2) {
 	    /* Do not log an error.  We are supposed to be able to cope with
 	       arbitrary vendor-specific gunk */
diff -Npru ppp/pppd/plugins/radius/etc/dictionary ppp-2.4.4b1/pppd/plugins/radius/etc/dictionary
--- ppp/pppd/plugins/radius/etc/dictionary	2004-11-14 08:26:26.000000000 +0100
+++ ppp-2.4.4b1/pppd/plugins/radius/etc/dictionary	2006-11-28 17:43:12.000000000 +0100
@@ -81,6 +81,8 @@ ATTRIBUTE	Acct-Authentic		45	integer
 ATTRIBUTE	Acct-Session-Time	46	integer
 ATTRIBUTE	Acct-Input-Packets	47	integer
 ATTRIBUTE	Acct-Output-Packets	48	integer
+ATTRIBUTE      Acct-Input-Gigawords    52      integer
+ATTRIBUTE      Acct-Output-Gigawords   53      integer
 ATTRIBUTE	Acct-Terminate-Cause	49	integer
 ATTRIBUTE       Chap-Challenge          60      string
 ATTRIBUTE	NAS-Port-Type		61	integer
diff -Npru ppp/pppd/plugins/radius/radius.c ppp-2.4.4b1/pppd/plugins/radius/radius.c
--- ppp/pppd/plugins/radius/radius.c	2005-07-10 12:28:55.000000000 +0200
+++ ppp-2.4.4b1/pppd/plugins/radius/radius.c	2006-11-28 17:57:00.000000000 +0100
@@ -963,18 +963,44 @@ radius_acct_stop(void)
 
 
     if (link_stats_valid) {
+    	DICT_ATTR*      attr;
+	static char     bigint[64];
+
 	av_type = link_connect_time;
 	rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE);
 
-	av_type = link_stats.bytes_out;
+	if ( (attr=rc_dict_findattr("Acct-Output-Octets-64")) ) {
+		snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_out);
+		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
+	}
+	av_type = (UINT4)link_stats.bytes_out;
 	rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE);
 
-	av_type = link_stats.bytes_in;
+	av_type = (UINT4)(link_stats.bytes_out >> 32);
+	rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
+	  
+	if ( (attr=rc_dict_findattr("Acct-Input-Octets-64")) ) {
+		snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_in);
+		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
+	}
+	av_type = (UINT4)link_stats.bytes_in;
 	rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE);
 
+	av_type = (UINT4)(link_stats.bytes_in >> 32);
+        rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
+  
+        if ( (attr=rc_dict_findattr("Acct-Output-Packets-64")) ) {
+        	snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_out);
+	        rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
+        }
+
 	av_type = link_stats.pkts_out;
 	rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE);
-
+ 
+        if ( (attr=rc_dict_findattr("Acct-Input-Packets-64")) ) {
+                snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_in);
+                rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
+        }
 	av_type = link_stats.pkts_in;
 	rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE);
     }
@@ -1105,20 +1131,45 @@ radius_acct_interim(void *ignored)
     update_link_stats(0);
 
     if (link_stats_valid) {
+	DICT_ATTR*      attr;
+	static char     bigint[64];
+ 
 	link_stats_valid = 0; /* Force later code to update */
 
 	av_type = link_connect_time;
 	rc_avpair_add(&send, PW_ACCT_SESSION_TIME, &av_type, 0, VENDOR_NONE);
 
-	av_type = link_stats.bytes_out;
+	if ( (attr=rc_dict_findattr("Acct-Output-Octets-64")) ) {
+		snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_out);
+		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
+	}
+	av_type = (UINT4)link_stats.bytes_out;
 	rc_avpair_add(&send, PW_ACCT_OUTPUT_OCTETS, &av_type, 0, VENDOR_NONE);
 
-	av_type = link_stats.bytes_in;
+	av_type = (UINT4)(link_stats.bytes_out >> 32);
+	rc_avpair_add(&send, PW_ACCT_OUTPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
+	  
+	if ( (attr=rc_dict_findattr("Acct-Input-Octets-64")) ) {
+		snprintf(bigint,sizeof(bigint),"%llu",link_stats.bytes_in);
+		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
+	}
+	av_type = (UINT4)link_stats.bytes_in;
 	rc_avpair_add(&send, PW_ACCT_INPUT_OCTETS, &av_type, 0, VENDOR_NONE);
 
+	av_type = (UINT4)(link_stats.bytes_in >> 32);
+	rc_avpair_add(&send, PW_ACCT_INPUT_GIGAWORDS, &av_type, 0, VENDOR_NONE);
+	  
+	if ( (attr=rc_dict_findattr("Acct-Output-Packets-64")) ) {
+		snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_out);
+		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
+	}
 	av_type = link_stats.pkts_out;
 	rc_avpair_add(&send, PW_ACCT_OUTPUT_PACKETS, &av_type, 0, VENDOR_NONE);
 
+	if ( (attr=rc_dict_findattr("Acct-Input-Packets-64")) ) {
+		snprintf(bigint,sizeof(bigint),"%llu",link_stats.pkts_in);
+		rc_avpair_add(&send,attr->value,bigint,0,attr->vendorcode);
+	}
 	av_type = link_stats.pkts_in;
 	rc_avpair_add(&send, PW_ACCT_INPUT_PACKETS, &av_type, 0, VENDOR_NONE);
     }
diff -Npru ppp/pppd/plugins/radius/radiusclient.h ppp-2.4.4b1/pppd/plugins/radius/radiusclient.h
--- ppp/pppd/plugins/radius/radiusclient.h	2004-11-14 08:26:26.000000000 +0100
+++ ppp-2.4.4b1/pppd/plugins/radius/radiusclient.h	2006-11-28 17:42:32.000000000 +0100
@@ -167,6 +167,8 @@ typedef struct pw_auth_hdr
 #define PW_ACCT_TERMINATE_CAUSE		49	/* integer */
 #define PW_ACCT_MULTI_SESSION_ID	50	/* string */
 #define PW_ACCT_LINK_COUNT		51	/* integer */
+#define PW_ACCT_INPUT_GIGAWORDS         52      /* integer */
+#define PW_ACCT_OUTPUT_GIGAWORDS        53      /* integer */
 
 /* From RFC 2869 */
 #define PW_ACCT_INTERIM_INTERVAL        85	/* integer */
@@ -292,6 +294,7 @@ typedef struct pw_auth_hdr
 /* Vendor codes */
 #define VENDOR_NONE     (-1)
 #define VENDOR_MICROSOFT	311
+#define VENDOR_USR             429
 
 /* Server data structures */
 
diff -Npru ppp/pppd/plugins/radius/sendserver.c ppp-2.4.4b1/pppd/plugins/radius/sendserver.c
--- ppp/pppd/plugins/radius/sendserver.c	2004-11-14 08:26:26.000000000 +0100
+++ ppp-2.4.4b1/pppd/plugins/radius/sendserver.c	2006-11-28 17:32:34.000000000 +0100
@@ -56,6 +56,14 @@ static int rc_pack_list (VALUE_PAIR *vp,
 		*buf++ = (((unsigned int) vp->vendorcode) >> 8) & 255;
 		*buf++ = ((unsigned int) vp->vendorcode) & 255;
 
+		/* Stolen from freeradius's source, that USR vendor
+		/* attributes are to handled otherwise */
+		if ( vp->vendorcode == VENDOR_USR ) {
+			*buf++ = (vp->attribute >> 24) & 0xff;
+			*buf++ = (vp->attribute >> 16) & 0xff;
+			*buf++ = (vp->attribute >> 8) & 0xff;
+		}
+
 		/* Insert vendor-type */
 		*buf++ = vp->attribute;
 
@@ -64,7 +72,8 @@ static int rc_pack_list (VALUE_PAIR *vp,
 		case PW_TYPE_STRING:
 		    length = vp->lvalue;
 		    *lenptr = length + 8;
-		    *buf++ = length+2;
+		    if ( vp->vendorcode != VENDOR_USR )
+		    	*buf++ = length+2;
 		    memcpy(buf, vp->strvalue, (size_t) length);
 		    buf += length;
 		    total_length += length+8;
@@ -73,7 +82,8 @@ static int rc_pack_list (VALUE_PAIR *vp,
 		case PW_TYPE_IPADDR:
 		    length = sizeof(UINT4);
 		    *lenptr = length + 8;
-		    *buf++ = length+2;
+		    if ( vp->vendorcode != VENDOR_USR )
+		    	*buf++ = length+2;
 		    lvalue = htonl(vp->lvalue);
 		    memcpy(buf, (char *) &lvalue, sizeof(UINT4));
 		    buf += length;
@@ -82,6 +92,10 @@ static int rc_pack_list (VALUE_PAIR *vp,
 		default:
 		    break;
 		}
+		if ( vp->vendorcode == VENDOR_USR ) {
+			*lenptr += 2;
+			total_length += 2;
+		}
 	    } else {
 		*buf++ = vp->attribute;
 		switch (vp->attribute) {
diff -Npru ppp/pppd/pppd.h ppp-2.4.4b1/pppd/pppd.h
--- ppp/pppd/pppd.h	2005-08-26 01:59:34.000000000 +0200
+++ ppp-2.4.4b1/pppd/pppd.h	2006-11-28 17:33:38.000000000 +0100
@@ -170,10 +170,10 @@ struct permitted_ip {
  * pppd needs.
  */
 struct pppd_stats {
-    unsigned int	bytes_in;
-    unsigned int	bytes_out;
-    unsigned int	pkts_in;
-    unsigned int	pkts_out;
+    unsigned long long	bytes_in;
+    unsigned long long	bytes_out;
+    unsigned long long	pkts_in;
+    unsigned long long	pkts_out;
 };
 
 /* Used for storing a sequence of words.  Usually malloced. */
diff -Npru ppp/pppd/sys-linux.c ppp-2.4.4b1/pppd/sys-linux.c
--- ppp/pppd/sys-linux.c	2005-08-28 07:23:26.000000000 +0200
+++ ppp-2.4.4b1/pppd/sys-linux.c	2006-11-28 17:37:16.000000000 +0100
@@ -1356,6 +1356,10 @@ get_idle_time(u, ip)
  *
  * get_ppp_stats - return statistics for the link.
  */
+
+static struct ifpppstatsreq prev_stat_req;
+static struct pppd_stats static_stats;
+
 int
 get_ppp_stats(u, stats)
     int u;
@@ -1371,10 +1371,21 @@ get_ppp_stats(u, stats)
 	error("Couldn't get PPP statistics: %m");
 	return 0;
     }
-    stats->bytes_in = req.stats.p.ppp_ibytes;
-    stats->bytes_out = req.stats.p.ppp_obytes;
-    stats->pkts_in = req.stats.p.ppp_ipackets;
-    stats->pkts_out = req.stats.p.ppp_opackets;
+    // Calculate the elapsed bytes since the last query
+    static_stats.bytes_in +=
+        (req.stats.p.ppp_ibytes - prev_stat_req.stats.p.ppp_ibytes);
+    static_stats.bytes_out +=
+        (req.stats.p.ppp_obytes - prev_stat_req.stats.p.ppp_obytes);
+    static_stats.pkts_in +=
+        (req.stats.p.ppp_ipackets - prev_stat_req.stats.p.ppp_ipackets);
+    static_stats.pkts_out +=
+        (req.stats.p.ppp_opackets - prev_stat_req.stats.p.ppp_opackets);
+    // Store the current state
+    memcpy(&prev_stat_req,&req,sizeof(prev_stat_req));
+    
+    // Give out the statistics
+    memcpy(stats,&static_stats,sizeof(static_stats));
+
     return 1;
 }
 
@@ -2185,6 +2185,10 @@ int sifup(int u)
 {
     struct ifreq ifr;
 
+    // Initialize the 'previous stats struct'
+    memset(&prev_stat_req,0,sizeof(prev_stat_req));
+    // And the static statistics puffer
+    memset(&static_stats,0,sizeof(static_stats));
     memset (&ifr, '\0', sizeof (ifr));
     strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
     if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {


Index: ppp.spec
===================================================================
RCS file: /cvs/extras/rpms/ppp/F-11/ppp.spec,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -p -r1.50 -r1.51
--- ppp.spec	6 Jan 2010 07:27:37 -0000	1.50
+++ ppp.spec	10 May 2010 19:58:13 -0000	1.51
@@ -1,7 +1,7 @@
 Summary: The PPP (Point-to-Point Protocol) daemon.
 Name: ppp
 Version: 2.4.4
-Release: 12%{?dist}
+Release: 13%{?dist}
 License: BSD and LGPLv2+ and GPLv2+ and Public Domain
 Group: System Environment/Daemons
 Source0: ftp://ftp.samba.org/pub/ppp/ppp-%{version}.tar.gz
@@ -29,6 +29,7 @@ Patch25: ppp-2.4.4-response_len.patch
 Patch26: ppp-2.4.4-new_speeds.patch
 Patch27: ppp-2.4.4-bogus_dns_addr.patch
 Patch28: ppp-2.4.4-fd_leak.patch
+Patch29: ppp-2.4.4-gigaword.patch
 
 BuildRoot: %{_tmppath}/%{name}-root
 BuildPrereq: pam-devel, libpcap-devel
@@ -74,6 +75,7 @@ This package contains the header files f
 %patch26 -p1 -b .new_speeds
 %patch27 -p1 -b .bogus_dns_addr
 %patch28 -p1 -b .fd_leak
+%patch29 -p1 -b .gigaword
 
 rm -f scripts/*.local
 rm -f scripts/*.change_resolv_conf
@@ -138,6 +140,10 @@ rm -rf $RPM_BUILD_ROOT
 %doc PLUGINS
 
 %changelog
+* Mon May 10 2010 - Jiri Skala <jskala at redhat.com> 2.4.4-13
+- removed ppp-2.4.3 from sources
+- fixes #521167 - RFE: Gigawords support in ppp
+
 * Wed Jan 06 2010 - Jiri Skala <jskala at redhat.com> 2.4.4-12
 - fixed #467004 - PPP sometimes gets incorrect DNS servers for mobile connection
 - added close-on-exec due to #498789


Index: sources
===================================================================
RCS file: /cvs/extras/rpms/ppp/F-11/sources,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -r1.7 -r1.8
--- sources	24 Jul 2006 18:09:32 -0000	1.7
+++ sources	10 May 2010 19:58:13 -0000	1.8
@@ -1,2 +1 @@
-848f6c3cafeb6074ffeb293c3af79b7c  ppp-2.4.3.tar.gz
 183800762e266132218b204dfb428d29  ppp-2.4.4.tar.gz



More information about the scm-commits mailing list