Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Sep 1999 23:32:32 +0200
From:      Gary Jennejohn <garyj@muc.de>
To:        mranner@netway.a
Cc:        freebsd-isdn@freebsd.org
Subject:   problems with 0.83 and sPPP
Message-ID:  <199909282132.XAA00525@peedub.muc.de>

next in thread | raw e-mail | index | archive | help
I looked into the problems with spppcontrol always returning an error.
There are 2 fixes.

First, the simple one:

*** /u7/garyj/src/sys/i4b_83/sppp/if_sppp.h	Mon Jul 19 16:00:55 1999
--- ./if_sppp.h	Tue Sep 28 23:08:33 1999
***************
*** 166,172 ****
  #define SPPPIOSDEFS  ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
  
  struct spppreq {
! 	int	cmd;
  	struct sppp defs;
  };
  
--- 166,172 ----
  #define SPPPIOSDEFS  ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp)))
  
  struct spppreq {
! 	u_long	cmd;
  	struct sppp defs;
  };
  
Next the more complex one:

*** /u7/garyj/src/sys/i4b_83/sppp/if_spppsubr.c	Mon Jul 19 16:00:55 1999
--- if_spppsubr.c	Tue Sep 28 22:56:53 1999
***************
*** 4167,4182 ****
  static int
  sppp_params(struct sppp *sp, IOCTL_CMD_T cmd, void *data)
  {
  	struct ifreq *ifr = (struct ifreq *)data;
  	struct spppreq spr;
  
  	/*
  	 * ifr->ifr_data is supposed to point to a struct spppreq.
  	 */
  	if (copyin((caddr_t)ifr->ifr_data, &spr, sizeof spr) != 0)
  		return EFAULT;
  
! 	switch (spr.cmd) {
  	case SPPPIOGDEFS:
  		if (cmd != SIOCGIFGENERIC)
  			return EINVAL;
--- 4167,4191 ----
  static int
  sppp_params(struct sppp *sp, IOCTL_CMD_T cmd, void *data)
  {
+ 	u_long subcmd;
  	struct ifreq *ifr = (struct ifreq *)data;
  	struct spppreq spr;
  
  	/*
  	 * ifr->ifr_data is supposed to point to a struct spppreq.
+ 	 * Check the cmd word first before attempting to fetch all the
+ 	 * data.
+ 	 */
+ 	if ((subcmd = fuword(ifr->ifr_data)) == -1)
+ 		return EFAULT;
+ 
+ 	/*
+ 	 * ifr->ifr_data is supposed to point to a struct spppreq.
  	 */
  	if (copyin((caddr_t)ifr->ifr_data, &spr, sizeof spr) != 0)
  		return EFAULT;
  
! 	switch (subcmd) {
  	case SPPPIOGDEFS:
  		if (cmd != SIOCGIFGENERIC)
  			return EINVAL;

The second patch corresponds to the code in -current.

I tried both of these and they both make spppcontrol work OK. Having looked
at this it is now pretty obvious where the problem was - the kernel expects
spr.cmd to be a u_long, but it was an int. Since the ioctl pretends to be
a caddr_t the mismatch apparently lead to the error.

--------
Gary Jennejohn
Home - garyj@muc.de
Work - garyj@fkr.dec.com




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isdn" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199909282132.XAA00525>