Bug 206724

Summary: Replacing PR_SetNetAddr with PRLDAP_SET_PORT for IPv6 support
Product: [Retired] 389 Reporter: Noriko Hosoi <nhosoi>
Component: Directory ServerAssignee: Noriko Hosoi <nhosoi>
Status: CLOSED CURRENTRELEASE QA Contact: Viktor Ashirov <vashirov>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.0.2CC: rmeggins
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-07 16:45:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 152373, 208654, 240316    
Attachments:
Description Flags
cvs diff slapi-private.h connection.c daemon.c none

Description Noriko Hosoi 2006-09-15 21:12:51 UTC
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 21:32:49 UTC
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 21:39:06 UTC
(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 22:46:12 UTC
(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 22:50:20 UTC
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-24 00:28:11 UTC
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-24 00:31:28 UTC
[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 22:50:28 UTC
*** Bug 180481 has been marked as a duplicate of this bug. ***

Comment 8 Noriko Hosoi 2007-11-30 00:31:57 UTC
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.