Skip to content

Commit fcda7ba

Browse files
authored
plugins/radius: avoid unnecessary own address lookups (#631)
rc_own_ipaddress() lookup in rc_find_server() is only needed when client/server pair is specified in "servers" file. Otherwise it triggers DNS lookup via gethostbyname() each plugin call. Signed-off-by: [anp/hsw] <sysop@880.ru>
1 parent f2a9109 commit fcda7ba

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

pppd/plugins/radius/config.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ static int find_match (UINT4 *ip_addr, char *hostname)
464464

465465
int rc_find_server (char *server_name, UINT4 *ip_addr, char *secret)
466466
{
467-
UINT4 myipaddr = 0;
467+
UINT4 myipaddr = 0xFFFFFFFF;
468468
int len;
469469
int result;
470470
FILE *clientfd;
@@ -484,8 +484,6 @@ int rc_find_server (char *server_name, UINT4 *ip_addr, char *secret)
484484
return (-1);
485485
}
486486

487-
myipaddr = rc_own_ipaddress();
488-
489487
result = 0;
490488
while (fgets (buffer, sizeof (buffer), clientfd) != (char *) NULL)
491489
{
@@ -512,8 +510,11 @@ int rc_find_server (char *server_name, UINT4 *ip_addr, char *secret)
512510
break;
513511
}
514512
}
515-
else /* <name1>/<name2> "paired" form */
513+
else if (myipaddr) /* <name1>/<name2> "paired" form */
516514
{
515+
if (myipaddr == 0xFFFFFFFF) myipaddr = rc_own_ipaddress();
516+
if (myipaddr == 0) continue;
517+
517518
strtok (hostnm, "/");
518519
if (find_match (&myipaddr, hostnm) == 0)
519520
{ /* If we're the 1st name, target is 2nd */

0 commit comments

Comments
 (0)