diff options
author | David S. Miller <davem@davemloft.net> | 2010-12-09 00:16:57 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-09 13:46:36 -0500 |
commit | defb3519a64141608725e2dac5a5aa9a3c644bae (patch) | |
tree | 2f44985e44aef53a0d99991b9f5c2f0eb6dbf4ad /net/decnet | |
parent | 84b3cdc38cd2882d7ac3c2ae4b6faf5c199874e3 (diff) |
net: Abstract away all dst_entry metrics accesses.
Use helper functions to hide all direct accesses, especially writes,
to dst_entry metrics values.
This will allow us to:
1) More easily change how the metrics are stored.
2) Implement COW for metrics.
In particular this will help us put metrics into the inetpeer
cache if that is what we end up doing. We can make the _metrics
member a pointer instead of an array, initially have it point
at the read-only metrics in the FIB, and then on the first set
grab an inetpeer entry and point the _metrics member there.
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Diffstat (limited to 'net/decnet')
-rw-r--r-- | net/decnet/dn_route.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 8280e43c8861..e2e926841fe6 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c | |||
@@ -240,13 +240,13 @@ static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
240 | 240 | ||
241 | if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= min_mtu) { | 241 | if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= min_mtu) { |
242 | if (!(dst_metric_locked(dst, RTAX_MTU))) { | 242 | if (!(dst_metric_locked(dst, RTAX_MTU))) { |
243 | dst->metrics[RTAX_MTU-1] = mtu; | 243 | dst_metric_set(dst, RTAX_MTU, mtu); |
244 | dst_set_expires(dst, dn_rt_mtu_expires); | 244 | dst_set_expires(dst, dn_rt_mtu_expires); |
245 | } | 245 | } |
246 | if (!(dst_metric_locked(dst, RTAX_ADVMSS))) { | 246 | if (!(dst_metric_locked(dst, RTAX_ADVMSS))) { |
247 | u32 mss = mtu - DN_MAX_NSP_DATA_HEADER; | 247 | u32 mss = mtu - DN_MAX_NSP_DATA_HEADER; |
248 | if (dst_metric(dst, RTAX_ADVMSS) > mss) | 248 | if (dst_metric(dst, RTAX_ADVMSS) > mss) |
249 | dst->metrics[RTAX_ADVMSS-1] = mss; | 249 | dst_metric_set(dst, RTAX_ADVMSS, mss); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | } | 252 | } |
@@ -806,8 +806,7 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res) | |||
806 | if (DN_FIB_RES_GW(*res) && | 806 | if (DN_FIB_RES_GW(*res) && |
807 | DN_FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) | 807 | DN_FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) |
808 | rt->rt_gateway = DN_FIB_RES_GW(*res); | 808 | rt->rt_gateway = DN_FIB_RES_GW(*res); |
809 | memcpy(rt->dst.metrics, fi->fib_metrics, | 809 | dst_import_metrics(&rt->dst, fi->fib_metrics); |
810 | sizeof(rt->dst.metrics)); | ||
811 | } | 810 | } |
812 | rt->rt_type = res->type; | 811 | rt->rt_type = res->type; |
813 | 812 | ||
@@ -820,11 +819,11 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res) | |||
820 | 819 | ||
821 | if (dst_metric(&rt->dst, RTAX_MTU) == 0 || | 820 | if (dst_metric(&rt->dst, RTAX_MTU) == 0 || |
822 | dst_metric(&rt->dst, RTAX_MTU) > rt->dst.dev->mtu) | 821 | dst_metric(&rt->dst, RTAX_MTU) > rt->dst.dev->mtu) |
823 | rt->dst.metrics[RTAX_MTU-1] = rt->dst.dev->mtu; | 822 | dst_metric_set(&rt->dst, RTAX_MTU, rt->dst.dev->mtu); |
824 | mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->dst)); | 823 | mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->dst)); |
825 | if (dst_metric(&rt->dst, RTAX_ADVMSS) == 0 || | 824 | if (dst_metric(&rt->dst, RTAX_ADVMSS) == 0 || |
826 | dst_metric(&rt->dst, RTAX_ADVMSS) > mss) | 825 | dst_metric(&rt->dst, RTAX_ADVMSS) > mss) |
827 | rt->dst.metrics[RTAX_ADVMSS-1] = mss; | 826 | dst_metric_set(&rt->dst, RTAX_ADVMSS, mss); |
828 | return 0; | 827 | return 0; |
829 | } | 828 | } |
830 | 829 | ||
@@ -1502,7 +1501,7 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, | |||
1502 | RTA_PUT(skb, RTA_PREFSRC, 2, &rt->rt_local_src); | 1501 | RTA_PUT(skb, RTA_PREFSRC, 2, &rt->rt_local_src); |
1503 | if (rt->rt_daddr != rt->rt_gateway) | 1502 | if (rt->rt_daddr != rt->rt_gateway) |
1504 | RTA_PUT(skb, RTA_GATEWAY, 2, &rt->rt_gateway); | 1503 | RTA_PUT(skb, RTA_GATEWAY, 2, &rt->rt_gateway); |
1505 | if (rtnetlink_put_metrics(skb, rt->dst.metrics) < 0) | 1504 | if (rtnetlink_put_metrics(skb, dst_metrics_ptr(&rt->dst)) < 0) |
1506 | goto rtattr_failure; | 1505 | goto rtattr_failure; |
1507 | expires = rt->dst.expires ? rt->dst.expires - jiffies : 0; | 1506 | expires = rt->dst.expires ? rt->dst.expires - jiffies : 0; |
1508 | if (rtnl_put_cacheinfo(skb, &rt->dst, 0, 0, 0, expires, | 1507 | if (rtnl_put_cacheinfo(skb, &rt->dst, 0, 0, 0, expires, |