ipvs: switch to notrack mode
[pandora-kernel.git] / net / netfilter / ipvs / ip_vs_xmit.c
index 21e1a5e..94b53b4 100644 (file)
@@ -26,9 +26,9 @@
 #include <net/route.h>                  /* for ip_route_output */
 #include <net/ipv6.h>
 #include <net/ip6_route.h>
+#include <net/addrconf.h>
 #include <linux/icmpv6.h>
 #include <linux/netfilter.h>
-#include <net/netfilter/nf_conntrack.h>
 #include <linux/netfilter_ipv4.h>
 
 #include <net/ip_vs.h>
  *      Destination cache to speed up outgoing route lookup
  */
 static inline void
-__ip_vs_dst_set(struct ip_vs_dest *dest, u32 rtos, struct dst_entry *dst)
+__ip_vs_dst_set(struct ip_vs_dest *dest, u32 rtos, struct dst_entry *dst,
+               u32 dst_cookie)
 {
        struct dst_entry *old_dst;
 
        old_dst = dest->dst_cache;
        dest->dst_cache = dst;
        dest->dst_rtos = rtos;
+       dest->dst_cookie = dst_cookie;
        dst_release(old_dst);
 }
 
 static inline struct dst_entry *
-__ip_vs_dst_check(struct ip_vs_dest *dest, u32 rtos, u32 cookie)
+__ip_vs_dst_check(struct ip_vs_dest *dest, u32 rtos)
 {
        struct dst_entry *dst = dest->dst_cache;
 
        if (!dst)
                return NULL;
-       if ((dst->obsolete
-            || (dest->af == AF_INET && rtos != dest->dst_rtos)) &&
-           dst->ops->check(dst, cookie) == NULL) {
+       if ((dst->obsolete || rtos != dest->dst_rtos) &&
+           dst->ops->check(dst, dest->dst_cookie) == NULL) {
                dest->dst_cache = NULL;
                dst_release(dst);
                return NULL;
@@ -67,15 +68,16 @@ __ip_vs_dst_check(struct ip_vs_dest *dest, u32 rtos, u32 cookie)
 }
 
 static struct rtable *
-__ip_vs_get_out_rt(struct ip_vs_conn *cp, u32 rtos)
+__ip_vs_get_out_rt(struct sk_buff *skb, struct ip_vs_conn *cp, u32 rtos)
 {
+       struct net *net = dev_net(skb->dev);
        struct rtable *rt;                      /* Route to the other host */
        struct ip_vs_dest *dest = cp->dest;
 
        if (dest) {
                spin_lock(&dest->dst_lock);
                if (!(rt = (struct rtable *)
-                     __ip_vs_dst_check(dest, rtos, 0))) {
+                     __ip_vs_dst_check(dest, rtos))) {
                        struct flowi fl = {
                                .oif = 0,
                                .nl_u = {
@@ -85,13 +87,13 @@ __ip_vs_get_out_rt(struct ip_vs_conn *cp, u32 rtos)
                                                .tos = rtos, } },
                        };
 
-                       if (ip_route_output_key(&init_net, &rt, &fl)) {
+                       if (ip_route_output_key(net, &rt, &fl)) {
                                spin_unlock(&dest->dst_lock);
                                IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n",
                                             &dest->addr.ip);
                                return NULL;
                        }
-                       __ip_vs_dst_set(dest, rtos, dst_clone(&rt->dst));
+                       __ip_vs_dst_set(dest, rtos, dst_clone(&rt->dst), 0);
                        IP_VS_DBG(10, "new dst %pI4, refcnt=%d, rtos=%X\n",
                                  &dest->addr.ip,
                                  atomic_read(&rt->dst.__refcnt), rtos);
@@ -107,7 +109,7 @@ __ip_vs_get_out_rt(struct ip_vs_conn *cp, u32 rtos)
                                        .tos = rtos, } },
                };
 
-               if (ip_route_output_key(&init_net, &rt, &fl)) {
+               if (ip_route_output_key(net, &rt, &fl)) {
                        IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n",
                                     &cp->daddr.ip);
                        return NULL;
@@ -118,62 +120,79 @@ __ip_vs_get_out_rt(struct ip_vs_conn *cp, u32 rtos)
 }
 
 #ifdef CONFIG_IP_VS_IPV6
