aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/server.c
diff options
context:
space:
mode:
authorJon Maloy <jon.maloy@ericsson.com>2018-02-15 04:40:46 -0500
committerDavid S. Miller <davem@davemloft.net>2018-02-16 15:26:33 -0500
commit8985ecc7c1e07c42acc1e44ac56fa224f8a5c62f (patch)
treeed564ee8b615b55e4569b38ea039e3eb89dccbe0 /net/tipc/server.c
parent414574a0af36d329f560f542e650cc4a81cc1d69 (diff)
tipc: simplify endianness handling in topology subscriber
Because of the requirement for total distribution transparency, users send subscriptions and receive topology events in their own host format. It is up to the topology server to determine this format and do the correct conversions to and from its own host format when needed. Until now, this has been handled in a rather non-transparent way inside the topology server and subscriber code, leading to unnecessary complexity when creating subscriptions and issuing events. We now improve this situation by adding two new macros, tipc_sub_read() and tipc_evt_write(). Both those functions calculate the need for conversion internally before performing their respective operations. Hence, all handling of such conversions become transparent to the rest of the code. Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/server.c')
-rw-r--r--net/tipc/server.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/net/tipc/server.c b/net/tipc/server.c
index 7933fb92d852..5d231fa8e4b5 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -98,18 +98,6 @@ static bool connected(struct tipc_conn *con)
98 return con && test_bit(CF_CONNECTED, &con->flags); 98 return con && test_bit(CF_CONNECTED, &con->flags);
99} 99}
100 100
101/**
102 * htohl - convert value to endianness used by destination
103 * @in: value to convert
104 * @swap: non-zero if endianness must be reversed
105 *
106 * Returns converted value
107 */
108static u32 htohl(u32 in, int swap)
109{
110 return swap ? swab32(in) : in;
111}
112
113static void tipc_conn_kref_release(struct kref *kref) 101static void tipc_conn_kref_release(struct kref *kref)
114{ 102{
115 struct tipc_conn *con = container_of(kref, struct tipc_conn, kref); 103 struct tipc_conn *con = container_of(kref, struct tipc_conn, kref);
@@ -285,21 +273,12 @@ static int tipc_con_rcv_sub(struct tipc_server *srv,
285 struct tipc_subscr *s) 273 struct tipc_subscr *s)
286{ 274{
287 struct tipc_subscription *sub; 275 struct tipc_subscription *sub;
288 bool status;
289 int swap;
290
291 /* Determine subscriber's endianness */
292 swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE |
293 TIPC_SUB_CANCEL));
294 276
295 /* Detect & process a subscription cancellation request */ 277 if (tipc_sub_read(s, filter) & TIPC_SUB_CANCEL) {
296 if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) {
297 s->filter &= ~htohl(TIPC_SUB_CANCEL, swap);
298 tipc_con_delete_sub(con, s); 278 tipc_con_delete_sub(con, s);
299 return 0; 279 return 0;
300 } 280 }
301 status = !(s->filter & htohl(TIPC_SUB_NO_STATUS, swap)); 281 sub = tipc_subscrp_subscribe(srv, s, con->conid);
302 sub = tipc_subscrp_subscribe(srv, s, con->conid, swap, status);
303 if (!sub) 282 if (!sub)
304 return -1; 283 return -1;
305 284