Skip to content

Commit 79dbd1b

Browse files
committed
libceph: msg signing callouts don't need con argument
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>
1 parent 8a703a3 commit 79dbd1b

4 files changed

Lines changed: 20 additions & 17 deletions

File tree

‎fs/ceph/mds_client.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3942,17 +3942,19 @@ static struct ceph_msg *mds_alloc_msg(struct ceph_connection *con,
39423942
return msg;
39433943
}
39443944

3945-
static int sign_message(struct ceph_connection *con, struct ceph_msg *msg)
3945+
static int mds_sign_message(struct ceph_msg *msg)
39463946
{
3947-
struct ceph_mds_session *s = con->private;
3947+
struct ceph_mds_session *s = msg->con->private;
39483948
struct ceph_auth_handshake *auth = &s->s_auth;
3949+
39493950
return ceph_auth_sign_message(auth, msg);
39503951
}
39513952

3952-
static int check_message_signature(struct ceph_connection *con, struct ceph_msg *msg)
3953+
static int mds_check_message_signature(struct ceph_msg *msg)
39533954
{
3954-
struct ceph_mds_session *s = con->private;
3955+
struct ceph_mds_session *s = msg->con->private;
39553956
struct ceph_auth_handshake *auth = &s->s_auth;
3957+
39563958
return ceph_auth_check_message_signature(auth, msg);
39573959
}
39583960

@@ -3965,8 +3967,8 @@ static const struct ceph_connection_operations mds_con_ops = {
39653967
.invalidate_authorizer = invalidate_authorizer,
39663968
.peer_reset = peer_reset,
39673969
.alloc_msg = mds_alloc_msg,
3968-
.sign_message = sign_message,
3969-
.check_message_signature = check_message_signature,
3970+
.sign_message = mds_sign_message,
3971+
.check_message_signature = mds_check_message_signature,
39703972
};
39713973

39723974
/* eof */

‎include/linux/ceph/messenger.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ struct ceph_connection_operations {
4343
struct ceph_msg * (*alloc_msg) (struct ceph_connection *con,
4444
struct ceph_msg_header *hdr,
4545
int *skip);
46-
int (*sign_message) (struct ceph_connection *con, struct ceph_msg *msg);
4746

48-
int (*check_message_signature) (struct ceph_connection *con,
49-
struct ceph_msg *msg);
47+
int (*sign_message) (struct ceph_msg *msg);
48+
int (*check_message_signature) (struct ceph_msg *msg);
5049
};
5150

5251
/* use format string %s%d */

‎net/ceph/messenger.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ static void prepare_write_message_footer(struct ceph_connection *con)
12051205
con->out_kvec[v].iov_base = &m->footer;
12061206
if (con->peer_features & CEPH_FEATURE_MSG_AUTH) {
12071207
if (con->ops->sign_message)
1208-
con->ops->sign_message(con, m);
1208+
con->ops->sign_message(m);
12091209
else
12101210
m->footer.sig = 0;
12111211
con->out_kvec[v].iov_len = sizeof(m->footer);
@@ -2422,7 +2422,7 @@ static int read_partial_message(struct ceph_connection *con)
24222422
}
24232423

24242424
if (need_sign && con->ops->check_message_signature &&
2425-
con->ops->check_message_signature(con, m)) {
2425+
con->ops->check_message_signature(m)) {
24262426
pr_err("read_partial_message %p signature check failed\n", m);
24272427
return -EBADMSG;
24282428
}

‎net/ceph/osd_client.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,17 +2979,19 @@ static int invalidate_authorizer(struct ceph_connection *con)
29792979
return ceph_monc_validate_auth(&osdc->client->monc);
29802980
}
29812981

2982-
static int sign_message(struct ceph_connection *con, struct ceph_msg *msg)
2982+
static int osd_sign_message(struct ceph_msg *msg)
29832983
{
2984-
struct ceph_osd *o = con->private;
2984+
struct ceph_osd *o = msg->con->private;
29852985
struct ceph_auth_handshake *auth = &o->o_auth;
2986+
29862987
return ceph_auth_sign_message(auth, msg);
29872988
}
29882989

2989-
static int check_message_signature(struct ceph_connection *con, struct ceph_msg *msg)
2990+
static int osd_check_message_signature(struct ceph_msg *msg)
29902991
{
2991-
struct ceph_osd *o = con->private;
2992+
struct ceph_osd *o = msg->con->private;
29922993
struct ceph_auth_handshake *auth = &o->o_auth;
2994+
29932995
return ceph_auth_check_message_signature(auth, msg);
29942996
}
29952997

@@ -3001,7 +3003,7 @@ static const struct ceph_connection_operations osd_con_ops = {
30013003
.verify_authorizer_reply = verify_authorizer_reply,
30023004
.invalidate_authorizer = invalidate_authorizer,
30033005
.alloc_msg = alloc_msg,
3004-
.sign_message = sign_message,
3005-
.check_message_signature = check_message_signature,
3006+
.sign_message = osd_sign_message,
3007+
.check_message_signature = osd_check_message_signature,
30063008
.fault = osd_reset,
30073009
};

0 commit comments

Comments
 (0)