libceph: msg signing callouts don't need con argument
authorIlya Dryomov <idryomov@gmail.com>
Mon, 26 Oct 2015 21:23:56 +0000 (22:23 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 2 Nov 2015 22:37:45 +0000 (23:37 +0100)
We can use msg->con instead - at the point we sign an outgoing message
or check the signature on the incoming one, msg->con is always set.  We
wouldn't know how to sign a message without an associated session (i.e.
msg->con == NULL) and being able to sign a message using an explicitly
provided authorizer is of no use.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/mds_client.c
include/linux/ceph/messenger.h
net/ceph/messenger.c
net/ceph/osd_client.c

index 89838a226fe91896972d945785e490214783dea6..e7b130a637f9f31a34efd67d6cf5789a8fcdef00 100644 (file)
@@ -3942,17 +3942,19 @@ static struct ceph_msg *mds_alloc_msg(struct ceph_connection *con,
        return msg;
 }
 
-static int sign_message(struct ceph_connection *con, struct ceph_msg *msg)
+static int mds_sign_message(struct ceph_msg *msg)
 {
-       struct ceph_mds_session *s = con->private;
+       struct ceph_mds_session *s = msg->con->private;
        struct ceph_auth_handshake *auth = &s->s_auth;
+
        return ceph_auth_sign_message(auth, msg);
 }
 
-static int check_message_signature(struct ceph_connection *con, struct ceph_msg *msg)
+static int mds_check_message_signature(struct ceph_msg *msg)
 {
-       struct ceph_mds_session *s = con->private;
+       struct ceph_mds_session *s = msg->con->private;
        struct ceph_auth_handshake *auth = &s->s_auth;
+
        return ceph_auth_check_message_signature(auth, msg);
 }
 
@@ -3965,8 +3967,8 @@ static const struct ceph_connection_operations mds_con_ops = {
        .invalidate_authorizer = invalidate_authorizer,
        .peer_reset = peer_reset,
        .alloc_msg = mds_alloc_msg,
-       .sign_message = sign_message,
-       .check_message_signature = check_message_signature,
+       .sign_message = mds_sign_message,
+       .check_message_signature = mds_check_message_signature,
 };
 
 /* eof */
index b2371d9b51fac6ea69032576ac1c3cddfc104016..3687ff0f013368295c5d511a72bd2f3fa1c107e8 100644 (file)
@@ -43,10 +43,9 @@ struct ceph_connection_operations {
        struct ceph_msg * (*alloc_msg) (struct ceph_connection *con,
                                        struct ceph_msg_header *hdr,
                                        int *skip);
-       int (*sign_message) (struct ceph_connection *con, struct ceph_msg *msg);
 
-       int (*check_message_signature) (struct ceph_connection *con,
-                                       struct ceph_msg *msg);
+       int (*sign_message) (struct ceph_msg *msg);
+       int (*check_message_signature) (struct ceph_msg *msg);
 };
 
 /* use format string %s%d */
index fce6ad636613a65f8515da5ce5e4eb928f8bc927..805f6f82139f5647c34098003b7563a89ff24597 100644 (file)
@@ -1205,7 +1205,7 @@ static void prepare_write_message_footer(struct ceph_connection *con)
        con->out_kvec[v].iov_base = &m->footer;
        if (con->peer_features & CEPH_FEATURE_MSG_AUTH) {
                if (con->ops->sign_message)
-                       con->ops->sign_message(con, m);
+                       con->ops->sign_message(m);
                else
                        m->footer.sig = 0;
                con->out_kvec[v].iov_len = sizeof(m->footer);
@@ -2422,7 +2422,7 @@ static int read_partial_message(struct ceph_connection *con)
        }
 
        if (need_sign && con->ops->check_message_signature &&
-           con->ops->check_message_signature(con, m)) {
+           con->ops->check_message_signature(m)) {
                pr_err("read_partial_message %p signature check failed\n", m);
                return -EBADMSG;
        }
index 191bc21cecea7dfd15090219b458423abfcbd469..118e4ce37ecc0ba12fbc737449d96d8899aded4a 100644 (file)
@@ -2979,17 +2979,19 @@ static int invalidate_authorizer(struct ceph_connection *con)
        return ceph_monc_validate_auth(&osdc->client->monc);
 }
 
-static int sign_message(struct ceph_connection *con, struct ceph_msg *msg)
+static int osd_sign_message(struct ceph_msg *msg)
 {
-       struct ceph_osd *o = con->private;
+       struct ceph_osd *o = msg->con->private;
        struct ceph_auth_handshake *auth = &o->o_auth;
+
        return ceph_auth_sign_message(auth, msg);
 }
 
-static int check_message_signature(struct ceph_connection *con, struct ceph_msg *msg)
+static int osd_check_message_signature(struct ceph_msg *msg)
 {
-       struct ceph_osd *o = con->private;
+       struct ceph_osd *o = msg->con->private;
        struct ceph_auth_handshake *auth = &o->o_auth;
+
        return ceph_auth_check_message_signature(auth, msg);
 }
 
@@ -3001,7 +3003,7 @@ static const struct ceph_connection_operations osd_con_ops = {
        .verify_authorizer_reply = verify_authorizer_reply,
        .invalidate_authorizer = invalidate_authorizer,
        .alloc_msg = alloc_msg,
-       .sign_message = sign_message,
-       .check_message_signature = check_message_signature,
+       .sign_message = osd_sign_message,
+       .check_message_signature = osd_check_message_signature,
        .fault = osd_reset,
 };