提交 3ab26a6f 编写于 作者: D David Howells

rxrpc: Consolidate sendmsg parameters

Consolidate the sendmsg control message parameters into a struct rather
than passing them individually through the argument list of
rxrpc_sendmsg_cmsg().  This makes it easier to add more parameters.
Signed-off-by: NDavid Howells <dhowells@redhat.com>
上级 515559ca
master alk-4.19.24 alk-4.19.30 alk-4.19.34 alk-4.19.36 alk-4.19.43 alk-4.19.48 alk-4.19.57 ck-4.19.67 ck-4.19.81 ck-4.19.91 github/fork/deepanshu1422/fix-typo-in-comment github/fork/haosdent/fix-typo linux-next v4.19.91 v4.19.90 v4.19.89 v4.19.88 v4.19.87 v4.19.86 v4.19.85 v4.19.84 v4.19.83 v4.19.82 v4.19.81 v4.19.80 v4.19.79 v4.19.78 v4.19.77 v4.19.76 v4.19.75 v4.19.74 v4.19.73 v4.19.72 v4.19.71 v4.19.70 v4.19.69 v4.19.68 v4.19.67 v4.19.66 v4.19.65 v4.19.64 v4.19.63 v4.19.62 v4.19.61 v4.19.60 v4.19.59 v4.19.58 v4.19.57 v4.19.56 v4.19.55 v4.19.54 v4.19.53 v4.19.52 v4.19.51 v4.19.50 v4.19.49 v4.19.48 v4.19.47 v4.19.46 v4.19.45 v4.19.44 v4.19.43 v4.19.42 v4.19.41 v4.19.40 v4.19.39 v4.19.38 v4.19.37 v4.19.36 v4.19.35 v4.19.34 v4.19.33 v4.19.32 v4.19.31 v4.19.30 v4.19.29 v4.19.28 v4.19.27 v4.19.26 v4.19.25 v4.19.24 v4.19.23 v4.19.22 v4.19.21 v4.19.20 v4.19.19 v4.19.18 v4.19.17 v4.19.16 v4.19.15 v4.19.14 v4.19.13 v4.19.12 v4.19.11 v4.19.10 v4.19.9 v4.19.8 v4.19.7 v4.19.6 v4.19.5 v4.19.4 v4.19.3 v4.19.2 v4.19.1 v4.19 v4.19-rc8 v4.19-rc7 v4.19-rc6 v4.19-rc5 v4.19-rc4 v4.19-rc3 v4.19-rc2 v4.19-rc1 ck-release-21 ck-release-20 ck-release-19.2 ck-release-19.1 ck-release-19 ck-release-18 ck-release-17.2 ck-release-17.1 ck-release-17 ck-release-16 ck-release-15.1 ck-release-15 ck-release-14 ck-release-13.2 ck-release-13 ck-release-12 ck-release-11 ck-release-10 ck-release-9 ck-release-7 alk-release-15 alk-release-14 alk-release-13.2 alk-release-13 alk-release-12 alk-release-11 alk-release-10 alk-release-9 alk-release-7
无相关合并请求
...@@ -28,6 +28,14 @@ enum rxrpc_command { ...@@ -28,6 +28,14 @@ enum rxrpc_command {
RXRPC_CMD_REJECT_BUSY, /* [server] reject a call as busy */ RXRPC_CMD_REJECT_BUSY, /* [server] reject a call as busy */
}; };
struct rxrpc_send_params {
unsigned long user_call_ID; /* User's call ID */
u32 abort_code; /* Abort code to Tx (if abort) */
enum rxrpc_command command : 8; /* The command to implement */
bool exclusive; /* Shared or exclusive call */
bool upgrade; /* If the connection is upgradeable */
};
/* /*
* wait for space to appear in the transmit/ACK window * wait for space to appear in the transmit/ACK window
* - caller holds the socket locked * - caller holds the socket locked
...@@ -362,19 +370,12 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ...@@ -362,19 +370,12 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
/* /*
* extract control messages from the sendmsg() control buffer * extract control messages from the sendmsg() control buffer
*/ */
static int rxrpc_sendmsg_cmsg(struct msghdr *msg, static int rxrpc_sendmsg_cmsg(struct msghdr *msg, struct rxrpc_send_params *p)
unsigned long *user_call_ID,
enum rxrpc_command *command,
u32 *abort_code,
bool *_exclusive,
bool *_upgrade)
{ {
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
bool got_user_ID = false; bool got_user_ID = false;
int len; int len;
*command = RXRPC_CMD_SEND_DATA;
if (msg->msg_controllen == 0) if (msg->msg_controllen == 0)
return -EINVAL; return -EINVAL;
...@@ -394,45 +395,43 @@ static int rxrpc_sendmsg_cmsg(struct msghdr *msg, ...@@ -394,45 +395,43 @@ static int rxrpc_sendmsg_cmsg(struct msghdr *msg,
if (msg->msg_flags & MSG_CMSG_COMPAT) { if (msg->msg_flags & MSG_CMSG_COMPAT) {
if (len != sizeof(u32)) if (len != sizeof(u32))
return -EINVAL; return -EINVAL;
*user_call_ID = *(u32 *) CMSG_DATA(cmsg); p->user_call_ID = *(u32 *)CMSG_DATA(cmsg);
} else { } else {
if (len != sizeof(unsigned long)) if (len != sizeof(unsigned long))
return -EINVAL; return -EINVAL;
*user_call_ID = *(unsigned long *) p->user_call_ID = *(unsigned long *)
CMSG_DATA(cmsg); CMSG_DATA(cmsg);
} }
_debug("User Call ID %lx", *user_call_ID);
got_user_ID = true; got_user_ID = true;
break; break;
case RXRPC_ABORT: case RXRPC_ABORT:
if (*command != RXRPC_CMD_SEND_DATA) if (p->command != RXRPC_CMD_SEND_DATA)
return -EINVAL; return -EINVAL;
*command = RXRPC_CMD_SEND_ABORT; p->command = RXRPC_CMD_SEND_ABORT;
if (len != sizeof(*abort_code)) if (len != sizeof(p->abort_code))
return -EINVAL; return -EINVAL;
*abort_code = *(unsigned int *) CMSG_DATA(cmsg); p->abort_code = *(unsigned int *)CMSG_DATA(cmsg);
_debug("Abort %x", *abort_code); if (p->abort_code == 0)
if (*abort_code == 0)
return -EINVAL; return -EINVAL;
break; break;
case RXRPC_ACCEPT: case RXRPC_ACCEPT:
if (*command != RXRPC_CMD_SEND_DATA) if (p->command != RXRPC_CMD_SEND_DATA)
return -EINVAL; return -EINVAL;
*command = RXRPC_CMD_ACCEPT; p->command = RXRPC_CMD_ACCEPT;
if (len != 0) if (len != 0)
return -EINVAL; return -EINVAL;
break; break;
case RXRPC_EXCLUSIVE_CALL: case RXRPC_EXCLUSIVE_CALL:
*_exclusive = true; p->exclusive = true;
if (len != 0) if (len != 0)
return -EINVAL; return -EINVAL;
break; break;
case RXRPC_UPGRADE_SERVICE: case RXRPC_UPGRADE_SERVICE:
*_upgrade = true; p->upgrade = true;
if (len != 0) if (len != 0)
return -EINVAL; return -EINVAL;
break; break;
...@@ -455,8 +454,7 @@ static int rxrpc_sendmsg_cmsg(struct msghdr *msg, ...@@ -455,8 +454,7 @@ static int rxrpc_sendmsg_cmsg(struct msghdr *msg,
*/ */
static struct rxrpc_call * static struct rxrpc_call *
rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,
unsigned long user_call_ID, bool exclusive, struct rxrpc_send_params *p)
bool upgrade)
__releases(&rx->sk.sk_lock.slock) __releases(&rx->sk.sk_lock.slock)
{ {
struct rxrpc_conn_parameters cp; struct rxrpc_conn_parameters cp;
...@@ -480,10 +478,10 @@ rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, ...@@ -480,10 +478,10 @@ rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,
cp.local = rx->local; cp.local = rx->local;
cp.key = rx->key; cp.key = rx->key;
cp.security_level = rx->min_sec_level; cp.security_level = rx->min_sec_level;
cp.exclusive = rx->exclusive | exclusive; cp.exclusive = rx->exclusive | p->exclusive;
cp.upgrade = upgrade; cp.upgrade = p->upgrade;
cp.service_id = srx->srx_service; cp.service_id = srx->srx_service;
call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, GFP_KERNEL); call = rxrpc_new_client_call(rx, &cp, srx, p->user_call_ID, GFP_KERNEL);
/* The socket is now unlocked */ /* The socket is now unlocked */
_leave(" = %p\n", call); _leave(" = %p\n", call);
...@@ -499,26 +497,28 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len) ...@@ -499,26 +497,28 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
__releases(&rx->sk.sk_lock.slock) __releases(&rx->sk.sk_lock.slock)
{ {
enum rxrpc_call_state state; enum rxrpc_call_state state;
enum rxrpc_command cmd;
struct rxrpc_call *call; struct rxrpc_call *call;
unsigned long user_call_ID = 0;
bool exclusive = false;
bool upgrade = true;
u32 abort_code = 0;
int ret; int ret;
struct rxrpc_send_params p = {
.user_call_ID = 0,
.abort_code = 0,
.command = RXRPC_CMD_SEND_DATA,
.exclusive = false,
.upgrade = true,
};
_enter(""); _enter("");
ret = rxrpc_sendmsg_cmsg(msg, &user_call_ID, &cmd, &abort_code, ret = rxrpc_sendmsg_cmsg(msg, &p);
&exclusive, &upgrade);
if (ret < 0) if (ret < 0)
goto error_release_sock; goto error_release_sock;
if (cmd == RXRPC_CMD_ACCEPT) { if (p.command == RXRPC_CMD_ACCEPT) {
ret = -EINVAL; ret = -EINVAL;
if (rx->sk.sk_state != RXRPC_SERVER_LISTENING) if (rx->sk.sk_state != RXRPC_SERVER_LISTENING)
goto error_release_sock; goto error_release_sock;
call = rxrpc_accept_call(rx, user_call_ID, NULL); call = rxrpc_accept_call(rx, p.user_call_ID, NULL);
/* The socket is now unlocked. */ /* The socket is now unlocked. */
if (IS_ERR(call)) if (IS_ERR(call))
return PTR_ERR(call); return PTR_ERR(call);
...@@ -526,13 +526,12 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len) ...@@ -526,13 +526,12 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
return 0; return 0;
} }
call = rxrpc_find_call_by_user_ID(rx, user_call_ID); call = rxrpc_find_call_by_user_ID(rx, p.user_call_ID);
if (!call) { if (!call) {
ret = -EBADSLT; ret = -EBADSLT;
if (cmd != RXRPC_CMD_SEND_DATA) if (p.command != RXRPC_CMD_SEND_DATA)
goto error_release_sock; goto error_release_sock;
call = rxrpc_new_client_call_for_sendmsg(rx, msg, user_call_ID, call = rxrpc_new_client_call_for_sendmsg(rx, msg, &p);
exclusive, upgrade);
/* The socket is now unlocked... */ /* The socket is now unlocked... */
if (IS_ERR(call)) if (IS_ERR(call))
return PTR_ERR(call); return PTR_ERR(call);
...@@ -565,11 +564,11 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len) ...@@ -565,11 +564,11 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
if (state >= RXRPC_CALL_COMPLETE) { if (state >= RXRPC_CALL_COMPLETE) {
/* it's too late for this call */ /* it's too late for this call */
ret = -ESHUTDOWN; ret = -ESHUTDOWN;
} else if (cmd == RXRPC_CMD_SEND_ABORT) { } else if (p.command == RXRPC_CMD_SEND_ABORT) {
ret = 0; ret = 0;
if (rxrpc_abort_call("CMD", call, 0, abort_code, -ECONNABORTED)) if (rxrpc_abort_call("CMD", call, 0, p.abort_code, -ECONNABORTED))
ret = rxrpc_send_abort_packet(call); ret = rxrpc_send_abort_packet(call);
} else if (cmd != RXRPC_CMD_SEND_DATA) { } else if (p.command != RXRPC_CMD_SEND_DATA) {
ret = -EINVAL; ret = -EINVAL;
} else if (rxrpc_is_client_call(call) && } else if (rxrpc_is_client_call(call) &&
state != RXRPC_CALL_CLIENT_SEND_REQUEST) { state != RXRPC_CALL_CLIENT_SEND_REQUEST) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部