Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 299525
b: refs/heads/master
c: 1716a96
h: refs/heads/master
i:
  299523: 62d1d08
v: v3
  • Loading branch information
Gao feng authored and David S. Miller committed Apr 13, 2012
1 parent 1db9804 commit 9df0bef
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d62f8dbb5b7771910f7c4657345df8ac93acb832
refs/heads/master: 1716a96101c49186bb0b8491922fd3e69030235f
6 changes: 5 additions & 1 deletion trunk/include/net/dst.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ struct dst_entry {
struct net_device *dev;
struct dst_ops *ops;
unsigned long _metrics;
unsigned long expires;
union {
unsigned long expires;
/* point to where the dst_entry copied from */
struct dst_entry *from;
};
struct dst_entry *path;
struct neighbour __rcu *_neighbour;
#ifdef CONFIG_XFRM
Expand Down
42 changes: 42 additions & 0 deletions trunk/include/net/ip6_fib.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,48 @@ static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
return ((struct rt6_info *)dst)->rt6i_idev;
}

static inline void rt6_clean_expires(struct rt6_info *rt)
{
if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
dst_release(rt->dst.from);

rt->rt6i_flags &= ~RTF_EXPIRES;
rt->dst.expires = 0;
}

static inline void rt6_set_expires(struct rt6_info *rt, unsigned long expires)
{
if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
dst_release(rt->dst.from);

rt->rt6i_flags |= RTF_EXPIRES;
rt->dst.expires = expires;
}

static inline void rt6_update_expires(struct rt6_info *rt, int timeout)
{
if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
dst_release(rt->dst.from);

dst_set_expires(&rt->dst, timeout);
rt->rt6i_flags |= RTF_EXPIRES;
}

static inline void rt6_set_from(struct rt6_info *rt, struct rt6_info *from)
{
struct dst_entry *new = (struct dst_entry *) from;

if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from) {
if (new == rt->dst.from)
return;
dst_release(rt->dst.from);
}

rt->rt6i_flags &= ~RTF_EXPIRES;
rt->dst.from = new;
dst_hold(new);
}

struct fib6_walker_t {
struct list_head lh;
struct fib6_node *root, *node;
Expand Down
9 changes: 3 additions & 6 deletions trunk/net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
ip6_del_rt(rt);
rt = NULL;
} else if (!(rt->rt6i_flags & RTF_EXPIRES)) {
rt->dst.expires = expires;
rt->rt6i_flags |= RTF_EXPIRES;
rt6_set_expires(rt, expires);
}
}
dst_release(&rt->dst);
Expand Down Expand Up @@ -1887,11 +1886,9 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
rt = NULL;
} else if (addrconf_finite_timeout(rt_expires)) {
/* not infinity */
rt->dst.expires = jiffies + rt_expires;
rt->rt6i_flags |= RTF_EXPIRES;
rt6_set_expires(rt, jiffies + rt_expires);
} else {
rt->rt6i_flags &= ~RTF_EXPIRES;
rt->dst.expires = 0;
rt6_clean_expires(rt);
}
} else if (valid_lft) {
clock_t expires = 0;
Expand Down
9 changes: 4 additions & 5 deletions trunk/net/ipv6/ip6_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,10 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
&rt->rt6i_gateway)) {
if (!(iter->rt6i_flags & RTF_EXPIRES))
return -EEXIST;
iter->dst.expires = rt->dst.expires;
if (!(rt->rt6i_flags & RTF_EXPIRES)) {
iter->rt6i_flags &= ~RTF_EXPIRES;
iter->dst.expires = 0;
}
if (!(rt->rt6i_flags & RTF_EXPIRES))
rt6_clean_expires(iter);
else
rt6_set_expires(iter, rt->dst.expires);
return -EEXIST;
}
}
Expand Down
3 changes: 1 addition & 2 deletions trunk/net/ipv6/ndisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
}

if (rt)
rt->dst.expires = jiffies + (HZ * lifetime);

rt6_set_expires(rt, jiffies + (HZ * lifetime));
if (ra_msg->icmph.icmp6_hop_limit) {
in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
if (rt)
Expand Down
71 changes: 44 additions & 27 deletions trunk/net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <linux/sysctl.h>
#endif

static struct rt6_info *ip6_rt_copy(const struct rt6_info *ort,
static struct rt6_info *ip6_rt_copy(struct rt6_info *ort,
const struct in6_addr *dest);
static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie);
static unsigned int ip6_default_advmss(const struct dst_entry *dst);
Expand Down Expand Up @@ -285,6 +285,10 @@ static void ip6_dst_destroy(struct dst_entry *dst)
rt->rt6i_idev = NULL;
in6_dev_put(idev);
}

if (!(rt->rt6i_flags & RTF_EXPIRES) && dst->from)
dst_release(dst->from);

