No subject



Fri Jan 28 21:34:03 2005
Return-Path: xorp-cvs-admin@icir.org
Delivery-Date: Fri, 28 Jan 2005 13:34:01 -0800
Received: from wyvern.icir.org (wyvern.icir.org [192.150.187.14])
	by tigger.icir.org (8.12.11/8.12.8) with ESMTP id j0SLY104016900
	for <atanu@tigger.icir.org>; Fri, 28 Jan 2005 13:34:01 -0800 (PST)
	(envelope-from xorp-cvs-admin@icir.org)
Received: from fruitcake.ICSI.Berkeley.EDU (fruitcake.ICSI.Berkeley.EDU [192.150.186.11])
	by wyvern.icir.org (8.12.9p1/8.12.8) with ESMTP id j0SLY11x015217
	for <atanu@icir.org>; Fri, 28 Jan 2005 13:34:01 -0800 (PST)
	(envelope-from xorp-cvs-admin@icir.org)
Received: from fruitcake.ICSI.Berkeley.EDU (localhost [127.0.0.1])
	by fruitcake.ICSI.Berkeley.EDU (8.12.10/8.12.9) with ESMTP id j0SLY1Ip020469;
	Fri, 28 Jan 2005 13:34:01 -0800 (PST)
Received: from wyvern.icir.org (wyvern.icir.org [192.150.187.14])
	by fruitcake.ICSI.Berkeley.EDU (8.12.10/8.12.9) with ESMTP id j0SLXVIp020440
	for <xorp-cvs@icsi.berkeley.edu>; Fri, 28 Jan 2005 13:33:31 -0800 (PST)
Received: from arginine.spc.org ([83.167.185.2])
	by wyvern.icir.org (8.12.9p1/8.12.8) with ESMTP id j0SLXU1x015212;
	Fri, 28 Jan 2005 13:33:31 -0800 (PST)
	(envelope-from bms@spc.org)
Received: from localhost (localhost [127.0.0.1])
	by arginine.spc.org (Postfix) with ESMTP
	id 994F16538E; Fri, 28 Jan 2005 21:32:10 +0000 (GMT)
Received: from arginine.spc.org ([127.0.0.1])
 by localhost (arginine.spc.org [127.0.0.1]) (amavisd-new, port 10024)
 with LMTP id 21278-03-2; Fri, 28 Jan 2005 21:32:09 +0000 (GMT)
Received: from empiric.dek.spc.org (unknown [213.210.24.3])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by arginine.spc.org (Postfix) with ESMTP
	id 03A1E6520E; Fri, 28 Jan 2005 21:32:06 +0000 (GMT)
Received: by empiric.dek.spc.org (Postfix, from userid 1001)
	id D734B652F; Fri, 28 Jan 2005 21:34:03 +0000 (GMT)
Date: Fri, 28 Jan 2005 21:34:03 +0000
From: Bruce M Simpson <bms@spc.org>
To: Pavlin Radoslavov <pavlin@icir.org>
Cc: xorp-cvs@icir.org
Subject: Re: [Xorp-cvs] XORP cvs commit: xorp/libxorp
Message-ID: <20050128213403.GN24432@dhcp120.icir.org>
References: <200501280330.j0S3UFqt081185@xorpc.icir.org> <20050128211635.GM24432@dhcp120.icir.org>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="H8ygTp4AXg6deix2"
Content-Disposition: inline
In-Reply-To: <20050128211635.GM24432@dhcp120.icir.org>
Sender: xorp-cvs-admin@icir.org
Errors-To: xorp-cvs-admin@icir.org
X-BeenThere: xorp-cvs@icir.org
X-Mailman-Version: 2.0
Precedence: bulk
List-Help: <mailto:xorp-cvs-request@icir.org?subject=help>
List-Post: <mailto:xorp-cvs@icir.org>
List-Subscribe: <http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-cvs>,
	<mailto:xorp-cvs-request@icir.org?subject=subscribe>
List-Id: Mailing list for XORP CVS commit messages <xorp-cvs.icir.org>
List-Unsubscribe: <http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-cvs>,
	<mailto:xorp-cvs-request@icir.org?subject=unsubscribe>


--H8ygTp4AXg6deix2
Content-Type: multipart/mixed; boundary="Pd0ReVV5GZGQvF3a"
Content-Disposition: inline


--Pd0ReVV5GZGQvF3a
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Fri, Jan 28, 2005 at 09:16:35PM +0000, Bruce M Simpson wrote:
> Wait, no worries, I've written a fix which uses IPvX::str() instead
> of trying to use inet_ntop() directly now.

