| .. | .. |
|---|
| 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 | |
|---|
| .. | .. |
|---|
| 990 | 991 | #endif |
|---|
| 991 | 992 | } |
|---|
| 992 | 993 | |
|---|
| 994 | + trace_svc_register(progname, version, protocol, port, family, error); |
|---|
| 993 | 995 | return error; |
|---|
| 994 | 996 | } |
|---|
| 997 | + |
|---|
| 998 | +int svc_rpcbind_set_version(struct net *net, |
|---|
| 999 | + const struct svc_program *progp, |
|---|
| 1000 | + u32 version, int family, |
|---|
| 1001 | + unsigned short proto, |
|---|
| 1002 | + unsigned short port) |
|---|
| 1003 | +{ |
|---|
| 1004 | + return __svc_register(net, progp->pg_name, progp->pg_prog, |
|---|
| 1005 | + version, family, proto, port); |
|---|
| 1006 | + |
|---|
| 1007 | +} |
|---|
| 1008 | +EXPORT_SYMBOL_GPL(svc_rpcbind_set_version); |
|---|
| 1009 | + |
|---|
| 1010 | +int svc_generic_rpcbind_set(struct net *net, |
|---|
| 1011 | + const struct svc_program *progp, |
|---|
| 1012 | + u32 version, int family, |
|---|
| 1013 | + unsigned short proto, |
|---|
| 1014 | + unsigned short port) |
|---|
| 1015 | +{ |
|---|
| 1016 | + const struct svc_version *vers = progp->pg_vers[version]; |
|---|
| 1017 | + int error; |
|---|
| 1018 | + |
|---|
| 1019 | + if (vers == NULL) |
|---|
| 1020 | + return 0; |
|---|
| 1021 | + |
|---|
| 1022 | + if (vers->vs_hidden) { |
|---|
| 1023 | + trace_svc_noregister(progp->pg_name, version, proto, |
|---|
| 1024 | + port, family, 0); |
|---|
| 1025 | + return 0; |
|---|
| 1026 | + } |
|---|
| 1027 | + |
|---|
| 1028 | + /* |
|---|
| 1029 | + * Don't register a UDP port if we need congestion |
|---|
| 1030 | + * control. |
|---|
| 1031 | + */ |
|---|
| 1032 | + if (vers->vs_need_cong_ctrl && proto == IPPROTO_UDP) |
|---|
| 1033 | + return 0; |
|---|
| 1034 | + |
|---|
| 1035 | + error = svc_rpcbind_set_version(net, progp, version, |
|---|
| 1036 | + family, proto, port); |
|---|
| 1037 | + |
|---|
| 1038 | + return (vers->vs_rpcb_optnl) ? 0 : error; |
|---|
| 1039 | +} |
|---|
| 1040 | +EXPORT_SYMBOL_GPL(svc_generic_rpcbind_set); |
|---|
| 995 | 1041 | |
|---|
| 996 | 1042 | /** |
|---|
| 997 | 1043 | * svc_register - register an RPC service with the local portmapper |
|---|
| .. | .. |
|---|
| 1008 | 1054 | const unsigned short port) |
|---|
| 1009 | 1055 | { |
|---|
| 1010 | 1056 | struct svc_program *progp; |
|---|
| 1011 | | - const struct svc_version *vers; |
|---|
| 1012 | 1057 | unsigned int i; |
|---|
| 1013 | 1058 | int error = 0; |
|---|
| 1014 | 1059 | |
|---|
| .. | .. |
|---|
| 1018 | 1063 | |
|---|
| 1019 | 1064 | for (progp = serv->sv_program; progp; progp = progp->pg_next) { |
|---|
| 1020 | 1065 | for (i = 0; i < progp->pg_nvers; i++) { |
|---|
| 1021 | | - vers = progp->pg_vers[i]; |
|---|
| 1022 | | - if (vers == NULL) |
|---|
| 1023 | | - continue; |
|---|
| 1024 | 1066 | |
|---|
| 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 | | - |
|---|
| 1067 | + error = progp->pg_rpcbind_set(net, progp, i, |
|---|
| 1068 | + family, proto, port); |
|---|
| 1052 | 1069 | if (error < 0) { |
|---|
| 1053 | 1070 | printk(KERN_WARNING "svc: failed to register " |
|---|
| 1054 | 1071 | "%sv%u RPC service (errno %d).\n", |
|---|
| .. | .. |
|---|
| 1082 | 1099 | if (error == -EPROTONOSUPPORT) |
|---|
| 1083 | 1100 | error = rpcb_register(net, program, version, 0, 0); |
|---|
| 1084 | 1101 | |
|---|
| 1085 | | - dprintk("svc: %s(%sv%u), error %d\n", |
|---|
| 1086 | | - __func__, progname, version, error); |
|---|
| 1102 | + trace_svc_unregister(progname, version, error); |
|---|
| 1087 | 1103 | } |
|---|
| 1088 | 1104 | |
|---|
| 1089 | 1105 | /* |
|---|
| .. | .. |
|---|
| 1108 | 1124 | continue; |
|---|
| 1109 | 1125 | if (progp->pg_vers[i]->vs_hidden) |
|---|
| 1110 | 1126 | continue; |
|---|
| 1111 | | - |
|---|
| 1112 | | - dprintk("svc: attempting to unregister %sv%u\n", |
|---|
| 1113 | | - progp->pg_name, i); |
|---|
| 1114 | 1127 | __svc_unregister(net, progp->pg_prog, i, progp->pg_name); |
|---|
| 1115 | 1128 | } |
|---|
| 1116 | 1129 | } |
|---|
| .. | .. |
|---|
| 1144 | 1157 | static __printf(2,3) void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) {} |
|---|
| 1145 | 1158 | #endif |
|---|
| 1146 | 1159 | |
|---|
| 1147 | | -extern void svc_tcp_prep_reply_hdr(struct svc_rqst *); |
|---|
| 1148 | | - |
|---|
| 1149 | 1160 | __be32 |
|---|
| 1150 | 1161 | svc_return_autherr(struct svc_rqst *rqstp, __be32 auth_err) |
|---|
| 1151 | 1162 | { |
|---|
| .. | .. |
|---|
| 1162 | 1173 | return rpc_auth_ok; |
|---|
| 1163 | 1174 | } |
|---|
| 1164 | 1175 | |
|---|
| 1176 | +static int |
|---|
| 1177 | +svc_generic_dispatch(struct svc_rqst *rqstp, __be32 *statp) |
|---|
| 1178 | +{ |
|---|
| 1179 | + struct kvec *argv = &rqstp->rq_arg.head[0]; |
|---|
| 1180 | + struct kvec *resv = &rqstp->rq_res.head[0]; |
|---|
| 1181 | + const struct svc_procedure *procp = rqstp->rq_procinfo; |
|---|
| 1182 | + |
|---|
| 1183 | + /* |
|---|
| 1184 | + * Decode arguments |
|---|
| 1185 | + * XXX: why do we ignore the return value? |
|---|
| 1186 | + */ |
|---|
| 1187 | + if (procp->pc_decode && |
|---|
| 1188 | + !procp->pc_decode(rqstp, argv->iov_base)) { |
|---|
| 1189 | + *statp = rpc_garbage_args; |
|---|
| 1190 | + return 1; |
|---|
| 1191 | + } |
|---|
| 1192 | + |
|---|
| 1193 | + *statp = procp->pc_func(rqstp); |
|---|
| 1194 | + |
|---|
| 1195 | + if (*statp == rpc_drop_reply || |
|---|
| 1196 | + test_bit(RQ_DROPME, &rqstp->rq_flags)) |
|---|
| 1197 | + return 0; |
|---|
| 1198 | + |
|---|
| 1199 | + if (test_bit(RQ_AUTHERR, &rqstp->rq_flags)) |
|---|
| 1200 | + return 1; |
|---|
| 1201 | + |
|---|
| 1202 | + if (*statp != rpc_success) |
|---|
| 1203 | + return 1; |
|---|
| 1204 | + |
|---|
| 1205 | + /* Encode reply */ |
|---|
| 1206 | + if (procp->pc_encode && |
|---|
| 1207 | + !procp->pc_encode(rqstp, resv->iov_base + resv->iov_len)) { |
|---|
| 1208 | + dprintk("svc: failed to encode reply\n"); |
|---|
| 1209 | + /* serv->sv_stats->rpcsystemerr++; */ |
|---|
| 1210 | + *statp = rpc_system_err; |
|---|
| 1211 | + } |
|---|
| 1212 | + return 1; |
|---|
| 1213 | +} |
|---|
| 1214 | + |
|---|
| 1215 | +__be32 |
|---|
| 1216 | +svc_generic_init_request(struct svc_rqst *rqstp, |
|---|
| 1217 | + const struct svc_program *progp, |
|---|
| 1218 | + struct svc_process_info *ret) |
|---|
| 1219 | +{ |
|---|
| 1220 | + const struct svc_version *versp = NULL; /* compiler food */ |
|---|
| 1221 | + const struct svc_procedure *procp = NULL; |
|---|
| 1222 | + |
|---|
| 1223 | + if (rqstp->rq_vers >= progp->pg_nvers ) |
|---|
| 1224 | + goto err_bad_vers; |
|---|
| 1225 | + versp = progp->pg_vers[rqstp->rq_vers]; |
|---|
| 1226 | + if (!versp) |
|---|
| 1227 | + goto err_bad_vers; |
|---|
| 1228 | + |
|---|
| 1229 | + /* |
|---|
| 1230 | + * Some protocol versions (namely NFSv4) require some form of |
|---|
| 1231 | + * congestion control. (See RFC 7530 section 3.1 paragraph 2) |
|---|
| 1232 | + * In other words, UDP is not allowed. We mark those when setting |
|---|
| 1233 | + * up the svc_xprt, and verify that here. |
|---|
| 1234 | + * |
|---|
| 1235 | + * The spec is not very clear about what error should be returned |
|---|
| 1236 | + * when someone tries to access a server that is listening on UDP |
|---|
| 1237 | + * for lower versions. RPC_PROG_MISMATCH seems to be the closest |
|---|
| 1238 | + * fit. |
|---|
| 1239 | + */ |
|---|
| 1240 | + if (versp->vs_need_cong_ctrl && rqstp->rq_xprt && |
|---|
| 1241 | + !test_bit(XPT_CONG_CTRL, &rqstp->rq_xprt->xpt_flags)) |
|---|
| 1242 | + goto err_bad_vers; |
|---|
| 1243 | + |
|---|
| 1244 | + if (rqstp->rq_proc >= versp->vs_nproc) |
|---|
| 1245 | + goto err_bad_proc; |
|---|
| 1246 | + rqstp->rq_procinfo = procp = &versp->vs_proc[rqstp->rq_proc]; |
|---|
| 1247 | + if (!procp) |
|---|
| 1248 | + goto err_bad_proc; |
|---|
| 1249 | + |
|---|
| 1250 | + /* Initialize storage for argp and resp */ |
|---|
| 1251 | + memset(rqstp->rq_argp, 0, procp->pc_argsize); |
|---|
| 1252 | + memset(rqstp->rq_resp, 0, procp->pc_ressize); |
|---|
| 1253 | + |
|---|
| 1254 | + /* Bump per-procedure stats counter */ |
|---|
| 1255 | + versp->vs_count[rqstp->rq_proc]++; |
|---|
| 1256 | + |
|---|
| 1257 | + ret->dispatch = versp->vs_dispatch; |
|---|
| 1258 | + return rpc_success; |
|---|
| 1259 | +err_bad_vers: |
|---|
| 1260 | + ret->mismatch.lovers = progp->pg_lovers; |
|---|
| 1261 | + ret->mismatch.hivers = progp->pg_hivers; |
|---|
| 1262 | + return rpc_prog_mismatch; |
|---|
| 1263 | +err_bad_proc: |
|---|
| 1264 | + return rpc_proc_unavail; |
|---|
| 1265 | +} |
|---|
| 1266 | +EXPORT_SYMBOL_GPL(svc_generic_init_request); |
|---|
| 1267 | + |
|---|
| 1165 | 1268 | /* |
|---|
| 1166 | 1269 | * Common routine for processing the RPC request. |
|---|
| 1167 | 1270 | */ |
|---|
| .. | .. |
|---|
| 1169 | 1272 | svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv) |
|---|
| 1170 | 1273 | { |
|---|
| 1171 | 1274 | struct svc_program *progp; |
|---|
| 1172 | | - const struct svc_version *versp = NULL; /* compiler food */ |
|---|
| 1173 | 1275 | const struct svc_procedure *procp = NULL; |
|---|
| 1174 | 1276 | struct svc_serv *serv = rqstp->rq_server; |
|---|
| 1277 | + struct svc_process_info process; |
|---|
| 1175 | 1278 | __be32 *statp; |
|---|
| 1176 | | - u32 prog, vers, proc; |
|---|
| 1279 | + u32 prog, vers; |
|---|
| 1177 | 1280 | __be32 auth_stat, rpc_stat; |
|---|
| 1178 | 1281 | int auth_res; |
|---|
| 1179 | 1282 | __be32 *reply_statp; |
|---|
| .. | .. |
|---|
| 1188 | 1291 | /* Will be turned off only when NFSv4 Sessions are used */ |
|---|
| 1189 | 1292 | set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); |
|---|
| 1190 | 1293 | 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 | 1294 | |
|---|
| 1196 | 1295 | svc_putu32(resv, rqstp->rq_xid); |
|---|
| 1197 | 1296 | |
|---|
| .. | .. |
|---|
| 1209 | 1308 | svc_putnl(resv, 0); /* ACCEPT */ |
|---|
| 1210 | 1309 | |
|---|
| 1211 | 1310 | 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 */ |
|---|
| 1311 | + rqstp->rq_vers = svc_getnl(argv); /* version number */ |
|---|
| 1312 | + rqstp->rq_proc = svc_getnl(argv); /* procedure number */ |
|---|
| 1214 | 1313 | |
|---|
| 1215 | 1314 | for (progp = serv->sv_program; progp; progp = progp->pg_next) |
|---|
| 1216 | 1315 | if (prog == progp->pg_prog) |
|---|
| .. | .. |
|---|
| 1227 | 1326 | auth_stat = rpc_autherr_badcred; |
|---|
| 1228 | 1327 | auth_res = progp->pg_authenticate(rqstp); |
|---|
| 1229 | 1328 | } |
|---|
| 1329 | + if (auth_res != SVC_OK) |
|---|
| 1330 | + trace_svc_authenticate(rqstp, auth_res, auth_stat); |
|---|
| 1230 | 1331 | switch (auth_res) { |
|---|
| 1231 | 1332 | case SVC_OK: |
|---|
| 1232 | 1333 | break; |
|---|
| .. | .. |
|---|
| 1248 | 1349 | if (progp == NULL) |
|---|
| 1249 | 1350 | goto err_bad_prog; |
|---|
| 1250 | 1351 | |
|---|
| 1251 | | - if (vers >= progp->pg_nvers || |
|---|
| 1252 | | - !(versp = progp->pg_vers[vers])) |
|---|
| 1352 | + rpc_stat = progp->pg_init_request(rqstp, progp, &process); |
|---|
| 1353 | + switch (rpc_stat) { |
|---|
| 1354 | + case rpc_success: |
|---|
| 1355 | + break; |
|---|
| 1356 | + case rpc_prog_unavail: |
|---|
| 1357 | + goto err_bad_prog; |
|---|
| 1358 | + case rpc_prog_mismatch: |
|---|
| 1253 | 1359 | 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) |
|---|
| 1360 | + case rpc_proc_unavail: |
|---|
| 1272 | 1361 | goto err_bad_proc; |
|---|
| 1273 | | - rqstp->rq_procinfo = procp; |
|---|
| 1362 | + } |
|---|
| 1363 | + |
|---|
| 1364 | + procp = rqstp->rq_procinfo; |
|---|
| 1365 | + /* Should this check go into the dispatcher? */ |
|---|
| 1366 | + if (!procp || !procp->pc_func) |
|---|
| 1367 | + goto err_bad_proc; |
|---|
| 1274 | 1368 | |
|---|
| 1275 | 1369 | /* Syntactic check complete */ |
|---|
| 1276 | 1370 | serv->sv_stats->rpccnt++; |
|---|
| .. | .. |
|---|
| 1280 | 1374 | statp = resv->iov_base +resv->iov_len; |
|---|
| 1281 | 1375 | svc_putnl(resv, RPC_SUCCESS); |
|---|
| 1282 | 1376 | |
|---|
| 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 | 1377 | /* un-reserve some of the out-queue now that we have a |
|---|
| 1291 | 1378 | * better idea of reply size |
|---|
| 1292 | 1379 | */ |
|---|
| .. | .. |
|---|
| 1294 | 1381 | svc_reserve_auth(rqstp, procp->pc_xdrressize<<2); |
|---|
| 1295 | 1382 | |
|---|
| 1296 | 1383 | /* 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)) |
|---|
| 1384 | + if (!process.dispatch) { |
|---|
| 1385 | + if (!svc_generic_dispatch(rqstp, statp)) |
|---|
| 1386 | + goto release_dropit; |
|---|
| 1387 | + if (*statp == rpc_garbage_args) |
|---|
| 1304 | 1388 | 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 | 1389 | auth_stat = svc_get_autherr(rqstp, statp); |
|---|
| 1316 | 1390 | if (auth_stat != rpc_auth_ok) |
|---|
| 1317 | 1391 | 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 | 1392 | } else { |
|---|
| 1325 | 1393 | 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 | | - } |
|---|
| 1394 | + if (!process.dispatch(rqstp, statp)) |
|---|
| 1395 | + goto release_dropit; /* Release reply info */ |
|---|
| 1332 | 1396 | } |
|---|
| 1333 | 1397 | |
|---|
| 1334 | 1398 | /* Check RPC status result */ |
|---|
| .. | .. |
|---|
| 1347 | 1411 | goto close_xprt; |
|---|
| 1348 | 1412 | return 1; /* Caller can now send it */ |
|---|
| 1349 | 1413 | |
|---|
| 1414 | +release_dropit: |
|---|
| 1415 | + if (procp->pc_release) |
|---|
| 1416 | + procp->pc_release(rqstp); |
|---|
| 1350 | 1417 | dropit: |
|---|
| 1351 | 1418 | svc_authorise(rqstp); /* doesn't hurt to call this twice */ |
|---|
| 1352 | 1419 | dprintk("svc: svc_process dropit\n"); |
|---|
| .. | .. |
|---|
| 1394 | 1461 | |
|---|
| 1395 | 1462 | err_bad_vers: |
|---|
| 1396 | 1463 | svc_printk(rqstp, "unknown version (%d for prog %d, %s)\n", |
|---|
| 1397 | | - vers, prog, progp->pg_name); |
|---|
| 1464 | + rqstp->rq_vers, rqstp->rq_prog, progp->pg_name); |
|---|
| 1398 | 1465 | |
|---|
| 1399 | 1466 | serv->sv_stats->rpcbadfmt++; |
|---|
| 1400 | 1467 | svc_putnl(resv, RPC_PROG_MISMATCH); |
|---|
| 1401 | | - svc_putnl(resv, progp->pg_lovers); |
|---|
| 1402 | | - svc_putnl(resv, progp->pg_hivers); |
|---|
| 1468 | + svc_putnl(resv, process.mismatch.lovers); |
|---|
| 1469 | + svc_putnl(resv, process.mismatch.hivers); |
|---|
| 1403 | 1470 | goto sendit; |
|---|
| 1404 | 1471 | |
|---|
| 1405 | 1472 | err_bad_proc: |
|---|
| 1406 | | - svc_printk(rqstp, "unknown procedure (%d)\n", proc); |
|---|
| 1473 | + svc_printk(rqstp, "unknown procedure (%d)\n", rqstp->rq_proc); |
|---|
| 1407 | 1474 | |
|---|
| 1408 | 1475 | serv->sv_stats->rpcbadfmt++; |
|---|
| 1409 | 1476 | svc_putnl(resv, RPC_PROC_UNAVAIL); |
|---|
| .. | .. |
|---|
| 1517 | 1584 | /* Parse and execute the bc call */ |
|---|
| 1518 | 1585 | proc_error = svc_process_common(rqstp, argv, resv); |
|---|
| 1519 | 1586 | |
|---|
| 1520 | | - atomic_inc(&req->rq_xprt->bc_free_slots); |
|---|
| 1587 | + atomic_dec(&req->rq_xprt->bc_slot_count); |
|---|
| 1521 | 1588 | if (!proc_error) { |
|---|
| 1522 | 1589 | /* Processing error: drop the request */ |
|---|
| 1523 | 1590 | xprt_free_bc_request(req); |
|---|
| 1524 | | - return 0; |
|---|
| 1591 | + error = -EINVAL; |
|---|
| 1592 | + goto out; |
|---|
| 1525 | 1593 | } |
|---|
| 1526 | | - |
|---|
| 1527 | 1594 | /* Finally, send the reply synchronously */ |
|---|
| 1528 | 1595 | memcpy(&req->rq_snd_buf, &rqstp->rq_res, sizeof(req->rq_snd_buf)); |
|---|
| 1529 | 1596 | task = rpc_run_bc_task(req); |
|---|
| .. | .. |
|---|
| 1557 | 1624 | EXPORT_SYMBOL_GPL(svc_max_payload); |
|---|
| 1558 | 1625 | |
|---|
| 1559 | 1626 | /** |
|---|
| 1627 | + * svc_encode_read_payload - mark a range of bytes as a READ payload |
|---|
| 1628 | + * @rqstp: svc_rqst to operate on |
|---|
| 1629 | + * @offset: payload's byte offset in rqstp->rq_res |
|---|
| 1630 | + * @length: size of payload, in bytes |
|---|
| 1631 | + * |
|---|
| 1632 | + * Returns zero on success, or a negative errno if a permanent |
|---|
| 1633 | + * error occurred. |
|---|
| 1634 | + */ |
|---|
| 1635 | +int svc_encode_read_payload(struct svc_rqst *rqstp, unsigned int offset, |
|---|
| 1636 | + unsigned int length) |
|---|
| 1637 | +{ |
|---|
| 1638 | + return rqstp->rq_xprt->xpt_ops->xpo_read_payload(rqstp, offset, length); |
|---|
| 1639 | +} |
|---|
| 1640 | +EXPORT_SYMBOL_GPL(svc_encode_read_payload); |
|---|
| 1641 | + |
|---|
| 1642 | +/** |
|---|
| 1560 | 1643 | * svc_fill_write_vector - Construct data argument for VFS write call |
|---|
| 1561 | 1644 | * @rqstp: svc_rqst to operate on |
|---|
| 1562 | 1645 | * @pages: list of pages containing data payload |
|---|