~ubuntu-branches/ubuntu/wily/linux-ti-omap4/wily

« back to all changes in this revision

Viewing changes to net/ceph/auth.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2013-07-11 18:35:20 UTC
  • Revision ID: package-import@ubuntu.com-20130711183520-htnf1x4y5r11hndr
Tags: 3.5.0-229.42
* Release Tracking Bug
  - LP: #1199276

[ Paolo Pisati ]

* [Config] CONFIG_ATH9K_LEGACY_RATE_CONTROL is not set

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        if (!ac)
48
48
                goto out;
49
49
 
 
50
        mutex_init(&ac->mutex);
50
51
        ac->negotiating = true;
51
52
        if (name)
52
53
                ac->name = name;
73
74
 */
74
75
void ceph_auth_reset(struct ceph_auth_client *ac)
75
76
{
 
77
        mutex_lock(&ac->mutex);
76
78
        dout("auth_reset %p\n", ac);
77
79
        if (ac->ops && !ac->negotiating)
78
80
                ac->ops->reset(ac);
79
81
        ac->negotiating = true;
 
82
        mutex_unlock(&ac->mutex);
80
83
}
81
84
 
82
85
int ceph_entity_name_encode(const char *name, void **p, void *end)
102
105
        int i, num;
103
106
        int ret;
104
107
 
 
108
        mutex_lock(&ac->mutex);
105
109
        dout("auth_build_hello\n");
106
110
        monhdr->have_version = 0;
107
111
        monhdr->session_mon = cpu_to_le16(-1);
122
126
 
123
127
        ret = ceph_entity_name_encode(ac->name, &p, end);
124
128
        if (ret < 0)
125
 
                return ret;
 
129
                goto out;
126
130
        ceph_decode_need(&p, end, sizeof(u64), bad);
127
131
        ceph_encode_64(&p, ac->global_id);
128
132
 
129
133
        ceph_encode_32(&lenp, p - lenp - sizeof(u32));
130
 
        return p - buf;
 
134
        ret = p - buf;
 
135
out:
 
136
        mutex_unlock(&ac->mutex);
 
137
        return ret;
131
138
 
132
139
bad:
133
 
        return -ERANGE;
 
140
        ret = -ERANGE;
 
141
        goto out;
134
142
}
135
143
 
136
144
static int ceph_build_auth_request(struct ceph_auth_client *ac,
151
159
        if (ret < 0) {
152
160
                pr_err("error %d building auth method %s request\n", ret,
153
161
                       ac->ops->name);
154
 
                return ret;
 
162
                goto out;
155
163
        }
156
164
        dout(" built request %d bytes\n", ret);
157
165
        ceph_encode_32(&p, ret);
158
 
        return p + ret - msg_buf;
 
166
        ret = p + ret - msg_buf;
 
167
out:
 
168
        return ret;
159
169
}
160
170
 
