aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-12-14 16:01:14 -0500
committerDavid S. Miller <davem@davemloft.net>2010-12-14 16:01:14 -0500
commitd33e455337ea2c71d09d7f4367d6ad6dd32b6965 (patch)
treed1b35b1be5ab73df6f7e57b86a2e68fad2990adf /include
parent9fe146aef44afe5ec677d8150b6ae94e09b773f7 (diff)
net: Abstract default MTU metric calculation behind an accessor.
Like RTAX_ADVMSS, make the default calculation go through a dst_ops method rather than caching the computation in the routing cache entries. Now dst metrics are pretty much left as-is when new entries are created, thus optimizing metric sharing becomes a real possibility. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/dst.h15
-rw-r--r--include/net/dst_ops.h1
2 files changed, 9 insertions, 7 deletions
diff --git a/include/net/dst.h b/include/net/dst.h
index 03a1c3d52d80..93b0310317be 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -113,7 +113,8 @@ static inline u32
113dst_metric(const struct dst_entry *dst, const int metric) 113dst_metric(const struct dst_entry *dst, const int metric)
114{ 114{
115 WARN_ON_ONCE(metric == RTAX_HOPLIMIT || 115 WARN_ON_ONCE(metric == RTAX_HOPLIMIT ||
116 metric == RTAX_ADVMSS); 116 metric == RTAX_ADVMSS ||
117 metric == RTAX_MTU);
117 return dst_metric_raw(dst, metric); 118 return dst_metric_raw(dst, metric);
118} 119}
119 120
@@ -156,11 +157,11 @@ dst_feature(const struct dst_entry *dst, u32 feature)
156 157
157static inline u32 dst_mtu(const struct dst_entry *dst) 158static inline u32 dst_mtu(const struct dst_entry *dst)
158{ 159{
159 u32 mtu = dst_metric(dst, RTAX_MTU); 160 u32 mtu = dst_metric_raw(dst, RTAX_MTU);
160 /* 161
161 * Alexey put it here, so ask him about it :) 162 if (!mtu)
162 */ 163 mtu = dst->ops->default_mtu(dst);
163 barrier(); 164
164 return mtu; 165 return mtu;
165} 166}
166 167
@@ -186,7 +187,7 @@ dst_allfrag(const struct dst_entry *dst)
186} 187}
187 188
188static inline int 189static inline int
189dst_metric_locked(struct dst_entry *dst, int metric) 190dst_metric_locked(const struct dst_entry *dst, int metric)
190{ 191{
191 return dst_metric(dst, RTAX_LOCK) & (1<<metric); 192 return dst_metric(dst, RTAX_LOCK) & (1<<metric);
192} 193}
diff --git a/include/net/dst_ops.h b/include/net/dst_ops.h
index 15fb7af08c42..21a320b8708e 100644
--- a/include/net/dst_ops.h
+++ b/include/net/dst_ops.h
@@ -17,6 +17,7 @@ struct dst_ops {
17 int (*gc)(struct dst_ops *ops); 17 int (*gc)(struct dst_ops *ops);
18 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); 18 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie);
19 unsigned int (*default_advmss)(const struct dst_entry *); 19 unsigned int (*default_advmss)(const struct dst_entry *);
20 unsigned int (*default_mtu)(const struct dst_entry *);
20 void (*destroy)(struct dst_entry *); 21 void (*destroy)(struct dst_entry *);
21 void (*ifdown)(struct dst_entry *, 22 void (*ifdown)(struct dst_entry *,
22 struct net_device *dev, int how); 23 struct net_device *dev, int how);