Skip to content

Commit

Permalink
batman-adv: Warn about sysfs file access
Browse files Browse the repository at this point in the history
The sysfs files to read and modify the configuration settings were replaced
by the batadv generic netlink family. They are also marked as obsolete in
the ABI documentation. But not all users of this functionality might follow
changes in the Documentation/ABI/obsolete/ folder. They might benefit from
a warning messages about the deprecation of the functionality which they
just tried to access

  batman_adv: [Deprecated]: batctl (pid 30381) Use of sysfs file "orig_interval".
  Use batadv genl family instead

Signed-off-by: Sven Eckelmann <[email protected]>
Signed-off-by: Simon Wunderlich <[email protected]>
  • Loading branch information
ecsv authored and simonwunderlich committed Mar 25, 2019
1 parent 42cdd52 commit 1392f55
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions net/batman-adv/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "sysfs.h"
#include "main.h"

#include <asm/current.h>
#include <linux/atomic.h>
#include <linux/compiler.h>
#include <linux/device.h>
Expand All @@ -22,6 +23,7 @@
#include <linux/rculist.h>
#include <linux/rcupdate.h>
#include <linux/rtnetlink.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/stddef.h>
#include <linux/string.h>
Expand All @@ -40,6 +42,16 @@
#include "network-coding.h"
#include "soft-interface.h"

/**
* batadv_sysfs_deprecated() - Log use of deprecated batadv sysfs access
* @attr: attribute which was accessed
*/
static void batadv_sysfs_deprecated(struct attribute *attr)
{
pr_warn_ratelimited(DEPRECATED "%s (pid %d) Use of sysfs file \"%s\".\nUse batadv genl family instead",
current->comm, task_pid_nr(current), attr->name);
}

static struct net_device *batadv_kobj_to_netdev(struct kobject *obj)
{
struct device *dev = container_of(obj->parent, struct device, kobj);
Expand Down Expand Up @@ -129,6 +141,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
struct batadv_priv *bat_priv = netdev_priv(net_dev); \
ssize_t length; \
\
batadv_sysfs_deprecated(attr); \
length = __batadv_store_bool_attr(buff, count, _post_func, attr,\
&bat_priv->_name, net_dev); \
\
Expand All @@ -143,6 +156,7 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \
{ \
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \
\
batadv_sysfs_deprecated(attr); \
return sprintf(buff, "%s\n", \
atomic_read(&bat_priv->_name) == 0 ? \
"disabled" : "enabled"); \
Expand All @@ -166,6 +180,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
struct batadv_priv *bat_priv = netdev_priv(net_dev); \
ssize_t length; \
\
batadv_sysfs_deprecated(attr); \
length = __batadv_store_uint_attr(buff, count, _min, _max, \
_post_func, attr, \
&bat_priv->_var, net_dev, \
Expand All @@ -182,6 +197,7 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \
{ \
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \
\
batadv_sysfs_deprecated(attr); \
return sprintf(buff, "%i\n", atomic_read(&bat_priv->_var)); \
} \

Expand All @@ -206,6 +222,7 @@ ssize_t batadv_store_vlan_##_name(struct kobject *kobj, \
attr, &vlan->_name, \
bat_priv->soft_iface); \
\
batadv_sysfs_deprecated(attr); \
if (vlan->vid) \
batadv_netlink_notify_vlan(bat_priv, vlan); \
else \
Expand All @@ -226,6 +243,7 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \
atomic_read(&vlan->_name) == 0 ? \
"disabled" : "enabled"); \
\
batadv_sysfs_deprecated(attr); \
batadv_softif_vlan_put(vlan); \
return res; \
}
Expand All @@ -247,6 +265,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
struct batadv_priv *bat_priv; \
ssize_t length; \
\
batadv_sysfs_deprecated(attr); \
hard_iface = batadv_hardif_get_by_netdev(net_dev); \
if (!hard_iface) \
return 0; \
Expand Down Expand Up @@ -274,6 +293,7 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \
struct batadv_hard_iface *hard_iface; \
ssize_t length; \
\
batadv_sysfs_deprecated(attr); \
hard_iface = batadv_hardif_get_by_netdev(net_dev); \
if (!hard_iface) \
return 0; \
Expand Down Expand Up @@ -418,6 +438,7 @@ static ssize_t batadv_show_bat_algo(struct kobject *kobj,
{
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);

batadv_sysfs_deprecated(attr);
return sprintf(buff, "%s\n", bat_priv->algo_ops->name);
}

