]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
canethgw: Better handling mismatched UDP messages
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 4 Apr 2014 18:43:35 +0000 (20:43 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 4 Apr 2014 18:43:35 +0000 (20:43 +0200)
Don't stop the gw, but print a message.

net/can/canethgw.c

index 532ce9540a9db78ea896835bf487c215de428df0..17fe0dc2a350ed9e52460265e93147aab0a32b40 100644 (file)
@@ -118,15 +118,21 @@ static int cegw_udp2can(void *data)
                vec[1].iov_len = sizeof(cf);
                ret = kernel_recvmsg(udp_sock, &mh, vec, 2,
                                     sizeof(type) + sizeof(cf), 0);
-               if (ret != sizeof(type) + sizeof(cf))
+               if (ret == 0)
                        break;
+               if (ret != sizeof(type) + sizeof(cf)) {
+                       pr_notice_ratelimited("canethgw: UDP length mismatch\n");
+                       continue;
+               }
 
                type = be16_to_cpu(type);
                switch (type) {
                case CAN_FRAME:
                        cf.can_id = be32_to_cpu(cf.can_id);
                        cegw_can_send(can_sock, &cf);
-               default:;
+                       break;
+               default:
+                       pr_notice_ratelimited("canethgw: Unknown message type\n");
                }
        }