aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2018-04-06 09:17:25 -0400
committerDavid Howells <dhowells@redhat.com>2018-04-09 16:54:48 -0400
commit5f702c8e124f967146a735a19f0b00a2469487d1 (patch)
tree16f1818dcb8412656be694a3071b7f31e4ee9094
parent63a4681ff39cb63314b8ff41319e70fb0e606ed2 (diff)
afs: Trace protocol errors
Trace protocol errors detected in afs. Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--fs/afs/cmservice.c4
-rw-r--r--fs/afs/fsclient.c68
-rw-r--r--fs/afs/inode.c2
-rw-r--r--fs/afs/internal.h1
-rw-r--r--fs/afs/rxrpc.c9
-rw-r--r--fs/afs/vlclient.c20
-rw-r--r--include/trace/events/afs.h21
7 files changed, 79 insertions, 46 deletions
diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index fa07f83e9f29..357de908df3a 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -201,7 +201,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
201 call->count = ntohl(call->tmp); 201 call->count = ntohl(call->tmp);
202 _debug("FID count: %u", call->count); 202 _debug("FID count: %u", call->count);
203 if (call->count > AFSCBMAX) 203 if (call->count > AFSCBMAX)
204 return -EBADMSG; 204 return afs_protocol_error(call, -EBADMSG);
205 205
206 call->buffer = kmalloc(call->count * 3 * 4, GFP_KERNEL); 206 call->buffer = kmalloc(call->count * 3 * 4, GFP_KERNEL);
207 if (!call->buffer) 207 if (!call->buffer)
@@ -245,7 +245,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
245 call->count2 = ntohl(call->tmp); 245 call->count2 = ntohl(call->tmp);
246 _debug("CB count: %u", call->count2); 246 _debug("CB count: %u", call->count2);
247 if (call->count2 != call->count && call->count2 != 0) 247 if (call->count2 != call->count && call->count2 != 0)
248 return -EBADMSG; 248 return afs_protocol_error(call, -EBADMSG);
249 call->offset = 0; 249 call->offset = 0;
250 call->unmarshall++; 250 call->unmarshall++;
251 251
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 20d6304a0d3e..efacdb7c1dee 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -126,7 +126,8 @@ void afs_update_inode_from_status(struct afs_vnode *vnode,
126/* 126/*
127 * decode an AFSFetchStatus block 127 * decode an AFSFetchStatus block
128 */ 128 */
129static int xdr_decode_AFSFetchStatus(const __be32 **_bp, 129static int xdr_decode_AFSFetchStatus(struct afs_call *call,
130 const __be32 **_bp,
130 struct afs_file_status *status, 131 struct afs_file_status *status,
131 struct afs_vnode *vnode, 132 struct afs_vnode *vnode,
132 const afs_dataversion_t *expected_version, 133 const afs_dataversion_t *expected_version,
@@ -167,6 +168,7 @@ static int xdr_decode_AFSFetchStatus(const __be32 **_bp,
167 case AFS_FTYPE_INVALID: 168 case AFS_FTYPE_INVALID:
168 if (abort_code != 0) { 169 if (abort_code != 0) {
169 status->abort_code = abort_code; 170 status->abort_code = abort_code;
171 ret = 0;
170 goto out; 172 goto out;
171 } 173 }
172 /* Fall through */ 174 /* Fall through */
@@ -229,7 +231,7 @@ out:
229 231
230bad: 232bad:
231 xdr_dump_bad(*_bp); 233 xdr_dump_bad(*_bp);
232 ret = -EBADMSG; 234 ret = afs_protocol_error(call, -EBADMSG);
233 goto out; 235 goto out;
234} 236}
235 237
@@ -372,9 +374,9 @@ static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call)
372 374
373 /* unmarshall the reply once we've received all of it */ 375 /* unmarshall the reply once we've received all of it */
374 bp = call->buffer; 376 bp = call->buffer;
375 if (xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, 377 if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
376 &call->expected_version, NULL) < 0) 378 &call->expected_version, NULL) < 0)
377 return -EBADMSG; 379 return afs_protocol_error(call, -EBADMSG);
378 xdr_decode_AFSCallBack(call, vnode, &bp); 380 xdr_decode_AFSCallBack(call, vnode, &bp);
379 if (call->reply[1]) 381 if (call->reply[1])
380 xdr_decode_AFSVolSync(&bp, call->reply[1]); 382 xdr_decode_AFSVolSync(&bp, call->reply[1]);
@@ -553,9 +555,9 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
553 return ret; 555 return ret;
554 556
555 bp = call->buffer; 557 bp = call->buffer;
556 if (xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, 558 if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
557 &vnode->status.data_version, req) < 0) 559 &vnode->status.data_version, req) < 0)
558 return -EBADMSG; 560 return afs_protocol_error(call, -EBADMSG);
559 xdr_decode_AFSCallBack(call, vnode, &bp); 561 xdr_decode_AFSCallBack(call, vnode, &bp);
560 if (call->reply[1]) 562 if (call->reply[1])
561 xdr_decode_AFSVolSync(&bp, call->reply[1]); 563 xdr_decode_AFSVolSync(&bp, call->reply[1]);
@@ -706,10 +708,10 @@ static int afs_deliver_fs_create_vnode(struct afs_call *call)
706 /* unmarshall the reply once we've received all of it */ 708 /* unmarshall the reply once we've received all of it */
707 bp = call->buffer; 709 bp = call->buffer;
708 xdr_decode_AFSFid(&bp, call->reply[1]); 710 xdr_decode_AFSFid(&bp, call->reply[1]);
709 if (xdr_decode_AFSFetchStatus(&bp, call->reply[2], NULL, NULL, NULL) < 0 || 711 if (xdr_decode_AFSFetchStatus(call, &bp, call->reply[2], NULL, NULL, NULL) < 0 ||
710 xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, 712 xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
711 &call->expected_version, NULL) < 0) 713 &call->expected_version, NULL) < 0)
712 return -EBADMSG; 714 return afs_protocol_error(call, -EBADMSG);
713 xdr_decode_AFSCallBack_raw(&bp, call->reply[3]); 715 xdr_decode_AFSCallBack_raw(&bp, call->reply[3]);
714 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */ 716 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
715 717
@@ -812,9 +814,9 @@ static int afs_deliver_fs_remove(struct afs_call *call)
812 814
813 /* unmarshall the reply once we've received all of it */ 815 /* unmarshall the reply once we've received all of it */
814 bp = call->buffer; 816 bp = call->buffer;
815 if (xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, 817 if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
816 &call->expected_version, NULL) < 0) 818 &call->expected_version, NULL) < 0)
817 return -EBADMSG; 819 return afs_protocol_error(call, -EBADMSG);
818 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */ 820 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
819 821
820 _leave(" = 0 [done]"); 822 _leave(" = 0 [done]");
@@ -902,10 +904,10 @@ static int afs_deliver_fs_link(struct afs_call *call)
902 904
903 /* unmarshall the reply once we've received all of it */ 905 /* unmarshall the reply once we've received all of it */
904 bp = call->buffer; 906 bp = call->buffer;
905 if (xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, NULL, NULL) < 0 || 907 if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode, NULL, NULL) < 0 ||
906 xdr_decode_AFSFetchStatus(&bp, &dvnode->status, dvnode, 908 xdr_decode_AFSFetchStatus(call, &bp, &dvnode->status, dvnode,
907 &call->expected_version, NULL) < 0) 909 &call->expected_version, NULL) < 0)
908 return -EBADMSG; 910 return afs_protocol_error(call, -EBADMSG);
909 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */ 911 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
910 912
911 _leave(" = 0 [done]"); 913 _leave(" = 0 [done]");
@@ -989,10 +991,10 @@ static int afs_deliver_fs_symlink(struct afs_call *call)
989 /* unmarshall the reply once we've received all of it */ 991 /* unmarshall the reply once we've received all of it */
990 bp = call->buffer; 992 bp = call->buffer;
991 xdr_decode_AFSFid(&bp, call->reply[1]); 993 xdr_decode_AFSFid(&bp, call->reply[1]);
992 if (xdr_decode_AFSFetchStatus(&bp, call->reply[2], NULL, NULL, NULL) || 994 if (xdr_decode_AFSFetchStatus(call, &bp, call->reply[2], NULL, NULL, NULL) ||
993 xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, 995 xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
994 &call->expected_version, NULL) < 0) 996 &call->expected_version, NULL) < 0)
995 return -EBADMSG; 997 return afs_protocol_error(call, -EBADMSG);
996 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */ 998 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
997 999
998 _leave(" = 0 [done]"); 1000 _leave(" = 0 [done]");
@@ -1095,13 +1097,13 @@ static int afs_deliver_fs_rename(struct afs_call *call)
1095 1097
1096 /* unmarshall the reply once we've received all of it */ 1098 /* unmarshall the reply once we've received all of it */
1097 bp = call->buffer; 1099 bp = call->buffer;
1098 if (xdr_decode_AFSFetchStatus(&bp, &orig_dvnode->status, orig_dvnode, 1100 if (xdr_decode_AFSFetchStatus(call, &bp, &orig_dvnode->status, orig_dvnode,
1099 &call->expected_version, NULL) < 0) 1101 &call->expected_version, NULL) < 0)
1100 return -EBADMSG; 1102 return afs_protocol_error(call, -EBADMSG);
1101 if (new_dvnode != orig_dvnode && 1103 if (new_dvnode != orig_dvnode &&
1102 xdr_decode_AFSFetchStatus(&bp, &new_dvnode->status, new_dvnode, 1104 xdr_decode_AFSFetchStatus(call, &bp, &new_dvnode->status, new_dvnode,
1103 &call->expected_version_2, NULL) < 0) 1105 &call->expected_version_2, NULL) < 0)
1104 return -EBADMSG; 1106 return afs_protocol_error(call, -EBADMSG);
1105 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */ 1107 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1106 1108
1107 _leave(" = 0 [done]"); 1109 _leave(" = 0 [done]");
@@ -1204,9 +1206,9 @@ static int afs_deliver_fs_store_data(struct afs_call *call)
1204 1206
1205 /* unmarshall the reply once we've received all of it */ 1207 /* unmarshall the reply once we've received all of it */
1206 bp = call->buffer; 1208 bp = call->buffer;
1207 if (xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, 1209 if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
1208 &call->expected_version, NULL) < 0) 1210 &call->expected_version, NULL) < 0)
1209 return -EBADMSG; 1211 return afs_protocol_error(call, -EBADMSG);
1210 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */ 1212 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1211 1213
1212 afs_pages_written_back(vnode, call); 1214 afs_pages_written_back(vnode, call);
@@ -1380,9 +1382,9 @@ static int afs_deliver_fs_store_status(struct afs_call *call)
1380 1382
1381 /* unmarshall the reply once we've received all of it */ 1383 /* unmarshall the reply once we've received all of it */
1382 bp = call->buffer; 1384 bp = call->buffer;
1383 if (xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, 1385 if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
1384 &call->expected_version, NULL) < 0) 1386 &call->expected_version, NULL) < 0)
1385 return -EBADMSG; 1387 return afs_protocol_error(call, -EBADMSG);
1386 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */ 1388 /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1387 1389
1388 _leave(" = 0 [done]"); 1390 _leave(" = 0 [done]");
@@ -1585,7 +1587,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
1585 call->count = ntohl(call->tmp); 1587 call->count = ntohl(call->tmp);
1586 _debug("volname length: %u", call->count); 1588 _debug("volname length: %u", call->count);
1587 if (call->count >= AFSNAMEMAX) 1589 if (call->count >= AFSNAMEMAX)
1588 return -EBADMSG; 1590 return afs_protocol_error(call, -EBADMSG);
1589 call->offset = 0; 1591 call->offset = 0;
1590 call->unmarshall++; 1592 call->unmarshall++;
1591 1593
@@ -1632,7 +1634,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
1632 call->count = ntohl(call->tmp); 1634 call->count = ntohl(call->tmp);
1633 _debug("offline msg length: %u", call->count); 1635 _debug("offline msg length: %u", call->count);
1634 if (call->count >= AFSNAMEMAX) 1636 if (call->count >= AFSNAMEMAX)
1635 return -EBADMSG; 1637 return afs_protocol_error(call, -EBADMSG);
1636 call->offset = 0; 1638 call->offset = 0;
1637 call->unmarshall++; 1639 call->unmarshall++;
1638 1640
@@ -1679,7 +1681,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
1679 call->count = ntohl(call->tmp); 1681 call->count = ntohl(call->tmp);
1680 _debug("motd length: %u", call->count); 1682 _debug("motd length: %u", call->count);
1681 if (call->count >= AFSNAMEMAX) 1683 if (call->count >= AFSNAMEMAX)
1682 return -EBADMSG; 1684 return afs_protocol_error(call, -EBADMSG);
1683 call->offset = 0; 1685 call->offset = 0;
1684 call->unmarshall++; 1686 call->unmarshall++;
1685 1687
@@ -2082,7 +2084,7 @@ static int afs_deliver_fs_fetch_status(struct afs_call *call)
2082 2084
2083 /* unmarshall the reply once we've received all of it */ 2085 /* unmarshall the reply once we've received all of it */
2084 bp = call->buffer; 2086 bp = call->buffer;
2085 xdr_decode_AFSFetchStatus(&bp, status, vnode, 2087 xdr_decode_AFSFetchStatus(call, &bp, status, vnode,
2086 &call->expected_version, NULL); 2088 &call->expected_version, NULL);
2087 callback[call->count].version = ntohl(bp[0]); 2089 callback[call->count].version = ntohl(bp[0]);
2088 callback[call->count].expiry = ntohl(bp[1]); 2090 callback[call->count].expiry = ntohl(bp[1]);
@@ -2179,7 +2181,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
2179 tmp = ntohl(call->tmp); 2181 tmp = ntohl(call->tmp);
2180 _debug("status count: %u/%u", tmp, call->count2); 2182 _debug("status count: %u/%u", tmp, call->count2);
2181 if (tmp != call->count2) 2183 if (tmp != call->count2)
2182 return -EBADMSG; 2184 return afs_protocol_error(call, -EBADMSG);
2183 2185
2184 call->count = 0; 2186 call->count = 0;
2185 call->unmarshall++; 2187 call->unmarshall++;
@@ -2194,10 +2196,10 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
2194 2196
2195 bp = call->buffer; 2197 bp = call->buffer;
2196 statuses = call->reply[1]; 2198 statuses = call->reply[1];
2197 if (xdr_decode_AFSFetchStatus(&bp, &statuses[call->count], 2199 if (xdr_decode_AFSFetchStatus(call, &bp, &statuses[call->count],
2198 call->count == 0 ? vnode : NULL, 2200 call->count == 0 ? vnode : NULL,
2199 NULL, NULL) < 0) 2201 NULL, NULL) < 0)
2200 return -EBADMSG; 2202 return afs_protocol_error(call, -EBADMSG);
2201 2203
2202 call->count++; 2204 call->count++;
2203 if (call->count < call->count2) 2205 if (call->count < call->count2)
@@ -2217,7 +2219,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
2217 tmp = ntohl(call->tmp); 2219 tmp = ntohl(call->tmp);
2218 _debug("CB count: %u", tmp); 2220 _debug("CB count: %u", tmp);
2219 if (tmp != call->count2) 2221 if (tmp != call->count2)
2220 return -EBADMSG; 2222 return afs_protocol_error(call, -EBADMSG);
2221 call->count = 0; 2223 call->count = 0;
2222 call->unmarshall++; 2224 call->unmarshall++;
2223 more_cbs: 2225 more_cbs:
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 3808dcbbac6d..06194cfe9724 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -82,7 +82,7 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key)
82 default: 82 default:
83 printk("kAFS: AFS vnode with undefined type\n"); 83 printk("kAFS: AFS vnode with undefined type\n");
84 read_sequnlock_excl(&vnode->cb_lock); 84 read_sequnlock_excl(&vnode->cb_lock);
85 return -EBADMSG; 85 return afs_protocol_error(NULL, -EBADMSG);
86 } 86 }
87 87
88 inode->i_blocks = 0; 88 inode->i_blocks = 0;
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 703ddb8c5d57..6ae023cbf00e 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -875,6 +875,7 @@ extern void afs_flat_call_destructor(struct afs_call *);
875extern void afs_send_empty_reply(struct afs_call *); 875extern void afs_send_empty_reply(struct afs_call *);
876extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); 876extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
877extern int afs_extract_data(struct afs_call *, void *, size_t, bool); 877extern int afs_extract_data(struct afs_call *, void *, size_t, bool);
878extern int afs_protocol_error(struct afs_call *, int);
878 879
879static inline int afs_transfer_reply(struct afs_call *call) 880static inline int afs_transfer_reply(struct afs_call *call)
880{ 881{
diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
index f7ae54b6a393..5c6263972ec9 100644
--- a/fs/afs/rxrpc.c
+++ b/fs/afs/rxrpc.c
@@ -926,3 +926,12 @@ int afs_extract_data(struct afs_call *call, void *buf, size_t count,
926 afs_set_call_complete(call, ret, remote_abort); 926 afs_set_call_complete(call, ret, remote_abort);
927 return ret; 927 return ret;
928} 928}
929
930/*
931 * Log protocol error production.
932 */
933noinline int afs_protocol_error(struct afs_call *call, int error)
934{
935 trace_afs_protocol_error(call, error, __builtin_return_address(0));
936 return error;
937}
diff --git a/fs/afs/vlclient.c b/fs/afs/vlclient.c
index f9d89795e41b..1ed7e2fd2f35 100644
--- a/fs/afs/vlclient.c
+++ b/fs/afs/vlclient.c
@@ -450,7 +450,7 @@ again:
450 call->count2 = ntohl(*bp); /* Type or next count */ 450 call->count2 = ntohl(*bp); /* Type or next count */
451 451
452 if (call->count > YFS_MAXENDPOINTS) 452 if (call->count > YFS_MAXENDPOINTS)
453 return -EBADMSG; 453 return afs_protocol_error(call, -EBADMSG);
454 454
455 alist = afs_alloc_addrlist(call->count, FS_SERVICE, AFS_FS_PORT); 455 alist = afs_alloc_addrlist(call->count, FS_SERVICE, AFS_FS_PORT);
456 if (!alist) 456 if (!alist)
@@ -474,7 +474,7 @@ again:
474 size = sizeof(__be32) * (1 + 4 + 1); 474 size = sizeof(__be32) * (1 + 4 + 1);
475 break; 475 break;
476 default: 476 default:
477 return -EBADMSG; 477 return afs_protocol_error(call, -EBADMSG);
478 } 478 }
479 479
480 size += sizeof(__be32); 480 size += sizeof(__be32);
@@ -487,18 +487,18 @@ again:
487 switch (call->count2) { 487 switch (call->count2) {
488 case YFS_ENDPOINT_IPV4: 488 case YFS_ENDPOINT_IPV4:
489 if (ntohl(bp[0]) != sizeof(__be32) * 2) 489 if (ntohl(bp[0]) != sizeof(__be32) * 2)
490 return -EBADMSG; 490 return afs_protocol_error(call, -EBADMSG);
491 afs_merge_fs_addr4(alist, bp[1], ntohl(bp[2])); 491 afs_merge_fs_addr4(alist, bp[1], ntohl(bp[2]));
492 bp += 3; 492 bp += 3;
493 break; 493 break;
494 case YFS_ENDPOINT_IPV6: 494 case YFS_ENDPOINT_IPV6:
495 if (ntohl(bp[0]) != sizeof(__be32) * 5) 495 if (ntohl(bp[0]) != sizeof(__be32) * 5)
496 return -EBADMSG; 496 return afs_protocol_error(call, -EBADMSG);
497 afs_merge_fs_addr6(alist, bp + 1, ntohl(bp[5])); 497 afs_merge_fs_addr6(alist, bp + 1, ntohl(bp[5]));
498 bp += 6; 498 bp += 6;
499 break; 499 break;
500 default: 500 default:
501 return -EBADMSG; 501 return afs_protocol_error(call, -EBADMSG);
502 } 502 }
503 503
504 /* Got either the type of the next entry or the count of 504 /* Got either the type of the next entry or the count of
@@ -517,7 +517,7 @@ again:
517 if (!call->count) 517 if (!call->count)
518 goto end; 518 goto end;
519 if (call->count > YFS_MAXENDPOINTS) 519 if (call->count > YFS_MAXENDPOINTS)
520 return -EBADMSG; 520 return afs_protocol_error(call, -EBADMSG);
521 521
522 call->unmarshall = 3; 522 call->unmarshall = 3;
523 523
@@ -545,7 +545,7 @@ again:
545 size = sizeof(__be32) * (1 + 4 + 1); 545 size = sizeof(__be32) * (1 + 4 + 1);
546 break; 546 break;
547 default: 547 default:
548 return -EBADMSG; 548 return afs_protocol_error(call, -EBADMSG);
549 } 549 }
550 550
551 if (call->count > 1) 551 if (call->count > 1)
@@ -558,16 +558,16 @@ again:
558 switch (call->count2) { 558 switch (call->count2) {
559 case YFS_ENDPOINT_IPV4: 559 case YFS_ENDPOINT_IPV4:
560 if (ntohl(bp[0]) != sizeof(__be32) * 2) 560 if (ntohl(bp[0]) != sizeof(__be32) * 2)
561 return -EBADMSG; 561 return afs_protocol_error(call, -EBADMSG);
562 bp += 3; 562 bp += 3;
563 break; 563 break;
564 case YFS_ENDPOINT_IPV6: 564 case YFS_ENDPOINT_IPV6:
565 if (ntohl(bp[0]) != sizeof(__be32) * 5) 565 if (ntohl(bp[0]) != sizeof(__be32) * 5)
566 return -EBADMSG; 566 return afs_protocol_error(call, -EBADMSG);
567 bp += 6; 567 bp += 6;
568 break; 568 break;
569 default: 569 default:
570 return -EBADMSG; 570 return afs_protocol_error(call, -EBADMSG);
571 } 571 }
572 572
573 /* Got either the type of the next entry or the count of 573 /* Got either the type of the next entry or the count of
diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h
index f46dee0f5ced..f0820554caa9 100644
--- a/include/trace/events/afs.h
+++ b/include/trace/events/afs.h
@@ -554,6 +554,27 @@ TRACE_EVENT(afs_edit_dir,
554 __entry->name) 554 __entry->name)
555 ); 555 );
556 556
557TRACE_EVENT(afs_protocol_error,
558 TP_PROTO(struct afs_call *call, int error, const void *where),
559
560 TP_ARGS(call, error, where),
561
562 TP_STRUCT__entry(
563 __field(unsigned int, call )
564 __field(int, error )
565 __field(const void *, where )
566 ),
567
568 TP_fast_assign(
569 __entry->call = call ? call->debug_id : 0;
570 __entry->error = error;
571 __entry->where = where;
572 ),
573
574 TP_printk("c=%08x r=%d sp=%pSR",
575 __entry->call, __entry->error, __entry->where)
576 );
577
557#endif /* _TRACE_AFS_H */ 578#endif /* _TRACE_AFS_H */
558 579
559/* This part must be outside protection */ 580/* This part must be outside protection */