devices: Fix processing /proc/net/dev file
Namhyung Kim
PATCH 1/1 devices: Fix processing /proc/net/dev file
The do_proc_net_dev() reads the /proc/net/dev file and counts tx/rx packets for each interface. However index for rx packet (1) is not match to the file:
$ cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16)Change the index to 2 to match to the number of receive packets.
--- src/devices/network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/devices/network.cpp +1 -1
@@ -114,7 +114,7 @@ static void do_proc_net_dev(void) c2 = c; val = strtoull(c, &c, 10); i++; - if (i == 1 || i == 10) + if (i == 2 || i == 10) pkt += val; }
Signature · 1 line
1.7.9.2
Sergey Senozhatsky
Quoted 22 lines · Namhyung Kim
The
do_proc_net_dev()reads the/proc/net/devfile and counts tx/rx packets for each interface. However index for rx packet (1) is not match to the file:$ cat /proc/net/dev Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16)Change the index to 2 to match to the number of receive packets.
Signed-off-by Namhyung Kim <namhyung(a)gmail.com>--- src/devices/network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/devices/network.cpp +0
-0
src/devices/network.cpp static void do_proc_net_dev(void) · line 120
Quoted 8 lines
src/devices/network.cpp +1
-1@@ -114,7 +114,7 @@ static void do_proc_net_dev(void) c2 = c; val = strtoull(c, &c, 10); i++; - if (i == 1 || i == 10) + if (i == 2 || i == 10) pkt += val; }
or i++' after if (i == 1 || i == 10)'.
the patch looks good to me, nice catch.
-ss
Namhyung Kim
2012-10-15 (월), 07:47 -0700, Sergey Senozhatsky:
Quoted 9 lines · Namhyung Kim
Quoted 8 lines
src/devices/network.cpp +1
-1@@ -114,7 +114,7 @@ static void do_proc_net_dev(void) c2 = c; val = strtoull(c, &c, 10); i++; - if (i == 1 || i == 10) + if (i == 2 || i == 10) pkt += val;
Quoted 4 lines
Review static void do_proc_net_dev(void) · line 120
Quoted 2 lines
(quoted diff) +0
-0}or
i++' afterif (i == 1 || i == 10)'.
But if we moved i++', it should be if (i == 1 || i == 9)'.
Thanks,
Namhyung
Sergey Senozhatsky
Quoted 10 lines · Namhyung Kim
2012-10-15 (월), 07:47 -0700, Sergey Senozhatsky:
Quoted 9 lines · Namhyung Kim
Quoted 8 lines
src/devices/network.cpp +1
-1@@ -114,7 +114,7 @@ static void do_proc_net_dev(void) c2 = c; val = strtoull(c, &c, 10); i++; - if (i == 1 || i == 10) + if (i == 2 || i == 10) pkt += val;
Quoted 7 lines
Quoted 4 lines
Review static void do_proc_net_dev(void) · line 120
Quoted 2 lines
(quoted diff) +0
-0}or
i++' afterif (i == 1 || i == 10)'.But if we moved
i++', it should beif (i == 1 || i == 9)'.
yeah, right :)
-ss
Chris Ferron
Quoted 21 lines · Namhyung Kim
The
do_proc_net_dev()reads the/proc/net/devfile and counts tx/rx packets for each interface. However index for rx packet (1) is not match to the file:$ cat /proc/net/dev Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16)Change the index to 2 to match to the number of receive packets.
Signed-off-by Namhyung Kim <namhyung(a)gmail.com>--- src/devices/network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/devices/network.cpp +0
-0
src/devices/network.cpp static void do_proc_net_dev(void) · line 120
Quoted 8 lines
src/devices/network.cpp +1
-1@@ -114,7 +114,7 @@ static void do_proc_net_dev(void) c2 = c; val = strtoull(c, &c, 10); i++; - if (i == 1 || i == 10) + if (i == 2 || i == 10) pkt += val; }
Your patch has been merged
Thank You
-C