]> git.ozlabs.org Git - ppp.git/commitdiff
Patch from Robert Vogelgesang:
authorPaul Mackerras <paulus@samba.org>
Thu, 28 Oct 2004 00:21:48 +0000 (00:21 +0000)
committerPaul Mackerras <paulus@samba.org>
Thu, 28 Oct 2004 00:21:48 +0000 (00:21 +0000)
        This patch avoids duplicate session IDs in RADIUS accounting,
        when the same pppd instance has multiple sessions during
        the same second.  This can happen when you have a really
        fast RADIUS server and fast clients, e. g. when using pppd
        as a back-end for PPPoE (either directly or via L2TP).

pppd/plugins/radius/radiusclient/lib/util.c

index 813ec7ec5452e832121dccdc8774ff5c6c32e817..491ef7f9848c1a867a0d21c92235132106ec2fff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: util.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
+ * $Id: util.c,v 1.3 2004/10/28 00:21:48 paulus Exp $
  *
  * Copyright (C) 1995,1996,1997 Lars Fenneberg
  *
@@ -231,7 +231,12 @@ void rc_mdelay(int msecs)
 char *
 rc_mksid (void)
 {
-  static char buf[14];
-  sprintf (buf, "%08lX%04X", (unsigned long int) time (NULL), (unsigned int) getpid ());
+  static char buf[15];
+  static unsigned short int cnt = 0;
+  sprintf (buf, "%08lX%04X%02hX",
+          (unsigned long int) time (NULL),
+          (unsigned int) getpid (),
+          cnt & 0xFF);
+  cnt++;
   return buf;
 }