Skip to content

Commit 7e6f461

Browse files
ecsvsimonwunderlich
authored andcommitted
batman-adv: Trigger genl notification on sysfs config change
The generic netlink code is expected to trigger notification messages when configuration might have been changed. But the configuration of batman-adv is most of the time still done using sysfs. So the sysfs interface should also trigger the corresponding netlink messages via the "config" multicast group. Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 9a18224 commit 7e6f461

File tree

3 files changed

+63
-16
lines changed

3 files changed

+63
-16
lines changed

net/batman-adv/netlink.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg,
385385
*
386386
* Return: 0 on success, < 0 on error
387387
*/
388-
static int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv)
388+
int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv)
389389
{
390390
struct sk_buff *msg;
391391
int ret;
@@ -852,8 +852,8 @@ static int batadv_netlink_hardif_fill(struct sk_buff *msg,
852852
*
853853
* Return: 0 on success, < 0 on error
854854
*/
855-
static int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv,
856-
struct batadv_hard_iface *hard_iface)
855+
int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv,
856+
struct batadv_hard_iface *hard_iface)
857857
{
858858
struct sk_buff *msg;
859859
int ret;
@@ -1057,8 +1057,8 @@ static int batadv_netlink_vlan_fill(struct sk_buff *msg,
10571057
*
10581058
* Return: 0 on success, < 0 on error
10591059
*/
1060-
static int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv,
1061-
struct batadv_softif_vlan *vlan)
1060+
int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv,
1061+
struct batadv_softif_vlan *vlan)
10621062
{
10631063
struct sk_buff *msg;
10641064
int ret;

net/batman-adv/netlink.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst,
3434
u8 result, u32 test_time, u64 total_bytes,
3535
u32 cookie);
3636

37+
int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv);
38+
int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv,
39+
struct batadv_hard_iface *hard_iface);
40+
int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv,
41+
struct batadv_softif_vlan *vlan);
42+
3743
extern struct genl_family batadv_netlink_family;
3844

3945
#endif /* _NET_BATMAN_ADV_NETLINK_H_ */

net/batman-adv/sysfs.c

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "gateway_common.h"
4949
#include "hard-interface.h"
5050
#include "log.h"
51+
#include "netlink.h"
5152
#include "network-coding.h"
5253
#include "soft-interface.h"
5354

@@ -154,9 +155,14 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
154155
{ \
155156
struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
156157
struct batadv_priv *bat_priv = netdev_priv(net_dev); \
158+
ssize_t length; \
159+
\
160+
length = __batadv_store_bool_attr(buff, count, _post_func, attr,\
161+
&bat_priv->_name, net_dev); \
157162
\
158-
return __batadv_store_bool_attr(buff, count, _post_func, attr, \
159-
&bat_priv->_name, net_dev); \
163+
batadv_netlink_notify_mesh(bat_priv); \
164+
\
165+
return length; \
160166
}
161167

162168
#define BATADV_ATTR_SIF_SHOW_BOOL(_name) \
@@ -186,11 +192,16 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
186192
{ \
187193
struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
188194
struct batadv_priv *bat_priv = netdev_priv(net_dev); \
195+
ssize_t length; \
189196
\
190-
return __batadv_store_uint_attr(buff, count, _min, _max, \
191-
_post_func, attr, \
192-
&bat_priv->_var, net_dev, \
193-
NULL); \
197+
length = __batadv_store_uint_attr(buff, count, _min, _max, \
198+
_post_func, attr, \
199+
&bat_priv->_var, net_dev, \
200+
NULL); \
201+
\
202+
batadv_netlink_notify_mesh(bat_priv); \
203+
\
204+
return length; \
194205
}
195206

