fix for transparent proxy in latest VGER CVS

David S. Miller (davem@jenolan.rutgers.edu)
Tue, 7 Oct 1997 18:14:48 -0400


This makes it compile once again. Things work without any
redirections enabled, as to whether those work I don't know yet.

--- net/ipv4/tcp_ipv4.c.~1~ Sun Oct 5 20:27:03 1997
+++ net/ipv4/tcp_ipv4.c Tue Oct 7 22:05:42 1997
@@ -5,7 +5,7 @@
*
* Implementation of the Transmission Control Protocol(TCP).
*
- * Version: $Id: tcp_ipv4.c,v 1.71 1997/10/05 20:31:39 davem Exp $
+ * Version: $Id: tcp_ipv4.c,v 1.72 1997/10/07 22:09:39 davem Exp $
*
* IPv4 specific functions
*
@@ -404,17 +404,25 @@
#define tcp_v4_proxy_loop_next(hnum, hpnum, sk, fpass) \
secondlist((hpnum),(sk)->bind_next,(fpass))

-struct sock *tcp_v4_proxy_lookup(unsigned short num, unsigned long raddr,
- unsigned short rnum, unsigned long laddr,
- unsigned long paddr, unsigned short pnum,
- int dif)
+static struct sock *tcp_v4_proxy_lookup(unsigned short num, unsigned long raddr,
+ unsigned short rnum, unsigned long laddr,
+ struct device *dev, unsigned short pnum,
+ int dif)
{
struct sock *s, *result = NULL;
int badness = -1;
+ u32 paddr = 0;
unsigned short hnum = ntohs(num);
unsigned short hpnum = ntohs(pnum);
int firstpass = 1;

+ if(dev && dev->ip_ptr) {
+ struct in_device *idev = dev->ip_ptr;
+
+ if(idev->ifa_list)
+ paddr = idev->ifa_list->ifa_local;
+ }
+
/* This code must run only from NET_BH. */
for(s = tcp_v4_proxy_loop_init(hnum, hpnum, s, firstpass);
s != NULL;
@@ -1554,11 +1562,13 @@

#ifdef CONFIG_IP_TRANSPARENT_PROXY
if (IPCB(skb)->redirport)
- sk = tcp_v4_proxy_lookup(th->dest, saddr, th->source, daddr,
- skb->dev->pa_addr, IPCB(skb)->redirport, skb->dev->ifindex);
+ sk = tcp_v4_proxy_lookup(th->dest, skb->nh.iph->saddr, th->source,
+ skb->nh.iph->daddr, skb->dev,
+ IPCB(skb)->redirport, skb->dev->ifindex);
else
#endif
- sk = __tcp_v4_lookup(th, skb->nh.iph->saddr, th->source, skb->nh.iph->daddr, th->dest, skb->dev->ifindex);
+ sk = __tcp_v4_lookup(th, skb->nh.iph->saddr, th->source,
+ skb->nh.iph->daddr, th->dest, skb->dev->ifindex);
if (!sk)
goto no_tcp_socket;
if(!ipsec_sk_policy(sk,skb))
--- net/ipv4/udp.c.~1~ Sun Oct 5 20:27:05 1997
+++ net/ipv4/udp.c Tue Oct 7 22:05:45 1997
@@ -5,7 +5,7 @@
*
* The User Datagram Protocol (UDP).
*
- * Version: $Id: udp.c,v 1.42 1997/10/05 20:31:41 davem Exp $
+ * Version: $Id: udp.c,v 1.43 1997/10/07 22:09:42 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -373,17 +373,25 @@
#define udp_v4_proxy_loop_next(hnum, hpnum, sk, fpass) \
secondlist((hpnum),(sk)->next,(fpass))

-struct sock *udp_v4_proxy_lookup(unsigned short num, unsigned long raddr,
- unsigned short rnum, unsigned long laddr,
- unsigned long paddr, unsigned short pnum,
- int dif)
+static struct sock *udp_v4_proxy_lookup(unsigned short num, unsigned long raddr,
+ unsigned short rnum, unsigned long laddr,
+ struct device *dev, unsigned short pnum,
+ int dif)
{
struct sock *s, *result = NULL;
int badness = -1;
+ u32 paddr = 0;
unsigned short hnum = ntohs(num);
unsigned short hpnum = ntohs(pnum);
int firstpass = 1;

+ if(dev && dev->ip_ptr) {
+ struct in_device *idev = dev->ip_ptr;
+
+ if(idev->ifa_list)
+ paddr = idev->ifa_list->ifa_local;
+ }
+
SOCKHASH_LOCK();
for(s = udp_v4_proxy_loop_init(hnum, hpnum, s, firstpass);
s != NULL;
@@ -1111,8 +1119,8 @@
#ifdef CONFIG_IP_TRANSPARENT_PROXY
if (IPCB(skb)->redirport)
sk = udp_v4_proxy_lookup(uh->dest, saddr, uh->source,
- daddr, skb->dev->pa_addr,
- IPCB(skb)->redirport, skb->dev->ifindex);
+ daddr, skb->dev, IPCB(skb)->redirport,
+ skb->dev->ifindex);
else
#endif
sk = udp_v4_lookup(saddr, uh->source, daddr, uh->dest, skb->dev->ifindex);