+
+static struct dst_entry *
+__ip_vs_route_output_v6(struct net *net, struct in6_addr *daddr,
+                       struct in6_addr *ret_saddr, int do_xfrm)
+{
+       struct dst_entry *dst;
+       struct flowi fl = {
+               .oif = 0,
+               .nl_u = {
+                       .ip6_u = {
+                               .daddr = *daddr,
+                       },
+               },
+       };
+
+       dst = ip6_route_output(net, NULL, &fl);
+       if (dst->error)
+               goto out_err;
+       if (!ret_saddr)
+               return dst;
+       if (ipv6_addr_any(&fl.fl6_src) &&
+           ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
+                              &fl.fl6_dst, 0, &fl.fl6_src) < 0)
+               goto out_err;
+       if (do_xfrm && xfrm_lookup(net, &dst, &fl, NULL, 0) < 0)
+               goto out_err;
+       ipv6_addr_copy(ret_saddr, &fl.fl6_src);
+       return dst;
+
+out_err:
+       dst_release(dst);
+       IP_VS_DBG_RL("ip6_route_output error, dest: %pI6\n", daddr);
+       return NULL;
+}
+
 static struct rt6_info *
-__ip_vs_get_out_rt_v6(struct ip_vs_conn *cp)
+__ip_vs_get_out_rt_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
+                     struct in6_addr *ret_saddr, int do_xfrm)
 {
+       struct net *net = dev_net(skb->dev);
        struct rt6_info *rt;                    /* Route to the other host */
        struct ip_vs_dest *dest = cp->dest;
+       struct dst_entry *dst;
 
        if (dest) {
                spin_lock(&dest->dst_lock);
-               rt = (struct rt6_info *)__ip_vs_dst_check(dest, 0, 0);
+               rt = (struct rt6_info *)__ip_vs_dst_check(dest, 0);
                if (!rt) {
-                       struct flowi fl = {
-                               .oif = 0,
-                               .nl_u = {
-                                       .ip6_u = {
-                                               .daddr = dest->addr.in6,
-                                               .saddr = {
-                                                       .s6_addr32 =
-                                                               { 0, 0, 0, 0 },
-                                               },
-                                       },
-                               },
-                       };
+                       u32 cookie;
 
-                       rt = (struct rt6_info *)ip6_route_output(&init_net,
-                                                                NULL, &fl);
-                       if (!rt) {
+                       dst = __ip_vs_route_output_v6(net, &dest->addr.in6,
+                                                     &dest->dst_saddr,
+                                                     do_xfrm);
+                       if (!dst) {
                                spin_unlock(&dest->dst_lock);
-                               IP_VS_DBG_RL("ip6_route_output error, dest: %pI6\n",
-                                            &dest->addr.in6);
                                return NULL;
                        }
-                       __ip_vs_dst_set(dest, 0, dst_clone(&rt->dst));
-                       IP_VS_DBG(10, "new dst %pI6, refcnt=%d\n",
-                                 &dest->addr.in6,
+                       rt = (struct rt6_info *) dst;
+                       cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+                       __ip_vs_dst_set(dest, 0, dst_clone(&rt->dst), cookie);
+                       IP_VS_DBG(10, "new dst %pI6, src %pI6, refcnt=%d\n",
+                                 &dest->addr.in6, &dest->dst_saddr,
                                  atomic_read(&rt->dst.__refcnt));
                }
+               if (ret_saddr)
+                       ipv6_addr_copy(ret_saddr, &dest->dst_saddr);
                spin_unlock(&dest->dst_lock);
        } else {
-               struct flowi fl = {
-                       .oif = 0,
-                       .nl_u = {
-                               .ip6_u = {
-                                       .daddr = cp->daddr.in6,
-                                       .saddr = {
-                                               .s6_addr32 = { 0, 0, 0, 0 },
-                                       },
-                               },
-                       },
-               };
-
-               rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl);
-               if (!rt) {
-                       IP_VS_DBG_RL("ip6_route_output error, dest: %pI6\n",
-                                    &cp->daddr.in6);
+               dst = __ip_vs_route_output_v6(net, &cp->daddr.in6, ret_saddr,
+                                             do_xfrm);
+               if (!dst)
                        return NULL;
-               }
+               rt = (struct rt6_info *) dst;
        }
 
        return rt;
@@ -194,12 +213,40 @@ ip_vs_dst_reset(struct ip_vs_dest *dest)
        dst_release(old_dst);
 }
 
-#define IP_VS_XMIT(pf, skb, rt)                                \
+#define IP_VS_XMIT_TUNNEL(skb, cp)                             \
+({                                                             \
+       int __ret = NF_ACCEPT;                                  \
+                                                               \
+       (skb)->ipvs_property = 1;                               \
+       if (unlikely((cp)->flags & IP_VS_CONN_F_NFCT))          \
+               __ret = ip_vs_confirm_conntrack(skb, cp);       \
+       if (__ret == NF_ACCEPT) {                               \
+               nf_reset(skb);                                  \
+               (skb)->ip_summed = CHECKSUM_NONE;               \
+       }                                                       \
+       __ret;                                                  \
+})
+
+#define IP_VS_XMIT_NAT(pf, skb, cp)                            \
 do {                                                   \
        (skb)->ipvs_property = 1;                       \
+       if (likely(!((cp)->flags & IP_VS_CONN_F_NFCT))) \
+               ip_vs_notrack(skb);                     \
+       else                                            \
+               ip_vs_update_conntrack(skb, cp, 1);     \
        skb_forward_csum(skb);                          \
        NF_HOOK(pf, NF_INET_LOCAL_OUT, (skb), NULL,     \
-               (rt)->dst.dev, dst_output);             \
+               skb_dst(skb)->dev, dst_output);         \
+} while (0)
+
+#define IP_VS_XMIT(pf, skb, cp)                                \
+do {                                                   \
+       (skb)->ipvs_property = 1;                       \
+       if (likely(!((cp)->flags & IP_VS_CONN_F_NFCT))) \
+               ip_vs_notrack(skb);                     \
+       skb_forward_csum(skb);                          \
+       NF_HOOK(pf, NF_INET_LOCAL_OUT, (skb), NULL,     \
+               skb_dst(skb)->dev, dst_output);         \
 } while (0)
 
 
