Blame view
net/ceph/auth_none.c
2.86 KB
4e7a5dcd1 ceph: negotiate a... |
1 |
|
3d14c5d2b ceph: factor out ... |
2 |
#include <linux/ceph/ceph_debug.h> |
4e7a5dcd1 ceph: negotiate a... |
3 4 5 6 |
#include <linux/err.h> #include <linux/module.h> #include <linux/random.h> |
5a0e3ad6a include cleanup: ... |
7 |
#include <linux/slab.h> |
4e7a5dcd1 ceph: negotiate a... |
8 |
|
3d14c5d2b ceph: factor out ... |
9 10 |
#include <linux/ceph/decode.h> #include <linux/ceph/auth.h> |
4e7a5dcd1 ceph: negotiate a... |
11 |
#include "auth_none.h" |
4e7a5dcd1 ceph: negotiate a... |
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
static void reset(struct ceph_auth_client *ac) { struct ceph_auth_none_info *xi = ac->private; xi->starting = true; xi->built_authorizer = false; } static void destroy(struct ceph_auth_client *ac) { kfree(ac->private); ac->private = NULL; } static int is_authenticated(struct ceph_auth_client *ac) { struct ceph_auth_none_info *xi = ac->private; return !xi->starting; } |
a41359fa3 ceph: renew auth ... |
33 34 35 36 37 38 |
static int should_authenticate(struct ceph_auth_client *ac) { struct ceph_auth_none_info *xi = ac->private; return xi->starting; } |
4e7a5dcd1 ceph: negotiate a... |
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
/* * the generic auth code decode the global_id, and we carry no actual * authenticate state, so nothing happens here. */ static int handle_reply(struct ceph_auth_client *ac, int result, void *buf, void *end) { struct ceph_auth_none_info *xi = ac->private; xi->starting = false; return result; } /* * build an 'authorizer' with our entity_name and global_id. we can * reuse a single static copy since it is identical for all services * we connect to. */ static int ceph_auth_none_create_authorizer( struct ceph_auth_client *ac, int peer_type, struct ceph_authorizer **a, void **buf, size_t *len, void **reply_buf, size_t *reply_len) { struct ceph_auth_none_info *ai = ac->private; struct ceph_none_authorizer *au = &ai->au; void *p, *end; int ret; if (!ai->built_authorizer) { p = au->buf; end = p + sizeof(au->buf); |
07c8739c5 ceph: add struct ... |
71 |
ceph_encode_8(&p, 1); |
4e7a5dcd1 ceph: negotiate a... |
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
ret = ceph_entity_name_encode(ac->name, &p, end - 8); if (ret < 0) goto bad; ceph_decode_need(&p, end, sizeof(u64), bad2); ceph_encode_64(&p, ac->global_id); au->buf_len = p - (void *)au->buf; ai->built_authorizer = true; dout("built authorizer len %d ", au->buf_len); } *a = (struct ceph_authorizer *)au; *buf = au->buf; *len = au->buf_len; *reply_buf = au->reply_buf; *reply_len = sizeof(au->reply_buf); return 0; bad2: ret = -ERANGE; bad: return ret; } static void ceph_auth_none_destroy_authorizer(struct ceph_auth_client *ac, struct ceph_authorizer *a) { /* nothing to do */ } static const struct ceph_auth_client_ops ceph_auth_none_ops = { |
559c1e007 ceph: include aut... |
103 |
.name = "none", |
4e7a5dcd1 ceph: negotiate a... |
104 105 106 |
.reset = reset, .destroy = destroy, .is_authenticated = is_authenticated, |
a41359fa3 ceph: renew auth ... |
107 |
.should_authenticate = should_authenticate, |
4e7a5dcd1 ceph: negotiate a... |
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
.handle_reply = handle_reply, .create_authorizer = ceph_auth_none_create_authorizer, .destroy_authorizer = ceph_auth_none_destroy_authorizer, }; int ceph_auth_none_init(struct ceph_auth_client *ac) { struct ceph_auth_none_info *xi; dout("ceph_auth_none_init %p ", ac); xi = kzalloc(sizeof(*xi), GFP_NOFS); if (!xi) return -ENOMEM; xi->starting = true; xi->built_authorizer = false; ac->protocol = CEPH_AUTH_NONE; ac->private = xi; ac->ops = &ceph_auth_none_ops; return 0; } |