Subject: Re: pkg/33926 (rp-pppoe report asyncReadFromPPP error on NetBSD-3.0)
To: None <martin@NetBSD.org, gnats-admin@netbsd.org,>
From: Martin Husemann <martin@duskware.de>
List: pkgsrc-bugs
Date: 08/05/2006 14:15:14
The following reply was made to PR pkg/33926; it has been noted by GNATS.

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/33926 (rp-pppoe report asyncReadFromPPP error on NetBSD-3.0)
Date: Sat, 5 Aug 2006 16:12:43 +0200

 --RASg3xLB4tUQ4RcS
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 The package seems broken in multiple ways. The patches patch-ac and
 patch-ad (both noops and unecessary) should be removed.
 
 The patch below fixes the obvious EINVAL problem reported in this PR, but
 it does not make the package work - to me it seems after restructuring
 rp-pppoe completely there has been no testing on OSes using BPF.
 
 If noone volunteers to debug the package all way through we should either
 mark it broken or consider downgrading it.
 
 Martin
 
 --RASg3xLB4tUQ4RcS
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=patch-ah
 
 --- src/ppp.c.orig	2002-07-08 16:38:24.000000000 +0200
 +++ src/ppp.c	2006-08-05 15:49:46.000000000 +0200
 @@ -164,13 +164,27 @@
  void
  asyncReadFromPPP(PPPoEConnection *conn, PPPoEPacket *packet)
  {
 -    unsigned char buf[READ_CHUNK];
 -    unsigned char *ptr = buf;
 +    unsigned char *ptr;
      unsigned char c;
 +    extern int bpfLength;
 +    static int readLength = 0;
 +    unsigned char *buf = NULL;
  
      int r;
  
 -    r = read(0, buf, READ_CHUNK);
 +    if (readLength == 0) {
 +	/*
 +	 * We need to read everything from BPF in the size the kernel
 +	 * told us (bpfLength), if we are using BPF.
 +	 * Otherwise just use READ_CHUNK.
 +	 */
 +	if (bpfLength == 0)
 +	    readLength = READ_CHUNK;
 +	else
 +	    readLength = bpfLength;
 +    }
 +    ptr = buf = malloc(readLength);
 +    r = read(0, buf, readLength);
      if (r < 0) {
  	fatalSys("read (asyncReadFromPPP)");
      }
 @@ -193,7 +207,7 @@
  	}
  
  	/* Still waiting... */
 -	if (PPPState == STATE_WAITFOR_FRAME_ADDR) return;
 +	if (PPPState == STATE_WAITFOR_FRAME_ADDR) goto done;
  
  	while(r && PPPState == STATE_DROP_PROTO) {
  	    --r;
 @@ -202,7 +216,7 @@
  	    }
  	}
  
 -	if (PPPState == STATE_DROP_PROTO) return;
 +	if (PPPState == STATE_DROP_PROTO) goto done;
  
  	/* Start building frame */
  	while(r && PPPState == STATE_BUILDING_PACKET) {
 @@ -234,6 +248,8 @@
  	    }
  	}
      }
 +done:
 +    free(buf);
  }
  
  /**********************************************************************
 
 --RASg3xLB4tUQ4RcS--