aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/dccp/ackvec.h49
-rw-r--r--net/dccp/ccid.c136
-rw-r--r--net/dccp/ccid.h3
-rw-r--r--net/dccp/feat.c2
4 files changed, 14 insertions, 176 deletions
diff --git a/net/dccp/ackvec.h b/net/dccp/ackvec.h
index 569a33a79baa..45f95e55f873 100644
--- a/net/dccp/ackvec.h
+++ b/net/dccp/ackvec.h
@@ -84,7 +84,6 @@ struct dccp_ackvec_record {
84struct sock; 84struct sock;
85struct sk_buff; 85struct sk_buff;
86 86
87#ifndef ___OLD_INTERFACE_TO_BE_REMOVED___
88extern int dccp_ackvec_init(void); 87extern int dccp_ackvec_init(void);
89extern void dccp_ackvec_exit(void); 88extern void dccp_ackvec_exit(void);
90 89
@@ -106,52 +105,4 @@ static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
106{ 105{
107 return av->av_vec_len; 106 return av->av_vec_len;
108} 107}
109#else /* ___OLD_INTERFACE_TO_BE_REMOVED___ */
110static inline int dccp_ackvec_init(void)
111{
112 return 0;
113}
114
115static inline void dccp_ackvec_exit(void)
116{
117}
118
119static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
120{
121 return NULL;
122}
123
124static inline void dccp_ackvec_free(struct dccp_ackvec *av)
125{
126}
127
128static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
129 const u64 ackno, const u8 state)
130{
131 return -1;
132}
133
134static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
135 struct sock *sk, const u64 ackno)
136{
137}
138
139static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
140 const u64 *ackno, const u8 opt,
141 const u8 *value, const u8 len)
142{
143 return -1;
144}
145
146static inline int dccp_insert_option_ackvec(const struct sock *sk,
147 const struct sk_buff *skb)
148{
149 return -1;
150}
151
152static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
153{
154 return 0;
155}
156#endif /* CONFIG_IP_DCCP_ACKVEC */
157#endif /* _ACKVEC_H */ 108#endif /* _ACKVEC_H */
diff --git a/net/dccp/ccid.c b/net/dccp/ccid.c
index 538d3b1da623..19b214ad5e06 100644
--- a/net/dccp/ccid.c
+++ b/net/dccp/ccid.c
@@ -76,58 +76,6 @@ int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
76 return err; 76 return err;
77} 77}
78 78
79#ifdef ___OLD_INTERFACE_TO_BE_REMOVED___
80static u8 builtin_ccids[] = {
81 DCCPC_CCID2, /* CCID2 is supported by default */
82#if defined(CONFIG_IP_DCCP_CCID3) || defined(CONFIG_IP_DCCP_CCID3_MODULE)
83 DCCPC_CCID3,
84#endif
85};
86
87static struct ccid_operations *ccids[CCID_MAX];
88#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
89static atomic_t ccids_lockct = ATOMIC_INIT(0);
90static DEFINE_SPINLOCK(ccids_lock);
91
92/*
93 * The strategy is: modifications ccids vector are short, do not sleep and
94 * veeery rare, but read access should be free of any exclusive locks.
95 */
96static void ccids_write_lock(void)
97{
98 spin_lock(&ccids_lock);
99 while (atomic_read(&ccids_lockct) != 0) {
100 spin_unlock(&ccids_lock);
101 yield();
102 spin_lock(&ccids_lock);
103 }
104}
105
106static inline void ccids_write_unlock(void)
107{
108 spin_unlock(&ccids_lock);
109}
110
111static inline void ccids_read_lock(void)
112{
113 atomic_inc(&ccids_lockct);
114 smp_mb__after_atomic_inc();
115 spin_unlock_wait(&ccids_lock);
116}
117
118static inline void ccids_read_unlock(void)
119{
120 atomic_dec(&ccids_lockct);
121}
122
123#else
124#define ccids_write_lock() do { } while(0)
125#define ccids_write_unlock() do { } while(0)
126#define ccids_read_lock() do { } while(0)
127#define ccids_read_unlock() do { } while(0)
128#endif
129#endif /* ___OLD_INTERFACE_TO_BE_REMOVED___ */
130
131static struct kmem_cache *ccid_kmem_cache_create(int obj_size, const char *fmt,...) 79static struct kmem_cache *ccid_kmem_cache_create(int obj_size, const char *fmt,...)
132{ 80{
133 struct kmem_cache *slab; 81 struct kmem_cache *slab;
@@ -158,49 +106,6 @@ static void ccid_kmem_cache_destroy(struct kmem_cache *slab)
158 } 106 }
159} 107}
160 108
161#ifdef ___OLD_INTERFACE_TO_BE_REMOVED___
162/* check that up to @array_len members in @ccid_array are supported */
163bool ccid_support_check(u8 const *ccid_array, u8 array_len)
164{
165 u8 i, j, found;
166
167 for (i = 0, found = 0; i < array_len; i++, found = 0) {
168 for (j = 0; !found && j < ARRAY_SIZE(builtin_ccids); j++)
169 found = (ccid_array[i] == builtin_ccids[j]);
170 if (!found)
171 return false;
172 }
173 return true;
174}
175
176/**
177 * ccid_get_builtin_ccids - Provide copy of `builtin' CCID array
178 * @ccid_array: pointer to copy into
179 * @array_len: value to return length into
180 * This function allocates memory - caller must see that it is freed after use.
181 */
182int ccid_get_builtin_ccids(u8 **ccid_array, u8 *array_len)
183{
184 *ccid_array = kmemdup(builtin_ccids, sizeof(builtin_ccids), gfp_any());
185 if (*ccid_array == NULL)
186 return -ENOBUFS;
187 *array_len = ARRAY_SIZE(builtin_ccids);
188 return 0;
189}
190
191int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
192 char __user *optval, int __user *optlen)
193{
194 if (len < sizeof(builtin_ccids))
195 return -EINVAL;
196
197 if (put_user(sizeof(builtin_ccids), optlen) ||
198 copy_to_user(optval, builtin_ccids, sizeof(builtin_ccids)))
199 return -EFAULT;
200 return 0;
201}
202#endif /* ___OLD_INTERFACE_TO_BE_REMOVED___ */
203
204static int ccid_activate(struct ccid_operations *ccid_ops) 109static int ccid_activate(struct ccid_operations *ccid_ops)
205{ 110{
206 int err = -ENOBUFS; 111 int err = -ENOBUFS;
@@ -241,7 +146,7 @@ static void ccid_deactivate(struct ccid_operations *ccid_ops)
241 ccid_ops->ccid_id, ccid_ops->ccid_name); 146 ccid_ops->ccid_id, ccid_ops->ccid_name);
242} 147}
243 148
244struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, gfp_t gfp) 149struct ccid *ccid_new(const u8 id, struct sock *sk, bool rx)
245{ 150{
246 struct ccid_operations *ccid_ops = ccid_by_number(id); 151 struct ccid_operations *ccid_ops = ccid_by_number(id);
247 struct ccid *ccid = NULL; 152 struct ccid *ccid = NULL;
@@ -250,7 +155,7 @@ struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, gfp_t gfp)
250 goto out; 155 goto out;
251 156
252 ccid = kmem_cache_alloc(rx ? ccid_ops->ccid_hc_rx_slab : 157 ccid = kmem_cache_alloc(rx ? ccid_ops->ccid_hc_rx_slab :
253 ccid_ops->ccid_hc_tx_slab, gfp); 158 ccid_ops->ccid_hc_tx_slab, gfp_any());
254 if (ccid == NULL) 159 if (ccid == NULL)
255 goto out; 160 goto out;
256 ccid->ccid_ops = ccid_ops; 161 ccid->ccid_ops = ccid_ops;
@@ -274,41 +179,24 @@ out_free_ccid:
274 goto out; 179 goto out;
275} 180}
276 181
277EXPORT_SYMBOL_GPL(ccid_new);
278
279static void ccid_delete(struct ccid *ccid, struct sock *sk, int rx)
280{
281 struct ccid_operations *ccid_ops;
282
283 if (ccid == NULL)
284 return;
285
286 ccid_ops = ccid->ccid_ops;
287 if (rx) {
288 if (ccid_ops->ccid_hc_rx_exit != NULL)
289 ccid_ops->ccid_hc_rx_exit(sk);
290 kmem_cache_free(ccid_ops->ccid_hc_rx_slab, ccid);
291 } else {
292 if (ccid_ops->ccid_hc_tx_exit != NULL)
293 ccid_ops->ccid_hc_tx_exit(sk);
294 kmem_cache_free(ccid_ops->ccid_hc_tx_slab, ccid);
295 }
296}
297
298void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk) 182void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk)
299{ 183{
300 ccid_delete(ccid, sk, 1); 184 if (ccid != NULL) {
185 if (ccid->ccid_ops->ccid_hc_rx_exit != NULL)
186 ccid->ccid_ops->ccid_hc_rx_exit(sk);
187 kmem_cache_free(ccid->ccid_ops->ccid_hc_rx_slab, ccid);
188 }
301} 189}
302 190
303EXPORT_SYMBOL_GPL(ccid_hc_rx_delete);
304
305void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk) 191void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk)
306{ 192{
307 ccid_delete(ccid, sk, 0); 193 if (ccid != NULL) {
194 if (ccid->ccid_ops->ccid_hc_tx_exit != NULL)
195 ccid->ccid_ops->ccid_hc_tx_exit(sk);
196 kmem_cache_free(ccid->ccid_ops->ccid_hc_tx_slab, ccid);
197 }
308} 198}
309 199
310EXPORT_SYMBOL_GPL(ccid_hc_tx_delete);
311
312int __init ccid_initialize_builtins(void) 200int __init ccid_initialize_builtins(void)
313{ 201{
314 int i, err; 202 int i, err;
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index 75c21c52ed7a..facedd20b531 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -111,8 +111,7 @@ extern int ccid_get_builtin_ccids(u8 **ccid_array, u8 *array_len);
111extern int ccid_getsockopt_builtin_ccids(struct sock *sk, int len, 111extern int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
112 char __user *, int __user *); 112 char __user *, int __user *);
113 113
114extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, 114extern struct ccid *ccid_new(const u8 id, struct sock *sk, bool rx);
115 gfp_t gfp);
116 115
117static inline int ccid_get_current_rx_ccid(struct dccp_sock *dp) 116static inline int ccid_get_current_rx_ccid(struct dccp_sock *dp)
118{ 117{
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index 30f9fb76b921..741b2db24735 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -34,7 +34,7 @@
34static int dccp_hdlr_ccid(struct sock *sk, u64 ccid, bool rx) 34static int dccp_hdlr_ccid(struct sock *sk, u64 ccid, bool rx)
35{ 35{
36 struct dccp_sock *dp = dccp_sk(sk); 36 struct dccp_sock *dp = dccp_sk(sk);
37 struct ccid *new_ccid = ccid_new(ccid, sk, rx, gfp_any()); 37 struct ccid *new_ccid = ccid_new(ccid, sk, rx);
38 38
39 if (new_ccid == NULL) 39 if (new_ccid == NULL)
40 return -ENOMEM; 40 return -ENOMEM;