@@ -224,6 +271,7 @@ int
 ip_vs_bypass_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
                  struct ip_vs_protocol *pp)
 {
+       struct net *net = dev_net(skb->dev);
        struct rtable *rt;                      /* Route to the other host */
        struct iphdr  *iph = ip_hdr(skb);
        u8     tos = iph->tos;
@@ -239,7 +287,7 @@ ip_vs_bypass_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
 
        EnterFunction(10);
 
-       if (ip_route_output_key(&init_net, &rt, &fl)) {
+       if (ip_route_output_key(net, &rt, &fl)) {
                IP_VS_DBG_RL("%s(): ip_route_output error, dest: %pI4\n",
                             __func__, &iph->daddr);
                goto tx_error_icmp;
@@ -271,7 +319,7 @@ ip_vs_bypass_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       IP_VS_XMIT(NFPROTO_IPV4, skb, rt);
+       IP_VS_XMIT(NFPROTO_IPV4, skb, cp);
 
        LeaveFunction(10);
        return NF_STOLEN;
@@ -289,25 +337,18 @@ int
 ip_vs_bypass_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
                     struct ip_vs_protocol *pp)
 {
+       struct net *net = dev_net(skb->dev);
+       struct dst_entry *dst;
        struct rt6_info *rt;                    /* Route to the other host */
        struct ipv6hdr  *iph = ipv6_hdr(skb);
        int    mtu;
-       struct flowi fl = {
-               .oif = 0,
-               .nl_u = {
-                       .ip6_u = {
-                               .daddr = iph->daddr,
-                               .saddr = { .s6_addr32 = {0, 0, 0, 0} }, } },
-       };
 
        EnterFunction(10);
 
-       rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl);
-       if (!rt) {
-               IP_VS_DBG_RL("%s(): ip6_route_output error, dest: %pI6\n",
-                            __func__, &iph->daddr);
+       dst = __ip_vs_route_output_v6(net, &iph->daddr, NULL, 0);
+       if (!dst)
                goto tx_error_icmp;
-       }
+       rt = (struct rt6_info *) dst;
 
        /* MTU checking */
        mtu = dst_mtu(&rt->dst);
@@ -335,7 +376,7 @@ ip_vs_bypass_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       IP_VS_XMIT(NFPROTO_IPV6, skb, rt);
+       IP_VS_XMIT(NFPROTO_IPV6, skb, cp);
 
        LeaveFunction(10);
        return NF_STOLEN;
@@ -349,30 +390,6 @@ ip_vs_bypass_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
 }
 #endif
 
-static void
-ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp)
-{
-       struct nf_conn *ct = (struct nf_conn *)skb->nfct;
-       struct nf_conntrack_tuple new_tuple;
-
-       if (ct == NULL || nf_ct_is_untracked(ct) || nf_ct_is_confirmed(ct))
-               return;
-
-       /*
-        * The connection is not yet in the hashtable, so we update it.
-        * CIP->VIP will remain the same, so leave the tuple in
-        * IP_CT_DIR_ORIGINAL untouched.  When the reply comes back from the
-        * real-server we will see RIP->DIP.
-        */
-       new_tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
-       new_tuple.src.u3 = cp->daddr;
-       /*
-        * This will also take care of UDP and other protocols.
-        */
-       new_tuple.src.u.tcp.port = cp->dport;
-       nf_conntrack_alter_reply(ct, &new_tuple);
-}
-
 /*
  *      NAT transmitter (only for outside-to-inside nat forwarding)
  *      Not used for related ICMP
@@ -397,7 +414,7 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
                IP_VS_DBG(10, "filled cport=%d\n", ntohs(*p));
        }
 
-       if (!(rt = __ip_vs_get_out_rt(cp, RT_TOS(iph->tos))))
+       if (!(rt = __ip_vs_get_out_rt(skb, cp, RT_TOS(iph->tos))))
                goto tx_error_icmp;
 
        /* MTU checking */
