Commit c6e97af6 authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji

[IPV4]: Store idev in routes.

parent d10920ba
...@@ -55,6 +55,8 @@ struct rtable ...@@ -55,6 +55,8 @@ struct rtable
struct rtable *rt_next; struct rtable *rt_next;
} u; } u;
struct in_device *idev;
unsigned rt_flags; unsigned rt_flags;
unsigned rt_type; unsigned rt_type;
......
...@@ -1040,6 +1040,8 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw, ...@@ -1040,6 +1040,8 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
rt->u.dst.child = NULL; rt->u.dst.child = NULL;
if (rt->u.dst.dev) if (rt->u.dst.dev)
dev_hold(rt->u.dst.dev); dev_hold(rt->u.dst.dev);
if (rt->idev)
in_dev_hold(rt->idev);
rt->u.dst.obsolete = 0; rt->u.dst.obsolete = 0;
rt->u.dst.lastuse = jiffies; rt->u.dst.lastuse = jiffies;
rt->u.dst.path = &rt->u.dst; rt->u.dst.path = &rt->u.dst;
...@@ -1321,11 +1323,17 @@ static void ipv4_dst_destroy(struct dst_entry *dst) ...@@ -1321,11 +1323,17 @@ static void ipv4_dst_destroy(struct dst_entry *dst)
{ {
struct rtable *rt = (struct rtable *) dst; struct rtable *rt = (struct rtable *) dst;
struct inet_peer *peer = rt->peer; struct inet_peer *peer = rt->peer;
struct in_device *idev = rt->idev;
if (peer) { if (peer) {
rt->peer = NULL; rt->peer = NULL;
inet_putpeer(peer); inet_putpeer(peer);
} }
if (idev) {
rt->idev = NULL;
in_dev_put(idev);
}
} }
static void ipv4_link_failure(struct sk_buff *skb) static void ipv4_link_failure(struct sk_buff *skb)
...@@ -1486,6 +1494,7 @@ static int ip_route_input_mc(struct sk_buff *skb, u32 daddr, u32 saddr, ...@@ -1486,6 +1494,7 @@ static int ip_route_input_mc(struct sk_buff *skb, u32 daddr, u32 saddr,
rth->fl.iif = dev->ifindex; rth->fl.iif = dev->ifindex;
rth->u.dst.dev = &loopback_dev; rth->u.dst.dev = &loopback_dev;
dev_hold(rth->u.dst.dev); dev_hold(rth->u.dst.dev);
rth->idev = in_dev_get(rth->u.dst.dev);
rth->fl.oif = 0; rth->fl.oif = 0;
rth->rt_gateway = daddr; rth->rt_gateway = daddr;
rth->rt_spec_dst= spec_dst; rth->rt_spec_dst= spec_dst;
...@@ -1695,6 +1704,7 @@ static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr, ...@@ -1695,6 +1704,7 @@ static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr,
rth->fl.iif = dev->ifindex; rth->fl.iif = dev->ifindex;
rth->u.dst.dev = out_dev->dev; rth->u.dst.dev = out_dev->dev;
dev_hold(rth->u.dst.dev); dev_hold(rth->u.dst.dev);
rth->idev = in_dev_get(rth->u.dst.dev);
rth->fl.oif = 0; rth->fl.oif = 0;
rth->rt_spec_dst= spec_dst; rth->rt_spec_dst= spec_dst;
...@@ -1774,6 +1784,7 @@ out: return err; ...@@ -1774,6 +1784,7 @@ out: return err;
rth->fl.iif = dev->ifindex; rth->fl.iif = dev->ifindex;
rth->u.dst.dev = &loopback_dev; rth->u.dst.dev = &loopback_dev;
dev_hold(rth->u.dst.dev); dev_hold(rth->u.dst.dev);
rth->idev = in_dev_get(rth->u.dst.dev);
rth->rt_gateway = daddr; rth->rt_gateway = daddr;
rth->rt_spec_dst= spec_dst; rth->rt_spec_dst= spec_dst;
rth->u.dst.input= ip_local_deliver; rth->u.dst.input= ip_local_deliver;
...@@ -2157,6 +2168,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp) ...@@ -2157,6 +2168,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
rth->rt_iif = oldflp->oif ? : dev_out->ifindex; rth->rt_iif = oldflp->oif ? : dev_out->ifindex;
rth->u.dst.dev = dev_out; rth->u.dst.dev = dev_out;
dev_hold(dev_out); dev_hold(dev_out);
rth->idev = in_dev_get(dev_out);
rth->rt_gateway = fl.fl4_dst; rth->rt_gateway = fl.fl4_dst;
rth->rt_spec_dst= fl.fl4_src; rth->rt_spec_dst= fl.fl4_src;
......
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