aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2018-09-27 10:13:08 -0400
committerDavid Howells <dhowells@redhat.com>2018-09-28 05:31:20 -0400
commitdc71db34e4f3c06b8277c8f3c2ff014610607a8c (patch)
tree24c55206f233ae13f999d814ee206d0d3842e936
parent092ffc51fb3f9b8369e737c9320bf0bffb2c898f (diff)
rxrpc: Fix checks as to whether we should set up a new call
There's a check in rxrpc_data_ready() that's checking the CLIENT_INITIATED flag in the packet type field rather than in the packet flags field. Fix this by creating a pair of helper functions to check whether the packet is going to the client or to the server and use them generally. Fixes: 248f219cb8bc ("rxrpc: Rewrite the data and ack handling code") Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--net/rxrpc/ar-internal.h10
-rw-r--r--net/rxrpc/conn_object.c2
-rw-r--r--net/rxrpc/input.c12
3 files changed, 15 insertions, 9 deletions
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index c97558710421..9fcb3e197b14 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -463,6 +463,16 @@ struct rxrpc_connection {
463 u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */ 463 u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
464}; 464};
465 465
466static inline bool rxrpc_to_server(const struct rxrpc_skb_priv *sp)
467{
468 return sp->hdr.flags & RXRPC_CLIENT_INITIATED;
469}
470
471static inline bool rxrpc_to_client(const struct rxrpc_skb_priv *sp)
472{
473 return !rxrpc_to_server(sp);
474}
475
466/* 476/*
467 * Flags in call->flags. 477 * Flags in call->flags.
468 */ 478 */
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index 1746b48cb165..390ba50cfab4 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -96,7 +96,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local,
96 k.epoch = sp->hdr.epoch; 96 k.epoch = sp->hdr.epoch;
97 k.cid = sp->hdr.cid & RXRPC_CIDMASK; 97 k.cid = sp->hdr.cid & RXRPC_CIDMASK;
98 98
99 if (sp->hdr.flags & RXRPC_CLIENT_INITIATED) { 99 if (rxrpc_to_server(sp)) {
100 /* We need to look up service connections by the full protocol 100 /* We need to look up service connections by the full protocol
101 * parameter set. We look up the peer first as an intermediate 101 * parameter set. We look up the peer first as an intermediate
102 * step and then the connection from the peer's tree. 102 * step and then the connection from the peer's tree.
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index cfdc199c6351..ec299c627f77 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -1177,10 +1177,6 @@ void rxrpc_data_ready(struct sock *udp_sk)
1177 1177
1178 trace_rxrpc_rx_packet(sp); 1178 trace_rxrpc_rx_packet(sp);
1179 1179
1180 _net("Rx RxRPC %s ep=%x call=%x:%x",
1181 sp->hdr.flags & RXRPC_CLIENT_INITIATED ? "ToServer" : "ToClient",
1182 sp->hdr.epoch, sp->hdr.cid, sp->hdr.callNumber);
1183
1184 if (sp->hdr.type >= RXRPC_N_PACKET_TYPES || 1180 if (sp->hdr.type >= RXRPC_N_PACKET_TYPES ||
1185 !((RXRPC_SUPPORTED_PACKET_TYPES >> sp->hdr.type) & 1)) { 1181 !((RXRPC_SUPPORTED_PACKET_TYPES >> sp->hdr.type) & 1)) {
1186 _proto("Rx Bad Packet Type %u", sp->hdr.type); 1182 _proto("Rx Bad Packet Type %u", sp->hdr.type);
@@ -1189,13 +1185,13 @@ void rxrpc_data_ready(struct sock *udp_sk)
1189 1185
1190 switch (sp->hdr.type) { 1186 switch (sp->hdr.type) {
1191 case RXRPC_PACKET_TYPE_VERSION: 1187 case RXRPC_PACKET_TYPE_VERSION:
1192 if (!(sp->hdr.flags & RXRPC_CLIENT_INITIATED)) 1188 if (rxrpc_to_client(sp))
1193 goto discard; 1189 goto discard;
1194 rxrpc_post_packet_to_local(local, skb); 1190 rxrpc_post_packet_to_local(local, skb);
1195 goto out; 1191 goto out;
1196 1192
1197 case RXRPC_PACKET_TYPE_BUSY: 1193 case RXRPC_PACKET_TYPE_BUSY:
1198 if (sp->hdr.flags & RXRPC_CLIENT_INITIATED) 1194 if (rxrpc_to_server(sp))
1199 goto discard; 1195 goto discard;
1200 /* Fall through */ 1196 /* Fall through */
1201 1197
@@ -1280,7 +1276,7 @@ void rxrpc_data_ready(struct sock *udp_sk)
1280 call = rcu_dereference(chan->call); 1276 call = rcu_dereference(chan->call);
1281 1277
1282 if (sp->hdr.callNumber > chan->call_id) { 1278 if (sp->hdr.callNumber > chan->call_id) {
1283 if (!(sp->hdr.flags & RXRPC_CLIENT_INITIATED)) { 1279 if (rxrpc_to_client(sp)) {
1284 rcu_read_unlock(); 1280 rcu_read_unlock();
1285 goto reject_packet; 1281 goto reject_packet;
1286 } 1282 }
@@ -1303,7 +1299,7 @@ void rxrpc_data_ready(struct sock *udp_sk)
1303 } 1299 }
1304 1300
1305 if (!call || atomic_read(&call->usage) == 0) { 1301 if (!call || atomic_read(&call->usage) == 0) {
1306 if (!(sp->hdr.type & RXRPC_CLIENT_INITIATED) || 1302 if (rxrpc_to_client(sp) ||
1307 sp->hdr.callNumber == 0 || 1303 sp->hdr.callNumber == 0 ||
1308 sp->hdr.type != RXRPC_PACKET_TYPE_DATA) 1304 sp->hdr.type != RXRPC_PACKET_TYPE_DATA)
1309 goto bad_message_unlock; 1305 goto bad_message_unlock;