[Ocfs2-commits] zab commits r2536 - trunk/fs/ocfs2/cluster
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Aug 19 16:39:52 CDT 2005
Author: zab
Signed-off-by: manish
Date: 2005-08-19 16:39:50 -0500 (Fri, 19 Aug 2005)
New Revision: 2536
Modified:
trunk/fs/ocfs2/cluster/net_proc.c
trunk/fs/ocfs2/cluster/tcp.c
Log:
o use __force to paper over the kernel networking's lack of sparse endian
cleanliness. ocfs2/configfs -Wbitwise is silent.
Signed-off-by: manish
Modified: trunk/fs/ocfs2/cluster/net_proc.c
===================================================================
--- trunk/fs/ocfs2/cluster/net_proc.c 2005-08-19 21:27:36 UTC (rev 2535)
+++ trunk/fs/ocfs2/cluster/net_proc.c 2005-08-19 21:39:50 UTC (rev 2536)
@@ -267,12 +267,16 @@
#else
struct inet_sock *inet = NULL;
#endif
- u32 saddr = 0, daddr = 0;
+ __be32 saddr = 0, daddr = 0;
+ __be16 sport = 0, dport = 0;
if (sc->sc_sock) {
inet = inet_sk(sc->sc_sock->sk);
- saddr = inet->saddr;
- daddr = inet->daddr;
+ /* the stack's structs aren't sparse endian clean */
+ saddr = (__force __be32)inet->saddr;
+ daddr = (__force __be32)inet->daddr;
+ sport = (__force __be16)inet->sport;
+ dport = (__force __be16)inet->dport;
}
/* XXX sigh, inet-> doesn't have sparse annotation so any
@@ -283,8 +287,8 @@
" remote node: %s\n"
" page off: %zu\n",
sc, atomic_read(&sc->sc_kref.refcount),
- NIPQUAD(saddr), inet ? ntohs(inet->sport) : 0,
- NIPQUAD(daddr), inet ? ntohs(inet->dport) : 0,
+ NIPQUAD(saddr), inet ? ntohs(sport) : 0,
+ NIPQUAD(daddr), inet ? ntohs(dport) : 0,
sc->sc_node->nd_name, sc->sc_page_off);
}
Modified: trunk/fs/ocfs2/cluster/tcp.c
===================================================================
--- trunk/fs/ocfs2/cluster/tcp.c 2005-08-19 21:27:36 UTC (rev 2535)
+++ trunk/fs/ocfs2/cluster/tcp.c 2005-08-19 21:39:50 UTC (rev 2536)
@@ -71,6 +71,14 @@
#include "tcp_internal.h"
+/*
+ * The linux network stack isn't sparse endian clean.. It has macros like
+ * ntohs() which perform the endian checks and structs like sockaddr_in
+ * which aren't annotated. So __force is found here to get the build
+ * clean. When they emerge from the dark ages and annotate the code
+ * we can remove these.
+ */
+
#define SC_NODEF_FMT "node %s (num %u) at %u.%u.%u.%u:%u"
#define SC_NODEF_ARGS(sc) sc->sc_node->nd_name, sc->sc_node->nd_num, \
NIPQUAD(sc->sc_node->nd_ipv4_address), \
@@ -1353,7 +1361,7 @@
sc->sc_sock = sock; /* freed by sc_kref_release */
myaddr.sin_family = AF_INET;
- myaddr.sin_port = htons(0); /* any port */
+ myaddr.sin_port = (__force u16)htons(0); /* any port */
ret = sock->ops->bind(sock, (struct sockaddr *)&myaddr,
sizeof(myaddr));
@@ -1376,8 +1384,8 @@
spin_unlock(&nn->nn_lock);
remoteaddr.sin_family = AF_INET;
- remoteaddr.sin_addr.s_addr = node->nd_ipv4_address;
- remoteaddr.sin_port = node->nd_ipv4_port;
+ remoteaddr.sin_addr.s_addr = (__force u32)node->nd_ipv4_address;
+ remoteaddr.sin_port = (__force u16)node->nd_ipv4_port;
ret = sc->sc_sock->ops->connect(sc->sc_sock,
(struct sockaddr *)&remoteaddr,
@@ -1567,11 +1575,11 @@
if (ret < 0)
goto out;
- node = o2nm_get_node_by_ip(sin.sin_addr.s_addr);
+ node = o2nm_get_node_by_ip((__force __be32)sin.sin_addr.s_addr);
if (node == NULL) {
mlog(ML_NOTICE, "attempt to connect from unknown node at "
"%u.%u.%u.%u:%d\n", NIPQUAD(sin.sin_addr.s_addr),
- ntohs(sin.sin_port));
+ ntohs((__force __be16)sin.sin_port));
ret = -EINVAL;
goto out;
}
@@ -1580,7 +1588,7 @@
mlog(ML_NOTICE, "unexpected connect attempted from a lower "
"numbered node '%s' at " "%u.%u.%u.%u:%d with num %u\n",
node->nd_name, NIPQUAD(sin.sin_addr.s_addr),
- ntohs(sin.sin_port), node->nd_num);
+ ntohs((__force __be16)sin.sin_port), node->nd_num);
ret = -EINVAL;
goto out;
}
@@ -1591,7 +1599,7 @@
mlog(ML_CONN, "attempt to connect from node '%s' at "
"%u.%u.%u.%u:%d but it isn't heartbeating\n",
node->nd_name, NIPQUAD(sin.sin_addr.s_addr),
- ntohs(sin.sin_port));
+ ntohs((__force __be16)sin.sin_port));
ret = -EINVAL;
goto out;
}
@@ -1608,7 +1616,7 @@
mlog(ML_NOTICE, "attempt to connect from node '%s' at "
"%u.%u.%u.%u:%d but it already has an open connection\n",
node->nd_name, NIPQUAD(sin.sin_addr.s_addr),
- ntohs(sin.sin_port));
+ ntohs((__force __be16)sin.sin_port));
goto out;
}
@@ -1678,8 +1686,8 @@
int ret;
struct sockaddr_in sin = {
.sin_family = PF_INET,
- .sin_addr = { .s_addr = htonl(INADDR_ANY) },
- .sin_port = port,
+ .sin_addr = { .s_addr = (__force u32)htonl(INADDR_ANY) },
+ .sin_port = (__force u16)port,
};
ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
More information about the Ocfs2-commits
mailing list