diff options
-rw-r--r-- | meta/recipes-extended/watchdog/files/fix-ping-failure.patch | 74 | ||||
-rw-r--r-- | meta/recipes-extended/watchdog/watchdog_5.11.bb | 6 |
2 files changed, 78 insertions, 2 deletions
diff --git a/meta/recipes-extended/watchdog/files/fix-ping-failure.patch b/meta/recipes-extended/watchdog/files/fix-ping-failure.patch new file mode 100644 index 0000000000..c6ee84345e --- /dev/null +++ b/meta/recipes-extended/watchdog/files/fix-ping-failure.patch | |||
@@ -0,0 +1,74 @@ | |||
1 | Fix ping mode failure | ||
2 | |||
3 | Upstream-Status: Pending | ||
4 | |||
5 | When watchdog works on ping mode, the system will be rebooted since | ||
6 | watchdog can not receive the expected ECOREPLY on a setting interval. | ||
7 | |||
8 | Ping mode uses a raw socket to send a ECO packet, then uses select() | ||
9 | to wait and recvfrom() to receive the ECOREPLY packet, if select() | ||
10 | shows the data is ready, and the data is not the expected ECOREPLY, | ||
11 | and waiting time is not overdue, it will continue use select() and | ||
12 | recvfrom(). | ||
13 | |||
14 | Problem is that the raw socket can receive any icmp packets, if we do | ||
15 | not set filters, and there are many icmp packets on socket, this | ||
16 | program will not find its interested ECOREPLY packet in a special | ||
17 | interval, which makes the ping mode fail. | ||
18 | |||
19 | |||
20 | Other program is that watchdog sometime can not reach the call of | ||
21 | recvfrom to try to receive packets since tv_sec of struct timeval | ||
22 | of select parameter is 0. | ||
23 | |||
24 | The timeout of select() is the result of ping interval minusing the | ||
25 | time of calling gettimeofday spending, when ping interval is 1 second, | ||
26 | and the call of gettimeofday() spends several useconds, the tv_sec of | ||
27 | struct timeval of select parameter must be 0, at that condition, we | ||
28 | should it is valid of tv_sec of struct timeval of select parameter be 0 | ||
29 | |||
30 | Signed-off-by: Roy.Li <rongqing.li@windriver.com> | ||
31 | --- | ||
32 | src/net.c | 2 +- | ||
33 | src/watchdog.c | 5 ++++- | ||
34 | 2 files changed, 5 insertions(+), 2 deletions(-) | ||
35 | |||
36 | --- a/src/net.c | ||
37 | +++ b/src/net.c | ||
38 | @@ -118,7 +118,7 @@ int check_net(char *target, int sock_fp, | ||
39 | dtimeout.tv_usec -= 1000000; | ||
40 | dtimeout.tv_sec++; | ||
41 | } | ||
42 | - if (dtimeout.tv_sec <= 0) | ||
43 | + if (dtimeout.tv_sec < 0) | ||
44 | break; | ||
45 | #if USE_SYSLOG | ||
46 | if (verbose && logtick && ticker == 1) | ||
47 | --- a/src/watchdog.c | ||
48 | +++ b/src/watchdog.c | ||
49 | @@ -28,6 +28,7 @@ | ||
50 | #include <sys/types.h> | ||
51 | #include <sys/ioctl.h> | ||
52 | #include <linux/oom.h> | ||
53 | +#include <linux/icmp.h> | ||
54 | #include <linux/watchdog.h> | ||
55 | #include <string.h> | ||
56 | |||
57 | @@ -567,6 +568,8 @@ int main(int argc, char *const argv[]) | ||
58 | pid_t child_pid; | ||
59 | int oom_adjusted = 0; | ||
60 | struct stat s; | ||
61 | + struct icmp_filter filt; | ||
62 | + filt.data = ~(1<<ICMP_ECHOREPLY); | ||
63 | |||
64 | #if USE_SYSLOG | ||
65 | char *opts = "d:i:n:Ffsvbql:p:t:c:r:m:a:"; | ||
66 | @@ -703,7 +706,7 @@ int main(int argc, char *const argv[]) | ||
67 | perror(progname); | ||
68 | exit(1); | ||
69 | } | ||
70 | - | ||
71 | + setsockopt(net->sock_fp, SOL_RAW, ICMP_FILTER, (char*)&filt, sizeof(filt)); | ||
72 | /* this is necessary for broadcast pings to work */ | ||
73 | (void) setsockopt(net->sock_fp, SOL_SOCKET, SO_BROADCAST, (char *)&hold, sizeof(hold)); | ||
74 | |||
diff --git a/meta/recipes-extended/watchdog/watchdog_5.11.bb b/meta/recipes-extended/watchdog/watchdog_5.11.bb index 3c4f77b141..6a611c99bb 100644 --- a/meta/recipes-extended/watchdog/watchdog_5.11.bb +++ b/meta/recipes-extended/watchdog/watchdog_5.11.bb | |||
@@ -8,9 +8,11 @@ BUGTRACKER = "http://sourceforge.net/tracker/?group_id=172030&atid=860194" | |||
8 | LICENSE = "GPL-1.0+" | 8 | LICENSE = "GPL-1.0+" |
9 | LIC_FILES_CHKSUM = "file://COPYING;md5=8a7258c60a71a2f04b67fb01f495889c" | 9 | LIC_FILES_CHKSUM = "file://COPYING;md5=8a7258c60a71a2f04b67fb01f495889c" |
10 | 10 | ||
11 | PR = "r0" | 11 | PR = "r1" |
12 | |||
13 | SRC_URI = "${SOURCEFORGE_MIRROR}/watchdog/watchdog_${PV}.tar.gz \ | ||
14 | file://fix-ping-failure.patch" | ||
12 | 15 | ||
13 | SRC_URI = "${SOURCEFORGE_MIRROR}/watchdog/watchdog_${PV}.tar.gz" | ||
14 | 16 | ||
15 | SRC_URI[md5sum] = "02c764219b3bdb2373091cbd67109eb6" | 17 | SRC_URI[md5sum] = "02c764219b3bdb2373091cbd67109eb6" |
16 | SRC_URI[sha256sum] = "723a7966e0c3d58e3f4df20943a5c9aa1553381f46aa0dbcf832016756e62792" | 18 | SRC_URI[sha256sum] = "723a7966e0c3d58e3f4df20943a5c9aa1553381f46aa0dbcf832016756e62792" |