aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/bat_sysfs.c71
-rw-r--r--net/batman-adv/bat_sysfs.h2
-rw-r--r--net/batman-adv/main.h11
3 files changed, 84 insertions, 0 deletions
diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c
index 63738ec10511..cd15deba60a1 100644
--- a/net/batman-adv/bat_sysfs.c
+++ b/net/batman-adv/bat_sysfs.c
@@ -40,6 +40,20 @@ static struct bat_priv *kobj_to_batpriv(struct kobject *obj)
40 return netdev_priv(net_dev); 40 return netdev_priv(net_dev);
41} 41}
42 42
43#define UEV_TYPE_VAR "BATTYPE="
44#define UEV_ACTION_VAR "BATACTION="
45#define UEV_DATA_VAR "BATDATA="
46
47static char *uev_action_str[] = {
48 "add",
49 "del",
50 "change"
51};
52
53static char *uev_type_str[] = {
54 "gw"
55};
56
43/* Use this, if you have customized show and store functions */ 57/* Use this, if you have customized show and store functions */
44#define BAT_ATTR(_name, _mode, _show, _store) \ 58#define BAT_ATTR(_name, _mode, _show, _store) \
45struct bat_attribute bat_attr_##_name = { \ 59struct bat_attribute bat_attr_##_name = { \
@@ -601,3 +615,60 @@ void sysfs_del_hardif(struct kobject **hardif_obj)
601 kobject_put(*hardif_obj); 615 kobject_put(*hardif_obj);
602 *hardif_obj = NULL; 616 *hardif_obj = NULL;
603} 617}
618
619int throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
620 enum uev_action action, const char *data)
621{
622 int ret = -1;
623 struct hard_iface *primary_if = NULL;
624 struct kobject *bat_kobj;
625 char *uevent_env[4] = { NULL, NULL, NULL, NULL };
626
627 primary_if = primary_if_get_selected(bat_priv);
628 if (!primary_if)
629 goto out;
630
631 bat_kobj = &primary_if->soft_iface->dev.kobj;
632
633 uevent_env[0] = kmalloc(strlen(UEV_TYPE_VAR) +
634 strlen(uev_type_str[type]) + 1,
635 GFP_ATOMIC);
636 if (!uevent_env[0])
637 goto out;
638
639 sprintf(uevent_env[0], "%s%s", UEV_TYPE_VAR, uev_type_str[type]);
640
641 uevent_env[1] = kmalloc(strlen(UEV_ACTION_VAR) +
642 strlen(uev_action_str[action]) + 1,
643 GFP_ATOMIC);
644 if (!uevent_env[1])
645 goto out;
646
647 sprintf(uevent_env[1], "%s%s", UEV_ACTION_VAR, uev_action_str[action]);
648
649 /* If the event is DEL, ignore the data field */
650 if (action != UEV_DEL) {
651 uevent_env[2] = kmalloc(strlen(UEV_DATA_VAR) +
652 strlen(data) + 1, GFP_ATOMIC);
653 if (!uevent_env[2])
654 goto out;
655
656 sprintf(uevent_env[2], "%s%s", UEV_DATA_VAR, data);
657 }
658
659 ret = kobject_uevent_env(bat_kobj, KOBJ_CHANGE, uevent_env);
660out:
661 kfree(uevent_env[0]);
662 kfree(uevent_env[1]);
663 kfree(uevent_env[2]);
664
665 if (primary_if)
666 hardif_free_ref(primary_if);
667
668 if (ret)
669 bat_dbg(DBG_BATMAN, bat_priv, "Impossible to send "
670 "uevent for (%s,%s,%s) event (err: %d)\n",
671 uev_type_str[type], uev_action_str[action],
672 (action == UEV_DEL ? "NULL" : data), ret);
673 return ret;
674}
diff --git a/net/batman-adv/bat_sysfs.h b/net/batman-adv/bat_sysfs.h
index 02f1fa7aadfa..a3f75a723c56 100644
--- a/net/batman-adv/bat_sysfs.h
+++ b/net/batman-adv/bat_sysfs.h
@@ -38,5 +38,7 @@ int sysfs_add_meshif(struct net_device *dev);
38void sysfs_del_meshif(struct net_device *dev); 38void sysfs_del_meshif(struct net_device *dev);
39int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev); 39int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev);
40void sysfs_del_hardif(struct kobject **hardif_obj); 40void sysfs_del_hardif(struct kobject **hardif_obj);
41int throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
42 enum uev_action action, const char *data);
41 43
42#endif /* _NET_BATMAN_ADV_SYSFS_H_ */ 44#endif /* _NET_BATMAN_ADV_SYSFS_H_ */
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 8eae05e4dc1b..f9e0e174b3f6 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -91,6 +91,17 @@ enum mesh_state {
91#define BCAST_QUEUE_LEN 256 91#define BCAST_QUEUE_LEN 256
92#define BATMAN_QUEUE_LEN 256 92#define BATMAN_QUEUE_LEN 256
93 93
94
95enum uev_action {
96 UEV_ADD = 0,
97 UEV_DEL,
98 UEV_CHANGE
99};
100
101enum uev_type {
102 UEV_GW = 0
103};
104
94/* 105/*
95 * Debug Messages 106 * Debug Messages
96 */ 107 */