Use I_LINK instead of I_PLINK on Solaris
authorDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 9 Dec 2011 13:05:33 +0000 (13:05 +0000)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 9 Dec 2011 13:08:35 +0000 (13:08 +0000)
This should avoid leaving stale tunnel devices around, because they'll
automatically go away when the fd gets closed.

This is only for Legacy IP though; We are still plumbing for IPv6 in the
vpnc-script, which is weird and inconsistent. If only I could work out
how to do it in tun.c like we do for IPv4...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
openconnect-internal.h
tun.c
www/changelog.xml

index 16db3ed..f879244 100644 (file)
@@ -190,7 +190,6 @@ struct openconnect_info {
 
 #ifdef __sun__
        int ip_fd;
-       int tun_muxid;
 #endif
        int tun_fd;
        int ssl_fd;
diff --git a/tun.c b/tun.c
index 6699143..ed61b72 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -500,7 +500,7 @@ int setup_tun(struct openconnect_info *vpninfo)
                        close(ip_fd);
                        return -EIO;
                }
-               mux_id = ioctl(ip_fd, I_PLINK, tun2_fd);
+               mux_id = ioctl(ip_fd, I_LINK, tun2_fd);
                if (mux_id < 0) {
                        perror(_("Can't link tun to IP"));
                        close(tun2_fd);
@@ -520,13 +520,9 @@ int setup_tun(struct openconnect_info *vpninfo)
                if (ioctl(ip_fd, SIOCSIFMUXID, &ifr) < 0) {
                        perror(_("Set mux id"));
                        close(tun_fd);
-                       ioctl(ip_fd, I_PUNLINK, mux_id);
                        close(ip_fd);
                        return -EIO;
                }
-               /* Solaris tunctl needs this in order to tear it down */
-               vpn_progress(vpninfo, PRG_DEBUG, _("mux id is %d\n"), mux_id);
-               vpninfo->tun_muxid = mux_id;
                vpninfo->ip_fd = ip_fd;
 
 #else /* BSD et al have /dev/tun$x devices */
@@ -699,9 +695,6 @@ void shutdown_tun(struct openconnect_info *vpninfo)
                        }
                }
 #ifdef __sun__
-               if (ioctl(vpninfo->ip_fd, I_PUNLINK, vpninfo->tun_muxid) < 0)
-                       perror(_("ioctl(I_PUNLINK)"));
-
                close(vpninfo->ip_fd);
                vpninfo->ip_fd = -1;
 #endif
index fbc9ce6..55194e5 100644 (file)
@@ -17,6 +17,7 @@
 <ul>
    <li><b>OpenConnect HEAD</b>
      <ul>
+       <li>Use <tt>I_LINK</tt> instead of <tt>I_PLINK</tt> on Solaris to plumb interface.</li>
        <li>Refer to <a href="vpnc-script.html">vpnc-script</a> and <a href="mail.html">help</a> web pages in openconnect output.</li>
        <li>Fix potential crash when processing libproxy results.</li>
        <li>Be more conservative in detecting libproxy without pkg-config.</li>