Expand All @@ -434,6 +455,8 @@ static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr,
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
int bytes_written;

batadv_sysfs_deprecated(attr);

/* GW mode is not available if the routing algorithm in use does not
* implement the GW API
*/
Expand Down Expand Up @@ -468,6 +491,8 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
char *curr_gw_mode_str;
int gw_mode_tmp = -1;

batadv_sysfs_deprecated(attr);

/* toggling GW mode is allowed only if the routing algorithm in use
* provides the GW API
*/
Expand Down Expand Up @@ -542,6 +567,8 @@ static ssize_t batadv_show_gw_sel_class(struct kobject *kobj,
{
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);

batadv_sysfs_deprecated(attr);

/* GW selection class is not available if the routing algorithm in use
* does not implement the GW API
*/
Expand All @@ -562,6 +589,8 @@ static ssize_t batadv_store_gw_sel_class(struct kobject *kobj,
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
ssize_t length;

batadv_sysfs_deprecated(attr);

/* setting the GW selection class is allowed only if the routing
* algorithm in use implements the GW API
*/
Expand Down Expand Up @@ -592,6 +621,8 @@ static ssize_t batadv_show_gw_bwidth(struct kobject *kobj,
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
u32 down, up;

batadv_sysfs_deprecated(attr);

down = atomic_read(&bat_priv->gw.bandwidth_down);
up = atomic_read(&bat_priv->gw.bandwidth_up);

Expand All @@ -607,6 +638,8 @@ static ssize_t batadv_store_gw_bwidth(struct kobject *kobj,
struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
ssize_t length;

batadv_sysfs_deprecated(attr);

if (buff[count - 1] == '\n')
buff[count - 1] = '\0';

Expand All @@ -631,6 +664,7 @@ static ssize_t batadv_show_isolation_mark(struct kobject *kobj,
{
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);

batadv_sysfs_deprecated(attr);
return sprintf(buff, "%#.8x/%#.8x\n", bat_priv->isolation_mark,
bat_priv->isolation_mark_mask);
}
Expand All @@ -654,6 +688,8 @@ static ssize_t batadv_store_isolation_mark(struct kobject *kobj,
u32 mark, mask;
char *mask_ptr;

batadv_sysfs_deprecated(attr);

/* parse the mask if it has been specified, otherwise assume the mask is
* the biggest possible
*/
Expand Down Expand Up @@ -909,6 +945,8 @@ static ssize_t batadv_show_mesh_iface(struct kobject *kobj,
ssize_t length;
const char *ifname;

batadv_sysfs_deprecated(attr);

hard_iface = batadv_hardif_get_by_netdev(net_dev);
if (!hard_iface)
return 0;
Expand Down Expand Up @@ -1013,6 +1051,8 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
struct batadv_store_mesh_work *store_work;

batadv_sysfs_deprecated(attr);

if (buff[count - 1] == '\n')
buff[count - 1] = '\0';

Expand Down Expand Up @@ -1044,6 +1084,8 @@ static ssize_t batadv_show_iface_status(struct kobject *kobj,
struct batadv_hard_iface *hard_iface;
ssize_t length;

batadv_sysfs_deprecated(attr);

hard_iface = batadv_hardif_get_by_netdev(net_dev);
if (!hard_iface)
return 0;
Expand Down Expand Up @@ -1095,6 +1137,8 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj,
u32 old_tp_override;
bool ret;

batadv_sysfs_deprecated(attr);

hard_iface = batadv_hardif_get_by_netdev(net_dev);
if (!hard_iface)
return -EINVAL;
Expand Down Expand Up @@ -1134,6 +1178,8 @@ static ssize_t batadv_show_throughput_override(struct kobject *kobj,
struct batadv_hard_iface *hard_iface;
u32 tp_override;

batadv_sysfs_deprecated(attr);

hard_iface = batadv_hardif_get_by_netdev(net_dev);
if (!hard_iface)
return -EINVAL;
Expand Down

0 comments on commit 1392f55

Please sign in to comment.