summaryrefslogtreecommitdiffstats
path: root/include/net/dst.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-12-09 06:16:57 +0100
committerDavid S. Miller <davem@davemloft.net>2010-12-09 19:46:36 +0100
commitdefb3519a64141608725e2dac5a5aa9a3c644bae (patch)
tree2f44985e44aef53a0d99991b9f5c2f0eb6dbf4ad /include/net/dst.h
parentcan: slcan: Add missing linux/sched.h include. (diff)
downloadlinux-defb3519a64141608725e2dac5a5aa9a3c644bae.tar.xz
linux-defb3519a64141608725e2dac5a5aa9a3c644bae.zip
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 'include/net/dst.h')
-rw-r--r--include/net/dst.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/include/net/dst.h b/include/net/dst.h
index a5bd72646d65..85dee3a57b9b 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -70,7 +70,7 @@ struct dst_entry {
struct dst_ops *ops;
- u32 metrics[RTAX_MAX];
+ u32 _metrics[RTAX_MAX];
#ifdef CONFIG_NET_CLS_ROUTE
__u32 tclassid;
@@ -106,7 +106,27 @@ struct dst_entry {
static inline u32
dst_metric(const struct dst_entry *dst, int metric)
{
- return dst->metrics[metric-1];
+ return dst->_metrics[metric-1];
+}
+
+static inline void dst_metric_set(struct dst_entry *dst, int metric, u32 val)
+{
+ dst->_metrics[metric-1] = val;
+}
+
+static inline void dst_import_metrics(struct dst_entry *dst, const u32 *src_metrics)
+{
+ memcpy(dst->_metrics, src_metrics, RTAX_MAX * sizeof(u32));
+}
+
+static inline void dst_copy_metrics(struct dst_entry *dest, const struct dst_entry *src)
+{
+ dst_import_metrics(dest, src->_metrics);
+}
+
+static inline u32 *dst_metrics_ptr(struct dst_entry *dst)
+{
+ return dst->_metrics;
}
static inline u32
@@ -134,7 +154,7 @@ static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metr
static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric,
unsigned long rtt)
{
- dst->metrics[metric-1] = jiffies_to_msecs(rtt);
+ dst_metric_set(dst, metric, jiffies_to_msecs(rtt));
}
static inline u32