Blame view
net/ceph/auth_none.c
3.06 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
4e7a5dcd1 ceph: negotiate a... |
2 |
|
3d14c5d2b ceph: factor out ... |
3 |
#include <linux/ceph/ceph_debug.h> |
4e7a5dcd1 ceph: negotiate a... |
4 5 6 7 |
#include <linux/err.h> #include <linux/module.h> #include <linux/random.h> |
5a0e3ad6a include cleanup: ... |
8 |
#include <linux/slab.h> |
4e7a5dcd1 ceph: negotiate a... |
9 |
|
3d14c5d2b ceph: factor out ... |
10 11 |
#include <linux/ceph/decode.h> #include <linux/ceph/auth.h> |
4e7a5dcd1 ceph: negotiate a... |
12 |
#include "auth_none.h" |
4e7a5dcd1 ceph: negotiate a... |
13 14 15 16 17 18 |
static void reset(struct ceph_auth_client *ac) { struct ceph_auth_none_info *xi = ac->private; xi->starting = true; |
4e7a5dcd1 ceph: negotiate a... |
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
} 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; } |
6c1ea260f libceph: make aut... |
39 40 41 42 43 44 45 46 |
static int ceph_auth_none_build_authorizer(struct ceph_auth_client *ac, struct ceph_none_authorizer *au) { void *p = au->buf; void *const end = p + sizeof(au->buf); int ret; ceph_encode_8_safe(&p, end, 1, e_range); |
f01d5cb24 libceph: rename c... |
47 |
ret = ceph_auth_entity_name_encode(ac->name, &p, end); |
6c1ea260f libceph: make aut... |
48 49 50 51 52 53 54 55 56 57 58 59 |
if (ret < 0) return ret; ceph_encode_64_safe(&p, end, ac->global_id, e_range); au->buf_len = p - (void *)au->buf; dout("%s built authorizer len %d ", __func__, au->buf_len); return 0; e_range: return -ERANGE; } |
2cb33cac6 libceph: Fix NULL... |
60 61 62 63 |
static int build_request(struct ceph_auth_client *ac, void *buf, void *end) { return 0; } |
4e7a5dcd1 ceph: negotiate a... |
64 65 66 67 68 69 70 71 72 73 74 75 |
/* * 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; } |
6c1ea260f libceph: make aut... |
76 77 78 79 |
static void ceph_auth_none_destroy_authorizer(struct ceph_authorizer *a) { kfree(a); } |
4e7a5dcd1 ceph: negotiate a... |
80 |
/* |
6c1ea260f libceph: make aut... |
81 82 |
* build an 'authorizer' with our entity_name and global_id. it is * identical for all services we connect to. |
4e7a5dcd1 ceph: negotiate a... |
83 84 85 |
*/ static int ceph_auth_none_create_authorizer( struct ceph_auth_client *ac, int peer_type, |
74f1869f7 ceph: messenger: ... |
86 |
struct ceph_auth_handshake *auth) |
4e7a5dcd1 ceph: negotiate a... |
87 |
{ |
6c1ea260f libceph: make aut... |
88 |
struct ceph_none_authorizer *au; |
4e7a5dcd1 ceph: negotiate a... |
89 |
int ret; |
6c1ea260f libceph: make aut... |
90 91 92 93 94 95 96 97 98 99 |
au = kmalloc(sizeof(*au), GFP_NOFS); if (!au) return -ENOMEM; au->base.destroy = ceph_auth_none_destroy_authorizer; ret = ceph_auth_none_build_authorizer(ac, au); if (ret) { kfree(au); return ret; |
4e7a5dcd1 ceph: negotiate a... |
100 |
} |
74f1869f7 ceph: messenger: ... |
101 102 103 104 105 |
auth->authorizer = (struct ceph_authorizer *) au; auth->authorizer_buf = au->buf; auth->authorizer_buf_len = au->buf_len; auth->authorizer_reply_buf = au->reply_buf; auth->authorizer_reply_buf_len = sizeof (au->reply_buf); |
4e7a5dcd1 ceph: negotiate a... |
106 |
return 0; |
4e7a5dcd1 ceph: negotiate a... |
107 108 109 |
} static const struct ceph_auth_client_ops ceph_auth_none_ops = { |
559c1e007 ceph: include aut... |
110 |
.name = "none", |
4e7a5dcd1 ceph: negotiate a... |
111 112 113 |
.reset = reset, .destroy = destroy, .is_authenticated = is_authenticated, |
a41359fa3 ceph: renew auth ... |
114 |
.should_authenticate = should_authenticate, |
2cb33cac6 libceph: Fix NULL... |
115 |
.build_request = build_request, |
4e7a5dcd1 ceph: negotiate a... |
116 117 |
.handle_reply = handle_reply, .create_authorizer = ceph_auth_none_create_authorizer, |
4e7a5dcd1 ceph: negotiate a... |
118 119 120 121 122 123 124 125 126 127 128 129 130 |
}; 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; |
4e7a5dcd1 ceph: negotiate a... |
131 132 133 134 135 136 |
ac->protocol = CEPH_AUTH_NONE; ac->private = xi; ac->ops = &ceph_auth_none_ops; return 0; } |