Bug 206724 - Replacing PR_SetNetAddr with PRLDAP_SET_PORT for IPv6 support
Replacing PR_SetNetAddr with PRLDAP_SET_PORT for IPv6 support
Status: CLOSED CURRENTRELEASE
Product: 389
Classification: Community
Component: Directory Server (Show other bugs)
1.0.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: Noriko Hosoi
Viktor Ashirov
:
: PR_GetAddrInfoByName (view as bug list)
Depends On:
Blocks: 152373 fds103trackingbug 240316
  Show dependency treegraph
 
Reported: 2006-09-15 17:12 EDT by Noriko Hosoi
Modified: 2015-12-07 11:45 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-07 11:45:43 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
cvs diff slapi-private.h connection.c daemon.c (21.30 KB, patch)
2006-09-15 17:32 EDT, Noriko Hosoi
no flags Details | Diff

  None (edit)
Description Noriko Hosoi 2006-09-15 17:12:51 EDT
Description of problem:
PR_SetNetAddr was used just to set port into PRNetAddr.  The function has a side
effect, which accidentally cleans up the scope_id field.  So, if the purpose of
calling PR_SetNetAddr is to set port, we were suggested to introduce a macro to
achieve the goal.
Comment 1 Noriko Hosoi 2006-09-15 17:32:49 EDT
Created attachment 136399 [details]
cvs diff slapi-private.h connection.c daemon.c

Files:
  slapi-private.h
  connection.c
  daemon.c

Changes:
slapi-private.h: introduced PRLDAP_SET_PORT to set port to the port field in
PRNetAddr.  A copy of the same macro in LDAP C SDK (v6).  Note: once NSPR
provides an equivalent API, we may want to replace this macro with the one. 
(the NSPR compatibility issue remains, though.)
connection.c, daemon.c: replaced PR_SetNetAddr with PRLDAP_SET_ADDR.
Comment 2 Noriko Hosoi 2006-09-15 17:39:06 EDT
(In reply to comment #1)
[...]
> connection.c, daemon.c: replaced PR_SetNetAddr with PRLDAP_SET_ADDR.

Oops, "PRLDAP_SET_PORT", of course...
Comment 3 Noriko Hosoi 2006-09-15 18:46:12 EDT
(In reply to comment #1)
[...]
> connection.c, daemon.c: replaced PR_SetNetAddr with PRLDAP_SET_ADDR.

Oops, "PRLDAP_SET_PORT", of course...
Comment 4 Noriko Hosoi 2006-09-15 18:50:20 EDT
Sorry, Rich.  I overrode your approval. :p  Recovered.

And checked in into the HEAD.

[206724] Replacing PR_SetNetAddr with PRLDAP_SET_PORT for IPv6 support
slapi-private.h: introduced PRLDAP_SET_PORT to set port to the port field in
PRNetAddr.  A copy of the same macro in LDAP C SDK (v6).  Note: once NSPR
provides an equivalent API, we may want to replace this macro with the one.
(the NSPR compatibility issue remains, though.)
connection.c, daemon.c: replaced PR_SetNetAddr with PRLDAP_SET_PORT.
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS:    slapi-private.h connection.c daemon.c
CVS: ----------------------------------------------------------------------
Checking in slapi-private.h;
/cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-private.h,v  <--  slapi-private.h
new revision: 1.11; previous revision: 1.10
done
Checking in connection.c;
/cvs/dirsec/ldapserver/ldap/servers/slapd/connection.c,v  <--  connection.c
new revision: 1.11; previous revision: 1.10
done
Checking in daemon.c;
/cvs/dirsec/ldapserver/ldap/servers/slapd/daemon.c,v  <--  daemon.c
new revision: 1.9; previous revision: 1.8
done
Comment 5 Noriko Hosoi 2006-09-23 20:28:11 EDT
A stupid copy and paste bug... :(

Index: connection.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/connection.c,v
retrieving revision 1.11
diff -t -w -U4 -r1.11 connection.c
--- connection.c        15 Sep 2006 22:45:11 -0000      1.11
+++ connection.c        24 Sep 2006 00:26:57 -0000
@@ -280,9 +280,9 @@
 
     /*
      * get destination address (server IP address this client connected to)
      */
-    slapi_ch_free( (void**)&conn->cin_addr ); /* just to be conservative */
+    slapi_ch_free( (void**)&conn->cin_destaddr ); /* just to be conservative */
     if ( conn->c_prfd != NULL ) {
         conn->cin_destaddr = (PRNetAddr *) slapi_ch_malloc( sizeof( PRNetAddr ) );
         memset( conn->cin_destaddr, 0, sizeof( PRNetAddr ));
         if (PR_GetSockName( conn->c_prfd, conn->cin_destaddr ) == 0) {
Comment 6 Noriko Hosoi 2006-09-23 20:31:28 EDT
[206724] Processed: Replacing PR_SetNetAddr with PRLDAP_SET_PORT for IPv6 support
comment#5: Fixed a stupid copy and paste bug...
CVS: ----------------------------------------------------------------------
CVS: Modified Files:
CVS:    connection.c
CVS: ----------------------------------------------------------------------
Checking in connection.c;
/cvs/dirsec/ldapserver/ldap/servers/slapd/connection.c,v  <--  connection.c
new revision: 1.12; previous revision: 1.11
done
   
Comment 7 Noriko Hosoi 2006-10-09 18:50:28 EDT
*** Bug 180481 has been marked as a duplicate of this bug. ***
Comment 8 Noriko Hosoi 2007-11-29 19:31:57 EST
Checked source code:
$ pwd
/share/dev4/ds/ds80/builds/20071129.1/earthquake_rhel4/ldapserver

PR_SetNetAddr is used only when netaddr needs to be set:
$ find . -name "*.[ch]" | xargs egrep PR_SetNetAddr
./ldap/servers/slapd/daemon.c:          if ( PR_SUCCESS !=
PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, netaddr)) {
./ldap/servers/slapd/daemon.c:                                 
"PR_SetNetAddr(PR_IpAddrAny) failed - %s error %d (%s)\n",
./ldap/servers/slapd/slapi-private.h: * Introduced to avoid calling
PR_SetNetAddr w/ PR_IpAddrNull just to set port.

Where the port needs to be set uses the macro PRLDAP_SET_PORT:
$ find . -name "*.[ch]" | xargs egrep PRLDAP_SET_PORT
./ldap/servers/slapd/connection.c:          PRLDAP_SET_PORT(conn->cin_addr,
addr.sin_port);
./ldap/servers/slapd/connection.c:          PRLDAP_SET_PORT( conn->cin_destaddr,
destaddr.sin_port );
./ldap/servers/slapd/daemon.c:          PRLDAP_SET_PORT( pr_netaddr, ((struct
sockaddr_in *)addr)->sin_port );
./ldap/servers/slapd/daemon.c:                  PRLDAP_SET_PORT( &sa_server, port );
./ldap/servers/slapd/slapi-private.h:#define PRLDAP_SET_PORT(myaddr,myport) \

Verified.

Note You need to log in before you can comment on or make changes to this bug.