Wednesday, October 29, 2008

HOWTO: Get tun/tap compile for x64 OpenSolaris

I've been trying to figure out how to get tun/tap working on OpenSolaris for a while so that I can use OpenVPN. I finally put together all the different pieces to make it work. There may be some things here that aren't strictly required, but this is what finally got it working for me. I've included the main references that helped get it working below.

Firstly, I used the Sun Studio C compiler so you'll need to install that to use this process. On OpenSolaris, you can do this by executing "pkg install sunstudioexpress". The download is over 500MB, so it will take some time.

The next step is to download and extract the tun/tap driver sources. These are freely available from http://vtun.sourceforge.net/tun/. At this time, the current version is 1.1. They will extract into a directory named tun-1.1. You'll also need to download a new version of tun.c from http://openvpn.net/solaris/tun.c and replace the tun-1.1/solaris/tun.c file. The version that is distributed with the tun/tap sources compiles but doesn't work correctly.

After downloading and updating the sources, now we need to configure the build environment. This is where the majority of the work was in getting tun/tap to work correctly. Firstly, make sure that the Sun Studio compilers are in your path by executing "export PATH=/opt/sunstudioexpress/bin/:$PATH". Now cd into tun-1.1/solaris and execute "./configure". Unfortunately, the Makefile that is generated doesn't work correctly. I've included the entire contents of my working Makefile below. The changes I've made are to use the Sun Studio C compiler, use a different set of CFLAGS, add some LDFLAGS, and install the driver files into some additional locations.

References:
Fixing the "relocation error: R_AMD64_32" error
http://opensolaris.org/jive/thread.jspa?messageID=185654

Fixing the failed to attach error:
http://openvpn.net/archive/openvpn-users/2005-08/msg00002.html


# Generated automatically from Makefile.in by configure.
#
# Universal TUN/TAP device driver.
#
# Multithreaded STREAMS tun pseudo device driver.
#
# Copyright (C) 1999-2000 Maxim Krasnyansky
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# $Id: Makefile.in,v 1.7 2000/06/20 03:14:17 maxk Exp $
#
CONFIGURE_FILES = Makefile config.status config.cache config.h config.log

CC = cc
LD = ld

DEFS = -DTUN_VER=\"\"
CFLAGS = $(DEFS) -O2 -m64 -D_KERNEL -I. -xmodel=kernel -KPIC
LDFLAGS = -64
ADD_DRV = /usr/sbin/add_drv
REM_DRV = /usr/sbin/rem_drv
DRV_DIR = /kernel/drv/
DRV_DIR2 = /kernel/drv/amd64
DRV_DIR3 = /platform/i86pc/kernel/drv

INSTALL = /usr/bin/ginstall -c

all: module

module: tun.o
$(LD) $(LDFLAGS) -r -o tun tun.o

tun.o: tun.c if_tun.h
$(CC) $(CFLAGS) -c tun.c

inst: module
$(INSTALL) -m 644 -o root -g root if_tun.h /usr/include/net
$(INSTALL) -m 644 -o root -g root tun $(DRV_DIR)
$(INSTALL) -m 644 -o root -g root tun.conf $(DRV_DIR)
$(INSTALL) -m 644 -o root -g root tun $(DRV_DIR2)
$(INSTALL) -m 644 -o root -g root tun.conf $(DRV_DIR2)
$(INSTALL) -m 644 -o root -g root tun $(DRV_DIR3)
$(INSTALL) -m 644 -o root -g root tun.conf $(DRV_DIR3)
-$(REM_DRV) tun >/dev/null 2>&1
$(ADD_DRV) tun

clean:
rm -f tun *.o *~

distclean:
rm -f $(CONFIGURE_FILES)

12 comments:

Anonymous said...

Thanks for the link to your blog post, Paul. I'm going to try this when I get back to my laptop (currently kept in the office).

-- Sriram

Anonymous said...

Thanks. I was able to build and install the 64 bit tun drivers using your instructions.

VPNC is able to detect this device and starts up too, but I am unable to ping my office internal IP addresses. I'm going to investigate this next.

Anonymous said...

