All of lore.kernel.org
 help / color / mirror / Atom feed
* TUN/TAP driver doesn't work.
@ 2002-02-10 21:44 Marek Zawadzki
  2002-02-11  0:13 ` J Sloan
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Zawadzki @ 2002-02-10 21:44 UTC (permalink / raw)
  To: linux-kernel

Hello,

I am trying to use TUN/TAP driver. My OS is RH71, kernel is 2.4.17, with
tuntap compiled as a module. Module is inserted properly when I try to
open '/dev/net/tun', and I get kernel message saying "TUN/TAP universal
driver, (c)...etc.". But ioctls don't work and always return '-1'.
To test it I was using code from tuntap's documentation (included below this
message and btw I don't understand dev's name str-copying in this code)
and pengaol, newest version, which I know works with tuntap. None of these
2 programs work for me.

Any help would be really greatly appreciated.

-marek

-- test code --
#include        <sys/fcntl.h>
#include        <sys/ioctl.h>
#include        <net/if.h>
#include        <linux/if_tun.h>

int tun_alloc(char *dev)
{
    struct ifreq ifr;
    int fd, err;

    if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
       printf("open error\n");
   	 return 0;
    }

    memset(&ifr, 0, sizeof(ifr));

    /* Flags: IFF_TUN   - TUN device (no Ethernet headers)
     *        IFF_TAP   - TAP device
     *        IFF_NO_PI - Do not provide packet information
     *
     */
    ifr.ifr_flags = IFF_TUN;

    if( *dev )
        strncpy(ifr.ifr_name, dev, IFNAMSIZ);

    if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
        printf("ioctl err %d: %s\n", err, strerror(err));
        close(fd);
        return err;
    }
    strcpy(dev, ifr.ifr_name);
    return fd;
}

int main(int argc, char **argv)
{
	char test[100] = "1234567890123456";
	tun_alloc(test);
	return 0;
}




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: TUN/TAP driver doesn't work.
  2002-02-10 21:44 TUN/TAP driver doesn't work Marek Zawadzki
@ 2002-02-11  0:13 ` J Sloan
  2002-02-11  3:17   ` Marek Zawadzki
  0 siblings, 1 reply; 4+ messages in thread
From: J Sloan @ 2002-02-11  0:13 UTC (permalink / raw)
  To: Marek Zawadzki; +Cc: linux-kernel

This program compiles and works here. I'm using
RH 7.2, but the vtund setup hasn't changed from
my RH 7.1 setup.

Have you successfully installed vtund and tun?

Make sure your kernel-headers package is newer
than 2.4.7 - maybe grab the rawhide kernel headers
package which is IIRC 2.4.17 -

The old kernel headers package (2.4.2) won't work
or allow compiling of current version of vtund.

Joe

Marek Zawadzki wrote:

>Hello,
>
>I am trying to use TUN/TAP driver. My OS is RH71, kernel is 2.4.17, with
>tuntap compiled as a module. Module is inserted properly when I try to
>open '/dev/net/tun', and I get kernel message saying "TUN/TAP universal
>driver, (c)...etc.". But ioctls don't work and always return '-1'.
>To test it I was using code from tuntap's documentation (included below this
>message and btw I don't understand dev's name str-copying in this code)
>and pengaol, newest version, which I know works with tuntap. None of these
>2 programs work for me.
>
>Any help would be really greatly appreciated.
>
>-marek
>
>-- test code --
>#include        <sys/fcntl.h>
>#include        <sys/ioctl.h>
>#include        <net/if.h>
>#include        <linux/if_tun.h>
>
>int tun_alloc(char *dev)
>{
>    struct ifreq ifr;
>    int fd, err;
>
>    if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
>       printf("open error\n");
>   	 return 0;
>    }
>
>    memset(&ifr, 0, sizeof(ifr));
>
>    /* Flags: IFF_TUN   - TUN device (no Ethernet headers)
>     *        IFF_TAP   - TAP device
>     *        IFF_NO_PI - Do not provide packet information
>     *
>     */
>    ifr.ifr_flags = IFF_TUN;
>
>    if( *dev )
>        strncpy(ifr.ifr_name, dev, IFNAMSIZ);
>
>    if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
>        printf("ioctl err %d: %s\n", err, strerror(err));
>        close(fd);
>        return err;
>    }
>    strcpy(dev, ifr.ifr_name);
>    return fd;
>}
>
>int main(int argc, char **argv)
>{
>	char test[100] = "1234567890123456";
>	tun_alloc(test);
>	return 0;
>}
>
>
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/
>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: TUN/TAP driver doesn't work.
  2002-02-11  0:13 ` J Sloan
@ 2002-02-11  3:17   ` Marek Zawadzki
  2002-02-12 15:49     ` Jeff Dike
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Zawadzki @ 2002-02-11  3:17 UTC (permalink / raw)
  To: linux-kernel

On Sun, 10 Feb 2002, J Sloan wrote:

> Have you successfully installed vtund and tun?

I just compiled my kernel with TUN=m support. I don't think I need
vtund.

> Make sure your kernel-headers package is newerthan 2.4.7

That was it - thanks! FYI - I upgraded my kernel-headers from 2.4.2-2 to
2.4.9-21 and recompiled pengaol and other software, which was using
TUN/TAP.
But it's pretty weird, though. Did they change values of #defines for
TUN/TAP ioctls' numbers, or what? If so, that's quite bad in my opinion
(what if somebody had binary-only version of his client?).

Anyway, once again thanks very much, Joe. This just proved that even
using crappy winmodem and the crappiest, most Windozed ISP ever (AOL) one
can succesfully rock with Linux ;-)

-marek



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: TUN/TAP driver doesn't work.
  2002-02-11  3:17   ` Marek Zawadzki
@ 2002-02-12 15:49     ` Jeff Dike
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Dike @ 2002-02-12 15:49 UTC (permalink / raw)
  To: Marek Zawadzki; +Cc: linux-kernel

mzawadzk@cs.stevens-tech.edu said:
> Did they change values of #defines for TUN/TAP ioctls' numbers, or
> what? 

Yup, they sure did.

> If so, that's quite bad in my opinion (what if somebody had
> binary-only version of his client?).

Yup, it sure is.  It screwed UML over too.

BTW, if you (or anyone else) still needs to look at working TUN/TAP code,
UML has had a TUN/TAP network backend for a while.  See 
arch/um/drivers/tuntap*.

I've also got persistent TUN/TAP support mostly working in my private pool,
it will appear in a patch shortly.

				Jeff


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-02-12 20:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-10 21:44 TUN/TAP driver doesn't work Marek Zawadzki
2002-02-11  0:13 ` J Sloan
2002-02-11  3:17   ` Marek Zawadzki
2002-02-12 15:49     ` Jeff Dike

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.