]> rtime.felk.cvut.cz Git - can-utils.git/commitdiff
cangw: Print error message on misspelled interface
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 5 Feb 2014 15:48:18 +0000 (16:48 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 25 Aug 2016 14:13:54 +0000 (16:13 +0200)
If can interface is misspelled or the kernel is configured without netlink
cangw displayed only generic usage instruction. Now, an appropriate error
message is displayed.

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
cangw.c

diff --git a/cangw.c b/cangw.c
index ff76fd71b68a9c4c068aa214c627041c2802a7ca..f408993b235fd24563cc40e31d32bd451345dc07 100644 (file)
--- a/cangw.c
+++ b/cangw.c
@@ -602,10 +602,18 @@ int main(int argc, char **argv)
 
                case 's':
                        src_ifindex = if_nametoindex(optarg);
+                       if (src_ifindex == 0) {
+                               perror(optarg);
+                               return 1;
+                       }
                        break;
 
                case 'd':
                        dst_ifindex = if_nametoindex(optarg);
+                       if (dst_ifindex == 0) {
+                               perror(optarg);
+                               return 1;
+                       }
                        break;
 
                case 't':