196207
#define BATADV_ATTR_SIF_SHOW_UINT(_name, _var) \
@@ -223,6 +234,11 @@ ssize_t batadv_store_vlan_##_name(struct kobject *kobj, \
223234
attr, &vlan->_name, \
224235
bat_priv->soft_iface); \
225236
\
237+
if (vlan->vid) \
238+
batadv_netlink_notify_vlan(bat_priv, vlan); \
239+
else \
240+
batadv_netlink_notify_mesh(bat_priv); \
241+
\
226242
batadv_softif_vlan_put(vlan); \
227243
return res; \
228244
}
@@ -256,6 +272,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
256272
{ \
257273
struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
258274
struct batadv_hard_iface *hard_iface; \
275+
struct batadv_priv *bat_priv; \
259276
ssize_t length; \
260277
\
261278
hard_iface = batadv_hardif_get_by_netdev(net_dev); \
@@ -268,6 +285,11 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
268285
hard_iface->soft_iface, \
269286
net_dev); \
270287
\
288+
if (hard_iface->soft_iface) { \
289+
bat_priv = netdev_priv(hard_iface->soft_iface); \
290+
batadv_netlink_notify_hardif(bat_priv, hard_iface); \
291+
} \
292+
\
271293
batadv_hardif_put(hard_iface); \
272294
return length; \
273295
}
@@ -537,6 +559,9 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
537559
batadv_gw_check_client_stop(bat_priv);
538560
atomic_set(&bat_priv->gw.mode, (unsigned int)gw_mode_tmp);
539561
batadv_gw_tvlv_container_update(bat_priv);
562+
563+
batadv_netlink_notify_mesh(bat_priv);
564+
540565
return count;
541566
}
542567

@@ -563,6 +588,7 @@ static ssize_t batadv_store_gw_sel_class(struct kobject *kobj,
563588
size_t count)
564589
{
565590
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
591+
ssize_t length;
566592

567593
/* setting the GW selection class is allowed only if the routing
568594
* algorithm in use implements the GW API
@@ -578,10 +604,14 @@ static ssize_t batadv_store_gw_sel_class(struct kobject *kobj,
578604
return bat_priv->algo_ops->gw.store_sel_class(bat_priv, buff,
579605
count);
580606

581-
return __batadv_store_uint_attr(buff, count, 1, BATADV_TQ_MAX_VALUE,
582-
batadv_post_gw_reselect, attr,
583-
&bat_priv->gw.sel_class,
584-
bat_priv->soft_iface, NULL);
607+
length = __batadv_store_uint_attr(buff, count, 1, BATADV_TQ_MAX_VALUE,
608+
batadv_post_gw_reselect, attr,
609+
&bat_priv->gw.sel_class,
610+
bat_priv->soft_iface, NULL);
611+
612+
batadv_netlink_notify_mesh(bat_priv);
613+
614+
return length;
585615
}
586616

587617
static ssize_t batadv_show_gw_bwidth(struct kobject *kobj,
@@ -601,12 +631,18 @@ static ssize_t batadv_store_gw_bwidth(struct kobject *kobj,
601631
struct attribute *attr, char *buff,
602632
size_t count)
603633
{
634+
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
604635
struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
636+
ssize_t length;
605637

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

609-
return batadv_gw_bandwidth_set(net_dev, buff, count);
641+
length = batadv_gw_bandwidth_set(net_dev, buff, count);
642+
643+
batadv_netlink_notify_mesh(bat_priv);
644+
645+
return length;
610646
}
611647

612648
/**
@@ -674,6 +710,8 @@ static ssize_t batadv_store_isolation_mark(struct kobject *kobj,
674710
"New skb mark for extended isolation: %#.8x/%#.8x\n",
675711
bat_priv->isolation_mark, bat_priv->isolation_mark_mask);
676712

713+
batadv_netlink_notify_mesh(bat_priv);
714+
677715
return count;
678716
}
679717

@@ -1078,6 +1116,7 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj,
10781116
struct attribute *attr,
10791117
char *buff, size_t count)
10801118
{
1119+
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
10811120
struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
10821121
struct batadv_hard_iface *hard_iface;
10831122
u32 tp_override;
@@ -1108,6 +1147,8 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj,
11081147

11091148
atomic_set(&hard_iface->bat_v.throughput_override, tp_override);
11101149

1150+
batadv_netlink_notify_hardif(bat_priv, hard_iface);
1151+
11111152
out:
11121153
batadv_hardif_put(hard_iface);
11131154
return count;

0 commit comments

Comments
 (0)