aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/dst.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/dst.h')
-rw-r--r--include/net/dst.h68
1 files changed, 54 insertions, 14 deletions
diff --git a/include/net/dst.h b/include/net/dst.h
index ffe9cb719c0e..93b0310317be 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -70,7 +70,7 @@ struct dst_entry {
70 70
71 struct dst_ops *ops; 71 struct dst_ops *ops;
72 72
73 u32 metrics[RTAX_MAX]; 73 u32 _metrics[RTAX_MAX];
74 74
75#ifdef CONFIG_NET_CLS_ROUTE 75#ifdef CONFIG_NET_CLS_ROUTE
76 __u32 tclassid; 76 __u32 tclassid;
@@ -94,19 +94,59 @@ struct dst_entry {
94 int __use; 94 int __use;
95 unsigned long lastuse; 95 unsigned long lastuse;
96 union { 96 union {
97 struct dst_entry *next; 97 struct dst_entry *next;
98 struct rtable __rcu *rt_next; 98 struct rtable __rcu *rt_next;
99 struct rt6_info *rt6_next; 99 struct rt6_info *rt6_next;
100 struct dn_route *dn_next; 100 struct dn_route __rcu *dn_next;
101 }; 101 };
102}; 102};
103 103
104#ifdef __KERNEL__ 104#ifdef __KERNEL__
105 105
106static inline u32 106static inline u32
107dst_metric(const struct dst_entry *dst, int metric) 107dst_metric_raw(const struct dst_entry *dst, const int metric)
108{ 108{
109 return dst->metrics[metric-1]; 109 return dst->_metrics[metric-1];
110}
111
112static inline u32
113dst_metric(const struct dst_entry *dst, const int metric)
114{
115 WARN_ON_ONCE(metric == RTAX_HOPLIMIT ||
116 metric == RTAX_ADVMSS ||
117 metric == RTAX_MTU);
118 return dst_metric_raw(dst, metric);
119}
120
121static inline u32
122dst_metric_advmss(const struct dst_entry *dst)
123{
124 u32 advmss = dst_metric_raw(dst, RTAX_ADVMSS);
125
126 if (!advmss)
127 advmss = dst->ops->default_advmss(dst);
128
129 return advmss;
130}
131
132static inline void dst_metric_set(struct dst_entry *dst, int metric, u32 val)
133{
134 dst->_metrics[metric-1] = val;
135}
136
137static inline void dst_import_metrics(struct dst_entry *dst, const u32 *src_metrics)
138{
139 memcpy(dst->_metrics, src_metrics, RTAX_MAX * sizeof(u32));
140}
141
142static inline void dst_copy_metrics(struct dst_entry *dest, const struct dst_entry *src)
143{
144 dst_import_metrics(dest, src->_metrics);
145}
146
147static inline u32 *dst_metrics_ptr(struct dst_entry *dst)
148{
149 return dst->_metrics;
110} 150}
111 151
112static inline u32 152static inline u32
@@ -117,11 +157,11 @@ dst_feature(const struct dst_entry *dst, u32 feature)
117 157
118static inline u32 dst_mtu(const struct dst_entry *dst) 158static inline u32 dst_mtu(const struct dst_entry *dst)
119{ 159{
120 u32 mtu = dst_metric(dst, RTAX_MTU); 160 u32 mtu = dst_metric_raw(dst, RTAX_MTU);
121 /* 161
122 * Alexey put it here, so ask him about it :) 162 if (!mtu)
123 */ 163 mtu = dst->ops->default_mtu(dst);
124 barrier(); 164
125 return mtu; 165 return mtu;
126} 166}
127 167
@@ -134,7 +174,7 @@ static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metr
134static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric, 174static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric,
135 unsigned long rtt) 175 unsigned long rtt)
136{ 176{
137 dst->metrics[metric-1] = jiffies_to_msecs(rtt); 177 dst_metric_set(dst, metric, jiffies_to_msecs(rtt));
138} 178}
139 179
140static inline u32 180static inline u32
@@ -147,7 +187,7 @@ dst_allfrag(const struct dst_entry *dst)
147} 187}
148 188
149static inline int 189static inline int
150dst_metric_locked(struct dst_entry *dst, int metric) 190dst_metric_locked(const struct dst_entry *dst, int metric)
151{ 191{
152 return dst_metric(dst, RTAX_LOCK) & (1<<metric); 192 return dst_metric(dst, RTAX_LOCK) & (1<<metric);
153} 193}