kasan: split out shadow.c from common.c
[linux-2.6-microblaze.git] / net / ceph / osd_client.c
index 7901ab6..61229c5 100644 (file)
@@ -3918,9 +3918,11 @@ static int handle_one_map(struct ceph_osd_client *osdc,
        set_pool_was_full(osdc);
 
        if (incremental)
-               newmap = osdmap_apply_incremental(&p, end, osdc->osdmap);
+               newmap = osdmap_apply_incremental(&p, end,
+                                                 ceph_msgr2(osdc->client),
+                                                 osdc->osdmap);
        else
-               newmap = ceph_osdmap_decode(&p, end);
+               newmap = ceph_osdmap_decode(&p, end, ceph_msgr2(osdc->client));
        if (IS_ERR(newmap))
                return PTR_ERR(newmap);
 
@@ -5575,6 +5577,7 @@ static void put_osd_con(struct ceph_connection *con)
 /*
  * authentication
  */
+
 /*
  * Note: returned pointer is the address of a structure that's
  * managed separately.  Caller must *not* attempt to free it.
@@ -5586,23 +5589,12 @@ static struct ceph_auth_handshake *get_authorizer(struct ceph_connection *con,
        struct ceph_osd_client *osdc = o->o_osdc;
        struct ceph_auth_client *ac = osdc->client->monc.auth;
        struct ceph_auth_handshake *auth = &o->o_auth;
+       int ret;
 
-       if (force_new && auth->authorizer) {
-               ceph_auth_destroy_authorizer(auth->authorizer);
-               auth->authorizer = NULL;
-       }
-       if (!auth->authorizer) {
-               int ret = ceph_auth_create_authorizer(ac, CEPH_ENTITY_TYPE_OSD,
-                                                     auth);
-               if (ret)
-                       return ERR_PTR(ret);
-       } else {
-               int ret = ceph_auth_update_authorizer(ac, CEPH_ENTITY_TYPE_OSD,
-                                                    auth);
-               if (ret)
-                       return ERR_PTR(ret);
-       }
-       *proto = ac->protocol;
+       ret = __ceph_auth_get_authorizer(ac, auth, CEPH_ENTITY_TYPE_OSD,
+                                        force_new, proto, NULL, NULL);
+       if (ret)
+               return ERR_PTR(ret);
 
        return auth;
 }
@@ -5623,8 +5615,11 @@ static int verify_authorizer_reply(struct ceph_connection *con)
        struct ceph_osd *o = con->private;
        struct ceph_osd_client *osdc = o->o_osdc;
        struct ceph_auth_client *ac = osdc->client->monc.auth;
+       struct ceph_auth_handshake *auth = &o->o_auth;
 
-       return ceph_auth_verify_authorizer_reply(ac, o->o_auth.authorizer);
+       return ceph_auth_verify_authorizer_reply(ac, auth->authorizer,
+               auth->authorizer_reply_buf, auth->authorizer_reply_buf_len,
+               NULL, NULL, NULL, NULL);
 }
 
 static int invalidate_authorizer(struct ceph_connection *con)
@@ -5637,6 +5632,80 @@ static int invalidate_authorizer(struct ceph_connection *con)
        return ceph_monc_validate_auth(&osdc->client->monc);
 }
 
+static int osd_get_auth_request(struct ceph_connection *con,
+                               void *buf, int *buf_len,
+                               void **authorizer, int *authorizer_len)
+{
+       struct ceph_osd *o = con->private;
+       struct ceph_auth_client *ac = o->o_osdc->client->monc.auth;
+       struct ceph_auth_handshake *auth = &o->o_auth;
+       int ret;
+
+       ret = ceph_auth_get_authorizer(ac, auth, CEPH_ENTITY_TYPE_OSD,
+                                      buf, buf_len);
+       if (ret)
+               return ret;
+
+       *authorizer = auth->authorizer_buf;
+       *authorizer_len = auth->authorizer_buf_len;
+       return 0;
+}
+
+static int osd_handle_auth_reply_more(struct ceph_connection *con,
+                                     void *reply, int reply_len,
+                                     void *buf, int *buf_len,
+                                     void **authorizer, int *authorizer_len)
+{
+       struct ceph_osd *o = con->private;
+       struct ceph_auth_client *ac = o->o_osdc->client->monc.auth;
+       struct ceph_auth_handshake *auth = &o->o_auth;
+       int ret;
+
+       ret = ceph_auth_handle_svc_reply_more(ac, auth, reply, reply_len,
+                                             buf, buf_len);
+       if (ret)
+               return ret;
+
+       *authorizer = auth->authorizer_buf;
+       *authorizer_len = auth->authorizer_buf_len;
+       return 0;
+}
+
+static int osd_handle_auth_done(struct ceph_connection *con,
+                               u64 global_id, void *reply, int reply_len,
+                               u8 *session_key, int *session_key_len,
+                               u8 *con_secret, int *con_secret_len)
+{
+       struct ceph_osd *o = con->private;
+       struct ceph_auth_client *ac = o->o_osdc->client->monc.auth;
+       struct ceph_auth_handshake *auth = &o->o_auth;
+
+       return ceph_auth_handle_svc_reply_done(ac, auth, reply, reply_len,
+                                              session_key, session_key_len,
+                                              con_secret, con_secret_len);
+}
+
+static int osd_handle_auth_bad_method(struct ceph_connection *con,
+                                     int used_proto, int result,
+                                     const int *allowed_protos, int proto_cnt,
+                                     const int *allowed_modes, int mode_cnt)
+{
+       struct ceph_osd *o = con->private;
+       struct ceph_mon_client *monc = &o->o_osdc->client->monc;
+       int ret;
+
+       if (ceph_auth_handle_bad_authorizer(monc->auth, CEPH_ENTITY_TYPE_OSD,
+                                           used_proto, result,
+                                           allowed_protos, proto_cnt,
+                                           allowed_modes, mode_cnt)) {
+               ret = ceph_monc_validate_auth(monc);
+               if (ret)
+                       return ret;
+       }
+
+       return -EACCES;
+}
+
 static void osd_reencode_message(struct ceph_msg *msg)
 {
        int type = le16_to_cpu(msg->hdr.type);
@@ -5674,4 +5743,8 @@ static const struct ceph_connection_operations osd_con_ops = {
        .sign_message = osd_sign_message,
        .check_message_signature = osd_check_message_signature,
        .fault = osd_fault,
+       .get_auth_request = osd_get_auth_request,
+       .handle_auth_reply_more = osd_handle_auth_reply_more,
+       .handle_auth_done = osd_handle_auth_done,
+       .handle_auth_bad_method = osd_handle_auth_bad_method,
 };