iputils: backport patch to fix arping hang problem

arping hangs if SIGALARM is blocked. Backport a patch to fix this problem.

Unblock SIGALRM so that the previously called alarm() can prevent recvfrom()
from blocking forever in case the inherited procmask is blocking SIGALRM and
no packet is received.

(From OE-Core rev: 818d4a97763c69e9289fb99822535cd3ca7af6a2)

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Chen Qi
2017-09-07 10:37:10 +08:00
committed by Richard Purdie
parent 3cf90c0205
commit 5764589c3d
2 changed files with 45 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
arping: fix arping hang if SIGALRM is blocked
Unblock SIGALRM so that the previously called alarm() can prevent
recvfrom() from blocking forever in case the inherited procmask is
blocking SIGALRM and no packet is received.
Upstream-Status: Backport
Reported-by: Rui Prior <rprior@dcc.fc.up.pt>
RH-Bugzilla: #1085971
Signed-off-by: Jan Synacek <jsynacek@redhat.com>
Signed-off-by: Zhenbo Gao <zhenbo.gao@windriver.com>
diff --git a/arping.c.orig b/arping.c
index 35408c1..2098159 100644
--- a/arping.c.orig
+++ b/arping.c
@@ -1215,16 +1215,22 @@ main(int argc, char **argv)
socklen_t alen = sizeof(from);
int cc;
+ sigemptyset(&sset);
+ sigaddset(&sset, SIGALRM);
+ sigaddset(&sset, SIGINT);
+ /* Unblock SIGALRM so that the previously called alarm()
+ * can prevent recvfrom from blocking forever in case the
+ * inherited procmask is blocking SIGALRM and no packet
+ * is received. */
+ sigprocmask(SIG_UNBLOCK, &sset, &osset);
+
if ((cc = recvfrom(s, packet, sizeof(packet), 0,
(struct sockaddr *)&from, &alen)) < 0) {
perror("arping: recvfrom");
continue;
}
- sigemptyset(&sset);
- sigaddset(&sset, SIGALRM);
- sigaddset(&sset, SIGINT);
- sigprocmask(SIG_BLOCK, &sset, &osset);
+ sigprocmask(SIG_BLOCK, &sset, NULL);
recv_pack(packet, cc, (struct sockaddr_ll *)&from);
sigprocmask(SIG_SETMASK, &osset, NULL);
}

View File

@@ -20,6 +20,7 @@ SRC_URI = "http://www.skbuff.net/iputils/${BPN}-${PV}.tar.bz2 \
file://nsgmls-path-fix.patch \
file://0001-Fix-header-inclusion-for-musl.patch \
file://0001-Intialize-struct-elements-by-name.patch \
file://arping-fix-arping-hang-if-SIGALRM-is-blocked.patch \
"
SRC_URI[md5sum] = "8aaa7395f27dff9f57ae016d4bc753ce"