libceph: add process_one_ticket() helper
[pandora-kernel.git] / net / ceph / auth_x.c
1
2 #include <linux/ceph/ceph_debug.h>
3
4 #include <linux/err.h>
5 #include <linux/module.h>
6 #include <linux/random.h>
7 #include <linux/slab.h>
8
9 #include <linux/ceph/decode.h>
10 #include <linux/ceph/auth.h>
11
12 #include "crypto.h"
13 #include "auth_x.h"
14 #include "auth_x_protocol.h"
15
16 #define TEMP_TICKET_BUF_LEN     256
17
18 static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed);
19
20 static int ceph_x_is_authenticated(struct ceph_auth_client *ac)
21 {
22         struct ceph_x_info *xi = ac->private;
23         int need;
24
25         ceph_x_validate_tickets(ac, &need);
26         dout("ceph_x_is_authenticated want=%d need=%d have=%d\n",
27              ac->want_keys, need, xi->have_keys);
28         return (ac->want_keys & xi->have_keys) == ac->want_keys;
29 }
30
31 static int ceph_x_should_authenticate(struct ceph_auth_client *ac)
32 {
33         struct ceph_x_info *xi = ac->private;
34         int need;
35
36         ceph_x_validate_tickets(ac, &need);
37         dout("ceph_x_should_authenticate want=%d need=%d have=%d\n",
38              ac->want_keys, need, xi->have_keys);
39         return need != 0;
40 }
41
42 static int ceph_x_encrypt_buflen(int ilen)
43 {
44         return sizeof(struct ceph_x_encrypt_header) + ilen + 16 +
45                 sizeof(u32);
46 }
47
48 static int ceph_x_encrypt(struct ceph_crypto_key *secret,
49                           void *ibuf, int ilen, void *obuf, size_t olen)
50 {
51         struct ceph_x_encrypt_header head = {
52                 .struct_v = 1,
53                 .magic = cpu_to_le64(CEPHX_ENC_MAGIC)
54         };
55         size_t len = olen - sizeof(u32);
56         int ret;
57
58         ret = ceph_encrypt2(secret, obuf + sizeof(u32), &len,
59                             &head, sizeof(head), ibuf, ilen);
60         if (ret)
61                 return ret;
62         ceph_encode_32(&obuf, len);
63         return len + sizeof(u32);
64 }
65
66 static int ceph_x_decrypt(struct ceph_crypto_key *secret,
67                           void **p, void *end, void *obuf, size_t olen)
68 {
69         struct ceph_x_encrypt_header head;
70         size_t head_len = sizeof(head);
71         int len, ret;
72
73         len = ceph_decode_32(p);
74         if (*p + len > end)
75                 return -EINVAL;
76
77         dout("ceph_x_decrypt len %d\n", len);
78         ret = ceph_decrypt2(secret, &head, &head_len, obuf, &olen,
79                             *p, len);
80         if (ret)
81                 return ret;
82         if (head.struct_v != 1 || le64_to_cpu(head.magic) != CEPHX_ENC_MAGIC)
83                 return -EPERM;
84         *p += len;
85         return olen;
86 }
87
88 /*
89  * get existing (or insert new) ticket handler
90  */
91 static struct ceph_x_ticket_handler *
92 get_ticket_handler(struct ceph_auth_client *ac, int service)
93 {
94         struct ceph_x_ticket_handler *th;
95         struct ceph_x_info *xi = ac->private;
96         struct rb_node *parent = NULL, **p = &xi->ticket_handlers.rb_node;
97
98         while (*p) {
99                 parent = *p;
100                 th = rb_entry(parent, struct ceph_x_ticket_handler, node);
101                 if (service < th->service)
102                         p = &(*p)->rb_left;
103                 else if (service > th->service)
104                         p = &(*p)->rb_right;
105                 else
106                         return th;
107         }
108
109         /* add it */
110         th = kzalloc(sizeof(*th), GFP_NOFS);
111         if (!th)
112                 return ERR_PTR(-ENOMEM);
113         th->service = service;
114         rb_link_node(&th->node, parent, p);
115         rb_insert_color(&th->node, &xi->ticket_handlers);
116         return th;
117 }
118
119 static void remove_ticket_handler(struct ceph_auth_client *ac,
120                                   struct ceph_x_ticket_handler *th)
121 {
122         struct ceph_x_info *xi = ac->private;
123
124         dout("remove_ticket_handler %p %d\n", th, th->service);
125         rb_erase(&th->node, &xi->ticket_handlers);
126         ceph_crypto_key_destroy(&th->session_key);
127         if (th->ticket_blob)
128                 ceph_buffer_put(th->ticket_blob);
129         kfree(th);
130 }
131
132 static int process_one_ticket(struct ceph_auth_client *ac,
133                               struct ceph_crypto_key *secret,
134                               void **p, void *end,
135                               void *dbuf, void *ticket_buf)
136 {
137         struct ceph_x_info *xi = ac->private;
138         int type;
139         u8 tkt_struct_v, blob_struct_v;
140         struct ceph_x_ticket_handler *th;
141         void *dp, *dend;
142         int dlen;
143         char is_enc;
144         struct timespec validity;
145         struct ceph_crypto_key old_key;
146         void *tp, *tpend;
147         struct ceph_timespec new_validity;
148         struct ceph_crypto_key new_session_key;
149         struct ceph_buffer *new_ticket_blob;
150         unsigned long new_expires, new_renew_after;
151         u64 new_secret_id;
152         int ret;
153
154         ceph_decode_need(p, end, sizeof(u32) + 1, bad);
155
156         type = ceph_decode_32(p);
157         dout(" ticket type %d %s\n", type, ceph_entity_type_name(type));
158
159         tkt_struct_v = ceph_decode_8(p);
160         if (tkt_struct_v != 1)
161                 goto bad;
162
163         th = get_ticket_handler(ac, type);
164         if (IS_ERR(th)) {
165                 ret = PTR_ERR(th);
166                 goto out;
167         }
168
169         /* blob for me */
170         dlen = ceph_x_decrypt(secret, p, end, dbuf,
171                               TEMP_TICKET_BUF_LEN);
172         if (dlen <= 0) {
173                 ret = dlen;
174                 goto out;
175         }
176         dout(" decrypted %d bytes\n", dlen);
177         dp = dbuf;
178         dend = dp + dlen;
179
180         tkt_struct_v = ceph_decode_8(&dp);
181         if (tkt_struct_v != 1)
182                 goto bad;
183
184         memcpy(&old_key, &th->session_key, sizeof(old_key));
185         ret = ceph_crypto_key_decode(&new_session_key, &dp, dend);
186         if (ret)
187                 goto out;
188
189         ceph_decode_copy(&dp, &new_validity, sizeof(new_validity));
190         ceph_decode_timespec(&validity, &new_validity);
191         new_expires = get_seconds() + validity.tv_sec;
192         new_renew_after = new_expires - (validity.tv_sec / 4);
193         dout(" expires=%lu renew_after=%lu\n", new_expires,
194              new_renew_after);
195
196         /* ticket blob for service */
197         ceph_decode_8_safe(p, end, is_enc, bad);
198         tp = ticket_buf;
199         if (is_enc) {
200                 /* encrypted */
201                 dout(" encrypted ticket\n");
202                 dlen = ceph_x_decrypt(&old_key, p, end, ticket_buf,
203                                       TEMP_TICKET_BUF_LEN);
204                 if (dlen < 0) {
205                         ret = dlen;
206                         goto out;
207                 }
208                 dlen = ceph_decode_32(&tp);
209         } else {
210                 /* unencrypted */
211                 ceph_decode_32_safe(p, end, dlen, bad);
212                 ceph_decode_need(p, end, dlen, bad);
213                 ceph_decode_copy(p, ticket_buf, dlen);
214         }
215         tpend = tp + dlen;
216         dout(" ticket blob is %d bytes\n", dlen);
217         ceph_decode_need(&tp, tpend, 1 + sizeof(u64), bad);
218         blob_struct_v = ceph_decode_8(&tp);
219         new_secret_id = ceph_decode_64(&tp);
220         ret = ceph_decode_buffer(&new_ticket_blob, &tp, tpend);
221         if (ret)
222                 goto out;
223
224         /* all is well, update our ticket */
225         ceph_crypto_key_destroy(&th->session_key);
226         if (th->ticket_blob)
227                 ceph_buffer_put(th->ticket_blob);
228         th->session_key = new_session_key;
229         th->ticket_blob = new_ticket_blob;
230         th->validity = new_validity;
231         th->secret_id = new_secret_id;
232         th->expires = new_expires;
233         th->renew_after = new_renew_after;
234         dout(" got ticket service %d (%s) secret_id %lld len %d\n",
235              type, ceph_entity_type_name(type), th->secret_id,
236              (int)th->ticket_blob->vec.iov_len);
237         xi->have_keys |= th->service;
238
239 out:
240         return ret;
241
242 bad:
243         ret = -EINVAL;
244         goto out;
245 }
246
247 static int ceph_x_proc_ticket_reply(struct ceph_auth_client *ac,
248                                     struct ceph_crypto_key *secret,
249                                     void *buf, void *end)
250 {
251         void *p = buf;
252         char *dbuf;
253         char *ticket_buf;
254         u8 reply_struct_v;
255         u32 num;
256         int ret;
257
258         dbuf = kmalloc(TEMP_TICKET_BUF_LEN, GFP_NOFS);
259         if (!dbuf)
260                 return -ENOMEM;
261
262         ret = -ENOMEM;
263         ticket_buf = kmalloc(TEMP_TICKET_BUF_LEN, GFP_NOFS);
264         if (!ticket_buf)
265                 goto out_dbuf;
266
267         ceph_decode_8_safe(&p, end, reply_struct_v, bad);
268         if (reply_struct_v != 1)
269                 return -EINVAL;
270
271         ceph_decode_32_safe(&p, end, num, bad);
272         dout("%d tickets\n", num);
273
274         while (num--) {
275                 ret = process_one_ticket(ac, secret, &p, end,
276                                          dbuf, ticket_buf);
277                 if (ret)
278                         goto out;
279         }
280
281         ret = 0;
282 out:
283         kfree(ticket_buf);
284 out_dbuf:
285         kfree(dbuf);
286         return ret;
287
288 bad:
289         ret = -EINVAL;
290         goto out;
291 }
292
293 static int ceph_x_build_authorizer(struct ceph_auth_client *ac,
294                                    struct ceph_x_ticket_handler *th,
295                                    struct ceph_x_authorizer *au)
296 {
297         int maxlen;
298         struct ceph_x_authorize_a *msg_a;
299         struct ceph_x_authorize_b msg_b;
300         void *p, *end;
301         int ret;
302         int ticket_blob_len =
303                 (th->ticket_blob ? th->ticket_blob->vec.iov_len : 0);
304
305         dout("build_authorizer for %s %p\n",
306              ceph_entity_type_name(th->service), au);
307
308         maxlen = sizeof(*msg_a) + sizeof(msg_b) +
309                 ceph_x_encrypt_buflen(ticket_blob_len);
310         dout("  need len %d\n", maxlen);
311         if (au->buf && au->buf->alloc_len < maxlen) {
312                 ceph_buffer_put(au->buf);
313                 au->buf = NULL;
314         }
315         if (!au->buf) {
316                 au->buf = ceph_buffer_new(maxlen, GFP_NOFS);
317                 if (!au->buf)
318                         return -ENOMEM;
319         }
320         au->service = th->service;
321
322         msg_a = au->buf->vec.iov_base;
323         msg_a->struct_v = 1;
324         msg_a->global_id = cpu_to_le64(ac->global_id);
325         msg_a->service_id = cpu_to_le32(th->service);
326         msg_a->ticket_blob.struct_v = 1;
327         msg_a->ticket_blob.secret_id = cpu_to_le64(th->secret_id);
328         msg_a->ticket_blob.blob_len = cpu_to_le32(ticket_blob_len);
329         if (ticket_blob_len) {
330                 memcpy(msg_a->ticket_blob.blob, th->ticket_blob->vec.iov_base,
331                        th->ticket_blob->vec.iov_len);
332         }
333         dout(" th %p secret_id %lld %lld\n", th, th->secret_id,
334              le64_to_cpu(msg_a->ticket_blob.secret_id));
335
336         p = msg_a + 1;
337         p += ticket_blob_len;
338         end = au->buf->vec.iov_base + au->buf->vec.iov_len;
339
340         get_random_bytes(&au->nonce, sizeof(au->nonce));
341         msg_b.struct_v = 1;
342         msg_b.nonce = cpu_to_le64(au->nonce);
343         ret = ceph_x_encrypt(&th->session_key, &msg_b, sizeof(msg_b),
344                              p, end - p);
345         if (ret < 0)
346                 goto out_buf;
347         p += ret;
348         au->buf->vec.iov_len = p - au->buf->vec.iov_base;
349         dout(" built authorizer nonce %llx len %d\n", au->nonce,
350              (int)au->buf->vec.iov_len);
351         BUG_ON(au->buf->vec.iov_len > maxlen);
352         return 0;
353
354 out_buf:
355         ceph_buffer_put(au->buf);
356         au->buf = NULL;
357         return ret;
358 }
359
360 static int ceph_x_encode_ticket(struct ceph_x_ticket_handler *th,
361                                 void **p, void *end)
362 {
363         ceph_decode_need(p, end, 1 + sizeof(u64), bad);
364         ceph_encode_8(p, 1);
365         ceph_encode_64(p, th->secret_id);
366         if (th->ticket_blob) {
367                 const char *buf = th->ticket_blob->vec.iov_base;
368                 u32 len = th->ticket_blob->vec.iov_len;
369
370                 ceph_encode_32_safe(p, end, len, bad);
371                 ceph_encode_copy_safe(p, end, buf, len, bad);
372         } else {
373                 ceph_encode_32_safe(p, end, 0, bad);
374         }
375
376         return 0;
377 bad:
378         return -ERANGE;
379 }
380
381 static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed)
382 {
383         int want = ac->want_keys;
384         struct ceph_x_info *xi = ac->private;
385         int service;
386
387         *pneed = ac->want_keys & ~(xi->have_keys);
388
389         for (service = 1; service <= want; service <<= 1) {
390                 struct ceph_x_ticket_handler *th;
391
392                 if (!(ac->want_keys & service))
393                         continue;
394
395                 if (*pneed & service)
396                         continue;
397
398                 th = get_ticket_handler(ac, service);
399
400                 if (IS_ERR(th)) {
401                         *pneed |= service;
402                         continue;
403                 }
404
405                 if (get_seconds() >= th->renew_after)
406                         *pneed |= service;
407                 if (get_seconds() >= th->expires)
408                         xi->have_keys &= ~service;
409         }
410 }
411
412
413 static int ceph_x_build_request(struct ceph_auth_client *ac,
414                                 void *buf, void *end)
415 {
416         struct ceph_x_info *xi = ac->private;
417         int need;
418         struct ceph_x_request_header *head = buf;
419         int ret;
420         struct ceph_x_ticket_handler *th =
421                 get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH);
422
423         if (IS_ERR(th))
424                 return PTR_ERR(th);
425
426         ceph_x_validate_tickets(ac, &need);
427
428         dout("build_request want %x have %x need %x\n",
429              ac->want_keys, xi->have_keys, need);
430
431         if (need & CEPH_ENTITY_TYPE_AUTH) {
432                 struct ceph_x_authenticate *auth = (void *)(head + 1);
433                 void *p = auth + 1;
434                 struct ceph_x_challenge_blob tmp;
435                 char tmp_enc[40];
436                 u64 *u;
437
438                 if (p > end)
439                         return -ERANGE;
440
441                 dout(" get_auth_session_key\n");
442                 head->op = cpu_to_le16(CEPHX_GET_AUTH_SESSION_KEY);
443
444                 /* encrypt and hash */
445                 get_random_bytes(&auth->client_challenge, sizeof(u64));
446                 tmp.client_challenge = auth->client_challenge;
447                 tmp.server_challenge = cpu_to_le64(xi->server_challenge);
448                 ret = ceph_x_encrypt(&xi->secret, &tmp, sizeof(tmp),
449                                      tmp_enc, sizeof(tmp_enc));
450                 if (ret < 0)
451                         return ret;
452
453                 auth->struct_v = 1;
454                 auth->key = 0;
455                 for (u = (u64 *)tmp_enc; u + 1 <= (u64 *)(tmp_enc + ret); u++)
456                         auth->key ^= *(__le64 *)u;
457                 dout(" server_challenge %llx client_challenge %llx key %llx\n",
458                      xi->server_challenge, le64_to_cpu(auth->client_challenge),
459                      le64_to_cpu(auth->key));
460
461                 /* now encode the old ticket if exists */
462                 ret = ceph_x_encode_ticket(th, &p, end);
463                 if (ret < 0)
464                         return ret;
465
466                 return p - buf;
467         }
468
469         if (need) {
470                 void *p = head + 1;
471                 struct ceph_x_service_ticket_request *req;
472
473                 if (p > end)
474                         return -ERANGE;
475                 head->op = cpu_to_le16(CEPHX_GET_PRINCIPAL_SESSION_KEY);
476
477                 ret = ceph_x_build_authorizer(ac, th, &xi->auth_authorizer);
478                 if (ret)
479                         return ret;
480                 ceph_encode_copy(&p, xi->auth_authorizer.buf->vec.iov_base,
481                                  xi->auth_authorizer.buf->vec.iov_len);
482
483                 req = p;
484                 req->keys = cpu_to_le32(need);
485                 p += sizeof(*req);
486                 return p - buf;
487         }
488
489         return 0;
490 }
491
492 static int ceph_x_handle_reply(struct ceph_auth_client *ac, int result,
493                                void *buf, void *end)
494 {
495         struct ceph_x_info *xi = ac->private;
496         struct ceph_x_reply_header *head = buf;
497         struct ceph_x_ticket_handler *th;
498         int len = end - buf;
499         int op;
500         int ret;
501
502         if (result)
503                 return result;  /* XXX hmm? */
504
505         if (xi->starting) {
506                 /* it's a hello */
507                 struct ceph_x_server_challenge *sc = buf;
508
509                 if (len != sizeof(*sc))
510                         return -EINVAL;
511                 xi->server_challenge = le64_to_cpu(sc->server_challenge);
512                 dout("handle_reply got server challenge %llx\n",
513                      xi->server_challenge);
514                 xi->starting = false;
515                 xi->have_keys &= ~CEPH_ENTITY_TYPE_AUTH;
516                 return -EAGAIN;
517         }
518
519         op = le16_to_cpu(head->op);
520         result = le32_to_cpu(head->result);
521         dout("handle_reply op %d result %d\n", op, result);
522         switch (op) {
523         case CEPHX_GET_AUTH_SESSION_KEY:
524                 /* verify auth key */
525                 ret = ceph_x_proc_ticket_reply(ac, &xi->secret,
526                                                buf + sizeof(*head), end);
527                 break;
528
529         case CEPHX_GET_PRINCIPAL_SESSION_KEY:
530                 th = get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH);
531                 if (IS_ERR(th))
532                         return PTR_ERR(th);
533                 ret = ceph_x_proc_ticket_reply(ac, &th->session_key,
534                                                buf + sizeof(*head), end);
535                 break;
536
537         default:
538                 return -EINVAL;
539         }
540         if (ret)
541                 return ret;
542         if (ac->want_keys == xi->have_keys)
543                 return 0;
544         return -EAGAIN;
545 }
546
547 static int ceph_x_create_authorizer(
548         struct ceph_auth_client *ac, int peer_type,
549         struct ceph_authorizer **a,
550         void **buf, size_t *len,
551         void **reply_buf, size_t *reply_len)
552 {
553         struct ceph_x_authorizer *au;
554         struct ceph_x_ticket_handler *th;
555         int ret;
556
557         th = get_ticket_handler(ac, peer_type);
558         if (IS_ERR(th))
559                 return PTR_ERR(th);
560
561         au = kzalloc(sizeof(*au), GFP_NOFS);
562         if (!au)
563                 return -ENOMEM;
564
565         ret = ceph_x_build_authorizer(ac, th, au);
566         if (ret) {
567                 kfree(au);
568                 return ret;
569         }
570
571         *a = (struct ceph_authorizer *)au;
572         *buf = au->buf->vec.iov_base;
573         *len = au->buf->vec.iov_len;
574         *reply_buf = au->reply_buf;
575         *reply_len = sizeof(au->reply_buf);
576         return 0;
577 }
578
579 static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac,
580                                           struct ceph_authorizer *a, size_t len)
581 {
582         struct ceph_x_authorizer *au = (void *)a;
583         struct ceph_x_ticket_handler *th;
584         int ret = 0;
585         struct ceph_x_authorize_reply reply;
586         void *p = au->reply_buf;
587         void *end = p + sizeof(au->reply_buf);
588
589         th = get_ticket_handler(ac, au->service);
590         if (IS_ERR(th))
591                 return PTR_ERR(th);
592         ret = ceph_x_decrypt(&th->session_key, &p, end, &reply, sizeof(reply));
593         if (ret < 0)
594                 return ret;
595         if (ret != sizeof(reply))
596                 return -EPERM;
597
598         if (au->nonce + 1 != le64_to_cpu(reply.nonce_plus_one))
599                 ret = -EPERM;
600         else
601                 ret = 0;
602         dout("verify_authorizer_reply nonce %llx got %llx ret %d\n",
603              au->nonce, le64_to_cpu(reply.nonce_plus_one), ret);
604         return ret;
605 }
606
607 static void ceph_x_destroy_authorizer(struct ceph_auth_client *ac,
608                                       struct ceph_authorizer *a)
609 {
610         struct ceph_x_authorizer *au = (void *)a;
611
612         ceph_buffer_put(au->buf);
613         kfree(au);
614 }
615
616
617 static void ceph_x_reset(struct ceph_auth_client *ac)
618 {
619         struct ceph_x_info *xi = ac->private;
620
621         dout("reset\n");
622         xi->starting = true;
623         xi->server_challenge = 0;
624 }
625
626 static void ceph_x_destroy(struct ceph_auth_client *ac)
627 {
628         struct ceph_x_info *xi = ac->private;
629         struct rb_node *p;
630
631         dout("ceph_x_destroy %p\n", ac);
632         ceph_crypto_key_destroy(&xi->secret);
633
634         while ((p = rb_first(&xi->ticket_handlers)) != NULL) {
635                 struct ceph_x_ticket_handler *th =
636                         rb_entry(p, struct ceph_x_ticket_handler, node);
637                 remove_ticket_handler(ac, th);
638         }
639
640         if (xi->auth_authorizer.buf)
641                 ceph_buffer_put(xi->auth_authorizer.buf);
642
643         kfree(ac->private);
644         ac->private = NULL;
645 }
646
647 static void ceph_x_invalidate_authorizer(struct ceph_auth_client *ac,
648                                    int peer_type)
649 {
650         struct ceph_x_ticket_handler *th;
651
652         th = get_ticket_handler(ac, peer_type);
653         if (!IS_ERR(th))
654                 remove_ticket_handler(ac, th);
655 }
656
657
658 static const struct ceph_auth_client_ops ceph_x_ops = {
659         .name = "x",
660         .is_authenticated = ceph_x_is_authenticated,
661         .should_authenticate = ceph_x_should_authenticate,
662         .build_request = ceph_x_build_request,
663         .handle_reply = ceph_x_handle_reply,
664         .create_authorizer = ceph_x_create_authorizer,
665         .verify_authorizer_reply = ceph_x_verify_authorizer_reply,
666         .destroy_authorizer = ceph_x_destroy_authorizer,
667         .invalidate_authorizer = ceph_x_invalidate_authorizer,
668         .reset =  ceph_x_reset,
669         .destroy = ceph_x_destroy,
670 };
671
672
673 int ceph_x_init(struct ceph_auth_client *ac)
674 {
675         struct ceph_x_info *xi;
676         int ret;
677
678         dout("ceph_x_init %p\n", ac);
679         ret = -ENOMEM;
680         xi = kzalloc(sizeof(*xi), GFP_NOFS);
681         if (!xi)
682                 goto out;
683
684         ret = -EINVAL;
685         if (!ac->key) {
686                 pr_err("no secret set (for auth_x protocol)\n");
687                 goto out_nomem;
688         }
689
690         ret = ceph_crypto_key_clone(&xi->secret, ac->key);
691         if (ret < 0) {
692                 pr_err("cannot clone key: %d\n", ret);
693                 goto out_nomem;
694         }
695
696         xi->starting = true;
697         xi->ticket_handlers = RB_ROOT;
698
699         ac->protocol = CEPH_AUTH_CEPHX;
700         ac->private = xi;
701         ac->ops = &ceph_x_ops;
702         return 0;
703
704 out_nomem:
705         kfree(xi);
706 out:
707         return ret;
708 }
709
710