I used the vpnc-connect script given here (http://my2ndhead.blogspot.com/2008/11/connecting-opensolaris-to-cisco-vpn.html) and was able to connect to servers inside my office network. I had to modify the script to replace the add_host "xx.xx.xx.xx" entries with the IP addresses that I wanted to connect to.

Thanks for all the help.

We'll be including scripts + binaries for all of this in Belenix and will be mentioning you in the credits :)

Anonymous said...

WoW shares many wow gold of its features with previously launched games. Essentially, you battle with wow gold cheap monsters and traverse the countryside, by yourself or as a buy cheap wow gold team, find challenging tasks, and go on to higher aoc gold levels as you gain skill and experience. In the course of your journey, you will be gaining new powers that are increased as your skill rating goes up. All the same, in terms of its features and quality, that is a ture stroy for this.WoW is far ahead of all other games of the genre the wow power leveling game undoubtedly is in a league of its own and cheapest wow gold playing it is another experience altogether.

Even though WoW is a Cheap Wow Gold rather complicated game, the controls and interface are done in warhammer gold such a way that you don't feel the complexity. A good feature of the game is that it buy wow items does not put off people with lengthy manuals. The instructions cannot be simpler and the pop up tips can help you start playing the game World Of Warcraft Gold immediately. If on the other hand, you need a detailed manual, the instructions are there for you to access. Buy wow gold in this site,good for you, BUY WOW GOLD.

Lunchbox said...

It'll be great to get these changes back into the upstream source.

You are going to push them upstream, right?

DMTMACHINEELVES said...

find the best search the internet website for just about anything when you search the net you will be amazed at just what you find. search the net is easy when you do it right here. the best information that you can find on internet tips is right at your fingertips. look no further because if you do you will only find shopping tips which you will want to view as well as some other finance tips which are very important as well. make sure to also go through to the shopping tips so that you do not miss out! there is car info just about anywhere that you look as well. they are scattered all over the net those car tips just for you to find. the only and best way to do your business on the internet is with many computer tips as well as free tips online

shopping said...

Replica Bags/Handbags- Louis Vuitton Replica Bags, Chanel Replica Bags, GUCCI Replica Bags, Hermes Handbags
Louis Vuitton Replica Bags
GUCCI Replica Bags
chanel Replica Bags
Hermes handbags
Balenciaga handbags
Replica Louis Vuitton Handbags, Replica Chanel Handbags, Replica Guccci Handbags, Tiffany Jewelry, Replica Designer Jewelry
 Louis Vuitton Replica Handbags, Replica Designer Handbags
Chanel Replica  Handbags, Replica Designer Handbags
Gucci Replica  Handbags, Replica Designer Handbags
Chloe Replica  Handbags, Replica Designer Handbags
Replica Designer Jewelry,Replica Jewelry wholesale
Dolce Gabbana Replica  Handbags
Mulberry Replica  Handbags
2009 Classic Handbags Wholesale, OEM production of Bags, New Arrivals Handbags - Discount Handbags Wholesale
2009 New arrivals coach handbag
classic CA handbags
classic Burberry handbags 
classic Miu Miu handbags

shopping said...

classic Guess handbags
Rolex Replica, Replica Rolex Watch, Fake Rolex, Rolex Replica Watches
Replica Watches
Fake Rolex
Wholesale Replica Handbags,Replica Gucci,Replica Chanel,Replica Christian Louboutin,Replica Louis Vuitton
replica LOUIS VUITTON
replica CHANEL
replica GUCCI
replica travel business
Buy cheap NFL Jerseys, cheap MLB Jerseys, cheap NHL Jerseys, cheap NBA Jerseys - Cheap Jerseys Wholesale
NFL jerseys supplier
MLB jerseys supplier
NHL jerseys supplier
NBA jerseys supplier
jimmy choo
manolo blahnik
alexander mcqueen
high heels wholesale

shopping said...

buy replacemant camcorder battery, laptop battery, digital camera battery, laptop ac/dc adapter Canon camcorder battery, Jvc camcorder battery, Samsung camcorder battery, Sharp camcorder battery, Sony camcorder battery, Toshiba camcorder battery, Panasonic camcorder battery

Ranjan said...

Hi,
I have a problem here. I seem to have got it to work but I am not sure what to do after i install. I am not able to see this interface using ifconfig -a though if I do a ls -l /dev , i can see the tun and tap interfaces in there. Can you please help ?
Thanks
Ranjan

milla said...

very good I liked your blog a lot, I think it is well done like buy viagra

Anonymous said...

This is very cute. I am going to use this idea for Easter! Thank you for your time to make this article!
wholesale wallets
20101231pilipalagaga