Merge branch 'postmerge' into for-linus
[firefly-linux-kernel-4.4.55.git] / net / ceph / auth_x.c
index a16bf14eb027cd4e765320f98b0fb378b5a5e7c4..96238ba95f2b6954c598294243b8f65931a82284 100644 (file)
@@ -298,6 +298,7 @@ static int ceph_x_build_authorizer(struct ceph_auth_client *ac,
                        return -ENOMEM;
        }
        au->service = th->service;
+       au->secret_id = th->secret_id;
 
        msg_a = au->buf->vec.iov_base;
        msg_a->struct_v = 1;
@@ -555,6 +556,26 @@ static int ceph_x_create_authorizer(
        return 0;
 }
 
+static int ceph_x_update_authorizer(
+       struct ceph_auth_client *ac, int peer_type,
+       struct ceph_auth_handshake *auth)
+{
+       struct ceph_x_authorizer *au;
+       struct ceph_x_ticket_handler *th;
+
+       th = get_ticket_handler(ac, peer_type);
+       if (IS_ERR(th))
+               return PTR_ERR(th);
+
+       au = (struct ceph_x_authorizer *)auth->authorizer;
+       if (au->secret_id < th->secret_id) {
+               dout("ceph_x_update_authorizer service %u secret %llu < %llu\n",
+                    au->service, au->secret_id, th->secret_id);
+               return ceph_x_build_authorizer(ac, th, au);
+       }
+       return 0;
+}
+
 static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac,
                                          struct ceph_authorizer *a, size_t len)
 {
@@ -630,7 +651,7 @@ static void ceph_x_invalidate_authorizer(struct ceph_auth_client *ac,
 
        th = get_ticket_handler(ac, peer_type);
        if (!IS_ERR(th))
-               remove_ticket_handler(ac, th);
+               memset(&th->validity, 0, sizeof(th->validity));
 }
 
 
@@ -641,6 +662,7 @@ static const struct ceph_auth_client_ops ceph_x_ops = {
        .build_request = ceph_x_build_request,
        .handle_reply = ceph_x_handle_reply,
        .create_authorizer = ceph_x_create_authorizer,
+       .update_authorizer = ceph_x_update_authorizer,
        .verify_authorizer_reply = ceph_x_verify_authorizer_reply,
        .destroy_authorizer = ceph_x_destroy_authorizer,
        .invalidate_authorizer = ceph_x_invalidate_authorizer,