]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert some old-TPROXY code in forward.cc not previously done.
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 1 Apr 2008 11:13:48 +0000 (23:13 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 1 Apr 2008 11:13:48 +0000 (23:13 +1200)
src/cache_cf.cc
src/client_side.cc
src/comm.cc
src/comm.h
src/forward.cc

index 37e1c31fe05e64b27d76585bafc120d151000684..d05034d035105ce22505991fd785795c29b0fafb 100644 (file)
@@ -2931,7 +2931,6 @@ parse_http_port_option(http_port_list * s, char *token)
 
     } else if (strcmp(token, "tproxy") == 0) {
         s->tproxy = 1;
-        s->transparent = 1;
         need_linux_tproxy = 1;
 #if USE_IPV6
         /* INET6: until transparent REDIRECT works on IPv6 SOCKET, force wildcard to IPv4 */
index 5cb617f5d9efe9f7f404610c0b6e1939d5944bc5..2914df089fe5a855ea0c9e58e9f03dade22f6d5a 100644 (file)
@@ -2712,7 +2712,6 @@ okToAccept()
 }
 
 ConnStateData *
-
 connStateCreate(const IPAddress &peer, const IPAddress &me, int fd, http_port_list *port)
 {
     ConnStateData *result = new ConnStateData;
@@ -2724,9 +2723,12 @@ connStateCreate(const IPAddress &peer, const IPAddress &me, int fd, http_port_li
     result->in.buf = (char *)memAllocBuf(CLIENT_REQ_BUF_SZ, &result->in.allocatedSize);
     result->port = cbdataReference(port);
 
-    if (port->transparent)
+#if LINUX_TPROXY4
+    if(port->transparent || port->tproxy)
+#else
+    if(port->transparent)
+#endif
     {
-
         IPAddress dst;
 
         if (clientNatLookup(fd, me, peer, dst) == 0) {
@@ -3120,8 +3122,8 @@ clientHttpConnectionsOpen(void)
 #if LINUX_TPROXY4
         /* because the transparent/non-transparent port info is only known here.
          * we have to set the IP_TRANSPARENT option here. */
-        if(s->transparent)
-            comm_set_transparent(fd,0);
+        if(s->tproxy)
+            comm_set_transparent(fd);
 #endif
 
         comm_listen(fd);
index 5d88c9abec75031c0469417468b4696223920850..4de15926e96c6eb2b473b4fec9733c890c76a5b3 100644 (file)
@@ -1328,7 +1328,7 @@ comm_old_accept(int fd, ConnectionDetail &details)
 #if LINUX_TPROXY4
     /* AYJ: do we need to set this again on every accept? */
     if(fd_table[fd].flags.transparent == 1) {
-        comm_set_transparent(sock, 0);
+        comm_set_transparent(sock);
         F->flags.transparent = 1;
     }
 #endif
index eab69615ac3851ea3d14462a0c912bacd2ef7f6b..f3068cfb06825797e4589216462b765fd7eee7d2 100644 (file)
@@ -59,7 +59,7 @@ SQUIDCEXTERN int comm_set_tos(int fd, int tos);
 /**
  * Set the socket IP_TRANSPARENT option for Linux TPROXY v4 support.
  */
-SQUIDCEXTERN void comm_set_transparent(int fd, int tos);
+SQUIDCEXTERN void comm_set_transparent(int fd);
 
 SQUIDCEXTERN void commSetSelect(int, unsigned int, PF *, void *, time_t);
 SQUIDCEXTERN void commResetSelect(int);
index 2c0144106259e43672191dcc760cd451ae7c5d9e..6a6bf5809d4501266cac44d039a94de0fccd430e 100644 (file)
@@ -270,7 +270,7 @@ FwdState::fwdStart(int client_fd, StoreEntry *entry, HttpRequest *request)
 
     default:
         FwdState::Pointer fwd = new FwdState(client_fd, entry, request);
-#if LINUX_TPROXY
+#if LINUX_TPROXY2 || LINUX_TPROXY4
         /* If we need to transparently proxy the request
          * then we need the client source protocol, address and port */
         fwd->src = request->client_addr;
@@ -775,7 +775,7 @@ FwdState::connectStart()
     const char *domain = NULL;
     int ctimeout;
     int ftimeout = Config.Timeout.forward - (squid_curtime - start_t);
-#if LINUX_TPROXY
+#if LINUX_TPROXY2
 
     struct in_tproxy itp;
 #endif
@@ -802,7 +802,7 @@ FwdState::connectStart()
         ctimeout = Config.Timeout.connect;
     }
 
-#if LINUX_TPROXY
+#if LINUX_TPROXY2 || LINUX_TPROXY4
     if (request->flags.tproxy)
         client_addr = request->client_addr;
 
@@ -888,9 +888,14 @@ FwdState::connectStart()
     if (fs->_peer) {
         hierarchyNote(&request->hier, fs->code, fs->_peer->host);
     } else {
-#if LINUX_TPROXY
+#if LINUX_TPROXY2 || LINUX_TPROXY4
 
         if (request->flags.tproxy) {
+
+#if LINUX_TPROXY4
+            comm_set_transparent(fd);
+
+#elif LINUX_TPROXY2
             IPAddress addr;
 
             src.GetInAddr(itp.v.addr.faddr);
@@ -918,6 +923,7 @@ FwdState::connectStart()
                     request->flags.tproxy = 0;
                 }
             }
+#endif
         }
 
 #endif