From: Alex Riesen <alexander.riesen@synopsys.COM>
To: David Hinds <dahinds@users.sourceforge.net>
Cc: linux-kernel@vger.kernel.org, brian@debian.org
Subject: pcmcia-cs: ifuser times out in gethostbyname for empty route tables
Date: Wed, 14 May 2003 11:54:28 +0200 [thread overview]
Message-ID: <20030514095428.GA14380@Synopsys.COM> (raw)
Hello, David!
[lkml: sorry for off-topic, but David is very slow on responses, and
the fix could be useful to someone
Brian: the sources are downloaded from debian-unstable]
If I try to stop pcmcia services without actually connecting to the network,
if user will hang for annoyngly long time. I narrowed the problem down
to ifuser tryng to resolve the word "Destination" (first word of the
last line of "netstat -rn" output for empty route table).
That are the second and the third hunks in the attached patch.
The first doesn't start netstat at all if there is nothing to do anyway,
and the last adds check for looopback network.
--- pcmcia-cs-3.2.2/cardmgr/ifuser.c 2001-08-24 14:19:20.000000000 +0200
+++ pcmcia-cs-3.2.2-fix/cardmgr/ifuser.c 2003-05-14 10:16:55.000000000 +0200
@@ -108,6 +108,8 @@ int main(int argc, char *argv[])
}
if ((*argv[i] == '-') || (argc < i+1)) usage(argv[0]);
dev = argv[i]; i++;
+ if ( i >= argc )
+ return (!busy);
/* Get routing table */
f = popen("netstat -nr", "r");
@@ -122,6 +124,8 @@ int main(int argc, char *argv[])
} while (!feof(f) && !isdigit(s[0]));
tail = &tbl;
+ if ( !isdigit(s[0]) )
+ goto rt_end;
do {
r = malloc(sizeof(route_t));
if (r == NULL) {
@@ -134,6 +138,7 @@ int main(int argc, char *argv[])
r->match = (strcmp(iface, dev) == 0);
*tail = r; tail = &(r->next);
} while (fgets(s, 128, f) != NULL);
+rt_end:
*tail = NULL;
pclose(f);
@@ -147,6 +152,8 @@ int main(int argc, char *argv[])
}
for (r = tbl; r; r = r->next) {
+ if ((a & 0xff000000) == 0x7f000000) /* loopback network */
+ continue;
if ((a & r->mask) == r->dest) {
if (r->match) {
if (verbose) {
reply other threads:[~2003-05-14 9:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030514095428.GA14380@Synopsys.COM \
--to=alexander.riesen@synopsys.com \
--cc=brian@debian.org \
--cc=dahinds@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox