dst.h (f43dc23d5ea91fca257be02138a255f02d98e806) dst.h (c7066f70d9610df0b9406cc635fc09e86136e714)
1/*
2 * net/dst.h Protocol independent destination cache definitions.
3 *
4 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
5 *
6 */
7
8#ifndef _NET_DST_H

--- 56 unchanged lines hidden (view full) ---

65#else
66 void *__pad1;
67#endif
68 int (*input)(struct sk_buff*);
69 int (*output)(struct sk_buff*);
70
71 struct dst_ops *ops;
72
1/*
2 * net/dst.h Protocol independent destination cache definitions.
3 *
4 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
5 *
6 */
7
8#ifndef _NET_DST_H

--- 56 unchanged lines hidden (view full) ---

65#else
66 void *__pad1;
67#endif
68 int (*input)(struct sk_buff*);
69 int (*output)(struct sk_buff*);
70
71 struct dst_ops *ops;
72
73 u32 _metrics[RTAX_MAX];
73 u32 metrics[RTAX_MAX];
74
74
75#ifdef CONFIG_NET_CLS_ROUTE
75#ifdef CONFIG_IP_ROUTE_CLASSID
76 __u32 tclassid;
77#else
78 __u32 __pad2;
79#endif
80
81
82 /*
83 * Align __refcnt to a 64 bytes alignment

--- 15 unchanged lines hidden (view full) ---

99 struct rt6_info *rt6_next;
100 struct dn_route __rcu *dn_next;
101 };
102};
103
104#ifdef __KERNEL__
105
106static inline u32
76 __u32 tclassid;
77#else
78 __u32 __pad2;
79#endif
80
81
82 /*
83 * Align __refcnt to a 64 bytes alignment

--- 15 unchanged lines hidden (view full) ---

99 struct rt6_info *rt6_next;
100 struct dn_route __rcu *dn_next;
101 };
102};
103
104#ifdef __KERNEL__
105
106static inline u32
107dst_metric_raw(const struct dst_entry *dst, const int metric)
107dst_metric(const struct dst_entry *dst, int metric)
108{
108{
109 return dst->_metrics[metric-1];
109 return dst->metrics[metric-1];
110}
111
112static inline u32
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;
150}
151
152static inline u32
153dst_feature(const struct dst_entry *dst, u32 feature)
154{
155 return dst_metric(dst, RTAX_FEATURES) & feature;
156}
157
158static inline u32 dst_mtu(const struct dst_entry *dst)
159{
113dst_feature(const struct dst_entry *dst, u32 feature)
114{
115 return dst_metric(dst, RTAX_FEATURES) & feature;
116}
117
118static inline u32 dst_mtu(const struct dst_entry *dst)
119{
160 u32 mtu = dst_metric_raw(dst, RTAX_MTU);
161
162 if (!mtu)
163 mtu = dst->ops->default_mtu(dst);
164
120 u32 mtu = dst_metric(dst, RTAX_MTU);
121 /*
122 * Alexey put it here, so ask him about it :)
123 */
124 barrier();
165 return mtu;
166}
167
168/* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */
169static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metric)
170{
171 return msecs_to_jiffies(dst_metric(dst, metric));
172}
173
174static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric,
175 unsigned long rtt)
176{
125 return mtu;
126}
127
128/* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */
129static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metric)
130{
131 return msecs_to_jiffies(dst_metric(dst, metric));
132}
133
134static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric,
135 unsigned long rtt)
136{
177 dst_metric_set(dst, metric, jiffies_to_msecs(rtt));
137 dst->metrics[metric-1] = jiffies_to_msecs(rtt);
178}
179
180static inline u32
181dst_allfrag(const struct dst_entry *dst)
182{
183 int ret = dst_feature(dst, RTAX_FEATURE_ALLFRAG);
184 /* Yes, _exactly_. This is paranoia. */
185 barrier();
186 return ret;
187}
188
189static inline int
138}
139
140static inline u32
141dst_allfrag(const struct dst_entry *dst)
142{
143 int ret = dst_feature(dst, RTAX_FEATURE_ALLFRAG);
144 /* Yes, _exactly_. This is paranoia. */
145 barrier();
146 return ret;
147}
148
149static inline int
190dst_metric_locked(const struct dst_entry *dst, int metric)
150dst_metric_locked(struct dst_entry *dst, int metric)
191{
192 return dst_metric(dst, RTAX_LOCK) & (1<<metric);
193}
194
195static inline void dst_hold(struct dst_entry * dst)
196{
197 /*
198 * If your kernel compilation stops here, please check

--- 213 unchanged lines hidden ---
151{
152 return dst_metric(dst, RTAX_LOCK) & (1<<metric);
153}
154
155static inline void dst_hold(struct dst_entry * dst)
156{
157 /*
158 * If your kernel compilation stops here, please check

--- 213 unchanged lines hidden ---