LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

[PATCH ipvs,v2 08/18] ipvs: Only do ip_hdr operations in *out_rt when sk

To: <horms@xxxxxxxxxxxx>
Subject: [PATCH ipvs,v2 08/18] ipvs: Only do ip_hdr operations in *out_rt when skb_af is AF_INET
Cc: <ja@xxxxxx>, <lvs-devel@xxxxxxxxxxxxxxx>, <kernel-team@xxxxxx>, Alex Gartrell <agartrell@xxxxxx>
From: Alex Gartrell <agartrell@xxxxxx>
Date: Thu, 14 Aug 2014 20:23:31 -0700
We can no longer count on always being able to access a v4 ip header, so
just drop the local variable and use ip_hdr only when skb_af is AF_INET.

Signed-off-by: Alex Gartrell <agartrell@xxxxxx>
---
 net/netfilter/ipvs/ip_vs_xmit.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 193ad01..7990641 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -228,8 +228,7 @@ __ip_vs_get_out_rt(int skb_af, struct sk_buff *skb, struct 
ip_vs_dest *dest,
        struct netns_ipvs *ipvs = net_ipvs(net);
        struct ip_vs_dest_dst *dest_dst;
        struct rtable *rt;                      /* Route to the other host */
-       struct iphdr *iph;
-       __be16 df;
+       __be16 df = 0;
        int mtu;
        int local, noref = 1;
 
@@ -284,7 +283,6 @@ __ip_vs_get_out_rt(int skb_af, struct sk_buff *skb, struct 
ip_vs_dest *dest,
                IP_VS_DBG_RL("We are crossing local and non-local addresses\n");
                goto err_put;
        }
-       iph = ip_hdr(skb);
 
        if (unlikely(local)) {
                /* skb to local stack, preserve old route */
@@ -295,7 +293,8 @@ __ip_vs_get_out_rt(int skb_af, struct sk_buff *skb, struct 
ip_vs_dest *dest,
 
        if (likely(!(rt_mode & IP_VS_RT_MODE_TUNNEL))) {
                mtu = dst_mtu(&rt->dst);
-               df = iph->frag_off & htons(IP_DF);
+               if (skb_af == AF_INET)
+                       df = ip_hdr(skb)->frag_off & htons(IP_DF);
        } else {
                mtu = dst_mtu(&rt->dst) - sizeof(struct iphdr);
                if (mtu < 68) {
@@ -304,13 +303,14 @@ __ip_vs_get_out_rt(int skb_af, struct sk_buff *skb, 
struct ip_vs_dest *dest,
                }
                maybe_update_pmtu(skb_af, skb, mtu);
                /* MTU check allowed? */
-               df = sysctl_pmtu_disc(ipvs) ? iph->frag_off & htons(IP_DF) : 0;
+               if (skb_af == AF_INET && sysctl_pmtu_disc(ipvs))
+                       df = ip_hdr(skb)->frag_off & htons(IP_DF);
        }
 
        /* MTU checking */
        if (unlikely(df && skb->len > mtu && !skb_is_gso(skb))) {
                icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
-               IP_VS_DBG(1, "frag needed for %pI4\n", &iph->saddr);
+               IP_VS_DBG(1, "frag needed for %pI4\n", &ip_hdr(skb)->saddr);
                goto err_put;
        }
 
-- 
1.8.1

--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

<Prev in Thread] Current Thread [Next in Thread>