commit 566f261ff6bae2842e2e64aaf70d2e31acc1efe7 Author: Olaf Kirch Date: Tue Sep 16 10:23:48 2008 -0400 Simplify port live check in pmap_svc.c There's some hack in pmap_getport that will cause a service to be unregistered from the portmap list if we find the port is no longer in use. Apart from being a gross hack, it is also a rather inefficient hack. Since we now restrict pmap emulation to IPv4, we know the address is always 0.0.0.0, so no need to mess with uaddr strings. (The bind_check code is a huge messy no-op anyway, since all ports are added with bind_check = FALSE). Signed-off-by: okir@suse.de Signed-off-by: Steve Dickson diff --git a/src/pmap_svc.c b/src/pmap_svc.c index 02a57d2..7a4f059 100644 --- a/src/pmap_svc.c +++ b/src/pmap_svc.c @@ -293,40 +293,24 @@ pmapproc_getport(struct svc_req *rqstp /*__unused*/, SVCXPRT *xprt) #endif fnd = find_service_pmap(reg.pm_prog, reg.pm_vers, reg.pm_prot); if (fnd) { - char serveuaddr[32], *ua; - char *pt1, *pt2; + char serveuaddr[32]; char *netid; netid = pmap_ipprot2netid(reg.pm_prot); - if (netid == NULL) - goto sendreply; - if (reg.pm_prot == IPPROTO_UDP) { - ua = udp_uaddr; - } else { - ua = tcp_uaddr; /* To get the len */ - } - if (ua == NULL) { - goto sendreply; - } - if ((pt1 = strrchr(ua, '.')) != NULL) { - *pt1 = 0; - if ((pt2 = strrchr(ua, '.')) != NULL) { - *pt2 = 0; - snprintf(serveuaddr, sizeof serveuaddr, - "%s.%ld.%ld", ua, - (fnd->pml_map.pm_port >> 8) & 0xff, - (fnd->pml_map.pm_port) & 0xff); - *pt2 = '.'; - if (is_bound(netid, serveuaddr)) { - port = fnd->pml_map.pm_port; - } else { /* this service is dead; delete it */ - delete_prog(reg.pm_prog); - } + if (netid != NULL) { + snprintf(serveuaddr, sizeof serveuaddr, + "0.0.0.0.%ld.%ld", + (fnd->pml_map.pm_port >> 8) & 0xff, + (fnd->pml_map.pm_port) & 0xff); + + if (is_bound(netid, serveuaddr)) { + port = fnd->pml_map.pm_port; + } else { /* this service is dead; delete it */ + delete_prog(reg.pm_prog); } - *pt1 = '.'; } } -sendreply: + lport = port; if ((!svc_sendreply(xprt, (xdrproc_t) xdr_long, (caddr_t)&lport)) && debugging) { diff --git a/src/rpcbind.c b/src/rpcbind.c index dc6f66b..e0e7ddf 100644 --- a/src/rpcbind.c +++ b/src/rpcbind.c @@ -570,18 +570,15 @@ init_transport(struct netconfig *nconf) pml->pml_map.pm_port = PMAPPORT; pml->pml_map.pm_prot = si.si_proto; - /* Stash away the universal address */ switch (si.si_proto) { case IPPROTO_TCP: tcptrans = strdup(nconf->nc_netid); - tcp_uaddr = taddr2uaddr(nconf, &taddr.addr); break; case IPPROTO_UDP: udptrans = strdup(nconf->nc_netid); - udp_uaddr = taddr2uaddr(nconf, &taddr.addr); break; } - pml->pml_next = list_pml; + pml->pml_next = list_pml; list_pml = pml; /* Add version 3 information */ diff --git a/src/rpcbind.h b/src/rpcbind.h index 58ab3ef..295711a 100644 --- a/src/rpcbind.h +++ b/src/rpcbind.h @@ -76,8 +76,6 @@ extern rpcblist_ptr list_rbl; /* A list of version 3 & 4 rpcbind services */ extern struct pmaplist *list_pml; /* A list of version 2 rpcbind services */ extern char *udptrans; /* Name of UDP transport */ extern char *tcptrans; /* Name of TCP transport */ -extern char *udp_uaddr; /* Universal UDP address */ -extern char *tcp_uaddr; /* Universal TCP address */ extern char *pmap_ipprot2netid(unsigned long); extern int pmap_netid2ipprot(const char *); #endif