@@ -428,8 +445,6 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
 
        IP_VS_DBG_PKT(10, pp, skb, 0, "After DNAT");
 
-       ip_vs_update_conntrack(skb, cp);
-
        /* FIXME: when application helper enlarges the packet and the length
           is larger than the MTU of outgoing device, there will be still
           MTU problem. */
@@ -437,7 +452,7 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       IP_VS_XMIT(NFPROTO_IPV4, skb, rt);
+       IP_VS_XMIT_NAT(NFPROTO_IPV4, skb, cp);
 
        LeaveFunction(10);
        return NF_STOLEN;
@@ -445,8 +460,8 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
   tx_error_icmp:
        dst_link_failure(skb);
   tx_error:
-       LeaveFunction(10);
        kfree_skb(skb);
+       LeaveFunction(10);
        return NF_STOLEN;
   tx_error_put:
        ip_rt_put(rt);
@@ -474,7 +489,7 @@ ip_vs_nat_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
                IP_VS_DBG(10, "filled cport=%d\n", ntohs(*p));
        }
 
-       rt = __ip_vs_get_out_rt_v6(cp);
+       rt = __ip_vs_get_out_rt_v6(skb, cp, NULL, 0);
        if (!rt)
                goto tx_error_icmp;
 
@@ -506,8 +521,6 @@ ip_vs_nat_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
 
        IP_VS_DBG_PKT(10, pp, skb, 0, "After DNAT");
 
-       ip_vs_update_conntrack(skb, cp);
-
        /* FIXME: when application helper enlarges the packet and the length
           is larger than the MTU of outgoing device, there will be still
           MTU problem. */
@@ -515,7 +528,7 @@ ip_vs_nat_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       IP_VS_XMIT(NFPROTO_IPV6, skb, rt);
+       IP_VS_XMIT_NAT(NFPROTO_IPV6, skb, cp);
 
        LeaveFunction(10);
        return NF_STOLEN;
@@ -561,10 +574,10 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
        struct iphdr  *old_iph = ip_hdr(skb);
        u8     tos = old_iph->tos;
        __be16 df = old_iph->frag_off;
-       sk_buff_data_t old_transport_header = skb->transport_header;
        struct iphdr  *iph;                     /* Our new IP header */
        unsigned int max_headroom;              /* The extra header space needed */
        int    mtu;
+       int ret;
 
        EnterFunction(10);
 
@@ -575,7 +588,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
                goto tx_error;
        }
 
-       if (!(rt = __ip_vs_get_out_rt(cp, RT_TOS(tos))))
+       if (!(rt = __ip_vs_get_out_rt(skb, cp, RT_TOS(tos))))
                goto tx_error_icmp;
 
        tdev = rt->dst.dev;
@@ -619,7 +632,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
                old_iph = ip_hdr(skb);
        }
 
-       skb->transport_header = old_transport_header;
+       skb->transport_header = skb->network_header;
 
        /* fix old IP header checksum */
        ip_send_check(old_iph);
@@ -649,7 +662,11 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       ip_local_out(skb);
+       ret = IP_VS_XMIT_TUNNEL(skb, cp);
+       if (ret == NF_ACCEPT)
+               ip_local_out(skb);
+       else if (ret == NF_DROP)
+               kfree_skb(skb);
 
        LeaveFunction(10);
 
@@ -669,12 +686,13 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
                     struct ip_vs_protocol *pp)
 {
        struct rt6_info *rt;            /* Route to the other host */
+       struct in6_addr saddr;          /* Source for tunnel */
        struct net_device *tdev;        /* Device to other host */
        struct ipv6hdr  *old_iph = ipv6_hdr(skb);
-       sk_buff_data_t old_transport_header = skb->transport_header;
        struct ipv6hdr  *iph;           /* Our new IP header */
        unsigned int max_headroom;      /* The extra header space needed */
        int    mtu;
+       int ret;
 
        EnterFunction(10);
 
@@ -685,17 +703,17 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
                goto tx_error;
        }
 
