]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix ICAP service sockets for splt-stack systems.
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 9 Aug 2010 08:23:45 +0000 (20:23 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 9 Aug 2010 08:23:45 +0000 (20:23 +1200)
Makes split-stack systems default to IPv4-only connections.
Adds "ipv6=on|off" option to icap_service config to make Squid do
IPv6-only connections for particular service.

There is currently no middle ground with connection failover possible.

doc/release-notes/release-3.1.sgml
src/adaptation/ServiceConfig.cc
src/adaptation/ServiceConfig.h
src/adaptation/icap/Xaction.cc
src/cf.data.pre

index f766cca90f6f7cc227488438022442a4414b8c53..38679f17988aabbac9846404e1c01e3987ee6f19 100644 (file)
@@ -1158,8 +1158,8 @@ NOCOMMENT_START
        <tag>https_port intercept sslbump connection-auth[=on|off]</tag>
        <p>New port options. see http_port.
 
-       <tag>icap_service bypass=on|off|1|0 routing=on|off|1|0</tag>
-       <p>New options 'bypass=' and 'routing='.
+       <tag>icap_service bypass=on|off|1|0 routing=on|off|1|0 ipv6=on|off</tag>
+       <p>New options 'bypass=', 'routing=' and 'ipv6='.
        <verb>
        bypass=on|off|1|0
                If set to 'on' or '1', the ICAP service is treated as
@@ -1186,6 +1186,11 @@ NOCOMMENT_START
 
                Routing is not allowed by default: the ICAP X-Next-Services
                response header is ignored.
+
+       ipv6=on|off
+               Only has effect on split-stack systems. The default on those systems
+               is to use IPv4-only connections. When set to 'on' this option will
+               make Squid use IPv6-only connections to contact this ICAP service.
        </verb>
 
        <tag>logfile_rotate</tag>
index 5372b3c78adfd32c4c939022c8c2679c98203cb7..f69f66e3117eb5a2024d28475a5ce671c2ea54ef 100644 (file)
@@ -8,7 +8,7 @@
 
 Adaptation::ServiceConfig::ServiceConfig():
         port(-1), method(methodNone), point(pointNone),
-        bypass(false), routing(false)
+        bypass(false), routing(false), ipv6(false)
 {}
 
 const char *
@@ -93,7 +93,9 @@ Adaptation::ServiceConfig::parse()
             grokked = grokBool(bypass, name, value);
         else if (strcmp(name, "routing") == 0)
             grokked = grokBool(routing, name, value);
-        else {
+        if (strcmp(name, "ipv6") == 0) {
+            grokked = grokBool(ipv6, name, value);
+        } else {
             debugs(3, 0, cfg_filename << ':' << config_lineno << ": " <<
                    "unknown adaptation service option: " << name << '=' << value);
         }
index 6fdd8a53bd097550a3b18518b90a139318873369..ceff004743d1824f5bf8c6eefcb5134be266dc10 100644 (file)
@@ -33,6 +33,7 @@ public:
     VectPoint point; // where the adaptation happens (pre- or post-cache)
     bool bypass;
     bool routing; ///< whether this service may determine the next service(s)
+    bool ipv6;    ///< whether this service uses IPv6 transport (default IPv4)
 
 protected:
     Method parseMethod(const char *buf) const;
index 6fbeb1fcc1896f95deb75f4d0897cdce0f6b461b..42cb0fcb2797d18abdab3b51e3c84eef7d4e463b 100644 (file)
@@ -13,6 +13,7 @@
 #include "pconn.h"
 #include "HttpRequest.h"
 #include "HttpReply.h"
+#include "ip/tools.h"
 #include "acl/FilledChecklist.h"
 #include "icap_log.h"
 #include "fde.h"
@@ -116,6 +117,15 @@ void Adaptation::Icap::Xaction::openConnection()
     disableRetries(); // we only retry pconn failures
 
     Ip::Address outgoing;
+    if (!Ip::EnableIpv6 && !outgoing.SetIPv4()) {
+        debugs(31, DBG_CRITICAL, "ERROR: IPv6 is disabled. " << outgoing << " is not an IPv4 address.");
+        dieOnConnectionFailure(); // throws
+    }
+    /* split-stack for now requires default IPv4-only socket */
+    if (Ip::EnableIpv6&IPV6_SPECIAL_SPLITSTACK && outgoing.IsAnyAddr() && !s.cfg().ipv6) {
+        outgoing.SetIPv4();
+    }
+
     connection = comm_open(SOCK_STREAM, 0, outgoing,
                            COMM_NONBLOCKING, s.cfg().uri.termedBuf());
 
index a338fdaf9a207ccfd760a082091daee41d245b82..01d20eee1406c24b0507a6e3afcdb8e2a2ce5e57 100644 (file)
@@ -6168,6 +6168,11 @@ DOC_START
                Routing is not allowed by default: the ICAP X-Next-Services
                response header is ignored.
 
+       ipv6=on|off
+               Only has effect on split-stack systems. The default on those systems
+               is to use IPv4-only connections. When set to 'on' this option will
+               make Squid use IPv6-only connections to contact this ICAP service.
+
        Older icap_service format without optional named parameters is
        deprecated but supported for backward compatibility.