TAP interface support for Solaris/OpenSolaris
PATCH 1/1 TAP interface support for Solaris/OpenSolaris
Hi,
I've attached a patch for tun.c which includes support for tap interface for solaris/opensolaris.
The code is based on OpneVPN 2.1.1. And it has a routine to plumb/unplumb tap interface like ifconfig command.
tap driver for solarsi/opensolaris is here:
http://www.whiteboard.ne.jp/~admin2/tuntap/
Thanks,
Kazuyoshi
---------------
Kazuyoshi Aizawa
openvpn-2.1.1/tun.c renamed from openvpn-2.1.1-org/tun.c +129 -53
@@ -63,6 +63,7 @@#ifdef TARGET_SOLARIS static void solaris_error_close (struct tuntap *tt,const struct env_set *es,const char *actual); +#include <stropts.h> #endif bool
@@ -701,7 +702,13 @@ ); }else -no_tap_ifconfig (); +argv_printf (&argv, +" %s %s %s netmask %s broadcast + up" , +IFCONFIG_PATH , + actual, + ifconfig_local, + ifconfig_remote_netmask + );argv_msg (M_INFO , &argv);if (!openvpn_execve_check (&argv, es,0 ,"Solaris ifconfig phase-2 failed" ))
@@ -1383,15 +1390,17 @@void open_tun (const char *dev,const char *dev_type,const char *dev_node,bool ipv6,struct tuntap *tt) { -int if_fd, muxid, ppa =-1 ; -struct ifreq ifr; +int if_fd, ip_muxid, arp_muxid, arp_fd, ppa =-1 ; +struct lifreq ifr;const char *ptr; -const char *ip_node; +const char *ip_node, *arp_node;const char *dev_tuntap_type;int link_type;bool is_tun; +struct strioctl strioc_if, strioc_ppa; -ipv6_support (ipv6, false, tt); +ipv6_support (ipv6, true, tt); +memset (&ifr,0x0 ,sizeof (ifr));if (tt->type ==DEV_TYPE_NULL ) {
@@ -1410,9 +1419,10 @@ }else if (tt->type ==DEV_TYPE_TAP ) { - ip_node ="/dev/ip" ; + ip_node ="/dev/udp" ;if (!dev_node) dev_node ="/dev/tap" ; + arp_node = dev_node; dev_tuntap_type ="tap" ; link_type =I_PLINK ;/* was: I_LINK */ is_tun = false;
@@ -1439,7 +1449,11 @@msg (M_ERR ,"Can't open %s" , dev_node);/* Assign a new PPA and get its unit number. */ -if ((ppa =ioctl (tt->fd,TUNNEWPPA , ppa)) <0 ) + strioc_ppa.ic_cmd =TUNNEWPPA ; + strioc_ppa.ic_timout =0 ; + strioc_ppa.ic_len =sizeof (ppa); + strioc_ppa.ic_dp = (char *)&ppa; +if ((ppa =ioctl (tt->fd,I_STR , &strioc_ppa)) <0 )msg (M_ERR ,"Can't assign new interface" );if ((if_fd =open (dev_node,O_RDWR ,0 )) <0 )
@@ -1448,27 +1462,83 @@if (ioctl (if_fd,I_PUSH ,"ip" ) <0 )msg (M_ERR ,"Can't push IP module" ); -/* Assign ppa according to the unit number returned by tun device */ -if (ioctl (if_fd,IF_UNITSEL , (char *) &ppa) <0 ) -msg (M_ERR ,"Can't set PPA %d" , ppa); +if (tt->type ==DEV_TYPE_TUN ) + { +/* Assign ppa according to the unit number returned by tun device */ +if (ioctl (if_fd,IF_UNITSEL , (char *) &ppa) <0 ) +msg (M_ERR ,"Can't set PPA %d" , ppa); + } -if ((muxid =ioctl (tt->ip_fd, link_type, if_fd)) <0 ) -msg (M_ERR ,"Can't link %s device to IP" , dev_tuntap_type); - -close (if_fd); - tt->actual_name = (char *)malloc (32 );check_malloc_return (tt->actual_name);openvpn_snprintf (tt->actual_name,32 ,"%s%d" , dev_tuntap_type, ppa); +if (tt->type ==DEV_TYPE_TAP ) + { +if (ioctl (if_fd,SIOCGLIFFLAGS , &ifr) <0 ) +msg (M_ERR ,"Can't get flags\n" ); +strncpynt (ifr.lifr_name, tt->actual_name,sizeof (ifr.lifr_name)); + ifr.lifr_ppa = ppa; +/* Assign ppa according to the unit number returned by tun device */ +if (ioctl (if_fd,SIOCSLIFNAME , &ifr) <0 ) +msg (M_ERR ,"Can't set PPA %d" , ppa); +if (ioctl (if_fd,SIOCGLIFFLAGS , &ifr) <0 ) +msg (M_ERR ,"Can't get flags\n" ); +/* Push arp module to if_fd */ +if (ioctl (if_fd,I_PUSH ,"arp" ) <0 ) +msg (M_ERR ,"Can't push ARP module" ); + +/* Pop any modules on the stream */ +while (true) + { +if (ioctl (tt->ip_fd,I_POP ,NULL ) <0 ) +break ; + } +/* Push arp module to ip_fd */ +if (ioctl (tt->ip_fd,I_PUSH ,"arp" ) <0 ) +msg (M_ERR ,"Can't push ARP module\n" ); + +/* Open arp_fd */ +if ((arp_fd =open (arp_node,O_RDWR ,0 )) <0 ) +msg (M_ERR ,"Can't open %s\n" , arp_node); +/* Push arp module to arp_fd */ +if (ioctl (arp_fd,I_PUSH ,"arp" ) <0 ) +msg (M_ERR ,"Can't push ARP module\n" ); + +/* Set ifname to arp */ + strioc_if.ic_cmd =SIOCSLIFNAME ; + strioc_if.ic_timout =0 ; + strioc_if.ic_len =sizeof (ifr); + strioc_if.ic_dp = (char *)𝔦 +if (ioctl (arp_fd,I_STR , &strioc_if) <0 ){ +msg (M_ERR ,"Can't set ifname to arp\n" ); + } + } + +if ((ip_muxid =ioctl (tt->ip_fd, link_type, if_fd)) <0 ) +msg (M_ERR ,"Can't link %s device to IP" , dev_tuntap_type); + +if (tt->type ==DEV_TYPE_TAP ) { +if ((arp_muxid =ioctl (tt->ip_fd, link_type, arp_fd)) <0 ) +msg (M_ERR ,"Can't link %s device to ARP" , dev_tuntap_type); +close (arp_fd); + } +CLEAR (ifr); -strncpynt (ifr.ifr_name, tt->actual_name,sizeof (ifr.ifr_name)); - ifr.ifr_ip_muxid = muxid; +strncpynt (ifr.lifr_name, tt->actual_name,sizeof (ifr.lifr_name)); + ifr.lifr_ip_muxid = ip_muxid; +if (tt->type ==DEV_TYPE_TAP ) { + ifr.lifr_arp_muxid = arp_muxid; + } -if (ioctl (tt->ip_fd,SIOCSIFMUXID , &ifr) <0 ) +if (ioctl (tt->ip_fd,SIOCSLIFMUXID , &ifr) <0 ) { -ioctl (tt->ip_fd,I_PUNLINK , muxid); +if (tt->type ==DEV_TYPE_TAP ) + { +ioctl (tt->ip_fd,I_PUNLINK , arp_muxid); + } +ioctl (tt->ip_fd,I_PUNLINK , ip_muxid);msg (M_ERR ,"Can't set multiplexor id" ); }
@@ -1485,20 +1555,26 @@if (tt) {if (tt->ip_fd >=0 ) - { -struct ifreq ifr; -CLEAR (ifr); -strncpynt (ifr.ifr_name, tt->actual_name,sizeof (ifr.ifr_name)); + { +struct lifreq ifr; +CLEAR (ifr); +strncpynt (ifr.lifr_name, tt->actual_name,sizeof (ifr.lifr_name)); -if (ioctl (tt->ip_fd,SIOCGIFFLAGS , &ifr) <0 ) -msg (M_WARN |M_ERRNO ,"Can't get iface flags" ); +if (ioctl (tt->ip_fd,SIOCGLIFFLAGS , &ifr) <0 ) +msg (M_WARN |M_ERRNO ,"Can't get iface flags" ); -if (ioctl (tt->ip_fd,SIOCGIFMUXID , &ifr) <0 ) -msg (M_WARN |M_ERRNO ,"Can't get multiplexor id" ); +if (ioctl (tt->ip_fd,SIOCGLIFMUXID , &ifr) <0 ) +msg (M_WARN |M_ERRNO ,"Can't get multiplexor id" ); -if (ioctl (tt->ip_fd,I_PUNLINK , ifr.ifr_ip_muxid) <0 ) -msg (M_WARN |M_ERRNO ,"Can't unlink interface" ); +if (tt->type ==DEV_TYPE_TAP ) + { +if (ioctl (tt->ip_fd,I_PUNLINK , ifr.lifr_arp_muxid) <0 ) +msg (M_WARN |M_ERRNO ,"Can't unlink interface(arp)" ); + } +if (ioctl (tt->ip_fd,I_PUNLINK , ifr.lifr_ip_muxid) <0 ) +msg (M_WARN |M_ERRNO ,"Can't unlink interface(ip)" ); +close (tt->ip_fd); tt->ip_fd =-1 ; }
@@ -1751,11 +1827,11 @@ i = tt->topology ==TOP_SUBNET ?IFF_BROADCAST :IFF_POINTOPOINT ; i |=IFF_MULTICAST ;if (ioctl (tt->fd,TUNSIFMODE , &i) <0 ) { -msg (M_WARN |M_ERRNO ,"ioctl(TUNSIFMODE): %s" ,strerror (errno)); +msg (M_WARN |M_ERRNO ,"ioctl(TUNSIFMODE): %s" ,strerror (errno)); } i =1 ;if (ioctl (tt->fd,TUNSIFHEAD , &i) <0 ) { -msg (M_WARN |M_ERRNO ,"ioctl(TUNSIFHEAD): %s" ,strerror (errno)); +msg (M_WARN |M_ERRNO ,"ioctl(TUNSIFHEAD): %s" ,strerror (errno)); } } }
@@ -3299,19 +3375,19 @@bool ret = false;const IP_ADAPTER_INDEX_MAP *inter =get_interface_info (adapter_index, &gc); -if (inter) - { -DWORD status =IpReleaseAddress ((IP_ADAPTER_INDEX_MAP *)inter); -if (status ==NO_ERROR ) +if (inter) { -msg (D_TUNTAP_INFO ,"TAP: DHCP address released" ); - ret = true; +DWORD status =IpReleaseAddress ((IP_ADAPTER_INDEX_MAP *)inter); +if (status ==NO_ERROR ) + { +msg (D_TUNTAP_INFO ,"TAP: DHCP address released" ); + ret = true; + } +else +msg (M_WARN ,"NOTE: Release of DHCP-assigned IP address lease on TAP-Win32 adapter failed: %s (code=%u)" , +strerror_win32 (status, &gc), + (unsigned int )status); } -else -msg (M_WARN ,"NOTE: Release of DHCP-assigned IP address lease on TAP-Win32 adapter failed: %s (code=%u)" , -strerror_win32 (status, &gc), - (unsigned int )status); - }gc_free (&gc);return ret;
@@ -3333,19 +3409,19 @@bool ret = false;const IP_ADAPTER_INDEX_MAP *inter =get_interface_info (adapter_index, &gc); -if (inter) - { -DWORD status =IpRenewAddress ((IP_ADAPTER_INDEX_MAP *)inter); -if (status ==NO_ERROR ) +if (inter) { -msg (D_TUNTAP_INFO ,"TAP: DHCP address renewal succeeded" ); - ret = true; +DWORD status =IpRenewAddress ((IP_ADAPTER_INDEX_MAP *)inter); +if (status ==NO_ERROR ) + { +msg (D_TUNTAP_INFO ,"TAP: DHCP address renewal succeeded" ); + ret = true; + } +else +msg (M_WARN ,"WARNING: Failed to renew DHCP IP address lease on TAP-Win32 adapter: %s (code=%u)" , +strerror_win32 (status, &gc), + (unsigned int )status); } -else -msg (M_WARN ,"WARNING: Failed to renew DHCP IP address lease on TAP-Win32 adapter: %s (code=%u)" , -strerror_win32 (status, &gc), - (unsigned int )status); - }gc_free (&gc);return ret; }
Hi,
Quoted 7 lines · Kazuyoshi Aizawa
I've attached a patch for
tun.cwhich includes support for tap interface for solaris/opensolaris.
The code is based on OpneVPN 2.1.1. And it has a routine to plumb/unplumb tap interface like ifconfig command.tap driver for solarsi/opensolaris is here:
http://www.whiteboard.ne.jp/~admin2/tuntap/
Thanks for your work!. I have already used bits from there when adding IPv6 payload support to OpenVPN on Solaris :-)
Question to the community: how do we want to integrate the tun.c changes for Solaris? Its own branch, feat_misc branch, feat_ipv6_payload branch?
If we include it in feat_ipv6_payload, it won't have merge conflicts - but then you only get the TAP-on-Solaris in combination with all the IPv6 stuff, which people might not want.
David?
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 14 lines · Gert Doering
Hi,
Quoted 7 lines · Kazuyoshi Aizawa
I've attached a patch for
tun.cwhich includes support for tap interface for solaris/opensolaris.
The code is based on OpneVPN 2.1.1. And it has a routine to plumb/unplumb tap interface like ifconfig command.tap driver for solarsi/opensolaris is here:
http://www.whiteboard.ne.jp/~admin2/tuntap/Thanks for your work!. I have already used bits from there when adding IPv6 payload support to OpenVPN on Solaris :-)
Quoted 8 lines
Question to the community: how do we want to integrate the
tun.cchanges for Solaris? Its own branch,feat_miscbranch,feat_ipv6_payloadbranch?If we include it in
feat_ipv6_payload, it won't have merge conflicts - but then you only get the TAP-on-Solaris in combination with all the IPv6 stuff, which people might not want.David?
You seem to have pretty well good control over this TUN/TAP infrastructure. So I have no problems with you pulling whatever you find useful into your IPv6 branch, which covers this.
If given a separate branch, I'm not going to be the one who solves potential conflicts unless they're bloody obvious and trivial. So I'll just be going to push someone to fix these branches so they can be merged.
Gert, I'll let you know decide if you feel this is good for inclusion into your tree. If you prefer to have it separately, including the work needed to make these branches merge-able, I'm fine with that. It's easier to track things if they have separate branches, but if this patch is close to what you do in your tree, I don't see it that important to split it out.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvZPUsACgkQDC186MBRfrpElQCdHZPAXh0LuPfiKtNWRt2+e6IK UEIAnjXlVySWFUgOxxhU3bCp3mv5hlSI
=SydE
-----END PGP SIGNATURE-----
Hi,
Quoted 9 lines · David Sommerseth
Quoted 5 lines
If we include it in
feat_ipv6_payload, it won't have merge conflicts - but then you only get the TAP-on-Solaris in combination with all the IPv6 stuff, which people might not want.David?
You seem to have pretty well good control over this TUN/TAP infrastructure. So I have no problems with you pulling whatever you find useful into your IPv6 branch, which covers this.
OK, if nobody objects, I'll integrate the rest of these patches into "my" tun.c, and commit to the IPv6 payload branch. (Will take a few days...)
If someone urgently needs TAP support for Solaris later on, but refuses to use the IPv6 stuff, we can still sort out what to do then.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 13 lines · Gert Doering
Hi,
Quoted 9 lines · David Sommerseth
Quoted 5 lines
If we include it in
feat_ipv6_payload, it won't have merge conflicts - but then you only get the TAP-on-Solaris in combination with all the IPv6 stuff, which people might not want.David?
You seem to have pretty well good control over this TUN/TAP infrastructure. So I have no problems with you pulling whatever you find useful into your IPv6 branch, which covers this.
Quoted 6 lines
OK, if nobody objects, I'll integrate the rest of these patches into "my"
tun.c, and commit to the IPv6 payload branch. (Will take a few days...)If someone urgently needs TAP support for Solaris later on, but refuses to use the IPv6 stuff, we can still sort out what to do then.
Agreed! And I really struggle to see this being a reality, unless the IPv6 branch got stability issues for IPv4 only users. Which I can't say is an issue now.
Send me a PULL REQUEST when you're ready, and I'll get it into allmerged after ACK.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvZQQ0ACgkQDC186MBRfroX0QCeL1nQ61nh+MDY1l0YUsS0gsQ0 D58AmgNK+LWCqJSNGzCeFh8QgouMdlXi
=no9p
-----END PGP SIGNATURE-----
Hi again,
Quoted 2 lines · Kazuyoshi Aizawa
I've attached a patch for
tun.cwhich includes support for tap interface for solaris/opensolaris.
I've glanced through the patch, and there's also changes in the Win32 part of the tun.c, for example this chunk:
----------------------- quote ----------------------
@@ -3333,19 +3409,19 @@
bool ret = false;
const IP_ADAPTER_INDEX_MAP *inter = get_interface_info (adapter_index, &gc);
- if (inter)
- {
- DWORD status = IpRenewAddress ((IP_ADAPTER_INDEX_MAP *)inter);
- if (status == NO_ERROR)
+ if (inter)
{
- msg (D_TUNTAP_INFO, "TAP: DHCP address renewal succeeded");
- ret = true;
+ DWORD status = IpRenewAddress ((IP_ADAPTER_INDEX_MAP *)inter);
+ if (status == NO_ERROR)+ {
+ msg (D_TUNTAP_INFO, "TAP: DHCP address renewal succeeded");
+ ret = true;
+ }
+ else
+ msg (M_WARN, "WARNING: Failed to renew DHCP IP address lease on TAP-Win32 adapter: %s (code=%u)",
+ strerror_win32 (status, &gc),
+ (unsigned int)status);
}
- else
- msg (M_WARN, "WARNING: Failed to renew DHCP IP address lease on TAP-Win32 adapter: %s (code=%u)",
- strerror_win32 (status, &gc),
- (unsigned int)status);
- }
gc_free (&gc);
return ret;
}
----------------------- quote ----------------------
From a first glance, this looks like "whitespace changes only".
For easier review: would you be so kind and re-send your patch with "diff -uw" (-w = ignore white space changes)?
thanks,
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi Gert,
Thank you for your support.
Please find attached patch with diff -uw.
Thanks,
Kazuyoshi
2010/4/29 Gert Doering <[email protected]...>:
Quoted 50 lines
Hi again,
Quoted 2 lines · Kazuyoshi Aizawa
I've attached a patch for
tun.cwhich includes support for tap interface for solaris/opensolaris.I've glanced through the patch, and there's also changes in the Win32 part of the
tun.c, for example this chunk:----------------------- quote ----------------------
(quoted diff) +11
-12@@ -3333,19 +3409,19 @@ bool ret = false; const IP_ADAPTER_INDEX_MAP *inter = get_interface_info (adapter_index, &gc); - if (inter) - { - DWORD status = IpRenewAddress ((IP_ADAPTER_INDEX_MAP *)inter); - if (status == NO_ERROR) + if (inter) { - msg (D_TUNTAP_INFO, "TAP: DHCP address renewal succeeded"); - ret = true; + DWORD status = IpRenewAddress ((IP_ADAPTER_INDEX_MAP *)inter); + if (status == NO_ERROR) + { + msg (D_TUNTAP_INFO, "TAP: DHCP address renewal succeeded"); + ret = true; + } + else + msg (M_WARN, "WARNING: Failed to renew DHCP IP address lease on TAP-Win32 adapter: %s (code=%u)", + strerror_win32 (status, &gc), + (unsigned int)status); } - else - msg (M_WARN, "WARNING: Failed to renew DHCP IP address lease on TAP-Win32 adapter: %s (code=%u)", - strerror_win32 (status, &gc), - (unsigned int)status); - } gc_free (&gc); return ret; } ----------------------- quote ----------------------From a first glance, this looks like "whitespace changes only".
For easier review: would you be so kind and re-send your patch with "diff -uw" (-w = ignore white space changes)?
Quoted 10 lines
thanks,
gert
--
USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...
openvpn-2.1.1/tun.c renamed from openvpn-2.1.1-org/tun.c +98 -22
@@ -63,6 +63,7 @@#ifdef TARGET_SOLARIS static void solaris_error_close (struct tuntap *tt,const struct env_set *es,const char *actual); +#include <stropts.h> #endif bool
@@ -701,7 +702,13 @@ ); }else -no_tap_ifconfig (); +argv_printf (&argv, +" %s %s %s netmask %s broadcast + up" , +IFCONFIG_PATH , + actual, + ifconfig_local, + ifconfig_remote_netmask + );argv_msg (M_INFO , &argv);if (!openvpn_execve_check (&argv, es,0 ,"Solaris ifconfig phase-2 failed" ))
@@ -1383,15 +1390,17 @@void open_tun (const char *dev,const char *dev_type,const char *dev_node,bool ipv6,struct tuntap *tt) { -int if_fd, muxid, ppa =-1 ; -struct ifreq ifr; +int if_fd, ip_muxid, arp_muxid, arp_fd, ppa =-1 ; +struct lifreq ifr;const char *ptr; -const char *ip_node; +const char *ip_node, *arp_node;const char *dev_tuntap_type;int link_type;bool is_tun; +struct strioctl strioc_if, strioc_ppa; -ipv6_support (ipv6, false, tt); +ipv6_support (ipv6, true, tt); +memset (&ifr,0x0 ,sizeof (ifr));if (tt->type ==DEV_TYPE_NULL ) {
@@ -1410,9 +1419,10 @@ }else if (tt->type ==DEV_TYPE_TAP ) { - ip_node ="/dev/ip" ; + ip_node ="/dev/udp" ;if (!dev_node) dev_node ="/dev/tap" ; + arp_node = dev_node; dev_tuntap_type ="tap" ; link_type =I_PLINK ;/* was: I_LINK */ is_tun = false;
@@ -1439,7 +1449,11 @@msg (M_ERR ,"Can't open %s" , dev_node);/* Assign a new PPA and get its unit number. */ -if ((ppa =ioctl (tt->fd,TUNNEWPPA , ppa)) <0 ) + strioc_ppa.ic_cmd =TUNNEWPPA ; + strioc_ppa.ic_timout =0 ; + strioc_ppa.ic_len =sizeof (ppa); + strioc_ppa.ic_dp = (char *)&ppa; +if ((ppa =ioctl (tt->fd,I_STR , &strioc_ppa)) <0 )msg (M_ERR ,"Can't assign new interface" );if ((if_fd =open (dev_node,O_RDWR ,0 )) <0 )
@@ -1448,27 +1462,83 @@if (ioctl (if_fd,I_PUSH ,"ip" ) <0 )msg (M_ERR ,"Can't push IP module" ); +if (tt->type ==DEV_TYPE_TUN ) + {/* Assign ppa according to the unit number returned by tun device */ if (ioctl (if_fd,IF_UNITSEL , (char *) &ppa) <0 )msg (M_ERR ,"Can't set PPA %d" , ppa); + } -if ((muxid =ioctl (tt->ip_fd, link_type, if_fd)) <0 ) -msg (M_ERR ,"Can't link %s device to IP" , dev_tuntap_type); - -close (if_fd); - tt->actual_name = (char *)malloc (32 );check_malloc_return (tt->actual_name);openvpn_snprintf (tt->actual_name,32 ,"%s%d" , dev_tuntap_type, ppa); +if (tt->type ==DEV_TYPE_TAP ) + { +if (ioctl (if_fd,SIOCGLIFFLAGS , &ifr) <0 ) +msg (M_ERR ,"Can't get flags\n" ); +strncpynt (ifr.lifr_name, tt->actual_name,sizeof (ifr.lifr_name)); + ifr.lifr_ppa = ppa; +/* Assign ppa according to the unit number returned by tun device */ +if (ioctl (if_fd,SIOCSLIFNAME , &ifr) <0 ) +msg (M_ERR ,"Can't set PPA %d" , ppa); +if (ioctl (if_fd,SIOCGLIFFLAGS , &ifr) <0 ) +msg (M_ERR ,"Can't get flags\n" ); +/* Push arp module to if_fd */ +if (ioctl (if_fd,I_PUSH ,"arp" ) <0 ) +msg (M_ERR ,"Can't push ARP module" ); + +/* Pop any modules on the stream */ +while (true) + { +if (ioctl (tt->ip_fd,I_POP ,NULL ) <0 ) +break ; + } +/* Push arp module to ip_fd */ +if (ioctl (tt->ip_fd,I_PUSH ,"arp" ) <0 ) +msg (M_ERR ,"Can't push ARP module\n" ); + +/* Open arp_fd */ +if ((arp_fd =open (arp_node,O_RDWR ,0 )) <0 ) +msg (M_ERR ,"Can't open %s\n" , arp_node); +/* Push arp module to arp_fd */ +if (ioctl (arp_fd,I_PUSH ,"arp" ) <0 ) +msg (M_ERR ,"Can't push ARP module\n" ); + +/* Set ifname to arp */ + strioc_if.ic_cmd =SIOCSLIFNAME ; + strioc_if.ic_timout =0 ; + strioc_if.ic_len =sizeof (ifr); + strioc_if.ic_dp = (char *)𝔦 +if (ioctl (arp_fd,I_STR , &strioc_if) <0 ){ +msg (M_ERR ,"Can't set ifname to arp\n" ); + } + } + +if ((ip_muxid =ioctl (tt->ip_fd, link_type, if_fd)) <0 ) +msg (M_ERR ,"Can't link %s device to IP" , dev_tuntap_type); + +if (tt->type ==DEV_TYPE_TAP ) { +if ((arp_muxid =ioctl (tt->ip_fd, link_type, arp_fd)) <0 ) +msg (M_ERR ,"Can't link %s device to ARP" , dev_tuntap_type); +close (arp_fd); + } +CLEAR (ifr); -strncpynt (ifr.ifr_name, tt->actual_name,sizeof (ifr.ifr_name)); - ifr.ifr_ip_muxid = muxid; +strncpynt (ifr.lifr_name, tt->actual_name,sizeof (ifr.lifr_name)); + ifr.lifr_ip_muxid = ip_muxid; +if (tt->type ==DEV_TYPE_TAP ) { + ifr.lifr_arp_muxid = arp_muxid; + } -if (ioctl (tt->ip_fd,SIOCSIFMUXID , &ifr) <0 ) +if (ioctl (tt->ip_fd,SIOCSLIFMUXID , &ifr) <0 ) { -ioctl (tt->ip_fd,I_PUNLINK , muxid); +if (tt->type ==DEV_TYPE_TAP ) + { +ioctl (tt->ip_fd,I_PUNLINK , arp_muxid); + } +ioctl (tt->ip_fd,I_PUNLINK , ip_muxid);msg (M_ERR ,"Can't set multiplexor id" ); }
@@ -1486,19 +1556,25 @@ {if (tt->ip_fd >=0 ) { -struct ifreq ifr; +struct lifreq ifr;CLEAR (ifr); -strncpynt (ifr.ifr_name, tt->actual_name,sizeof (ifr.ifr_name)); +strncpynt (ifr.lifr_name, tt->actual_name,sizeof (ifr.lifr_name)); -if (ioctl (tt->ip_fd,SIOCGIFFLAGS , &ifr) <0 ) +if (ioctl (tt->ip_fd,SIOCGLIFFLAGS , &ifr) <0 )msg (M_WARN |M_ERRNO ,"Can't get iface flags" ); -if (ioctl (tt->ip_fd,SIOCGIFMUXID , &ifr) <0 ) +if (ioctl (tt->ip_fd,SIOCGLIFMUXID , &ifr) <0 )msg (M_WARN |M_ERRNO ,"Can't get multiplexor id" ); -if (ioctl (tt->ip_fd,I_PUNLINK , ifr.ifr_ip_muxid) <0 ) -msg (M_WARN |M_ERRNO ,"Can't unlink interface" ); +if (tt->type ==DEV_TYPE_TAP ) + { +if (ioctl (tt->ip_fd,I_PUNLINK , ifr.lifr_arp_muxid) <0 ) +msg (M_WARN |M_ERRNO ,"Can't unlink interface(arp)" ); + } +if (ioctl (tt->ip_fd,I_PUNLINK , ifr.lifr_ip_muxid) <0 ) +msg (M_WARN |M_ERRNO ,"Can't unlink interface(ip)" ); +close (tt->ip_fd); tt->ip_fd =-1 ; }
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Hi,
Quoted 2 lines · Kazuyoshi Aizawa
Thank you for your support.
Please find attached patch with diff -uw.
Thanks.
I wouldn't claim to understand why the specific changes are needed, but this way it is obvious that the changes really only affect the Solaris-specific part of tun.c.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...