-       rt = __ip_vs_get_out_rt_v6(cp);
+       rt = __ip_vs_get_out_rt_v6(skb, cp, &saddr, 1);
        if (!rt)
                goto tx_error_icmp;
 
        tdev = rt->dst.dev;
 
        mtu = dst_mtu(&rt->dst) - sizeof(struct ipv6hdr);
-       /* TODO IPv6: do we need this check in IPv6? */
-       if (mtu < 1280) {
+       if (mtu < IPV6_MIN_MTU) {
                dst_release(&rt->dst);
-               IP_VS_DBG_RL("%s(): mtu less than 1280\n", __func__);
+               IP_VS_DBG_RL("%s(): mtu less than %d\n", __func__,
+                            IPV6_MIN_MTU);
                goto tx_error;
        }
        if (skb_dst(skb))
@@ -728,7 +746,7 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
                old_iph = ipv6_hdr(skb);
        }
 
-       skb->transport_header = old_transport_header;
+       skb->transport_header = skb->network_header;
 
        skb_push(skb, sizeof(struct ipv6hdr));
        skb_reset_network_header(skb);
@@ -748,14 +766,18 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
        be16_add_cpu(&iph->payload_len, sizeof(*old_iph));
        iph->priority           =       old_iph->priority;
        memset(&iph->flow_lbl, 0, sizeof(iph->flow_lbl));
-       iph->daddr              =       rt->rt6i_dst.addr;
-       iph->saddr              =       cp->vaddr.in6; /* rt->rt6i_src.addr; */
+       ipv6_addr_copy(&iph->daddr, &cp->daddr.in6);
+       ipv6_addr_copy(&iph->saddr, &saddr);
        iph->hop_limit          =       old_iph->hop_limit;
 
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       ip6_local_out(skb);
+       ret = IP_VS_XMIT_TUNNEL(skb, cp);
+       if (ret == NF_ACCEPT)
+               ip6_local_out(skb);
+       else if (ret == NF_DROP)
+               kfree_skb(skb);
 
        LeaveFunction(10);
 
@@ -785,7 +807,7 @@ ip_vs_dr_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
 
        EnterFunction(10);
 
-       if (!(rt = __ip_vs_get_out_rt(cp, RT_TOS(iph->tos))))
+       if (!(rt = __ip_vs_get_out_rt(skb, cp, RT_TOS(iph->tos))))
                goto tx_error_icmp;
 
        /* MTU checking */
@@ -814,7 +836,7 @@ ip_vs_dr_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       IP_VS_XMIT(NFPROTO_IPV4, skb, rt);
+       IP_VS_XMIT(NFPROTO_IPV4, skb, cp);
 
        LeaveFunction(10);
        return NF_STOLEN;
@@ -837,7 +859,7 @@ ip_vs_dr_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
 
        EnterFunction(10);
 
-       rt = __ip_vs_get_out_rt_v6(cp);
+       rt = __ip_vs_get_out_rt_v6(skb, cp, NULL, 0);
        if (!rt)
                goto tx_error_icmp;
 
@@ -867,7 +889,7 @@ ip_vs_dr_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       IP_VS_XMIT(NFPROTO_IPV6, skb, rt);
+       IP_VS_XMIT(NFPROTO_IPV6, skb, cp);
 
        LeaveFunction(10);
        return NF_STOLEN;
@@ -913,7 +935,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
         * mangle and send the packet here (only for VS/NAT)
         */
 
-       if (!(rt = __ip_vs_get_out_rt(cp, RT_TOS(ip_hdr(skb)->tos))))
+       if (!(rt = __ip_vs_get_out_rt(skb, cp, RT_TOS(ip_hdr(skb)->tos))))
                goto tx_error_icmp;
 
        /* MTU checking */
@@ -941,7 +963,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       IP_VS_XMIT(NFPROTO_IPV4, skb, rt);
+       IP_VS_XMIT(NFPROTO_IPV4, skb, cp);
 
        rc = NF_STOLEN;
        goto out;
@@ -987,7 +1009,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
         * mangle and send the packet here (only for VS/NAT)
         */
 
-       rt = __ip_vs_get_out_rt_v6(cp);
+       rt = __ip_vs_get_out_rt_v6(skb, cp, NULL, 0);
        if (!rt)
                goto tx_error_icmp;
 
@@ -1016,7 +1038,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* Another hack: avoid icmp_send in ip_fragment */
        skb->local_df = 1;
 
-       IP_VS_XMIT(NFPROTO_IPV6, skb, rt);
+       IP_VS_XMIT(NFPROTO_IPV6, skb, cp);
 
        rc = NF_STOLEN;
        goto out;