Commit 9b074657 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

net: Drop @ri test but use known ARRA_SIZE

We might miss entry in "ri ? ri - 1" expression when ri = 1.
Lets use known array size instead.

For some reason it didn't trigger on my tests earlier.
Reported-by: 's avatarAndrew Vagin <avagin@odin.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarAndrew Vagin <avagin@odin.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 4120637f
...@@ -79,7 +79,6 @@ static char *devconfs[] = { ...@@ -79,7 +79,6 @@ static char *devconfs[] = {
"shared_media", "shared_media",
"src_valid_mark", "src_valid_mark",
"tag", "tag",
NULL,
}; };
#define NET_CONF_PATH "net/ipv4/conf" #define NET_CONF_PATH "net/ipv4/conf"
...@@ -89,10 +88,10 @@ static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns) ...@@ -89,10 +88,10 @@ static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns)
{ {
int i, ri; int i, ri;
int ret; int ret;
struct sysctl_req req[ARRAY_SIZE(devconfs) + 1]; struct sysctl_req req[ARRAY_SIZE(devconfs)];
char path[ARRAY_SIZE(devconfs)][MAX_CONF_OPT_PATH]; char path[ARRAY_SIZE(devconfs)][MAX_CONF_OPT_PATH];
for (i = 0, ri = 0; devconfs[i]; i++) { for (i = 0, ri = 0; i < ARRAY_SIZE(devconfs); i++) {
/* /*
* If dev conf value is the same as default skip restoring it * If dev conf value is the same as default skip restoring it
*/ */
...@@ -107,9 +106,8 @@ static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns) ...@@ -107,9 +106,8 @@ static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns)
req[ri].type = CTL_32; req[ri].type = CTL_32;
ri++; ri++;
} }
req[ri].name = NULL;
ret = sysctl_op(req, ri ? ri - 1 : 0, op); ret = sysctl_op(req, ri, op);
if (ret < 0) { if (ret < 0) {
pr_err("Failed to %s %s/<confs>\n", (op == CTL_READ)?"read":"write", tgt); pr_err("Failed to %s %s/<confs>\n", (op == CTL_READ)?"read":"write", tgt);
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment