diff options
author | David Howells <dhowells@redhat.com> | 2016-09-30 08:26:03 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2016-09-30 09:39:28 -0400 |
commit | 775e5b71db6aca47d49d43d08751f2e8ebad7f60 (patch) | |
tree | 54beb3163dd5d3184d55cf8c46ae60fed3cbb963 | |
parent | 0851115090a3eb9585d6a804a61e47f3d89ac2a8 (diff) |
rxrpc: The offset field in struct rxrpc_skb_priv is unnecessary
The offset field in struct rxrpc_skb_priv is unnecessary as the value can
always be calculated.
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | net/rxrpc/ar-internal.h | 1 | ||||
-rw-r--r-- | net/rxrpc/conn_event.c | 3 | ||||
-rw-r--r-- | net/rxrpc/input.c | 23 | ||||
-rw-r--r-- | net/rxrpc/local_event.c | 3 | ||||
-rw-r--r-- | net/rxrpc/recvmsg.c | 6 | ||||
-rw-r--r-- | net/rxrpc/rxkad.c | 9 |
6 files changed, 24 insertions, 21 deletions
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index 539db54697f9..fd64a2bd1072 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h | |||
@@ -144,7 +144,6 @@ struct rxrpc_skb_priv { | |||
144 | u8 nr_jumbo; /* Number of jumbo subpackets */ | 144 | u8 nr_jumbo; /* Number of jumbo subpackets */ |
145 | }; | 145 | }; |
146 | union { | 146 | union { |
147 | unsigned int offset; /* offset into buffer of next read */ | ||
148 | int remain; /* amount of space remaining for next write */ | 147 | int remain; /* amount of space remaining for next write */ |
149 | u32 error; /* network error code */ | 148 | u32 error; /* network error code */ |
150 | }; | 149 | }; |
diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c index 37609ce89f52..3f9d8d7ec632 100644 --- a/net/rxrpc/conn_event.c +++ b/net/rxrpc/conn_event.c | |||
@@ -276,7 +276,8 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, | |||
276 | return 0; | 276 | return 0; |
277 | 277 | ||
278 | case RXRPC_PACKET_TYPE_ABORT: | 278 | case RXRPC_PACKET_TYPE_ABORT: |
279 | if (skb_copy_bits(skb, sp->offset, &wtmp, sizeof(wtmp)) < 0) | 279 | if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header), |
280 | &wtmp, sizeof(wtmp)) < 0) | ||
280 | return -EPROTO; | 281 | return -EPROTO; |
281 | abort_code = ntohl(wtmp); | 282 | abort_code = ntohl(wtmp); |
282 | _proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code); | 283 | _proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code); |
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c index 7993473e56bb..5ba35b4a907b 100644 --- a/net/rxrpc/input.c +++ b/net/rxrpc/input.c | |||
@@ -358,7 +358,7 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call) | |||
358 | static bool rxrpc_validate_jumbo(struct sk_buff *skb) | 358 | static bool rxrpc_validate_jumbo(struct sk_buff *skb) |
359 | { | 359 | { |
360 | struct rxrpc_skb_priv *sp = rxrpc_skb(skb); | 360 | struct rxrpc_skb_priv *sp = rxrpc_skb(skb); |
361 | unsigned int offset = sp->offset; | 361 | unsigned int offset = sizeof(struct rxrpc_wire_header); |
362 | unsigned int len = skb->len; | 362 | unsigned int len = skb->len; |
363 | int nr_jumbo = 1; | 363 | int nr_jumbo = 1; |
364 | u8 flags = sp->hdr.flags; | 364 | u8 flags = sp->hdr.flags; |
@@ -419,7 +419,7 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb, | |||
419 | u16 skew) | 419 | u16 skew) |
420 | { | 420 | { |
421 | struct rxrpc_skb_priv *sp = rxrpc_skb(skb); | 421 | struct rxrpc_skb_priv *sp = rxrpc_skb(skb); |
422 | unsigned int offset = sp->offset; | 422 | unsigned int offset = sizeof(struct rxrpc_wire_header); |
423 | unsigned int ix; | 423 | unsigned int ix; |
424 | rxrpc_serial_t serial = sp->hdr.serial, ack_serial = 0; | 424 | rxrpc_serial_t serial = sp->hdr.serial, ack_serial = 0; |
425 | rxrpc_seq_t seq = sp->hdr.seq, hard_ack; | 425 | rxrpc_seq_t seq = sp->hdr.seq, hard_ack; |
@@ -746,15 +746,16 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb, | |||
746 | } buf; | 746 | } buf; |
747 | rxrpc_serial_t acked_serial; | 747 | rxrpc_serial_t acked_serial; |
748 | rxrpc_seq_t first_soft_ack, hard_ack; | 748 | rxrpc_seq_t first_soft_ack, hard_ack; |
749 | int nr_acks, offset; | 749 | int nr_acks, offset, ioffset; |
750 | 750 | ||
751 | _enter(""); | 751 | _enter(""); |
752 | 752 | ||
753 | if (skb_copy_bits(skb, sp->offset, &buf.ack, sizeof(buf.ack)) < 0) { | 753 | offset = sizeof(struct rxrpc_wire_header); |
754 | if (skb_copy_bits(skb, offset, &buf.ack, sizeof(buf.ack)) < 0) { | ||
754 | _debug("extraction failure"); | 755 | _debug("extraction failure"); |
755 | return rxrpc_proto_abort("XAK", call, 0); | 756 | return rxrpc_proto_abort("XAK", call, 0); |
756 | } | 757 | } |
757 | sp->offset += sizeof(buf.ack); | 758 | offset += sizeof(buf.ack); |
758 | 759 | ||
759 | acked_serial = ntohl(buf.ack.serial); | 760 | acked_serial = ntohl(buf.ack.serial); |
760 | first_soft_ack = ntohl(buf.ack.firstPacket); | 761 | first_soft_ack = ntohl(buf.ack.firstPacket); |
@@ -792,9 +793,9 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb, | |||
792 | rxrpc_propose_ack_respond_to_ack); | 793 | rxrpc_propose_ack_respond_to_ack); |
793 | } | 794 | } |
794 | 795 | ||
795 | offset = sp->offset + nr_acks + 3; | 796 | ioffset = offset + nr_acks + 3; |
796 | if (skb->len >= offset + sizeof(buf.info)) { | 797 | if (skb->len >= ioffset + sizeof(buf.info)) { |
797 | if (skb_copy_bits(skb, offset, &buf.info, sizeof(buf.info)) < 0) | 798 | if (skb_copy_bits(skb, ioffset, &buf.info, sizeof(buf.info)) < 0) |
798 | return rxrpc_proto_abort("XAI", call, 0); | 799 | return rxrpc_proto_abort("XAI", call, 0); |
799 | rxrpc_input_ackinfo(call, skb, &buf.info); | 800 | rxrpc_input_ackinfo(call, skb, &buf.info); |
800 | } | 801 | } |
@@ -832,7 +833,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb, | |||
832 | rxrpc_rotate_tx_window(call, hard_ack, &summary); | 833 | rxrpc_rotate_tx_window(call, hard_ack, &summary); |
833 | 834 | ||
834 | if (nr_acks > 0) { | 835 | if (nr_acks > 0) { |
835 | if (skb_copy_bits(skb, sp->offset, buf.acks, nr_acks) < 0) | 836 | if (skb_copy_bits(skb, offset, buf.acks, nr_acks) < 0) |
836 | return rxrpc_proto_abort("XSA", call, 0); | 837 | return rxrpc_proto_abort("XSA", call, 0); |
837 | rxrpc_input_soft_acks(call, buf.acks, first_soft_ack, nr_acks, | 838 | rxrpc_input_soft_acks(call, buf.acks, first_soft_ack, nr_acks, |
838 | &summary); | 839 | &summary); |
@@ -880,7 +881,8 @@ static void rxrpc_input_abort(struct rxrpc_call *call, struct sk_buff *skb) | |||
880 | _enter(""); | 881 | _enter(""); |
881 | 882 | ||
882 | if (skb->len >= 4 && | 883 | if (skb->len >= 4 && |
883 | skb_copy_bits(skb, sp->offset, &wtmp, sizeof(wtmp)) >= 0) | 884 | skb_copy_bits(skb, sizeof(struct rxrpc_wire_header), |
885 | &wtmp, sizeof(wtmp)) >= 0) | ||
884 | abort_code = ntohl(wtmp); | 886 | abort_code = ntohl(wtmp); |
885 | 887 | ||
886 | _proto("Rx ABORT %%%u { %x }", sp->hdr.serial, abort_code); | 888 | _proto("Rx ABORT %%%u { %x }", sp->hdr.serial, abort_code); |
@@ -996,7 +998,6 @@ int rxrpc_extract_header(struct rxrpc_skb_priv *sp, struct sk_buff *skb) | |||
996 | sp->hdr.securityIndex = whdr.securityIndex; | 998 | sp->hdr.securityIndex = whdr.securityIndex; |
997 | sp->hdr._rsvd = ntohs(whdr._rsvd); | 999 | sp->hdr._rsvd = ntohs(whdr._rsvd); |
998 | sp->hdr.serviceId = ntohs(whdr.serviceId); | 1000 | sp->hdr.serviceId = ntohs(whdr.serviceId); |
999 | sp->offset = sizeof(whdr); | ||
1000 | return 0; | 1001 | return 0; |
1001 | } | 1002 | } |
1002 | 1003 | ||
diff --git a/net/rxrpc/local_event.c b/net/rxrpc/local_event.c index 190f68bd9e27..540d3955c1bc 100644 --- a/net/rxrpc/local_event.c +++ b/net/rxrpc/local_event.c | |||
@@ -95,7 +95,8 @@ void rxrpc_process_local_events(struct rxrpc_local *local) | |||
95 | 95 | ||
96 | switch (sp->hdr.type) { | 96 | switch (sp->hdr.type) { |
97 | case RXRPC_PACKET_TYPE_VERSION: | 97 | case RXRPC_PACKET_TYPE_VERSION: |
98 | if (skb_copy_bits(skb, sp->offset, &v, 1) < 0) | 98 | if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header), |
99 | &v, 1) < 0) | ||
99 | return; | 100 | return; |
100 | _proto("Rx VERSION { %02x }", v); | 101 | _proto("Rx VERSION { %02x }", v); |
101 | if (v == 0) | 102 | if (v == 0) |
diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c index 038ae62ddb4d..f05ea0a88076 100644 --- a/net/rxrpc/recvmsg.c +++ b/net/rxrpc/recvmsg.c | |||
@@ -261,15 +261,13 @@ static int rxrpc_locate_data(struct rxrpc_call *call, struct sk_buff *skb, | |||
261 | u8 *_annotation, | 261 | u8 *_annotation, |
262 | unsigned int *_offset, unsigned int *_len) | 262 | unsigned int *_offset, unsigned int *_len) |
263 | { | 263 | { |
264 | struct rxrpc_skb_priv *sp = rxrpc_skb(skb); | 264 | unsigned int offset = sizeof(struct rxrpc_wire_header); |
265 | unsigned int offset = *_offset; | ||
266 | unsigned int len = *_len; | 265 | unsigned int len = *_len; |
267 | int ret; | 266 | int ret; |
268 | u8 annotation = *_annotation; | 267 | u8 annotation = *_annotation; |
269 | 268 | ||
270 | /* Locate the subpacket */ | 269 | /* Locate the subpacket */ |
271 | offset = sp->offset; | 270 | len = skb->len - offset; |
272 | len = skb->len - sp->offset; | ||
273 | if ((annotation & RXRPC_RX_ANNO_JUMBO) > 0) { | 271 | if ((annotation & RXRPC_RX_ANNO_JUMBO) > 0) { |
274 | offset += (((annotation & RXRPC_RX_ANNO_JUMBO) - 1) * | 272 | offset += (((annotation & RXRPC_RX_ANNO_JUMBO) - 1) * |
275 | RXRPC_JUMBO_SUBPKTLEN); | 273 | RXRPC_JUMBO_SUBPKTLEN); |
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c index 88d080a1a3de..627abed5f999 100644 --- a/net/rxrpc/rxkad.c +++ b/net/rxrpc/rxkad.c | |||
@@ -771,7 +771,8 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn, | |||
771 | } | 771 | } |
772 | 772 | ||
773 | abort_code = RXKADPACKETSHORT; | 773 | abort_code = RXKADPACKETSHORT; |
774 | if (skb_copy_bits(skb, sp->offset, &challenge, sizeof(challenge)) < 0) | 774 | if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header), |
775 | &challenge, sizeof(challenge)) < 0) | ||
775 | goto protocol_error; | 776 | goto protocol_error; |
776 | 777 | ||
777 | version = ntohl(challenge.version); | 778 | version = ntohl(challenge.version); |
@@ -1028,7 +1029,8 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, | |||
1028 | _enter("{%d,%x}", conn->debug_id, key_serial(conn->server_key)); | 1029 | _enter("{%d,%x}", conn->debug_id, key_serial(conn->server_key)); |
1029 | 1030 | ||
1030 | abort_code = RXKADPACKETSHORT; | 1031 | abort_code = RXKADPACKETSHORT; |
1031 | if (skb_copy_bits(skb, sp->offset, &response, sizeof(response)) < 0) | 1032 | if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header), |
1033 | &response, sizeof(response)) < 0) | ||
1032 | goto protocol_error; | 1034 | goto protocol_error; |
1033 | if (!pskb_pull(skb, sizeof(response))) | 1035 | if (!pskb_pull(skb, sizeof(response))) |
1034 | BUG(); | 1036 | BUG(); |
@@ -1057,7 +1059,8 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, | |||
1057 | return -ENOMEM; | 1059 | return -ENOMEM; |
1058 | 1060 | ||
1059 | abort_code = RXKADPACKETSHORT; | 1061 | abort_code = RXKADPACKETSHORT; |
1060 | if (skb_copy_bits(skb, sp->offset, ticket, ticket_len) < 0) | 1062 | if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header), |
1063 | ticket, ticket_len) < 0) | ||
1061 | goto protocol_error_free; | 1064 | goto protocol_error_free; |
1062 | 1065 | ||
1063 | ret = rxkad_decrypt_ticket(conn, ticket, ticket_len, &session_key, | 1066 | ret = rxkad_decrypt_ticket(conn, ticket, ticket_len, &session_key, |