walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
a81d97c
Author: Steve Dickson <steved@redhat.com>
a81d97c
Date:   Sat Jan 31 05:30:13 2009 -0500
a81d97c
a81d97c
    Only hash on IP address and Program number. Including the Procedure
a81d97c
    number only creates needles extra hash entries.
a81d97c
    
a81d97c
    Signed-off-by: Steve Dickson <steved@redhat.com>
a81d97c
a81d97c
diff -up nfs-utils-1.1.4/support/misc/tcpwrapper.c.orig nfs-utils-1.1.4/support/misc/tcpwrapper.c
a81d97c
--- nfs-utils-1.1.4/support/misc/tcpwrapper.c.orig	2009-01-31 06:22:35.000000000 -0500
a81d97c
+++ nfs-utils-1.1.4/support/misc/tcpwrapper.c	2009-01-31 06:23:22.000000000 -0500
a81d97c
@@ -106,8 +106,8 @@ typedef struct _hash_head {
a81d97c
 	TAILQ_HEAD(host_list, _haccess_t) h_head;
a81d97c
 } hash_head;
a81d97c
 hash_head haccess_tbl[HASH_TABLE_SIZE];
a81d97c
-static haccess_t *haccess_lookup(struct sockaddr_in *addr, u_long, u_long);
a81d97c
-static void haccess_add(struct sockaddr_in *addr, u_long, u_long, int);
a81d97c
+static haccess_t *haccess_lookup(struct sockaddr_in *addr, u_long);
a81d97c
+static void haccess_add(struct sockaddr_in *addr, u_long, int);
a81d97c
 
a81d97c
 inline unsigned int strtoint(char *str)
a81d97c
 {
a81d97c
@@ -124,11 +124,10 @@ inline int hashint(unsigned int num)
a81d97c
 {
a81d97c
 	return num % HASH_TABLE_SIZE;
a81d97c
 }
a81d97c
-#define HASH(_addr, _proc, _prog) \
a81d97c
-	hashint((strtoint((_addr))+(_proc)+(_prog)))
a81d97c
+#define HASH(_addr, _prog) \
a81d97c
+	hashint((strtoint((_addr))+(_prog)))
a81d97c
 
a81d97c
-void haccess_add(struct sockaddr_in *addr, u_long proc, 
a81d97c
-	u_long prog, int access)
a81d97c
+void haccess_add(struct sockaddr_in *addr, u_long prog, int access)
a81d97c
 {
a81d97c
 	hash_head *head;
a81d97c
  	haccess_t *hptr;
a81d97c
@@ -138,7 +137,7 @@ void haccess_add(struct sockaddr_in *add
a81d97c
 	if (hptr == NULL)
a81d97c
 		return;
a81d97c
 
a81d97c
-	hash = HASH(inet_ntoa(addr->sin_addr), proc, prog);
a81d97c
+	hash = HASH(inet_ntoa(addr->sin_addr), prog);
a81d97c
 	head = &(haccess_tbl[hash]);
a81d97c
 
a81d97c
 	hptr->access = access;
a81d97c
@@ -149,13 +148,13 @@ void haccess_add(struct sockaddr_in *add
a81d97c
 	else
a81d97c
 		TAILQ_INSERT_TAIL(&head->h_head, hptr, list);
a81d97c
 }
a81d97c
-haccess_t *haccess_lookup(struct sockaddr_in *addr, u_long proc, u_long prog)
a81d97c
+haccess_t *haccess_lookup(struct sockaddr_in *addr, u_long prog)
a81d97c
 {
a81d97c
 	hash_head *head;
a81d97c
  	haccess_t *hptr;
a81d97c
 	int hash;
a81d97c
 
a81d97c
-	hash = HASH(inet_ntoa(addr->sin_addr), proc, prog);
a81d97c
+	hash = HASH(inet_ntoa(addr->sin_addr), prog);
a81d97c
 	head = &(haccess_tbl[hash]);
a81d97c
 
a81d97c
 	TAILQ_FOREACH(hptr, &head->h_head, list) {
a81d97c
@@ -300,7 +299,7 @@ u_long  prog;
a81d97c
 	haccess_t *acc = NULL;
a81d97c
 	int changed = check_files();
a81d97c
 
a81d97c
-	acc = haccess_lookup(addr, proc, prog);
a81d97c
+	acc = haccess_lookup(addr, prog);
a81d97c
 	if (acc && changed == 0)
a81d97c
 		return (acc->access);
a81d97c
 
a81d97c
@@ -309,7 +308,7 @@ u_long  prog;
a81d97c
 		if (acc)
a81d97c
 			acc->access = FALSE;
a81d97c
 		else 
a81d97c
-			haccess_add(addr, proc, prog, FALSE);
a81d97c
+			haccess_add(addr, prog, FALSE);
a81d97c
 		return (FALSE);
a81d97c
 	}
a81d97c
 	if (verboselog)
a81d97c
@@ -318,7 +317,7 @@ u_long  prog;
a81d97c
 	if (acc)
a81d97c
 		acc->access = TRUE;
a81d97c
 	else 
a81d97c
-		haccess_add(addr, proc, prog, TRUE);
a81d97c
+		haccess_add(addr, prog, TRUE);
a81d97c
     return (TRUE);
a81d97c
 }
a81d97c