if (peer) {
rt->rt6i_peer = NULL;
inet_putpeer(peer);
Expand Down Expand Up @@ -329,8 +333,17 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,

static __inline__ int rt6_check_expired(const struct rt6_info *rt)
{
return (rt->rt6i_flags & RTF_EXPIRES) &&
time_after(jiffies, rt->dst.expires);
struct rt6_info *ort = NULL;

if (rt->rt6i_flags & RTF_EXPIRES) {
if (time_after(jiffies, rt->dst.expires))
return 1;
} else if (rt->dst.from) {
ort = (struct rt6_info *) rt->dst.from;
return (ort->rt6i_flags & RTF_EXPIRES) &&
time_after(jiffies, ort->dst.expires);
}
return 0;
}

static inline int rt6_need_strict(const struct in6_addr *daddr)
Expand Down Expand Up @@ -620,12 +633,11 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
(rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);

if (rt) {
if (!addrconf_finite_timeout(lifetime)) {
rt->rt6i_flags &= ~RTF_EXPIRES;
} else {
rt->dst.expires = jiffies + HZ * lifetime;
rt->rt6i_flags |= RTF_EXPIRES;
}
if (!addrconf_finite_timeout(lifetime))
rt6_clean_expires(rt);
else
rt6_set_expires(rt, jiffies + HZ * lifetime);

dst_release(&rt->dst);
}
return 0;
Expand Down Expand Up @@ -730,7 +742,7 @@ int ip6_ins_rt(struct rt6_info *rt)
return __ip6_ins_rt(rt, &info);
}

static struct rt6_info *rt6_alloc_cow(const struct rt6_info *ort,
static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort,
const struct in6_addr *daddr,
const struct in6_addr *saddr)
{
Expand Down Expand Up @@ -954,10 +966,10 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
rt->rt6i_idev = ort->rt6i_idev;
if (rt->rt6i_idev)
in6_dev_hold(rt->rt6i_idev);
rt->dst.expires = 0;

rt->rt6i_gateway = ort->rt6i_gateway;
rt->rt6i_flags = ort->rt6i_flags & ~RTF_EXPIRES;
rt->rt6i_flags = ort->rt6i_flags;
rt6_clean_expires(rt);
rt->rt6i_metric = 0;

memcpy(&rt->rt6i_dst, &ort->rt6i_dst, sizeof(struct rt6key));
Expand Down Expand Up @@ -1019,10 +1031,9 @@ static void ip6_link_failure(struct sk_buff *skb)

rt = (struct rt6_info *) skb_dst(skb);
if (rt) {
if (rt->rt6i_flags & RTF_CACHE) {
dst_set_expires(&rt->dst, 0);
rt->rt6i_flags |= RTF_EXPIRES;
} else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT))
if (rt->rt6i_flags & RTF_CACHE)
rt6_update_expires(rt, 0);
else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT))
rt->rt6i_node->fn_sernum = -1;
}
}
Expand Down Expand Up @@ -1289,9 +1300,12 @@ int ip6_route_add(struct fib6_config *cfg)
}

rt->dst.obsolete = -1;
rt->dst.expires = (cfg->fc_flags & RTF_EXPIRES) ?
jiffies + clock_t_to_jiffies(cfg->fc_expires) :
0;

if (cfg->fc_flags & RTF_EXPIRES)
rt6_set_expires(rt, jiffies +
clock_t_to_jiffies(cfg->fc_expires));
else
rt6_clean_expires(rt);

if (cfg->fc_protocol == RTPROT_UNSPEC)
cfg->fc_protocol = RTPROT_BOOT;
Expand Down Expand Up @@ -1736,8 +1750,8 @@ static void rt6_do_pmtu_disc(const struct in6_addr *daddr, const struct in6_addr
features |= RTAX_FEATURE_ALLFRAG;
dst_metric_set(&rt->dst, RTAX_FEATURES, features);
}
dst_set_expires(&rt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires);
rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES;
rt6_update_expires(rt, net->ipv6.sysctl.ip6_rt_mtu_expires);
rt->rt6i_flags |= RTF_MODIFIED;
goto out;
}

Expand Down Expand Up @@ -1765,9 +1779,8 @@ static void rt6_do_pmtu_disc(const struct in6_addr *daddr, const struct in6_addr
* which is 10 mins. After 10 mins the decreased pmtu is expired
* and detecting PMTU increase will be automatically happened.
*/
dst_set_expires(&nrt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires);
nrt->rt6i_flags |= RTF_DYNAMIC|RTF_EXPIRES;

rt6_update_expires(nrt, net->ipv6.sysctl.ip6_rt_mtu_expires);
nrt->rt6i_flags |= RTF_DYNAMIC;
ip6_ins_rt(nrt);
}
out:
Expand Down Expand Up @@ -1799,7 +1812,7 @@ void rt6_pmtu_discovery(const struct in6_addr *daddr, const struct in6_addr *sad
* Misc support functions
*/

static struct rt6_info *ip6_rt_copy(const struct rt6_info *ort,
static struct rt6_info *ip6_rt_copy(struct rt6_info *ort,
const struct in6_addr *dest)
{
struct net *net = dev_net(ort->dst.dev);
Expand All @@ -1819,10 +1832,14 @@ static struct rt6_info *ip6_rt_copy(const struct rt6_info *ort,
if (rt->rt6i_idev)
in6_dev_hold(rt->rt6i_idev);
rt->dst.lastuse = jiffies;
rt->dst.expires = 0;

rt->rt6i_gateway = ort->rt6i_gateway;
rt->rt6i_flags = ort->rt6i_flags & ~RTF_EXPIRES;
rt->rt6i_flags = ort->rt6i_flags;
if ((ort->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ==
(RTF_DEFAULT | RTF_ADDRCONF))
rt6_set_from(rt, ort);
else
rt6_clean_expires(rt);
rt->rt6i_metric = 0;

#ifdef CONFIG_IPV6_SUBTREES
Expand Down

0 comments on commit 9df0bef

Please sign in to comment.