161
171
/*
176
186
        int result_msg_len;
177
187
        int ret = -EINVAL;
178
188
 
 
189
        mutex_lock(&ac->mutex);
179
190
        dout("handle_auth_reply %p %p\n", p, end);
180
191
        ceph_decode_need(&p, end, sizeof(u32) * 3 + sizeof(u64), bad);
181
192
        protocol = ceph_decode_32(&p);
227
238
 
228
239
        ret = ac->ops->handle_reply(ac, result, payload, payload_end);
229
240
        if (ret == -EAGAIN) {
230
 
                return ceph_build_auth_request(ac, reply_buf, reply_len);
 
241
                ret = ceph_build_auth_request(ac, reply_buf, reply_len);
231
242
        } else if (ret) {
232
243
                pr_err("auth method '%s' error %d\n", ac->ops->name, ret);
233
 
                return ret;
234
244
        }
235
 
        return 0;
 
245
 
 
246
out:
 
247
        mutex_unlock(&ac->mutex);
 
248
        return ret;
236
249
 
237
250
bad:
238
251
        pr_err("failed to decode auth msg\n");
239
 
out:
240
 
        return ret;
 
252
        ret = -EINVAL;
 
253
        goto out;
241
254
}
242
255
 
243
256
int ceph_build_auth(struct ceph_auth_client *ac,
244
257
                    void *msg_buf, size_t msg_len)
245
258
{
 
259
        int ret = 0;
 
260
 
 
261
        mutex_lock(&ac->mutex);
246
262
        if (!ac->protocol)
247
 
                return ceph_auth_build_hello(ac, msg_buf, msg_len);
248
 
        BUG_ON(!ac->ops);
249
 
        if (ac->ops->should_authenticate(ac))
250
 
                return ceph_build_auth_request(ac, msg_buf, msg_len);
251
 
        return 0;
 
263
                ret = ceph_auth_build_hello(ac, msg_buf, msg_len);
 
264
        else if (ac->ops->should_authenticate(ac))
 
265
                ret = ceph_build_auth_request(ac, msg_buf, msg_len);
 
266
        mutex_unlock(&ac->mutex);
 
267
        return ret;
252
268
}
253
269
 
254
270
int ceph_auth_is_authenticated(struct ceph_auth_client *ac)
255
271
{
256
 
        if (!ac->ops)
257
 
                return 0;
258
 
        return ac->ops->is_authenticated(ac);
259
 
}
 
272
        int ret = 0;
 
273
 
 
274
        mutex_lock(&ac->mutex);
 
275
        if (ac->ops)
 
276
                ret = ac->ops->is_authenticated(ac);
 
277
        mutex_unlock(&ac->mutex);
 
278
        return ret;
 
279
}
 
280
EXPORT_SYMBOL(ceph_auth_is_authenticated);
 
281
 
 
282
int ceph_auth_create_authorizer(struct ceph_auth_client *ac,
 
283
                                int peer_type,
 
284
                                struct ceph_auth_handshake *auth)
 
285
{
 
286
        int ret = 0;
 
287
 
 
288
        mutex_lock(&ac->mutex);
 
289
        if (ac->ops && ac->ops->create_authorizer)
 
290
                ret = ac->ops->create_authorizer(ac, peer_type, auth);
 
291
        mutex_unlock(&ac->mutex);
 
292
        return ret;
 
293
}
 
294
EXPORT_SYMBOL(ceph_auth_create_authorizer);
 
295
 
 
296
void ceph_auth_destroy_authorizer(struct ceph_auth_client *ac,
 
297
                                  struct ceph_authorizer *a)
 
298
{
 
299
        mutex_lock(&ac->mutex);
 
300
        if (ac->ops && ac->ops->destroy_authorizer)
 
301
                ac->ops->destroy_authorizer(ac, a);
 
302
        mutex_unlock(&ac->mutex);
 
303
}
 
304
EXPORT_SYMBOL(ceph_auth_destroy_authorizer);
 
305
 
 
306
int ceph_auth_update_authorizer(struct ceph_auth_client *ac,
 
307
                                int peer_type,
 
308
                                struct ceph_auth_handshake *a)
 
309
{
 
310
        int ret = 0;
 
311
 
 
312
        mutex_lock(&ac->mutex);
 
313
        if (ac->ops && ac->ops->update_authorizer)
 
314
                ret = ac->ops->update_authorizer(ac, peer_type, a);
 
315
        mutex_unlock(&ac->mutex);
 
316
        return ret;
 
317
}
 
318
EXPORT_SYMBOL(ceph_auth_update_authorizer);
 
319
 
 
320
int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac,
 
321
                                      struct ceph_authorizer *a, size_t len)
 
322
{
 
323
        int ret = 0;
 
324
 
 
325
        mutex_lock(&ac->mutex);
 
326
        if (ac->ops && ac->ops->verify_authorizer_reply)
 
327
                ret = ac->ops->verify_authorizer_reply(ac, a, len);
 
328
        mutex_unlock(&ac->mutex);
 
329
        return ret;
 
330
}
 
331
EXPORT_SYMBOL(ceph_auth_verify_authorizer_reply);
 
332
 
 
333
void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac, int peer_type)
 
334
{
 
335
        mutex_lock(&ac->mutex);
 
336
        if (ac->ops && ac->ops->invalidate_authorizer)
 
337
                ac->ops->invalidate_authorizer(ac, peer_type);
 
338
        mutex_unlock(&ac->mutex);
 
339
}
 
340
EXPORT_SYMBOL(ceph_auth_invalidate_authorizer);