pull request for net-next: batman-adv 2019-02-13
Subsystems (3)
Simon Wunderlich
maintainercover pull request for net-next: batman-adv 2019-02-13
Hi David,
here is another pull request for batman-adv to go into net-next. The main patchset is Svens netlink restructure series, which was also discussed on netdev for quite some time now and should be ready to be integrated.
Please pull or let me know of any problem!
Thank you,
Simon
The following changes since commit 7a79d717e0817610932ce3b7b6033ea06ee1d577:
batman-adv: Update copyright years for 2019 (2019-01-04 11:04:24 +0100)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20190213
for you to fetch changes up to 7e6f461efe2554e35b740f3faea2994fc9551947:
batman-adv: Trigger genl notification on sysfs config change (2019-02-09 14:28:15 +0100)
----------------------------------------------------------------
This feature/cleanup patchset includes the following patches:
- fix memory leak in in batadv_dat_put_dhcp, by Martin Weinelt
- fix typo, by Sven Eckelmann
- netlink restructuring patch series (part 2), by Sven Eckelmann (19 patches)
----------------------------------------------------------------
Martin Weinelt (1):
batman-adv: fix memory leak in in batadv_dat_put_dhcp
Sven Eckelmann (20):
batman-adv: Fix typo "reseved" -> "reserved"
batman-adv: Move common genl doit code pre/post hooks
batman-adv: Prepare framework for mesh genl config
batman-adv: Prepare framework for hardif genl config
batman-adv: Prepare framework for vlan genl config
batman-adv: Add aggregated_ogms mesh genl configuration
batman-adv: Add ap_isolation mesh/vlan genl configuration
batman-adv: Add bonding mesh genl configuration
batman-adv: Add bridge_loop_avoidance mesh genl configuration
batman-adv: Add distributed_arp_table mesh genl configuration
batman-adv: Add fragmentation mesh genl configuration
batman-adv: Add gateway mesh genl configuration
batman-adv: Add hop_penalty mesh genl configuration
batman-adv: Add log_level mesh genl configuration
batman-adv: Add multicast forceflood mesh genl configuration
batman-adv: Add network_coding mesh genl configuration
batman-adv: Add orig_interval mesh genl configuration
batman-adv: Add elp_interval hardif genl configuration
batman-adv: Add throughput_override hardif genl configuration
batman-adv: Trigger genl notification on sysfs config change
include/uapi/linux/batadv_packet.h | 2 +- include/uapi/linux/batman_adv.h | 190 +++++- net/batman-adv/distributed-arp-table.c | 2 + net/batman-adv/gateway_client.c | 1 - net/batman-adv/gateway_common.c | 1 + net/batman-adv/gateway_common.h | 6 - net/batman-adv/netlink.c | 1080 ++++++++++++++++++++++++++++---- net/batman-adv/netlink.h | 6 + net/batman-adv/soft-interface.c | 2 +- net/batman-adv/sysfs.c | 64 +- 10 files changed, 1206 insertions(+), 148 deletions(-)
Simon Wunderlich
maintainerPATCH 1/21 batman-adv: fix memory leak in in batadv_dat_put_dhcp
From: Martin Weinelt <[email protected]>
batadv_dat_put_dhcp is creating a new ARP packet via batadv_dat_arp_create_reply and tries to forward it via batadv_dat_send_data to different peers in the DHT. The original skb is not consumed by batadv_dat_send_data and thus has to be consumed by the caller.
--- net/batman-adv/distributed-arp-table.c | 2 ++ 1 file changed, 2 insertions(+)
net/batman-adv/distributed-arp-table.c +2 -0
@@ -1711,6 +1711,8 @@ static void batadv_dat_put_dhcp(struct batadv_priv *bat_priv, u8 *chaddr,batadv_dat_send_data (bat_priv, skb, yiaddr, vid,BATADV_P_DAT_DHT_PUT );batadv_dat_send_data (bat_priv, skb, ip_dst, vid,BATADV_P_DAT_DHT_PUT ); +consume_skb (skb); +batadv_dbg (BATADV_DBG_DAT , bat_priv,"Snooped from outgoing DHCPACK (server address): %pI4, %pM (vid: %i)\n" , &ip_dst, hw_dst,batadv_print_vid (vid));
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 2/21 batman-adv: Fix typo "reseved" -> "reserved"
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
checkpatch.pl complains since commit 45e417022023 ("scripts/spelling.txt:
add more spellings to spelling.txt") about an additional spelling mistake in batman-adv:`
CHECK: 'reseved' may be misspelled - perhaps 'reserved'? #232: FILE: include/uapi/linux/batadv_packet.h:232:
+ * @flags: reseved for routing relevant flags - currently always 0
--- include/uapi/linux/batadv_packet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/batadv_packet.h +1 -1
@@ -229,7 +229,7 @@ struct batadv_ogm_packet {* @packet_type: batman-adv packet type, part of the general header * @version: batman-adv protocol version, part of the general header * @ttl: time to live for this packet, part of the general header -* @flags: reseved for routing relevant flags - currently always 0 +* @flags: reserved for routing relevant flags - currently always 0 * @seqno: sequence number * @orig: originator mac address * @tvlv_len: length of the appended tvlv buffer (in bytes)
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 3/21 batman-adv: Move common genl doit code pre/post hooks
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The commit ff4c92d85c6f ("genetlink: introduce pre_doit/post_doit hooks") intoduced a mechanism to run specific code for doit hooks before/after the hooks are run. Since all doit hooks are requiring the batadv softif, it should be retrieved/freed in these helpers to simplify the code.
--- net/batman-adv/netlink.c | 143 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 100 insertions(+), 43 deletions(-)
net/batman-adv/netlink.c +100 -43
@@ -20,8 +20,10 @@#include "main.h" #include <linux/atomic.h> +#include <linux/bitops.h> #include <linux/byteorder/generic.h> #include <linux/cache.h> +#include <linux/err.h> #include <linux/errno.h> #include <linux/export.h> #include <linux/genetlink.h>
@@ -54,6 +56,8 @@#include "tp_meter.h" #include "translation-table.h" +struct net ; +struct genl_family batadv_netlink_family;/* multicast groups */
@@ -61,6 +65,18 @@ enum batadv_netlink_multicast_groups { BATADV_NL_MCGRP_TPMETER, }; +/** +* enum batadv_genl_ops_flags - flags for genl_ops's internal_flags +*/ +enum batadv_genl_ops_flags { +/** +* @BATADV_FLAG_NEED_MESH: request requires valid soft interface in +* attribute BATADV_ATTR_MESH_IFINDEX and expects a pointer to it to be +* saved in info->user_ptr[0] +*/ +BATADV_FLAG_NEED_MESH =BIT (0 ), +}; +static const struct genl_multicast_group batadv_netlink_mcgrps[] = { [BATADV_NL_MCGRP_TPMETER ] = { .name =BATADV_NL_MCAST_GROUP_TPMETER }, };
@@ -329,40 +345,24 @@ int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst,static int batadv_netlink_tp_meter_start (struct sk_buff *skb,struct genl_info *info) { -struct net *net =genl_info_net (info); -struct net_device *soft_iface; -struct batadv_priv *bat_priv; +struct batadv_priv *bat_priv = info->user_ptr[0 ];struct sk_buff *msg =NULL ;u32 test_length;void *msg_head; -int ifindex;u32 cookie;u8 *dst;int ret; -if (!info->attrs[BATADV_ATTR_MESH_IFINDEX ]) -return -EINVAL ; -if (!info->attrs[BATADV_ATTR_ORIG_ADDRESS ])return -EINVAL ;if (!info->attrs[BATADV_ATTR_TPMETER_TEST_TIME ])return -EINVAL ; - ifindex =nla_get_u32 (info->attrs[BATADV_ATTR_MESH_IFINDEX ]); -if (!ifindex) -return -EINVAL ; - dst =nla_data (info->attrs[BATADV_ATTR_ORIG_ADDRESS ]); test_length =nla_get_u32 (info->attrs[BATADV_ATTR_TPMETER_TEST_TIME ]); - soft_iface =dev_get_by_index (net, ifindex); -if (!soft_iface || !batadv_softif_is_valid (soft_iface)) { - ret = -ENODEV ; - goto out; - } - msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg) { ret = -ENOMEM ;
@@ -377,15 +377,11 @@ batadv_netlink_tp_meter_start(struct sk_buff *skb, struct genl_info *info) goto out; } - bat_priv =netdev_priv (soft_iface);batadv_tp_start (bat_priv, dst, test_length, &cookie); ret =batadv_netlink_tp_meter_put (msg, cookie); out: -if (soft_iface) -dev_put (soft_iface); -if (ret) {if (msg)nlmsg_free (msg);
@@ -406,38 +402,17 @@ batadv_netlink_tp_meter_start(struct sk_buff *skb, struct genl_info *info)static int batadv_netlink_tp_meter_cancel (struct sk_buff *skb,struct genl_info *info) { -struct net *net =genl_info_net (info); -struct net_device *soft_iface; -struct batadv_priv *bat_priv; -int ifindex; +struct batadv_priv *bat_priv = info->user_ptr[0 ];u8 *dst;int ret =0 ; -if (!info->attrs[BATADV_ATTR_MESH_IFINDEX ]) -return -EINVAL ; -if (!info->attrs[BATADV_ATTR_ORIG_ADDRESS ])return -EINVAL ; - ifindex =nla_get_u32 (info->attrs[BATADV_ATTR_MESH_IFINDEX ]); -if (!ifindex) -return -EINVAL ; - dst =nla_data (info->attrs[BATADV_ATTR_ORIG_ADDRESS ]); - soft_iface =dev_get_by_index (net, ifindex); -if (!soft_iface || !batadv_softif_is_valid (soft_iface)) { - ret = -ENODEV ; - goto out; - } - - bat_priv =netdev_priv (soft_iface);batadv_tp_stop (bat_priv, dst,BATADV_TP_REASON_CANCEL ); -out: -if (soft_iface) -dev_put (soft_iface); -return ret; }
@@ -545,6 +520,84 @@ batadv_netlink_dump_hardifs(struct sk_buff *msg, struct netlink_callback *cb)return msg->len; } +/** +* batadv_get_softif_from_info() - Retrieve soft interface from genl attributes +* @net: the applicable net namespace +* @info: receiver information +* +* Return: Pointer to soft interface (with increased refcnt) on success, error +* pointer on error +*/ +static struct net_device * +batadv_get_softif_from_info (struct net *net,struct genl_info *info) +{ +struct net_device *soft_iface; +int ifindex; + +if (!info->attrs[BATADV_ATTR_MESH_IFINDEX ]) +return ERR_PTR (-EINVAL ); + + ifindex =nla_get_u32 (info->attrs[BATADV_ATTR_MESH_IFINDEX ]); + + soft_iface =dev_get_by_index (net, ifindex); +if (!soft_iface) +return ERR_PTR (-ENODEV ); + +if (!batadv_softif_is_valid (soft_iface)) + goto err_put_softif; + +return soft_iface; + +err_put_softif: +dev_put (soft_iface); + +return ERR_PTR (-EINVAL ); +} + +/** +* batadv_pre_doit() - Prepare batman-adv genl doit request +* @ops: requested netlink operation +* @skb: Netlink message with request data +* @info: receiver information +* +* Return: 0 on success or negative error number in case of failure +*/ +static int batadv_pre_doit (const struct genl_ops *ops,struct sk_buff *skb, +struct genl_info *info) +{ +struct net *net =genl_info_net (info); +struct net_device *soft_iface; +struct batadv_priv *bat_priv; + +if (ops->internal_flags &BATADV_FLAG_NEED_MESH ) { + soft_iface =batadv_get_softif_from_info (net, info); +if (IS_ERR (soft_iface)) +return PTR_ERR (soft_iface); + + bat_priv =netdev_priv (soft_iface); + info->user_ptr[0 ] = bat_priv; + } + +return 0 ; +} + +/** +* batadv_post_doit() - End batman-adv genl doit request +* @ops: requested netlink operation +* @skb: Netlink message with request data +* @info: receiver information +*/ +static void batadv_post_doit (const struct genl_ops *ops,struct sk_buff *skb, +struct genl_info *info) +{ +struct batadv_priv *bat_priv; + +if (ops->internal_flags &BATADV_FLAG_NEED_MESH && info->user_ptr[0 ]) { + bat_priv = info->user_ptr[0 ]; +dev_put (bat_priv->soft_iface); + } +} +static const struct genl_ops batadv_netlink_ops[] = { { .cmd =BATADV_CMD_GET_MESH_INFO ,
@@ -557,12 +610,14 @@ static const struct genl_ops batadv_netlink_ops[] = { .flags = GENL_ADMIN_PERM, .policy = batadv_netlink_policy, .doit = batadv_netlink_tp_meter_start, + .internal_flags = BATADV_FLAG_NEED_MESH, }, { .cmd = BATADV_CMD_TP_METER_CANCEL, .flags = GENL_ADMIN_PERM, .policy = batadv_netlink_policy, .doit = batadv_netlink_tp_meter_cancel, + .internal_flags = BATADV_FLAG_NEED_MESH, }, { .cmd = BATADV_CMD_GET_ROUTING_ALGOS,
@@ -639,6 +694,8 @@ struct genl_family batadv_netlink_family __ro_after_init = { .version = 1, .maxattr = BATADV_ATTR_MAX, .netnsok = true, + .pre_doit = batadv_pre_doit, + .post_doit = batadv_post_doit, .module = THIS_MODULE, .ops = batadv_netlink_ops, .n_ops = ARRAY_SIZE(batadv_netlink_ops),
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 4/21 batman-adv: Prepare framework for mesh genl config
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The batman-adv configuration interface was implemented solely using sysfs. This approach was condemned by non-batadv developers as "huge mistake". Instead a netlink/genl based implementation was suggested.
The main objects for this configuration is the mesh/soft-interface object. Its actual object in memory already contains most of the available configuration settings. The genl interface reflects this by allowing to get/set it using the mesh specific commands.
The BATADV_CMD_GET_MESH_INFO (or short version BATADV_CMD_GET_MESH) is reused as get command because it already provides the content of other information from the mesh/soft-interface which are not yet configuration specific.
The set command BATADV_CMD_SET_MESH will also notify interested userspace listeners of the "config" mcast group using the BATADV_CMD_SET_MESH command message type that settings might have been changed and what the current values are.
--- include/uapi/linux/batman_adv.h | 16 +++- net/batman-adv/netlink.c | 160 ++++++++++++++++++++++++---------------- 2 files changed, 111 insertions(+), 65 deletions(-)
include/uapi/linux/batman_adv.h +13 -3
@@ -27,6 +27,7 @@#define BATADV_NL_NAME "batadv" +#define BATADV_NL_MCAST_GROUP_CONFIG "config"#define BATADV_NL_MCAST_GROUP_TPMETER "tpmeter"/**
@@ -372,10 +373,14 @@ enum batadv_nl_commands {BATADV_CMD_UNSPEC ,/** -* @BATADV_CMD_GET_MESH_INFO: Query basic information about batman-adv -* device +* @BATADV_CMD_GET_MESH: Get attributes from softif/mesh */ - BATADV_CMD_GET_MESH_INFO, +BATADV_CMD_GET_MESH , + +/** +* @BATADV_CMD_GET_MESH_INFO: Alias for @BATADV_CMD_GET_MESH +*/ + BATADV_CMD_GET_MESH_INFO = BATADV_CMD_GET_MESH,/** * @BATADV_CMD_TP_METER: Start a tp meter session
@@ -443,6 +448,11 @@ enum batadv_nl_commands {*/ BATADV_CMD_GET_MCAST_FLAGS , +/** +* @BATADV_CMD_SET_MESH: Set attributes for softif/mesh +*/ + BATADV_CMD_SET_MESH, +/* add new commands above here */ /**
net/batman-adv/netlink.c +98 -62
240 lines not on this page · raw message
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 5/21 batman-adv: Prepare framework for hardif genl config
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The batman-adv configuration interface was implemented solely using sysfs. This approach was condemned by non-batadv developers as "huge mistake". Instead a netlink/genl based implementation was suggested.
Beside the mesh/soft-interface specific configuration, the slave/hard-interface have B.A.T.M.A.N. V specific configuration settings. The genl interface reflects this by allowing to get/set it using the hard-interface specific commands.
The BATADV_CMD_GET_HARDIFS (or short version BATADV_CMD_GET_HARDIF) is reused as get command because it already allow sto dump the content of other information from the slave/hard-interface which are not yet configuration specific.
The set command BATADV_CMD_SET_HARDIF will also notify interested userspace listeners of the "config" mcast group using the BATADV_CMD_SET_HARDIF command message type that settings might have been changed and what the current values are.
--- include/uapi/linux/batman_adv.h | 16 ++- net/batman-adv/netlink.c | 240 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 233 insertions(+), 23 deletions(-)
include/uapi/linux/batman_adv.h +14 -2
@@ -398,9 +398,15 @@ enum batadv_nl_commands {BATADV_CMD_GET_ROUTING_ALGOS ,/** -* @BATADV_CMD_GET_HARDIFS: Query list of hard interfaces +* @BATADV_CMD_GET_HARDIF: Get attributes from a hardif of the +* current softif */ - BATADV_CMD_GET_HARDIFS, +BATADV_CMD_GET_HARDIF , + +/** +* @BATADV_CMD_GET_HARDIFS: Alias for @BATADV_CMD_GET_HARDIF +*/ + BATADV_CMD_GET_HARDIFS = BATADV_CMD_GET_HARDIF,/** * @BATADV_CMD_GET_TRANSTABLE_LOCAL: Query list of local translations
@@ -453,6 +459,12 @@ enum batadv_nl_commands {*/ BATADV_CMD_SET_MESH , +/** +* @BATADV_CMD_SET_HARDIF: Set attributes for hardif of the +* current softif +*/ + BATADV_CMD_SET_HARDIF, +/* add new commands above here */ /**
net/batman-adv/netlink.c +219 -21
343 lines not on this page · raw message
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 6/21 batman-adv: Prepare framework for vlan genl config
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The batman-adv configuration interface was implemented solely using sysfs. This approach was condemned by non-batadv developers as "huge mistake". Instead a netlink/genl based implementation was suggested.
Beside the mesh/soft-interface specific configuration, the VLANs on top of the mesh/soft-interface have configuration settings. The genl interface reflects this by allowing to get/set it using the vlan specific commands BATADV_CMD_GET_VLAN/BATADV_CMD_SET_VLAN.
The set command BATADV_CMD_SET_MESH will also notify interested userspace listeners of the "config" mcast group using the BATADV_CMD_SET_VLAN command message type that settings might have been changed and what the current values are.
--- include/uapi/linux/batman_adv.h | 17 ++++ net/batman-adv/netlink.c | 191 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 206 insertions(+), 2 deletions(-)
include/uapi/linux/batman_adv.h +17 -0
@@ -345,6 +345,11 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_MCAST_FLAGS_PRIV , +/** +* @BATADV_ATTR_VLANID: VLAN id on top of soft interface +*/ + BATADV_ATTR_VLANID, +/* add attributes above here, update the policy in netlink.c */ /**
@@ -465,6 +470,18 @@ enum batadv_nl_commands {*/ BATADV_CMD_SET_HARDIF , +/** +* @BATADV_CMD_GET_VLAN: Get attributes from a VLAN of the +* current softif +*/ +BATADV_CMD_GET_VLAN , + +/** +* @BATADV_CMD_SET_VLAN: Set attributes for VLAN of the +* current softif +*/ + BATADV_CMD_SET_VLAN, +/* add new commands above here */ /**
net/batman-adv/netlink.c +189 -2
259 lines not on this page · raw message
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 7/21 batman-adv: Add aggregated_ogms mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The mesh interface can delay OGM messages to aggregate different ogms together in a single OGM packet.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the BATADV_ATTR_AGGREGATED_OGMS_ENABLED attribute. Setting the u8 to zero will disable this feature and setting it to something else is enabling this feature.
--- include/uapi/linux/batman_adv.h | 6 ++++++ net/batman-adv/netlink.c | 12 ++++++++++++ 2 files changed, 18 insertions(+)
include/uapi/linux/batman_adv.h +6 -0
@@ -350,6 +350,12 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_VLANID , +/** +* @BATADV_ATTR_AGGREGATED_OGMS_ENABLED: whether the batman protocol +* messages of the mesh interface shall be aggregated or not. +*/ + BATADV_ATTR_AGGREGATED_OGMS_ENABLED, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +12 -0
@@ -139,6 +139,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_MCAST_FLAGS] = { .type = NLA_U32 }, [BATADV_ATTR_MCAST_FLAGS_PRIV] = { .type = NLA_U32 }, [BATADV_ATTR_VLANID] = { .type = NLA_U16 }, + [BATADV_ATTR_AGGREGATED_OGMS_ENABLED] = { .type = NLA_U8 }, };/**
@@ -214,6 +215,10 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, goto nla_put_failure; } +if (nla_put_u8 (msg,BATADV_ATTR_AGGREGATED_OGMS_ENABLED , + !!atomic_read (&bat_priv->aggregated_ogms))) + goto nla_put_failure; +if (primary_if)batadv_hardif_put (primary_if);
@@ -296,6 +301,13 @@ static int batadv_netlink_get_mesh(struct sk_buff *skb, struct genl_info *info)static int batadv_netlink_set_mesh (struct sk_buff *skb,struct genl_info *info) {struct batadv_priv *bat_priv = info->user_ptr[0 ]; +struct nlattr *attr; + +if (info->attrs[BATADV_ATTR_AGGREGATED_OGMS_ENABLED ]) { + attr = info->attrs[BATADV_ATTR_AGGREGATED_OGMS_ENABLED ]; + +atomic_set (&bat_priv->aggregated_ogms, !!nla_get_u8 (attr)); + }batadv_netlink_notify_mesh (bat_priv);
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 8/21 batman-adv: Add ap_isolation mesh/vlan genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The mesh interface can drop messages between clients to implement a mesh-wide AP isolation.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH and BATADV_CMD_SET_VLAN/BATADV_CMD_GET_VLAN commands allow to set/get the configuration of this feature using the BATADV_ATTR_AP_ISOLATION_ENABLED attribute. Setting the u8 to zero will disable this feature and setting it to something else is enabling this feature.
This feature also requires that skbuff which should be handled as isolated are marked. The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the mark/mask using the u32 attributes BATADV_ATTR_ISOLATION_MARK and BATADV_ATTR_ISOLATION_MASK.
--- include/uapi/linux/batman_adv.h | 19 +++++++++ net/batman-adv/netlink.c | 89 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+)
include/uapi/linux/batman_adv.h +19 -0
@@ -356,6 +356,25 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_AGGREGATED_OGMS_ENABLED , +/** +* @BATADV_ATTR_AP_ISOLATION_ENABLED: whether the data traffic going +* from a wireless client to another wireless client will be silently +* dropped. +*/ +BATADV_ATTR_AP_ISOLATION_ENABLED , + +/** +* @BATADV_ATTR_ISOLATION_MARK: the isolation mark which is used to +* classify clients as "isolated" by the Extended Isolation feature. +*/ +BATADV_ATTR_ISOLATION_MARK , + +/** +* @BATADV_ATTR_ISOLATION_MASK: the isolation (bit)mask which is used to +* classify clients as "isolated" by the Extended Isolation feature. +*/ +BATADV_ATTR_ISOLATION_MASK , +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +89 -0
125 lines not on this page · raw message
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 9/21 batman-adv: Add bonding mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The mesh interface can use multiple slave/hard-interface ports at the same time to transport the traffic to other nodes.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the BATADV_ATTR_BONDING_ENABLED attribute. Setting the u8 to zero will disable this feature and setting it to something else is enabling this feature.
--- include/uapi/linux/batman_adv.h | 6 ++++++ net/batman-adv/netlink.c | 11 +++++++++++ 2 files changed, 17 insertions(+)
include/uapi/linux/batman_adv.h +6 -0
@@ -375,6 +375,12 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_ISOLATION_MASK , +/** +* @BATADV_ATTR_BONDING_ENABLED: whether the data traffic going through +* the mesh will be sent using multiple interfaces at the same time. +*/ + BATADV_ATTR_BONDING_ENABLED, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +11 -0
@@ -143,6 +143,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_AP_ISOLATION_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_ISOLATION_MARK] = { .type = NLA_U32 }, [BATADV_ATTR_ISOLATION_MASK] = { .type = NLA_U32 }, + [BATADV_ATTR_BONDING_ENABLED] = { .type = NLA_U8 }, };/**
@@ -279,6 +280,10 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, bat_priv->isolation_mark_mask)) goto nla_put_failure; +if (nla_put_u8 (msg,BATADV_ATTR_BONDING_ENABLED , + !!atomic_read (&bat_priv->bonding))) + goto nla_put_failure; +if (primary_if)batadv_hardif_put (primary_if);
@@ -387,6 +392,12 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info) bat_priv->isolation_mark_mask =nla_get_u32 (attr); } +if (info->attrs[BATADV_ATTR_BONDING_ENABLED ]) { + attr = info->attrs[BATADV_ATTR_BONDING_ENABLED ]; + +atomic_set (&bat_priv->bonding, !!nla_get_u8 (attr)); + } +batadv_netlink_notify_mesh (bat_priv);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 10/21 batman-adv: Add bridge_loop_avoidance mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The mesh interface can try to detect loops in the same mesh caused by (indirectly) bridged mesh/soft-interfaces of different nodes. Some of the loops can also be resolved without breaking the mesh.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED attribute. Setting the u8 to zero will disable this feature and setting it to something else is enabling this feature.
--- include/uapi/linux/batman_adv.h | 7 +++++++ net/batman-adv/netlink.c | 17 +++++++++++++++++ 2 files changed, 24 insertions(+)
include/uapi/linux/batman_adv.h +7 -0
@@ -381,6 +381,13 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_BONDING_ENABLED , +/** +* @BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED: whether the bridge loop +* avoidance feature is enabled. This feature detects and avoids loops +* between the mesh and devices bridged with the soft interface +*/ + BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +17 -0
@@ -144,6 +144,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_ISOLATION_MARK] = { .type = NLA_U32 }, [BATADV_ATTR_ISOLATION_MASK] = { .type = NLA_U32 }, [BATADV_ATTR_BONDING_ENABLED] = { .type = NLA_U8 }, + [BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED] = { .type = NLA_U8 }, };/**
@@ -284,6 +285,12 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, !!atomic_read(&bat_priv->bonding))) goto nla_put_failure; +#ifdef CONFIG_BATMAN_ADV_BLA +if (nla_put_u8 (msg,BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED , + !!atomic_read (&bat_priv->bridge_loop_avoidance))) + goto nla_put_failure; +#endif /* CONFIG_BATMAN_ADV_BLA */ +if (primary_if)batadv_hardif_put (primary_if);
@@ -398,6 +405,16 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info)atomic_set (&bat_priv->bonding, !!nla_get_u8 (attr)); } +#ifdef CONFIG_BATMAN_ADV_BLA +if (info->attrs[BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED ]) { + attr = info->attrs[BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED ]; + +atomic_set (&bat_priv->bridge_loop_avoidance, + !!nla_get_u8 (attr)); +batadv_bla_status_update (bat_priv->soft_iface); + } +#endif /* CONFIG_BATMAN_ADV_BLA */ +batadv_netlink_notify_mesh (bat_priv);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 11/21 batman-adv: Add distributed_arp_table mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The mesh interface can use a distributed hash table to answer ARP requests without flooding the request through the whole mesh.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED attribute. Setting the u8 to zero will disable this feature and setting it to something else is enabling this feature.
--- include/uapi/linux/batman_adv.h | 8 ++++++++ net/batman-adv/netlink.c | 17 +++++++++++++++++ 2 files changed, 25 insertions(+)
include/uapi/linux/batman_adv.h +8 -0
@@ -388,6 +388,14 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED , +/** +* @BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED: whether the distributed +* arp table feature is enabled. This feature uses a distributed hash +* table to answer ARP requests without flooding the request through +* the whole mesh. +*/ + BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +17 -0
@@ -145,6 +145,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_ISOLATION_MASK] = { .type = NLA_U32 }, [BATADV_ATTR_BONDING_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED] = { .type = NLA_U8 }, + [BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED] = { .type = NLA_U8 }, };/**
@@ -291,6 +292,12 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, goto nla_put_failure;#endif /* CONFIG_BATMAN_ADV_BLA */ +#ifdef CONFIG_BATMAN_ADV_DAT +if (nla_put_u8 (msg,BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED , + !!atomic_read (&bat_priv->distributed_arp_table))) + goto nla_put_failure; +#endif /* CONFIG_BATMAN_ADV_DAT */ +if (primary_if)batadv_hardif_put (primary_if);
@@ -415,6 +422,16 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info) }#endif /* CONFIG_BATMAN_ADV_BLA */ +#ifdef CONFIG_BATMAN_ADV_DAT +if (info->attrs[BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED ]) { + attr = info->attrs[BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED ]; + +atomic_set (&bat_priv->distributed_arp_table, + !!nla_get_u8 (attr)); +batadv_dat_status_update (bat_priv->soft_iface); + } +#endif /* CONFIG_BATMAN_ADV_DAT */ +batadv_netlink_notify_mesh (bat_priv);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 12/21 batman-adv: Add fragmentation mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The mesh interface can fragment unicast packets when the packet size exceeds the outgoing slave/hard-interface MTU.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the BATADV_ATTR_FRAGMENTATION_ENABLED attribute. Setting the u8 to zero will disable this feature and setting it to something else is enabling this feature.
--- include/uapi/linux/batman_adv.h | 7 +++++++ net/batman-adv/netlink.c | 12 ++++++++++++ 2 files changed, 19 insertions(+)
include/uapi/linux/batman_adv.h +7 -0
@@ -396,6 +396,13 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED , +/** +* @BATADV_ATTR_FRAGMENTATION_ENABLED: whether the data traffic going +* through the mesh will be fragmented or silently discarded if the +* packet size exceeds the outgoing interface MTU. +*/ + BATADV_ATTR_FRAGMENTATION_ENABLED, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +12 -0
@@ -146,6 +146,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_BONDING_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED] = { .type = NLA_U8 }, + [BATADV_ATTR_FRAGMENTATION_ENABLED] = { .type = NLA_U8 }, };/**
@@ -298,6 +299,10 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, goto nla_put_failure;#endif /* CONFIG_BATMAN_ADV_DAT */ +if (nla_put_u8 (msg,BATADV_ATTR_FRAGMENTATION_ENABLED , + !!atomic_read (&bat_priv->fragmentation))) + goto nla_put_failure; +if (primary_if)batadv_hardif_put (primary_if);
@@ -432,6 +437,13 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info) }#endif /* CONFIG_BATMAN_ADV_DAT */ +if (info->attrs[BATADV_ATTR_FRAGMENTATION_ENABLED ]) { + attr = info->attrs[BATADV_ATTR_FRAGMENTATION_ENABLED ]; + +atomic_set (&bat_priv->fragmentation, !!nla_get_u8 (attr)); +batadv_update_min_mtu (bat_priv->soft_iface); + } +batadv_netlink_notify_mesh (bat_priv);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 13/21 batman-adv: Add gateway mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The mesh/soft-interface can optimize the handling of DHCP packets. Instead of flooding them through the whole mesh, it can be forwarded as unicast to a specific gateway server. The originator which injects the packets in the mesh has to select (based on sel_class thresholds) a responsible gateway server. This is done by switching this originator to the gw_mode client. The servers announce their forwarding bandwidth (download/upload) when the gw_mode server was selected.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the attributes:
* u8 BATADV_ATTR_GW_MODE (0 == off, 1 == client, 2 == server)
* u32 BATADV_ATTR_GW_BANDWIDTH_DOWN (in 100 kbit/s steps)
* u32 BATADV_ATTR_GW_BANDWIDTH_UP (in 100 kbit/s steps)
* u32 BATADV_ATTR_GW_SEL_CLASS
--- include/uapi/linux/batman_adv.h | 40 ++++++++++++++++++ net/batman-adv/gateway_client.c | 1 - net/batman-adv/gateway_common.c | 1 + net/batman-adv/gateway_common.h | 6 --- net/batman-adv/netlink.c | 92 +++++++++++++++++++++++++++++++++++++++++ net/batman-adv/soft-interface.c | 2 +- net/batman-adv/sysfs.c | 1 + 7 files changed, 135 insertions(+), 8 deletions(-)
include/uapi/linux/batman_adv.h +40 -0
@@ -140,6 +140,20 @@ enum batadv_mcast_flags_priv { };/** +* enum batadv_gw_modes - gateway mode of node +*/ +enum batadv_gw_modes { +/** @BATADV_GW_MODE_OFF: gw mode disabled */ +BATADV_GW_MODE_OFF , + +/** @BATADV_GW_MODE_CLIENT: send DHCP requests to gw servers */ +BATADV_GW_MODE_CLIENT , + +/** @BATADV_GW_MODE_SERVER: announce itself as gatway server */ +BATADV_GW_MODE_SERVER , +}; + +/** * enum batadv_nl_attrs - batman-adv netlink attributes */ enum batadv_nl_attrs {
@@ -403,6 +417,32 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_FRAGMENTATION_ENABLED , +/** +* @BATADV_ATTR_GW_BANDWIDTH_DOWN: defines the download bandwidth which +* is propagated by this node if %BATADV_ATTR_GW_BANDWIDTH_MODE was set +* to 'server'. +*/ +BATADV_ATTR_GW_BANDWIDTH_DOWN , + +/** +* @BATADV_ATTR_GW_BANDWIDTH_UP: defines the upload bandwidth which +* is propagated by this node if %BATADV_ATTR_GW_BANDWIDTH_MODE was set +* to 'server'. +*/ +BATADV_ATTR_GW_BANDWIDTH_UP , + +/** +* @BATADV_ATTR_GW_MODE: defines the state of the gateway features. +* Possible values are specified in enum batadv_gw_modes +*/ +BATADV_ATTR_GW_MODE , + +/** +* @BATADV_ATTR_GW_SEL_CLASS: defines the selection criteria this node +* will use to choose a gateway if gw_mode was set to 'client'. +*/ +BATADV_ATTR_GW_SEL_CLASS , +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/gateway_client.c +0 -1
@@ -47,7 +47,6 @@#include <uapi/linux/batadv_packet.h> #include <uapi/linux/batman_adv.h> -#include "gateway_common.h" #include "hard-interface.h" #include "log.h" #include "netlink.h"
net/batman-adv/gateway_common.c +1 -0
@@ -28,6 +28,7 @@#include <linux/stddef.h> #include <linux/string.h> #include <uapi/linux/batadv_packet.h> +#include <uapi/linux/batman_adv.h> #include "gateway_client.h" #include "log.h"
net/batman-adv/gateway_common.h +0 -6
@@ -25,12 +25,6 @@struct net_device ; -enum batadv_gw_modes { -BATADV_GW_MODE_OFF , -BATADV_GW_MODE_CLIENT , -BATADV_GW_MODE_SERVER , -}; -/** * enum batadv_bandwidth_units - bandwidth unit types */
net/batman-adv/netlink.c +92 -0
116 lines not on this page · raw message
net/batman-adv/soft-interface.c +1 -1
@@ -50,13 +50,13 @@#include <linux/string.h> #include <linux/types.h> #include <uapi/linux/batadv_packet.h> +#include <uapi/linux/batman_adv.h> #include "bat_algo.h" #include "bridge_loop_avoidance.h" #include "debugfs.h" #include "distributed-arp-table.h" #include "gateway_client.h" -#include "gateway_common.h" #include "hard-interface.h" #include "multicast.h" #include "network-coding.h"
net/batman-adv/sysfs.c +1 -0
@@ -40,6 +40,7 @@#include <linux/stringify.h> #include <linux/workqueue.h> #include <uapi/linux/batadv_packet.h> +#include <uapi/linux/batman_adv.h> #include "bridge_loop_avoidance.h" #include "distributed-arp-table.h"
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 14/21 batman-adv: Add hop_penalty mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The TQ (B.A.T.M.A.N. IV) and throughput values (B.A.T.M.A.N. V) are reduced when they are forwarded. One of the reductions is the penalty for traversing an additional hop. This hop_penalty (0-255) defines the percentage of reduction (0-100%).
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the u8 BATADV_ATTR_HOP_PENALTY attribute.
--- include/uapi/linux/batman_adv.h | 6 ++++++ net/batman-adv/netlink.c | 11 +++++++++++ 2 files changed, 17 insertions(+)
include/uapi/linux/batman_adv.h +6 -0
@@ -443,6 +443,12 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_GW_SEL_CLASS , +/** +* @BATADV_ATTR_HOP_PENALTY: defines the penalty which will be applied +* to an originator message's tq-field on every hop. +*/ + BATADV_ATTR_HOP_PENALTY, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +11 -0
@@ -152,6 +152,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_GW_BANDWIDTH_UP] = { .type = NLA_U32 }, [BATADV_ATTR_GW_MODE] = { .type = NLA_U8 }, [BATADV_ATTR_GW_SEL_CLASS] = { .type = NLA_U32 }, + [BATADV_ATTR_HOP_PENALTY] = { .type = NLA_U8 }, };/**
@@ -330,6 +331,10 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, goto nla_put_failure; } +if (nla_put_u8 (msg,BATADV_ATTR_HOP_PENALTY , +atomic_read (&bat_priv->hop_penalty))) + goto nla_put_failure; +if (primary_if)batadv_hardif_put (primary_if);
@@ -536,6 +541,12 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info) } } +if (info->attrs[BATADV_ATTR_HOP_PENALTY ]) { + attr = info->attrs[BATADV_ATTR_HOP_PENALTY ]; + +atomic_set (&bat_priv->hop_penalty,nla_get_u8 (attr)); + } +batadv_netlink_notify_mesh (bat_priv);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 15/21 batman-adv: Add log_level mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
In contrast to other modules, batman-adv allows to set the debug message verbosity per mesh/soft-interface and not per module (via modparam).
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the u32 (bitmask) BATADV_ATTR_LOG_LEVEL attribute.
--- include/uapi/linux/batman_adv.h | 6 ++++++ net/batman-adv/netlink.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+)
include/uapi/linux/batman_adv.h +6 -0
@@ -449,6 +449,12 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_HOP_PENALTY , +/** +* @BATADV_ATTR_LOG_LEVEL: bitmask with to define which debug messages +* should be send to the debug log/trace ring buffer +*/ + BATADV_ATTR_LOG_LEVEL, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +17 -0
@@ -53,6 +53,7 @@#include "gateway_client.h" #include "gateway_common.h" #include "hard-interface.h" +#include "log.h" #include "multicast.h" #include "originator.h" #include "soft-interface.h"
@@ -153,6 +154,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_GW_MODE] = { .type = NLA_U8 }, [BATADV_ATTR_GW_SEL_CLASS] = { .type = NLA_U32 }, [BATADV_ATTR_HOP_PENALTY] = { .type = NLA_U8 }, + [BATADV_ATTR_LOG_LEVEL] = { .type = NLA_U32 }, };/**
@@ -335,6 +337,12 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, atomic_read(&bat_priv->hop_penalty))) goto nla_put_failure; +#ifdef CONFIG_BATMAN_ADV_DEBUG +if (nla_put_u32 (msg,BATADV_ATTR_LOG_LEVEL , +atomic_read (&bat_priv->log_level))) + goto nla_put_failure; +#endif /* CONFIG_BATMAN_ADV_DEBUG */ +if (primary_if)batadv_hardif_put (primary_if);
@@ -547,6 +555,15 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info)atomic_set (&bat_priv->hop_penalty,nla_get_u8 (attr)); } +#ifdef CONFIG_BATMAN_ADV_DEBUG +if (info->attrs[BATADV_ATTR_LOG_LEVEL ]) { + attr = info->attrs[BATADV_ATTR_LOG_LEVEL ]; + +atomic_set (&bat_priv->log_level, +nla_get_u32 (attr) &BATADV_DBG_ALL ); + } +#endif /* CONFIG_BATMAN_ADV_DEBUG */ +batadv_netlink_notify_mesh (bat_priv);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 16/21 batman-adv: Add multicast forceflood mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The mesh interface can optimize the flooding of multicast packets based on the content of the global translation tables. To disable this behavior and use the broadcast-like flooding of the packets, forceflood has to be enabled.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED attribute. Setting the u8 to zero will disable this feature (allowing multicast optimizations) and setting it to something else is enabling this feature (forcing simple flooding).
--- include/uapi/linux/batman_adv.h | 9 +++++++++ net/batman-adv/netlink.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+)
include/uapi/linux/batman_adv.h +9 -0
@@ -455,6 +455,15 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_LOG_LEVEL , +/** +* @BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED: whether multicast +* optimizations should be replaced by simple broadcast-like flooding +* of multicast packets. If set to non-zero then all nodes in the mesh +* are going to use classic flooding for any multicast packet with no +* optimizations. +*/ + BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +15 -0
@@ -155,6 +155,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_GW_SEL_CLASS] = { .type = NLA_U32 }, [BATADV_ATTR_HOP_PENALTY] = { .type = NLA_U8 }, [BATADV_ATTR_LOG_LEVEL] = { .type = NLA_U32 }, + [BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED] = { .type = NLA_U8 }, };/**
@@ -343,6 +344,12 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, goto nla_put_failure;#endif /* CONFIG_BATMAN_ADV_DEBUG */ +#ifdef CONFIG_BATMAN_ADV_MCAST +if (nla_put_u8 (msg,BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED , + !atomic_read (&bat_priv->multicast_mode))) + goto nla_put_failure; +#endif /* CONFIG_BATMAN_ADV_MCAST */ +if (primary_if)batadv_hardif_put (primary_if);
@@ -564,6 +571,14 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info) }#endif /* CONFIG_BATMAN_ADV_DEBUG */ +#ifdef CONFIG_BATMAN_ADV_MCAST +if (info->attrs[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED ]) { + attr = info->attrs[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED ]; + +atomic_set (&bat_priv->multicast_mode, !nla_get_u8 (attr)); + } +#endif /* CONFIG_BATMAN_ADV_MCAST */ +batadv_netlink_notify_mesh (bat_priv);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 17/21 batman-adv: Add network_coding mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The mesh interface can use (in an homogeneous mesh) network coding, a mechanism that aims to increase the overall network throughput by fusing multiple packets in one transmission.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the BATADV_ATTR_NETWORK_CODING_ENABLED attribute. Setting the u8 to zero will disable this feature and setting it to something else is enabling this feature.
--- include/uapi/linux/batman_adv.h | 7 +++++++ net/batman-adv/netlink.c | 17 +++++++++++++++++ 2 files changed, 24 insertions(+)
include/uapi/linux/batman_adv.h +7 -0
@@ -464,6 +464,13 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED , +/** +* @BATADV_ATTR_NETWORK_CODING_ENABLED: whether Network Coding (using +* some magic to send fewer wifi packets but still the same content) is +* enabled or not. +*/ + BATADV_ATTR_NETWORK_CODING_ENABLED, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +17 -0
@@ -55,6 +55,7 @@#include "hard-interface.h" #include "log.h" #include "multicast.h" +#include "network-coding.h" #include "originator.h" #include "soft-interface.h" #include "tp_meter.h"
@@ -156,6 +157,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_HOP_PENALTY] = { .type = NLA_U8 }, [BATADV_ATTR_LOG_LEVEL] = { .type = NLA_U32 }, [BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED] = { .type = NLA_U8 }, + [BATADV_ATTR_NETWORK_CODING_ENABLED] = { .type = NLA_U8 }, };/**
@@ -350,6 +352,12 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, goto nla_put_failure;#endif /* CONFIG_BATMAN_ADV_MCAST */ +#ifdef CONFIG_BATMAN_ADV_NC +if (nla_put_u8 (msg,BATADV_ATTR_NETWORK_CODING_ENABLED , + !!atomic_read (&bat_priv->network_coding))) + goto nla_put_failure; +#endif /* CONFIG_BATMAN_ADV_NC */ +if (primary_if)batadv_hardif_put (primary_if);
@@ -579,6 +587,15 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info) }#endif /* CONFIG_BATMAN_ADV_MCAST */ +#ifdef CONFIG_BATMAN_ADV_NC +if (info->attrs[BATADV_ATTR_NETWORK_CODING_ENABLED ]) { + attr = info->attrs[BATADV_ATTR_NETWORK_CODING_ENABLED ]; + +atomic_set (&bat_priv->network_coding, !!nla_get_u8 (attr)); +batadv_nc_status_update (bat_priv->soft_iface); + } +#endif /* CONFIG_BATMAN_ADV_NC */ +batadv_netlink_notify_mesh (bat_priv);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 18/21 batman-adv: Add orig_interval mesh genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The OGM packets are transmitted every orig_interval milliseconds. This value can be changed using the configuration interface.
The BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH commands allow to set/get the configuration of this feature using the u32 BATADV_ATTR_ORIG_INTERVAL attribute.
--- include/uapi/linux/batman_adv.h | 6 ++++++ net/batman-adv/netlink.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+)
include/uapi/linux/batman_adv.h +6 -0
@@ -471,6 +471,12 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_NETWORK_CODING_ENABLED , +/** +* @BATADV_ATTR_ORIG_INTERVAL: defines the interval in milliseconds in +* which batman sends its protocol messages. +*/ + BATADV_ATTR_ORIG_INTERVAL, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +17 -0
@@ -158,6 +158,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_LOG_LEVEL] = { .type = NLA_U32 }, [BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_NETWORK_CODING_ENABLED] = { .type = NLA_U8 }, + [BATADV_ATTR_ORIG_INTERVAL] = { .type = NLA_U32 }, };/**
@@ -358,6 +359,10 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, goto nla_put_failure;#endif /* CONFIG_BATMAN_ADV_NC */ +if (nla_put_u32 (msg,BATADV_ATTR_ORIG_INTERVAL , +atomic_read (&bat_priv->orig_interval))) + goto nla_put_failure; +if (primary_if)batadv_hardif_put (primary_if);
@@ -596,6 +601,18 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info) }#endif /* CONFIG_BATMAN_ADV_NC */ +if (info->attrs[BATADV_ATTR_ORIG_INTERVAL ]) { +u32 orig_interval; + + attr = info->attrs[BATADV_ATTR_ORIG_INTERVAL ]; + orig_interval =nla_get_u32 (attr); + + orig_interval =min_t (u32, orig_interval,INT_MAX ); + orig_interval =max_t (u32, orig_interval,2 *BATADV_JITTER ); + +atomic_set (&bat_priv->orig_interval, orig_interval); + } +batadv_netlink_notify_mesh (bat_priv);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 19/21 batman-adv: Add elp_interval hardif genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The ELP packets are transmitted every elp_interval milliseconds on an slave/hard-interface. This value can be changed using the configuration interface.
The BATADV_CMD_SET_HARDIF/BATADV_CMD_GET_HARDIF commands allow to set/get the configuration of this feature using the u32 BATADV_ATTR_ELP_INTERVAL attribute.
--- include/uapi/linux/batman_adv.h | 6 ++++++ net/batman-adv/netlink.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+)
include/uapi/linux/batman_adv.h +6 -0
@@ -477,6 +477,12 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_ORIG_INTERVAL , +/** +* @BATADV_ATTR_ELP_INTERVAL: defines the interval in milliseconds in +* which batman emits probing packets for neighbor sensing (ELP). +*/ + BATADV_ATTR_ELP_INTERVAL, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +17 -0
@@ -159,6 +159,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_NETWORK_CODING_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_ORIG_INTERVAL] = { .type = NLA_U32 }, + [BATADV_ATTR_ELP_INTERVAL] = { .type = NLA_U32 }, };/**
@@ -825,6 +826,12 @@ static int batadv_netlink_hardif_fill(struct sk_buff *msg, goto nla_put_failure; } +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +if (nla_put_u32 (msg,BATADV_ATTR_ELP_INTERVAL , +atomic_read (&hard_iface->bat_v.elp_interval))) + goto nla_put_failure; +#endif /* CONFIG_BATMAN_ADV_BATMAN_V */ +genlmsg_end (msg, hdr);return 0 ;
@@ -910,6 +917,16 @@ static int batadv_netlink_set_hardif(struct sk_buff *skb,struct batadv_hard_iface *hard_iface = info->user_ptr[1 ];struct batadv_priv *bat_priv = info->user_ptr[0 ]; +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +struct nlattr *attr; + +if (info->attrs[BATADV_ATTR_ELP_INTERVAL ]) { + attr = info->attrs[BATADV_ATTR_ELP_INTERVAL ]; + +atomic_set (&hard_iface->bat_v.elp_interval,nla_get_u32 (attr)); + } +#endif /* CONFIG_BATMAN_ADV_BATMAN_V */ +batadv_netlink_notify_hardif (bat_priv, hard_iface);return 0 ;
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 20/21 batman-adv: Add throughput_override hardif genl configuration
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The B.A.T.M.A.N. V implementation tries to estimate the link throughput of an interface to an originator using different automatic methods. It is still possible to overwrite it the link throughput for all reachable originators via this interface.
The BATADV_CMD_SET_HARDIF/BATADV_CMD_GET_HARDIF commands allow to set/get the configuration of this feature using the u32 BATADV_ATTR_THROUGHPUT_OVERRIDE attribute. The used unit is in 100 Kbit/s. If the value is set to 0 then batman-adv will try to estimate the throughput by itself.
--- include/uapi/linux/batman_adv.h | 8 ++++++++ net/batman-adv/netlink.c | 12 ++++++++++++ 2 files changed, 20 insertions(+)
include/uapi/linux/batman_adv.h +8 -0
@@ -483,6 +483,14 @@ enum batadv_nl_attrs {*/ BATADV_ATTR_ELP_INTERVAL , +/** +* @BATADV_ATTR_THROUGHPUT_OVERRIDE: defines the throughput value to be +* used by B.A.T.M.A.N. V when estimating the link throughput using +* this interface. If the value is set to 0 then batman-adv will try to +* estimate the throughput by itself. +*/ + BATADV_ATTR_THROUGHPUT_OVERRIDE, +/* add attributes above here, update the policy in netlink.c */ /**
net/batman-adv/netlink.c +12 -0
@@ -160,6 +160,7 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_NETWORK_CODING_ENABLED] = { .type = NLA_U8 }, [BATADV_ATTR_ORIG_INTERVAL] = { .type = NLA_U32 }, [BATADV_ATTR_ELP_INTERVAL] = { .type = NLA_U32 }, + [BATADV_ATTR_THROUGHPUT_OVERRIDE] = { .type = NLA_U32 }, };/**
@@ -830,6 +831,10 @@ static int batadv_netlink_hardif_fill(struct sk_buff *msg,if (nla_put_u32 (msg,BATADV_ATTR_ELP_INTERVAL ,atomic_read (&hard_iface->bat_v.elp_interval))) goto nla_put_failure; + +if (nla_put_u32 (msg,BATADV_ATTR_THROUGHPUT_OVERRIDE , +atomic_read (&hard_iface->bat_v.throughput_override))) + goto nla_put_failure;#endif /* CONFIG_BATMAN_ADV_BATMAN_V */ genlmsg_end (msg, hdr);
@@ -925,6 +930,13 @@ static int batadv_netlink_set_hardif(struct sk_buff *skb, atomic_set(&hard_iface->bat_v.elp_interval, nla_get_u32(attr)); } + +if (info->attrs[BATADV_ATTR_THROUGHPUT_OVERRIDE ]) { + attr = info->attrs[BATADV_ATTR_THROUGHPUT_OVERRIDE ]; + +atomic_set (&hard_iface->bat_v.throughput_override, +nla_get_u32 (attr)); + }#endif /* CONFIG_BATMAN_ADV_BATMAN_V */ batadv_netlink_notify_hardif (bat_priv, hard_iface);
Signature · 1 line
2.11.0
Simon Wunderlich
maintainerPATCH 21/21 batman-adv: Trigger genl notification on sysfs config change
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
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.
--- net/batman-adv/netlink.c | 10 ++++---- net/batman-adv/netlink.h | 6 +++++ net/batman-adv/sysfs.c | 63 +++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 63 insertions(+), 16 deletions(-)
net/batman-adv/netlink.c +5 -5
@@ -385,7 +385,7 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg,* * Return: 0 on success, < 0 on error */ -static int batadv_netlink_notify_mesh (struct batadv_priv *bat_priv) +int batadv_netlink_notify_mesh (struct batadv_priv *bat_priv) {struct sk_buff *msg;int ret;
@@ -852,8 +852,8 @@ static int batadv_netlink_hardif_fill(struct sk_buff *msg,* * Return: 0 on success, < 0 on error */ -static int batadv_netlink_notify_hardif (struct batadv_priv *bat_priv, -struct batadv_hard_iface *hard_iface) +int batadv_netlink_notify_hardif (struct batadv_priv *bat_priv, +struct batadv_hard_iface *hard_iface) {struct sk_buff *msg;int ret;
@@ -1057,8 +1057,8 @@ static int batadv_netlink_vlan_fill(struct sk_buff *msg,* * Return: 0 on success, < 0 on error */ -static int batadv_netlink_notify_vlan (struct batadv_priv *bat_priv, -struct batadv_softif_vlan *vlan) +int batadv_netlink_notify_vlan (struct batadv_priv *bat_priv, +struct batadv_softif_vlan *vlan) {struct sk_buff *msg;int ret;
net/batman-adv/netlink.h +6 -0
@@ -34,6 +34,12 @@ int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst, u8 result, u32 test_time, u64 total_bytes, u32 cookie); +int batadv_netlink_notify_mesh (struct batadv_priv *bat_priv); +int batadv_netlink_notify_hardif (struct batadv_priv *bat_priv, +struct batadv_hard_iface *hard_iface); +int batadv_netlink_notify_vlan (struct batadv_priv *bat_priv, +struct batadv_softif_vlan *vlan); +extern struct genl_family batadv_netlink_family;#endif /* _NET_BATMAN_ADV_NETLINK_H_ */
net/batman-adv/sysfs.c +52 -11
148 lines not on this page · raw message
Signature · 1 line
2.11.0
David Miller
maintainerFrom: Simon Wunderlich <[email protected]>
Date: Wed, 13 Feb 2019 10:55:03 +0100
Quoted 5 lines
here is another pull request for batman-adv to go into net-next. The main patchset is Svens netlink restructure series, which was also discussed on netdev for quite some time now and should be ready to be integrated.
Please pull or let me know of any problem!
Pulled, thanks a lot Simon.