Commit efd85700 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

route: Set lwtstate for local traffic and cached input dsts

A route on the output path hitting a RTN_LOCAL route will keep the dst
associated on its way through the loopback device. On the receive path,
the dst_input() call will thus invoke the input handler of the route
created in the output path. Thus, lwt redirection for input must be done
for dsts allocated in the otuput path as well.

Also, if a route is cached in the input path, the allocated dst should
respect lwtunnel configuration on the nexthop as well.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 11b3d9c5
...@@ -1603,6 +1603,19 @@ static void ip_del_fnhe(struct fib_nh *nh, __be32 daddr) ...@@ -1603,6 +1603,19 @@ static void ip_del_fnhe(struct fib_nh *nh, __be32 daddr)
spin_unlock_bh(&fnhe_lock); spin_unlock_bh(&fnhe_lock);
} }
static void set_lwt_redirect(struct rtable *rth)
{
if (lwtunnel_output_redirect(rth->dst.lwtstate)) {
rth->dst.lwtstate->orig_output = rth->dst.output;
rth->dst.output = lwtunnel_output;
}
if (lwtunnel_input_redirect(rth->dst.lwtstate)) {
rth->dst.lwtstate->orig_input = rth->dst.input;
rth->dst.input = lwtunnel_input;
}
}
/* called in rcu_read_lock() section */ /* called in rcu_read_lock() section */
static int __mkroute_input(struct sk_buff *skb, static int __mkroute_input(struct sk_buff *skb,
const struct fib_result *res, const struct fib_result *res,
...@@ -1692,14 +1705,7 @@ static int __mkroute_input(struct sk_buff *skb, ...@@ -1692,14 +1705,7 @@ static int __mkroute_input(struct sk_buff *skb,
rth->dst.input = ip_forward; rth->dst.input = ip_forward;
rt_set_nexthop(rth, daddr, res, fnhe, res->fi, res->type, itag); rt_set_nexthop(rth, daddr, res, fnhe, res->fi, res->type, itag);
if (lwtunnel_output_redirect(rth->dst.lwtstate)) { set_lwt_redirect(rth);
rth->dst.lwtstate->orig_output = rth->dst.output;
rth->dst.output = lwtunnel_output;
}
if (lwtunnel_input_redirect(rth->dst.lwtstate)) {
rth->dst.lwtstate->orig_input = rth->dst.input;
rth->dst.input = lwtunnel_input;
}
skb_dst_set(skb, &rth->dst); skb_dst_set(skb, &rth->dst);
out: out:
err = 0; err = 0;
...@@ -1926,8 +1932,18 @@ out: return err; ...@@ -1926,8 +1932,18 @@ out: return err;
rth->dst.error= -err; rth->dst.error= -err;
rth->rt_flags &= ~RTCF_LOCAL; rth->rt_flags &= ~RTCF_LOCAL;
} }
if (do_cache) { if (do_cache) {
if (unlikely(!rt_cache_route(&FIB_RES_NH(res), rth))) { struct fib_nh *nh = &FIB_RES_NH(res);
rth->dst.lwtstate = lwtstate_get(nh->nh_lwtstate);
if (lwtunnel_input_redirect(rth->dst.lwtstate)) {
WARN_ON(rth->dst.input == lwtunnel_input);
rth->dst.lwtstate->orig_input = rth->dst.input;
rth->dst.input = lwtunnel_input;
}
if (unlikely(!rt_cache_route(nh, rth))) {
rth->dst.flags |= DST_NOCACHE; rth->dst.flags |= DST_NOCACHE;
rt_add_uncached_list(rth); rt_add_uncached_list(rth);
} }
...@@ -2155,10 +2171,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res, ...@@ -2155,10 +2171,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
} }
rt_set_nexthop(rth, fl4->daddr, res, fnhe, fi, type, 0); rt_set_nexthop(rth, fl4->daddr, res, fnhe, fi, type, 0);
if (lwtunnel_output_redirect(rth->dst.lwtstate)) { set_lwt_redirect(rth);
rth->dst.lwtstate->orig_output = rth->dst.output;
rth->dst.output = lwtunnel_output;
}
return rth; return rth;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment