]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - include/net/dst.h
net: Abstract default ADVMSS behind an accessor.
[mv-sheeva.git] / include / net / dst.h
index ffe9cb719c0e526302bb2d4635c6f402ce31c867..03a1c3d52d808c06f9349405c30f85663bcaf313 100644 (file)
@@ -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;
@@ -94,19 +94,58 @@ struct dst_entry {
        int                     __use;
        unsigned long           lastuse;
        union {
-               struct dst_entry *next;
-               struct rtable __rcu *rt_next;
-               struct rt6_info   *rt6_next;
-               struct dn_route  *dn_next;
+               struct dst_entry        *next;
+               struct rtable __rcu     *rt_next;
+               struct rt6_info         *rt6_next;
+               struct dn_route __rcu   *dn_next;
        };
 };
 
 #ifdef __KERNEL__
 
 static inline u32
-dst_metric(const struct dst_entry *dst, int metric)
+dst_metric_raw(const struct dst_entry *dst, const int metric)
 {
-       return dst->metrics[metric-1];
+       return dst->_metrics[metric-1];
+}
+
+static inline u32
+dst_metric(const struct dst_entry *dst, const int metric)
+{
+       WARN_ON_ONCE(metric == RTAX_HOPLIMIT ||
+                    metric == RTAX_ADVMSS);
+       return dst_metric_raw(dst, metric);
+}
+
+static inline u32
+dst_metric_advmss(const struct dst_entry *dst)
+{
+       u32 advmss = dst_metric_raw(dst, RTAX_ADVMSS);
+
+       if (!advmss)
+               advmss = dst->ops->default_advmss(dst);
+
+       return advmss;
+}
+
+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 +173,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