trelay: log "started" and "stopped"
authorAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>
Wed, 25 Sep 2019 14:47:13 +0000 (17:47 +0300)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 12 Oct 2019 21:51:29 +0000 (23:51 +0200)
It is informative especially when using multiple device pairs.

Signed-off-by: Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>
package/kernel/trelay/src/trelay.c

index 3871ace070e7e83778f04c5395e5697a972b110c..1f147475971f2906bcf73c3654c504c5298b0c0f 100644 (file)
 #include <linux/rtnetlink.h>
 #include <linux/debugfs.h>
 
+#define trelay_log(loglevel, tr, fmt, ...) \
+       printk(loglevel "trelay: %s <-> %s: " fmt "\n", \
+               tr->dev1->name, tr->dev2->name, ##__VA_ARGS__);
+
 static LIST_HEAD(trelay_devs);
 static struct dentry *debugfs_dir;
 
@@ -71,6 +75,8 @@ static int trelay_do_remove(struct trelay *tr)
        netdev_rx_handler_unregister(tr->dev1);
        netdev_rx_handler_unregister(tr->dev2);
 
+       trelay_log(KERN_INFO, tr, "stopped");
+
        kfree(tr);
 
        return 0;
@@ -183,6 +189,8 @@ static int trelay_do_add(char *name, char *devn1, char *devn2)
        tr->dev2 = dev2;
        list_add_tail(&tr->list, &trelay_devs);
 
+       trelay_log(KERN_INFO, tr, "started");
+
        tr->debugfs = debugfs_create_dir(name, debugfs_dir);
        debugfs_create_file("remove", S_IWUSR, tr->debugfs, tr, &fops_remove);
        ret = 0;