Here is my diff as it currently stands.
[p4x diff2 -dbuw //depot/vendor/xorp/bgp/socket.cc //depot/user/bms/xorp_ng/bgp/socket.cc]

Atanu, you mentioned a change further up in bgp which catches an exception
and might make the function signature / return value checks in my diff
unnecessary.

Can you point me at this change (off the top of your head) ?

[I appreciate that moving BGP to use the FEA for sockets is what we want
to do long term, but I would consider it better to fix the issue in
the short term.]

I'd like to merge a fix for this we're happy with so we can kill off the
bug, so review would be much appreciated!

Pavlin: I agree that the presence/absence of inet_ntop() is a separate
issue (IPvX et al wrap it), let's get the bugs smashed and worry about
portability later.

Thanks,
BMS

--Pd0ReVV5GZGQvF3a
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=1
Content-Transfer-Encoding: quoted-printable

=3D=3D=3D=3D //depot/vendor/xorp/bgp/socket.cc#2 (text) - //depot/user/bms/=
xorp_ng/bgp/socket.cc#6 (text) =3D=3D=3D=3D content
@@ -32,7 +32,6 @@
 #include "socket.hh"
 #include "packet.hh"
=20
-
 /* **************** BGPSocket - PUBLIC METHODS *********************** */
=20
 Socket::Socket(const Iptuple& iptuple, EventLoop& e)
@@ -49,7 +48,7 @@
 #endif
 }
=20
-void
+int
 Socket::create_listener()
 {
     debug_msg("create_listener called");
@@ -57,15 +56,28 @@
     size_t len;
     const struct sockaddr *sin =3D get_local_socket(len);
=20
-    create_socket(sin);
+    if (create_socket(sin) !=3D XORP_OK)
+	return (XORP_ERROR);
=20
     int opt =3D 1;
-    if(-1 =3D=3D setsockopt(get_sock(),
-			SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)))
-	XLOG_FATAL("setsockopt failed: %s", strerror(errno));
+    if (::setsockopt(get_sock(), SOL_SOCKET, SO_REUSEADDR, &opt,
+		     sizeof(opt)) =3D=3D -1) {
+	XLOG_WARNING("setsockopt failed: %s", strerror(errno));
+    }
+
+    if (::bind(get_sock(), sin, len) =3D=3D -1) {
+	int saved_errno =3D errno;
+	try {
+	    IPvX addr(*sin);
+	    XLOG_ERROR("Failed to bind socket %d to address %s: %s",
+		get_sock(), addr.str().c_str(), strerror(saved_errno));
+	} catch (...) {
+	    XLOG_ERROR("Failed to bind socket %d to address %s: %s",
+		get_sock(), "(unprintable)", strerror(saved_errno));
+	};
+    }
    =20
-    if(-1 =3D=3D bind(get_sock(), sin, len))
-	XLOG_FATAL("Bind failed: %s", strerror(errno));
+    return (XORP_OK);
 }
=20
 /* **************** BGPSocket - PROTECTED METHODS *********************** =
*/
@@ -79,17 +91,20 @@
     _s =3D UNCONNECTED;
 }
=20
-void
+int
 Socket::create_socket(const struct sockaddr *sin)
 {
     debug_msg("create_socket called\n");
=20
     XLOG_ASSERT(UNCONNECTED =3D=3D _s);
=20
-    if(UNCONNECTED =3D=3D (_s =3D ::socket (sin->sa_family, SOCK_STREAM, 0=
)))
-	XLOG_FATAL("Socket call failed: %s", strerror(errno));
+    if (UNCONNECTED =3D=3D (_s =3D ::socket (sin->sa_family, SOCK_STREAM, =
0))) {
+	XLOG_ERROR("socket() failed: %s", strerror(errno));
+	return (XORP_ERROR);
+    }
=20
     debug_msg("BGPSocket socket created (sock - %d)\n", _s);
+    return (XORP_OK);
 }
=20
 void

--Pd0ReVV5GZGQvF3a--

--H8ygTp4AXg6deix2
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Comment: ''

iD8DBQFB+q/LueUpAYYNtTsRAsbWAKCXRnjV884XfzEMeCEEwdhF4kaPHgCcC6Yw
P+w+q8GmPkub7WKONc9YBGA=
=Hthu
-----END PGP SIGNATURE-----

--H8ygTp4AXg6deix2--
_______________________________________________
Xorp-cvs mailing list
Xorp-cvs@icir.org
http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-cvs