| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/net/sunrpc/svc.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 87 | 88 | switch (*ip) |
|---|
| 88 | 89 | { |
|---|
| 89 | 90 | case SVC_POOL_AUTO: |
|---|
| 90 | | - return strlcpy(buf, "auto", 20); |
|---|
| 91 | + return strlcpy(buf, "auto\n", 20); |
|---|
| 91 | 92 | case SVC_POOL_GLOBAL: |
|---|
| 92 | | - return strlcpy(buf, "global", 20); |
|---|
| 93 | + return strlcpy(buf, "global\n", 20); |
|---|
| 93 | 94 | case SVC_POOL_PERCPU: |
|---|
| 94 | | - return strlcpy(buf, "percpu", 20); |
|---|
| 95 | + return strlcpy(buf, "percpu\n", 20); |
|---|
| 95 | 96 | case SVC_POOL_PERNODE: |
|---|
| 96 | | - return strlcpy(buf, "pernode", 20); |
|---|
| 97 | + return strlcpy(buf, "pernode\n", 20); |
|---|
| 97 | 98 | default: |
|---|
| 98 | | - return sprintf(buf, "%d", *ip); |
|---|
| 99 | + return sprintf(buf, "%d\n", *ip); |
|---|
| 99 | 100 | } |
|---|
| 100 | 101 | } |
|---|
| 101 | 102 | |
|---|
| .. | .. |
|---|
| 799 | 800 | static int |
|---|
| 800 | 801 | svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) |
|---|
| 801 | 802 | { |
|---|
| 803 | + struct svc_rqst *rqstp; |
|---|
| 802 | 804 | struct task_struct *task; |
|---|
| 803 | 805 | unsigned int state = serv->sv_nrthreads-1; |
|---|
| 804 | 806 | |
|---|
| .. | .. |
|---|
| 807 | 809 | task = choose_victim(serv, pool, &state); |
|---|
| 808 | 810 | if (task == NULL) |
|---|
| 809 | 811 | break; |
|---|
| 810 | | - kthread_stop(task); |
|---|
| 812 | + rqstp = kthread_data(task); |
|---|
| 813 | + /* Did we lose a race to svo_function threadfn? */ |
|---|
| 814 | + if (kthread_stop(task) == -EINTR) |
|---|
| 815 | + svc_exit_thread(rqstp); |
|---|
| 811 | 816 | nrservs++; |
|---|
| 812 | 817 | } while (nrservs < 0); |
|---|
| 813 | 818 | return 0; |
|---|
| .. | .. |
|---|
| 990 | 995 | #endif |
|---|
| 991 | 996 | } |
|---|
| 992 | 997 | |
|---|
| 998 | + trace_svc_register(progname, version, family, protocol, port, error); |
|---|
| 993 | 999 | return error; |
|---|
| 994 | 1000 | } |
|---|
| 1001 | + |
|---|
| 1002 | +int svc_rpcbind_set_version(struct net *net, |
|---|
| 1003 | + const struct svc_program *progp, |
|---|
| 1004 | + u32 version, int family, |
|---|
| 1005 | + unsigned short proto, |
|---|
| 1006 | + unsigned short port) |
|---|
| 1007 | +{ |
|---|
| 1008 | + return __svc_register(net, progp->pg_name, progp->pg_prog, |
|---|
| 1009 | + version, family, proto, port); |
|---|
| 1010 | + |
|---|
| 1011 | +} |
|---|
| 1012 | +EXPORT_SYMBOL_GPL(svc_rpcbind_set_version); |
|---|
| 1013 | + |
|---|
| 1014 | +int svc_generic_rpcbind_set(struct net *net, |
|---|
| 1015 | + const struct svc_program *progp, |
|---|
| 1016 | + u32 version, int family, |
|---|
| 1017 | + unsigned short proto, |
|---|
| 1018 | + unsigned short port) |
|---|
| 1019 | +{ |
|---|
| 1020 | + const struct svc_version *vers = progp->pg_vers[version]; |
|---|
| 1021 | + int error; |
|---|
| 1022 | + |
|---|
| 1023 | + if (vers == NULL) |
|---|
| 1024 | + return 0; |
|---|
| 1025 | + |
|---|
| 1026 | + if (vers->vs_hidden) { |
|---|
| 1027 | + trace_svc_noregister(progp->pg_name, version, proto, |
|---|
| 1028 | + port, family, 0); |
|---|
| 1029 | + return 0; |
|---|
| 1030 | + } |
|---|
| 1031 | + |
|---|
| 1032 | + /* |
|---|
| 1033 | + * Don't register a UDP port if we need congestion |
|---|
| 1034 | + * control. |
|---|
| 1035 | + */ |
|---|
| 1036 | + if (vers->vs_need_cong_ctrl && proto == IPPROTO_UDP) |
|---|
| 1037 | + return 0; |
|---|
| 1038 | + |
|---|
| 1039 | + error = svc_rpcbind_set_version(net, progp, version, |
|---|
| 1040 | + family, proto, port); |
|---|
| 1041 | + |
|---|
| 1042 | + return (vers->vs_rpcb_optnl) ? 0 : error; |
|---|
| 1043 | +} |
|---|
| 1044 | +EXPORT_SYMBOL_GPL(svc_generic_rpcbind_set); |
|---|
| 995 | 1045 | |
|---|
| 996 | 1046 | /** |
|---|
| 997 | 1047 | * svc_register - register an RPC service with the local portmapper |
|---|
| .. | .. |
|---|
| 1008 | 1058 | const unsigned short port) |
|---|
| 1009 | 1059 | { |
|---|
| 1010 | 1060 | struct svc_program *progp; |
|---|
| 1011 | | - const struct svc_version *vers; |
|---|
| 1012 | 1061 | unsigned int i; |
|---|
| 1013 | 1062 | int error = 0; |
|---|
| 1014 | 1063 | |
|---|
| .. | .. |
|---|
| 1018 | 1067 | |
|---|
| 1019 | 1068 | for (progp = serv->sv_program; progp; progp = progp->pg_next) { |
|---|
| 1020 | 1069 | for (i = 0; i < progp->pg_nvers; i++) { |
|---|
| 1021 | | - vers = progp->pg_vers[i]; |
|---|
| 1022 | | - if (vers == NULL) |
|---|
| 1023 | | - continue; |
|---|
| 1024 | 1070 | |
|---|
| 1025 | | - dprintk("svc: svc_register(%sv%d, %s, %u, %u)%s\n", |
|---|
| 1026 | | - progp->pg_name, |
|---|
| 1027 | | - i, |
|---|
| 1028 | | - proto == IPPROTO_UDP? "udp" : "tcp", |
|---|
| 1029 | | - port, |
|---|
| 1030 | | - family, |
|---|
| 1031 | | - vers->vs_hidden ? |
|---|
| 1032 | | - " (but not telling portmap)" : ""); |
|---|
| 1033 | | - |
|---|
| 1034 | | - if (vers->vs_hidden) |
|---|
| 1035 | | - continue; |
|---|
| 1036 | | - |
|---|
| 1037 | | - /* |
|---|
| 1038 | | - * Don't register a UDP port if we need congestion |
|---|
| 1039 | | - * control. |
|---|
| 1040 | | - */ |
|---|
| 1041 | | - if (vers->vs_need_cong_ctrl && proto == IPPROTO_UDP) |
|---|
| 1042 | | - continue; |
|---|
| 1043 | | - |
|---|
| 1044 | | - error = __svc_register(net, progp->pg_name, progp->pg_prog, |
|---|
| 1045 | | - i, family, proto, port); |
|---|
| 1046 | | - |
|---|
| 1047 | | - if (vers->vs_rpcb_optnl) { |
|---|
| 1048 | | - error = 0; |
|---|
| 1049 | | - continue; |
|---|
| 1050 | | - } |
|---|
| 1051 | | - |
|---|
| 1071 | + error = progp->pg_rpcbind_set(net, progp, i, |
|---|
| 1072 | + family, proto, port); |
|---|
| 1052 | 1073 | if (error < 0) { |
|---|
| 1053 | 1074 | printk(KERN_WARNING "svc: failed to register " |
|---|
| 1054 | 1075 | "%sv%u RPC service (errno %d).\n", |
|---|
| .. | .. |
|---|
| 1082 | 1103 | if (error == -EPROTONOSUPPORT) |
|---|
| 1083 | 1104 | error = rpcb_register(net, program, version, 0, 0); |
|---|
| 1084 | 1105 | |
|---|
| 1085 | | - dprintk("svc: %s(%sv%u), error %d\n", |
|---|
| 1086 | | - __func__, progname, version, error); |
|---|
| 1106 | + trace_svc_unregister(progname, version, error); |
|---|
| 1087 | 1107 | } |
|---|
| 1088 | 1108 | |
|---|
| 1089 | 1109 | /* |
|---|
| .. | .. |
|---|
| 1108 | 1128 | continue; |
|---|
| 1109 | 1129 | if (progp->pg_vers[i]->vs_hidden) |
|---|
| 1110 | 1130 | continue; |
|---|
| 1111 | | - |
|---|
| 1112 | | - dprintk("svc: attempting to unregister %sv%u\n", |
|---|
| 1113 | | - progp->pg_name, i); |
|---|
| 1114 | 1131 | __svc_unregister(net, progp->pg_prog, i, progp->pg_name); |
|---|
| 1115 | 1132 | } |
|---|
| 1116 | 1133 | } |
|---|
| .. | .. |
|---|
| 1144 | 1161 | static __printf(2,3) void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) {} |
|---|
| 1145 | 1162 | #endif |
|---|
| 1146 | 1163 | |
|---|
| 1147 | | -extern void svc_tcp_prep_reply_hdr(struct svc_rqst *); |
|---|
| 1148 | | - |
|---|
| 1149 | 1164 | __be32 |
|---|
| 1150 | 1165 | svc_return_autherr(struct svc_rqst *rqstp, __be32 auth_err) |
|---|
| 1151 | 1166 | { |
|---|
| .. | .. |
|---|
| 1162 | 1177 | return rpc_auth_ok; |
|---|
| 1163 | 1178 | } |
|---|
| 1164 | 1179 | |
|---|
| 1180 | +static int |
|---|
| 1181 | +svc_generic_dispatch(struct svc_rqst *rqstp, __be32 *statp) |
|---|
| 1182 | +{ |
|---|
| 1183 | + struct kvec *argv = &rqstp->rq_arg.head[0]; |
|---|
| 1184 | + struct kvec *resv = &rqstp->rq_res.head[0]; |
|---|
| 1185 | + const struct svc_procedure *procp = rqstp->rq_procinfo; |
|---|
| 1186 | + |
|---|
| 1187 | + /* |
|---|
| 1188 | + * Decode arguments |
|---|
| 1189 | + * XXX: why do we ignore the return value? |
|---|
| 1190 | + */ |
|---|
| 1191 | + if (procp->pc_decode && |
|---|
| 1192 | + !procp->pc_decode(rqstp, argv->iov_base)) { |
|---|
| 1193 | + *statp = rpc_garbage_args; |
|---|
| 1194 | + return 1; |
|---|
| 1195 | + } |
|---|
| 1196 | + |
|---|
| 1197 | + *statp = procp->pc_func(rqstp); |
|---|
| 1198 | + |
|---|
| 1199 | + if (*statp == rpc_drop_reply || |
|---|
| 1200 | + test_bit(RQ_DROPME, &rqstp->rq_flags)) |
|---|
| 1201 | + return 0; |
|---|
| 1202 | + |
|---|
| 1203 | + if (test_bit(RQ_AUTHERR, &rqstp->rq_flags)) |
|---|
| 1204 | + return 1; |
|---|
| 1205 | + |
|---|
| 1206 | + if (*statp != rpc_success) |
|---|
| 1207 | + return 1; |
|---|
| 1208 | + |
|---|
| 1209 | + /* Encode reply */ |
|---|
| 1210 | + if (procp->pc_encode && |
|---|
| 1211 | + !procp->pc_encode(rqstp, resv->iov_base + resv->iov_len)) { |
|---|
| 1212 | + dprintk("svc: failed to encode reply\n"); |
|---|
| 1213 | + /* serv->sv_stats->rpcsystemerr++; */ |
|---|
| 1214 | + *statp = rpc_system_err; |
|---|
| 1215 | + } |
|---|
| 1216 | + return 1; |
|---|
| 1217 | +} |
|---|
| 1218 | + |
|---|
| 1219 | +__be32 |
|---|
| 1220 | +svc_generic_init_request(struct svc_rqst *rqstp, |
|---|
| 1221 | + const struct svc_program *progp, |
|---|
| 1222 | + struct svc_process_info *ret) |
|---|
| 1223 | +{ |
|---|
| 1224 | + const struct svc_version *versp = NULL; /* compiler food */ |
|---|
| 1225 | + const struct svc_procedure *procp = NULL; |
|---|
| 1226 | + |
|---|
| 1227 | + if (rqstp->rq_vers >= progp->pg_nvers ) |
|---|
| 1228 | + goto err_bad_vers; |
|---|
| 1229 | + versp = progp->pg_vers[rqstp->rq_vers]; |
|---|
| 1230 | + if (!versp) |
|---|
| 1231 | + goto err_bad_vers; |
|---|
| 1232 | + |
|---|
| 1233 | + /* |
|---|
| 1234 | + * Some protocol versions (namely NFSv4) require some form of |
|---|
| 1235 | + * congestion control. (See RFC 7530 section 3.1 paragraph 2) |
|---|
| 1236 | + * In other words, UDP is not allowed. We mark those when setting |
|---|
| 1237 | + * up the svc_xprt, and verify that here. |
|---|
| 1238 | + * |
|---|
| 1239 | + * The spec is not very clear about what error should be returned |
|---|
| 1240 | + * when someone tries to access a server that is listening on UDP |
|---|
| 1241 | + * for lower versions. RPC_PROG_MISMATCH seems to be the closest |
|---|
| 1242 | + * fit. |
|---|
| 1243 | + */ |
|---|
| 1244 | + if (versp->vs_need_cong_ctrl && rqstp->rq_xprt && |
|---|
| 1245 | + !test_bit(XPT_CONG_CTRL, &rqstp->rq_xprt->xpt_flags)) |
|---|
| 1246 | + goto err_bad_vers; |
|---|
| 1247 | + |
|---|
| 1248 | + if (rqstp->rq_proc >= versp->vs_nproc) |
|---|
| 1249 | + goto err_bad_proc; |
|---|
| 1250 | + rqstp->rq_procinfo = procp = &versp->vs_proc[rqstp->rq_proc]; |
|---|
| 1251 | + if (!procp) |
|---|
| 1252 | + goto err_bad_proc; |
|---|
| 1253 | + |
|---|
| 1254 | + /* Initialize storage for argp and resp */ |
|---|
| 1255 | + memset(rqstp->rq_argp, 0, procp->pc_argsize); |
|---|
| 1256 | + memset(rqstp->rq_resp, 0, procp->pc_ressize); |
|---|
| 1257 | + |
|---|
| 1258 | + /* Bump per-procedure stats counter */ |
|---|
| 1259 | + versp->vs_count[rqstp->rq_proc]++; |
|---|
| 1260 | + |
|---|
| 1261 | + ret->dispatch = versp->vs_dispatch; |
|---|
| 1262 | + return rpc_success; |
|---|
| 1263 | +err_bad_vers: |
|---|
| 1264 | + ret->mismatch.lovers = progp->pg_lovers; |
|---|
| 1265 | + ret->mismatch.hivers = progp->pg_hivers; |
|---|
| 1266 | + return rpc_prog_mismatch; |
|---|
| 1267 | +err_bad_proc: |
|---|
| 1268 | + return rpc_proc_unavail; |
|---|
| 1269 | +} |
|---|
| 1270 | +EXPORT_SYMBOL_GPL(svc_generic_init_request); |
|---|
| 1271 | + |
|---|
| 1165 | 1272 | /* |
|---|
| 1166 | 1273 | * Common routine for processing the RPC request. |
|---|
| 1167 | 1274 | */ |
|---|
| .. | .. |
|---|
| 1169 | 1276 | svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv) |
|---|
| 1170 | 1277 | { |
|---|
| 1171 | 1278 | struct svc_program *progp; |
|---|
| 1172 | | - const struct svc_version *versp = NULL; /* compiler food */ |
|---|
| 1173 | 1279 | const struct svc_procedure *procp = NULL; |
|---|
| 1174 | 1280 | struct svc_serv *serv = rqstp->rq_server; |
|---|
| 1281 | + struct svc_process_info process; |
|---|
| 1175 | 1282 | __be32 *statp; |
|---|
| 1176 | | - u32 prog, vers, proc; |
|---|
| 1283 | + u32 prog, vers; |
|---|
| 1177 | 1284 | __be32 auth_stat, rpc_stat; |
|---|
| 1178 | 1285 | int auth_res; |
|---|
| 1179 | 1286 | __be32 *reply_statp; |
|---|
| .. | .. |
|---|
| 1188 | 1295 | /* Will be turned off only when NFSv4 Sessions are used */ |
|---|
| 1189 | 1296 | set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); |
|---|
| 1190 | 1297 | clear_bit(RQ_DROPME, &rqstp->rq_flags); |
|---|
| 1191 | | - |
|---|
| 1192 | | - /* Setup reply header */ |
|---|
| 1193 | | - if (rqstp->rq_prot == IPPROTO_TCP) |
|---|
| 1194 | | - svc_tcp_prep_reply_hdr(rqstp); |
|---|
| 1195 | 1298 | |
|---|
| 1196 | 1299 | svc_putu32(resv, rqstp->rq_xid); |
|---|
| 1197 | 1300 | |
|---|
| .. | .. |
|---|
| 1209 | 1312 | svc_putnl(resv, 0); /* ACCEPT */ |
|---|
| 1210 | 1313 | |
|---|
| 1211 | 1314 | rqstp->rq_prog = prog = svc_getnl(argv); /* program number */ |
|---|
| 1212 | | - rqstp->rq_vers = vers = svc_getnl(argv); /* version number */ |
|---|
| 1213 | | - rqstp->rq_proc = proc = svc_getnl(argv); /* procedure number */ |
|---|
| 1315 | + rqstp->rq_vers = svc_getnl(argv); /* version number */ |
|---|
| 1316 | + rqstp->rq_proc = svc_getnl(argv); /* procedure number */ |
|---|
| 1214 | 1317 | |
|---|
| 1215 | 1318 | for (progp = serv->sv_program; progp; progp = progp->pg_next) |
|---|
| 1216 | 1319 | if (prog == progp->pg_prog) |
|---|
| .. | .. |
|---|
| 1227 | 1330 | auth_stat = rpc_autherr_badcred; |
|---|
| 1228 | 1331 | auth_res = progp->pg_authenticate(rqstp); |
|---|
| 1229 | 1332 | } |
|---|
| 1333 | + if (auth_res != SVC_OK) |
|---|
| 1334 | + trace_svc_authenticate(rqstp, auth_res, auth_stat); |
|---|
| 1230 | 1335 | switch (auth_res) { |
|---|
| 1231 | 1336 | case SVC_OK: |
|---|
| 1232 | 1337 | break; |
|---|
| .. | .. |
|---|
| 1248 | 1353 | if (progp == NULL) |
|---|
| 1249 | 1354 | goto err_bad_prog; |
|---|
| 1250 | 1355 | |
|---|
| 1251 | | - if (vers >= progp->pg_nvers || |
|---|
| 1252 | | - !(versp = progp->pg_vers[vers])) |
|---|
| 1356 | + rpc_stat = progp->pg_init_request(rqstp, progp, &process); |
|---|
| 1357 | + switch (rpc_stat) { |
|---|
| 1358 | + case rpc_success: |
|---|
| 1359 | + break; |
|---|
| 1360 | + case rpc_prog_unavail: |
|---|
| 1361 | + goto err_bad_prog; |
|---|
| 1362 | + case rpc_prog_mismatch: |
|---|
| 1253 | 1363 | goto err_bad_vers; |
|---|
| 1254 | | - |
|---|
| 1255 | | - /* |
|---|
| 1256 | | - * Some protocol versions (namely NFSv4) require some form of |
|---|
| 1257 | | - * congestion control. (See RFC 7530 section 3.1 paragraph 2) |
|---|
| 1258 | | - * In other words, UDP is not allowed. We mark those when setting |
|---|
| 1259 | | - * up the svc_xprt, and verify that here. |
|---|
| 1260 | | - * |
|---|
| 1261 | | - * The spec is not very clear about what error should be returned |
|---|
| 1262 | | - * when someone tries to access a server that is listening on UDP |
|---|
| 1263 | | - * for lower versions. RPC_PROG_MISMATCH seems to be the closest |
|---|
| 1264 | | - * fit. |
|---|
| 1265 | | - */ |
|---|
| 1266 | | - if (versp->vs_need_cong_ctrl && rqstp->rq_xprt && |
|---|
| 1267 | | - !test_bit(XPT_CONG_CTRL, &rqstp->rq_xprt->xpt_flags)) |
|---|
| 1268 | | - goto err_bad_vers; |
|---|
| 1269 | | - |
|---|
| 1270 | | - procp = versp->vs_proc + proc; |
|---|
| 1271 | | - if (proc >= versp->vs_nproc || !procp->pc_func) |
|---|
| 1364 | + case rpc_proc_unavail: |
|---|
| 1272 | 1365 | goto err_bad_proc; |
|---|
| 1273 | | - rqstp->rq_procinfo = procp; |
|---|
| 1366 | + } |
|---|
| 1367 | + |
|---|
| 1368 | + procp = rqstp->rq_procinfo; |
|---|
| 1369 | + /* Should this check go into the dispatcher? */ |
|---|
| 1370 | + if (!procp || !procp->pc_func) |
|---|
| 1371 | + goto err_bad_proc; |
|---|
| 1274 | 1372 | |
|---|
| 1275 | 1373 | /* Syntactic check complete */ |
|---|
| 1276 | 1374 | serv->sv_stats->rpccnt++; |
|---|
| .. | .. |
|---|
| 1280 | 1378 | statp = resv->iov_base +resv->iov_len; |
|---|
| 1281 | 1379 | svc_putnl(resv, RPC_SUCCESS); |
|---|
| 1282 | 1380 | |
|---|
| 1283 | | - /* Bump per-procedure stats counter */ |
|---|
| 1284 | | - versp->vs_count[proc]++; |
|---|
| 1285 | | - |
|---|
| 1286 | | - /* Initialize storage for argp and resp */ |
|---|
| 1287 | | - memset(rqstp->rq_argp, 0, procp->pc_argsize); |
|---|
| 1288 | | - memset(rqstp->rq_resp, 0, procp->pc_ressize); |
|---|
| 1289 | | - |
|---|
| 1290 | 1381 | /* un-reserve some of the out-queue now that we have a |
|---|
| 1291 | 1382 | * better idea of reply size |
|---|
| 1292 | 1383 | */ |
|---|
| .. | .. |
|---|
| 1294 | 1385 | svc_reserve_auth(rqstp, procp->pc_xdrressize<<2); |
|---|
| 1295 | 1386 | |
|---|
| 1296 | 1387 | /* Call the function that processes the request. */ |
|---|
| 1297 | | - if (!versp->vs_dispatch) { |
|---|
| 1298 | | - /* |
|---|
| 1299 | | - * Decode arguments |
|---|
| 1300 | | - * XXX: why do we ignore the return value? |
|---|
| 1301 | | - */ |
|---|
| 1302 | | - if (procp->pc_decode && |
|---|
| 1303 | | - !procp->pc_decode(rqstp, argv->iov_base)) |
|---|
| 1388 | + if (!process.dispatch) { |
|---|
| 1389 | + if (!svc_generic_dispatch(rqstp, statp)) |
|---|
| 1390 | + goto release_dropit; |
|---|
| 1391 | + if (*statp == rpc_garbage_args) |
|---|
| 1304 | 1392 | goto err_garbage; |
|---|
| 1305 | | - |
|---|
| 1306 | | - *statp = procp->pc_func(rqstp); |
|---|
| 1307 | | - |
|---|
| 1308 | | - /* Encode reply */ |
|---|
| 1309 | | - if (*statp == rpc_drop_reply || |
|---|
| 1310 | | - test_bit(RQ_DROPME, &rqstp->rq_flags)) { |
|---|
| 1311 | | - if (procp->pc_release) |
|---|
| 1312 | | - procp->pc_release(rqstp); |
|---|
| 1313 | | - goto dropit; |
|---|
| 1314 | | - } |
|---|
| 1315 | 1393 | auth_stat = svc_get_autherr(rqstp, statp); |
|---|
| 1316 | 1394 | if (auth_stat != rpc_auth_ok) |
|---|
| 1317 | 1395 | goto err_release_bad_auth; |
|---|
| 1318 | | - if (*statp == rpc_success && procp->pc_encode && |
|---|
| 1319 | | - !procp->pc_encode(rqstp, resv->iov_base + resv->iov_len)) { |
|---|
| 1320 | | - dprintk("svc: failed to encode reply\n"); |
|---|
| 1321 | | - /* serv->sv_stats->rpcsystemerr++; */ |
|---|
| 1322 | | - *statp = rpc_system_err; |
|---|
| 1323 | | - } |
|---|
| 1324 | 1396 | } else { |
|---|
| 1325 | 1397 | dprintk("svc: calling dispatcher\n"); |
|---|
| 1326 | | - if (!versp->vs_dispatch(rqstp, statp)) { |
|---|
| 1327 | | - /* Release reply info */ |
|---|
| 1328 | | - if (procp->pc_release) |
|---|
| 1329 | | - procp->pc_release(rqstp); |
|---|
| 1330 | | - goto dropit; |
|---|
| 1331 | | - } |
|---|
| 1398 | + if (!process.dispatch(rqstp, statp)) |
|---|
| 1399 | + goto release_dropit; /* Release reply info */ |
|---|
| 1332 | 1400 | } |
|---|
| 1333 | 1401 | |
|---|
| 1334 | 1402 | /* Check RPC status result */ |
|---|
| .. | .. |
|---|
| 1347 | 1415 | goto close_xprt; |
|---|
| 1348 | 1416 | return 1; /* Caller can now send it */ |
|---|
| 1349 | 1417 | |
|---|
| 1418 | +release_dropit: |
|---|
| 1419 | + if (procp->pc_release) |
|---|
| 1420 | + procp->pc_release(rqstp); |
|---|
| 1350 | 1421 | dropit: |
|---|
| 1351 | 1422 | svc_authorise(rqstp); /* doesn't hurt to call this twice */ |
|---|
| 1352 | 1423 | dprintk("svc: svc_process dropit\n"); |
|---|
| .. | .. |
|---|
| 1394 | 1465 | |
|---|
| 1395 | 1466 | err_bad_vers: |
|---|
| 1396 | 1467 | svc_printk(rqstp, "unknown version (%d for prog %d, %s)\n", |
|---|
| 1397 | | - vers, prog, progp->pg_name); |
|---|
| 1468 | + rqstp->rq_vers, rqstp->rq_prog, progp->pg_name); |
|---|
| 1398 | 1469 | |
|---|
| 1399 | 1470 | serv->sv_stats->rpcbadfmt++; |
|---|
| 1400 | 1471 | svc_putnl(resv, RPC_PROG_MISMATCH); |
|---|
| 1401 | | - svc_putnl(resv, progp->pg_lovers); |
|---|
| 1402 | | - svc_putnl(resv, progp->pg_hivers); |
|---|
| 1472 | + svc_putnl(resv, process.mismatch.lovers); |
|---|
| 1473 | + svc_putnl(resv, process.mismatch.hivers); |
|---|
| 1403 | 1474 | goto sendit; |
|---|
| 1404 | 1475 | |
|---|
| 1405 | 1476 | err_bad_proc: |
|---|
| 1406 | | - svc_printk(rqstp, "unknown procedure (%d)\n", proc); |
|---|
| 1477 | + svc_printk(rqstp, "unknown procedure (%d)\n", rqstp->rq_proc); |
|---|
| 1407 | 1478 | |
|---|
| 1408 | 1479 | serv->sv_stats->rpcbadfmt++; |
|---|
| 1409 | 1480 | svc_putnl(resv, RPC_PROC_UNAVAIL); |
|---|
| .. | .. |
|---|
| 1517 | 1588 | /* Parse and execute the bc call */ |
|---|
| 1518 | 1589 | proc_error = svc_process_common(rqstp, argv, resv); |
|---|
| 1519 | 1590 | |
|---|
| 1520 | | - atomic_inc(&req->rq_xprt->bc_free_slots); |
|---|
| 1591 | + atomic_dec(&req->rq_xprt->bc_slot_count); |
|---|
| 1521 | 1592 | if (!proc_error) { |
|---|
| 1522 | 1593 | /* Processing error: drop the request */ |
|---|
| 1523 | 1594 | xprt_free_bc_request(req); |
|---|
| 1524 | | - return 0; |
|---|
| 1595 | + error = -EINVAL; |
|---|
| 1596 | + goto out; |
|---|
| 1525 | 1597 | } |
|---|
| 1526 | | - |
|---|
| 1527 | 1598 | /* Finally, send the reply synchronously */ |
|---|
| 1528 | 1599 | memcpy(&req->rq_snd_buf, &rqstp->rq_res, sizeof(req->rq_snd_buf)); |
|---|
| 1529 | 1600 | task = rpc_run_bc_task(req); |
|---|
| .. | .. |
|---|
| 1557 | 1628 | EXPORT_SYMBOL_GPL(svc_max_payload); |
|---|
| 1558 | 1629 | |
|---|
| 1559 | 1630 | /** |
|---|
| 1631 | + * svc_encode_read_payload - mark a range of bytes as a READ payload |
|---|
| 1632 | + * @rqstp: svc_rqst to operate on |
|---|
| 1633 | + * @offset: payload's byte offset in rqstp->rq_res |
|---|
| 1634 | + * @length: size of payload, in bytes |
|---|
| 1635 | + * |
|---|
| 1636 | + * Returns zero on success, or a negative errno if a permanent |
|---|
| 1637 | + * error occurred. |
|---|
| 1638 | + */ |
|---|
| 1639 | +int svc_encode_read_payload(struct svc_rqst *rqstp, unsigned int offset, |
|---|
| 1640 | + unsigned int length) |
|---|
| 1641 | +{ |
|---|
| 1642 | + return rqstp->rq_xprt->xpt_ops->xpo_read_payload(rqstp, offset, length); |
|---|
| 1643 | +} |
|---|
| 1644 | +EXPORT_SYMBOL_GPL(svc_encode_read_payload); |
|---|
| 1645 | + |
|---|
| 1646 | +/** |
|---|
| 1560 | 1647 | * svc_fill_write_vector - Construct data argument for VFS write call |
|---|
| 1561 | 1648 | * @rqstp: svc_rqst to operate on |
|---|
| 1562 | 1649 | * @pages: list of pages containing data payload |
|---|