[Patch] Fix /proc/{pid}/om/where

Ansgar Esztermann <[email protected]>
Newsgroups gmane.linux.cluster.openmosix.devel
Message-ID <[email protected]>
Upon read, return the socket's peer address, not its own. In the
current version, a migrated process would report the IP address of
its home node.

---

 hpc/comm.c         |    7 ++++---
 hpc/proc.c         |    2 +-
 hpc/remote.c       |    2 +-
 hpc/service.c      |    2 +-
 include/hpc/comm.h |    2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)

bcc1be911a8f504a3814b8356ff1f2c485303b29
diff --git a/hpc/comm.c b/hpc/comm.c
index 8d3f425..2b519ad 100644
--- a/hpc/comm.c
+++ b/hpc/comm.c
@@ -54,10 +54,11 @@ static void comm_shutdown(om_link_t *mli
 
 /**
  * comm_getname - get the name of socket
- * @mlink:	openMosix link to shutdown
+ * @mlink:	openMosix link to query
  * @address:	the sockaddr to fill
+ * @peer:	get peer name instead?
  **/
-int comm_getname(om_link_t *mlink, struct sockaddr *address)
+int comm_getname(om_link_t *mlink, struct sockaddr *address, int peer)
 {
 	struct socket *sock;
 	int val, ret;
@@ -66,7 +67,7 @@ int comm_getname(om_link_t *mlink, struc
 	sock = mlink->sock;
 	if (!sock->ops || !sock->ops->getname)
 		return -1;
-	ret = sock->ops->getname(sock, address, &val, 0);
+	ret = sock->ops->getname(sock, address, &val, peer);
 	if (ret)
 		return -1;
 	return val;
diff --git a/hpc/proc.c b/hpc/proc.c
index e6398a7..88b611f 100644
--- a/hpc/proc.c
+++ b/hpc/proc.c
@@ -57,7 +57,7 @@ static int proc_pid_get_where(struct tas
 	struct sockaddr address;
 
 	if (p->om.contact) {
-		comm_getname(p->om.contact, &address);
+		comm_getname(p->om.contact, &address, 1);
 		length = sockaddr_to_string(&address, buf);
 		length += sprintf(buf + length, "\n");
 	} else
diff --git a/hpc/remote.c b/hpc/remote.c
index 8602906..6152d2a 100644
--- a/hpc/remote.c
+++ b/hpc/remote.c
@@ -264,7 +264,7 @@ long remote_do_fork(unsigned long clone_
 	if (!childsock)
 		goto fail;
 
-	if (comm_getname(childsock, &sa) < 0)
+	if (comm_getname(childsock, &sa, 0) < 0)
 		goto fail;
 
 	memcpy(&m.sockaddr, &sa, sizeof(struct sockaddr));
diff --git a/hpc/service.c b/hpc/service.c
index 3e7d715..6990438 100644
--- a/hpc/service.c
+++ b/hpc/service.c
@@ -131,7 +131,7 @@ int sockaddr_inherit(om_link_t *mlink, s
 {
 	struct sockaddr tmp;
 
-	if (comm_getname(mlink, &tmp) < 0)
+	if (comm_getname(mlink, &tmp, 0) < 0)
 		return -1;
 
 	memset(sa, 0, sizeof(struct sockaddr));
diff --git a/include/hpc/comm.h b/include/hpc/comm.h
index 4cf3ab4..d802a6e 100644
--- a/include/hpc/comm.h
+++ b/include/hpc/comm.h
@@ -61,7 +61,7 @@ int comm_connect(om_link_t *, struct soc
 int comm_accept(om_link_t *, om_link_t **, struct sockaddr *, unsigned long);
 int comm_recv(om_link_t *, void *, int);
 int comm_send(om_link_t *, void *, int);
-int comm_getname(om_link_t *, struct sockaddr *);
+int comm_getname(om_link_t *, struct sockaddr *, int);
 
 void set_our_addr(int, struct sockaddr *, int);
 om_link_t * comm_setup_listen(struct sockaddr *);
-- 
1.2.4

-- 
Ansgar Esztermann
Researcher & Sysadmin
http://www2.thphy.uni-duesseldorf.de/~ansgar
signature.asc (application/pgp-signature, 191 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFELVQgwAkt8h1/xRgRAquRAKC5m5aSaBhxaeFnRKvNcXOqN4lbAACeKscl
wxUS87jop9qo/k7GbkXMuLA=
=bOFU
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.