Commit 03b96742 authored by David S. Miller's avatar David S. Miller

Merge tag 'batadv-next-for-davem-20190213' of git://git.open-mesh.org/linux-merge

Simon Wunderlich says:

====================
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)
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e7c2e3b5 7e6f461e
...@@ -229,7 +229,7 @@ struct batadv_ogm_packet { ...@@ -229,7 +229,7 @@ struct batadv_ogm_packet {
* @packet_type: batman-adv packet type, part of the general header * @packet_type: batman-adv packet type, part of the general header
* @version: batman-adv protocol version, 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 * @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 * @seqno: sequence number
* @orig: originator mac address * @orig: originator mac address
* @tvlv_len: length of the appended tvlv buffer (in bytes) * @tvlv_len: length of the appended tvlv buffer (in bytes)
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define BATADV_NL_NAME "batadv" #define BATADV_NL_NAME "batadv"
#define BATADV_NL_MCAST_GROUP_CONFIG "config"
#define BATADV_NL_MCAST_GROUP_TPMETER "tpmeter" #define BATADV_NL_MCAST_GROUP_TPMETER "tpmeter"
/** /**
...@@ -138,6 +139,20 @@ enum batadv_mcast_flags_priv { ...@@ -138,6 +139,20 @@ enum batadv_mcast_flags_priv {
BATADV_MCAST_FLAGS_QUERIER_IPV6_SHADOWING = (1 << 4), BATADV_MCAST_FLAGS_QUERIER_IPV6_SHADOWING = (1 << 4),
}; };
/**
* 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 - batman-adv netlink attributes
*/ */
...@@ -344,6 +359,138 @@ enum batadv_nl_attrs { ...@@ -344,6 +359,138 @@ enum batadv_nl_attrs {
*/ */
BATADV_ATTR_MCAST_FLAGS_PRIV, BATADV_ATTR_MCAST_FLAGS_PRIV,
/**
* @BATADV_ATTR_VLANID: VLAN id on top of soft interface
*/
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,
/**
* @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,
/**
* @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,
/**
* @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,
/**
* @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,
/**
* @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,
/**
* @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,
/**
* @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,
/**
* @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,
/**
* @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,
/**
* @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,
/**
* @BATADV_ATTR_ORIG_INTERVAL: defines the interval in milliseconds in
* which batman sends its protocol messages.
*/
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,
/**
* @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 */ /* add attributes above here, update the policy in netlink.c */
/** /**
...@@ -372,10 +519,14 @@ enum batadv_nl_commands { ...@@ -372,10 +519,14 @@ enum batadv_nl_commands {
BATADV_CMD_UNSPEC, BATADV_CMD_UNSPEC,
/** /**
* @BATADV_CMD_GET_MESH_INFO: Query basic information about batman-adv * @BATADV_CMD_GET_MESH: Get attributes from softif/mesh
* device */
BATADV_CMD_GET_MESH,
/**
* @BATADV_CMD_GET_MESH_INFO: Alias for @BATADV_CMD_GET_MESH
*/ */
BATADV_CMD_GET_MESH_INFO, BATADV_CMD_GET_MESH_INFO = BATADV_CMD_GET_MESH,
/** /**
* @BATADV_CMD_TP_METER: Start a tp meter session * @BATADV_CMD_TP_METER: Start a tp meter session
...@@ -393,9 +544,15 @@ enum batadv_nl_commands { ...@@ -393,9 +544,15 @@ enum batadv_nl_commands {
BATADV_CMD_GET_ROUTING_ALGOS, 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 * @BATADV_CMD_GET_TRANSTABLE_LOCAL: Query list of local translations
...@@ -443,6 +600,29 @@ enum batadv_nl_commands { ...@@ -443,6 +600,29 @@ enum batadv_nl_commands {
*/ */
BATADV_CMD_GET_MCAST_FLAGS, BATADV_CMD_GET_MCAST_FLAGS,
/**
* @BATADV_CMD_SET_MESH: Set attributes for softif/mesh
*/
BATADV_CMD_SET_MESH,
/**
* @BATADV_CMD_SET_HARDIF: Set attributes for hardif of the
* current softif
*/
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 */ /* add new commands above here */
/** /**
......
...@@ -1711,6 +1711,8 @@ static void batadv_dat_put_dhcp(struct batadv_priv *bat_priv, u8 *chaddr, ...@@ -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, yiaddr, vid, BATADV_P_DAT_DHT_PUT);
batadv_dat_send_data(bat_priv, skb, ip_dst, 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, batadv_dbg(BATADV_DBG_DAT, bat_priv,
"Snooped from outgoing DHCPACK (server address): %pI4, %pM (vid: %i)\n", "Snooped from outgoing DHCPACK (server address): %pI4, %pM (vid: %i)\n",
&ip_dst, hw_dst, batadv_print_vid(vid)); &ip_dst, hw_dst, batadv_print_vid(vid));
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include <uapi/linux/batadv_packet.h> #include <uapi/linux/batadv_packet.h>
#include <uapi/linux/batman_adv.h> #include <uapi/linux/batman_adv.h>
#include "gateway_common.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "log.h" #include "log.h"
#include "netlink.h" #include "netlink.h"
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/string.h> #include <linux/string.h>
#include <uapi/linux/batadv_packet.h> #include <uapi/linux/batadv_packet.h>
#include <uapi/linux/batman_adv.h>
#include "gateway_client.h" #include "gateway_client.h"
#include "log.h" #include "log.h"
......
...@@ -25,12 +25,6 @@ ...@@ -25,12 +25,6 @@
struct net_device; 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 * enum batadv_bandwidth_units - bandwidth unit types
*/ */
......
...@@ -20,13 +20,17 @@ ...@@ -20,13 +20,17 @@
#include "main.h" #include "main.h"
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/byteorder/generic.h> #include <linux/byteorder/generic.h>
#include <linux/cache.h> #include <linux/cache.h>
#include <linux/err.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/genetlink.h> #include <linux/genetlink.h>
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -47,21 +51,54 @@ ...@@ -47,21 +51,54 @@
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
#include "distributed-arp-table.h" #include "distributed-arp-table.h"
#include "gateway_client.h" #include "gateway_client.h"
#include "gateway_common.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "log.h"
#include "multicast.h" #include "multicast.h"
#include "network-coding.h"
#include "originator.h" #include "originator.h"
#include "soft-interface.h" #include "soft-interface.h"
#include "tp_meter.h" #include "tp_meter.h"
#include "translation-table.h" #include "translation-table.h"
struct net;
struct genl_family batadv_netlink_family; struct genl_family batadv_netlink_family;
/* multicast groups */ /* multicast groups */
enum batadv_netlink_multicast_groups { enum batadv_netlink_multicast_groups {
BATADV_NL_MCGRP_CONFIG,
BATADV_NL_MCGRP_TPMETER, 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),
/**
* @BATADV_FLAG_NEED_HARDIF: request requires valid hard interface in
* attribute BATADV_ATTR_HARD_IFINDEX and expects a pointer to it to be
* saved in info->user_ptr[1]
*/
BATADV_FLAG_NEED_HARDIF = BIT(1),
/**
* @BATADV_FLAG_NEED_VLAN: request requires valid vlan in
* attribute BATADV_ATTR_VLANID and expects a pointer to it to be
* saved in info->user_ptr[1]
*/
BATADV_FLAG_NEED_VLAN = BIT(2),
};
static const struct genl_multicast_group batadv_netlink_mcgrps[] = { static const struct genl_multicast_group batadv_netlink_mcgrps[] = {
[BATADV_NL_MCGRP_CONFIG] = { .name = BATADV_NL_MCAST_GROUP_CONFIG },
[BATADV_NL_MCGRP_TPMETER] = { .name = BATADV_NL_MCAST_GROUP_TPMETER }, [BATADV_NL_MCGRP_TPMETER] = { .name = BATADV_NL_MCAST_GROUP_TPMETER },
}; };
...@@ -104,6 +141,26 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { ...@@ -104,6 +141,26 @@ static const struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = {
[BATADV_ATTR_DAT_CACHE_VID] = { .type = NLA_U16 }, [BATADV_ATTR_DAT_CACHE_VID] = { .type = NLA_U16 },
[BATADV_ATTR_MCAST_FLAGS] = { .type = NLA_U32 }, [BATADV_ATTR_MCAST_FLAGS] = { .type = NLA_U32 },
[BATADV_ATTR_MCAST_FLAGS_PRIV] = { .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 },
[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 },
[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 },
[BATADV_ATTR_GW_BANDWIDTH_DOWN] = { .type = NLA_U32 },
[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 },
[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 },
[BATADV_ATTR_ELP_INTERVAL] = { .type = NLA_U32 },
[BATADV_ATTR_THROUGHPUT_OVERRIDE] = { .type = NLA_U32 },
}; };
/** /**
...@@ -122,20 +179,75 @@ batadv_netlink_get_ifindex(const struct nlmsghdr *nlh, int attrtype) ...@@ -122,20 +179,75 @@ batadv_netlink_get_ifindex(const struct nlmsghdr *nlh, int attrtype)
} }
/** /**
* batadv_netlink_mesh_info_put() - fill in generic information about mesh * batadv_netlink_mesh_fill_ap_isolation() - Add ap_isolation softif attribute
* interface * @msg: Netlink message to dump into
* @msg: netlink message to be sent back * @bat_priv: the bat priv with all the soft interface information
* @soft_iface: interface for which the data should be taken
* *
* Return: 0 on success, < 0 on error * Return: 0 on success or negative error number in case of failure
*/ */
static int static int batadv_netlink_mesh_fill_ap_isolation(struct sk_buff *msg,
batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface) struct batadv_priv *bat_priv)
{
struct batadv_softif_vlan *vlan;
u8 ap_isolation;
vlan = batadv_softif_vlan_get(bat_priv, BATADV_NO_FLAGS);
if (!vlan)
return 0;
ap_isolation = atomic_read(&vlan->ap_isolation);
batadv_softif_vlan_put(vlan);
return nla_put_u8(msg, BATADV_ATTR_AP_ISOLATION_ENABLED,
!!ap_isolation);
}
/**
* batadv_option_set_ap_isolation() - Set ap_isolation from genl msg
* @attr: parsed BATADV_ATTR_AP_ISOLATION_ENABLED attribute
* @bat_priv: the bat priv with all the soft interface information
*
* Return: 0 on success or negative error number in case of failure
*/
static int batadv_netlink_set_mesh_ap_isolation(struct nlattr *attr,
struct batadv_priv *bat_priv)
{
struct batadv_softif_vlan *vlan;
vlan = batadv_softif_vlan_get(bat_priv, BATADV_NO_FLAGS);
if (!vlan)
return -ENOENT;
atomic_set(&vlan->ap_isolation, !!nla_get_u8(attr));
batadv_softif_vlan_put(vlan);
return 0;
}
/**
* batadv_netlink_mesh_fill() - Fill message with mesh attributes
* @msg: Netlink message to dump into
* @bat_priv: the bat priv with all the soft interface information
* @cmd: type of message to generate
* @portid: Port making netlink request
* @seq: sequence number for message
* @flags: Additional flags for message
*
* Return: 0 on success or negative error number in case of failure
*/
static int batadv_netlink_mesh_fill(struct sk_buff *msg,
struct batadv_priv *bat_priv,
enum batadv_nl_commands cmd,
u32 portid, u32 seq, int flags)
{ {
struct batadv_priv *bat_priv = netdev_priv(soft_iface); struct net_device *soft_iface = bat_priv->soft_iface;
struct batadv_hard_iface *primary_if = NULL; struct batadv_hard_iface *primary_if = NULL;
struct net_device *hard_iface; struct net_device *hard_iface;
int ret = -ENOBUFS; void *hdr;
hdr = genlmsg_put(msg, portid, seq, &batadv_netlink_family, flags, cmd);
if (!hdr)
return -ENOBUFS;
if (nla_put_string(msg, BATADV_ATTR_VERSION, BATADV_SOURCE_VERSION) || if (nla_put_string(msg, BATADV_ATTR_VERSION, BATADV_SOURCE_VERSION) ||
nla_put_string(msg, BATADV_ATTR_ALGO_NAME, nla_put_string(msg, BATADV_ATTR_ALGO_NAME,
...@@ -146,16 +258,16 @@ batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface) ...@@ -146,16 +258,16 @@ batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface)
soft_iface->dev_addr) || soft_iface->dev_addr) ||
nla_put_u8(msg, BATADV_ATTR_TT_TTVN, nla_put_u8(msg, BATADV_ATTR_TT_TTVN,
(u8)atomic_read(&bat_priv->tt.vn))) (u8)atomic_read(&bat_priv->tt.vn)))
goto out; goto nla_put_failure;
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
if (nla_put_u16(msg, BATADV_ATTR_BLA_CRC, if (nla_put_u16(msg, BATADV_ATTR_BLA_CRC,
ntohs(bat_priv->bla.claim_dest.group))) ntohs(bat_priv->bla.claim_dest.group)))
goto out; goto nla_put_failure;
#endif #endif
if (batadv_mcast_mesh_info_put(msg, bat_priv)) if (batadv_mcast_mesh_info_put(msg, bat_priv))
goto out; goto nla_put_failure;
primary_if = batadv_primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (primary_if && primary_if->if_status == BATADV_IF_ACTIVE) { if (primary_if && primary_if->if_status == BATADV_IF_ACTIVE) {
...@@ -167,77 +279,345 @@ batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface) ...@@ -167,77 +279,345 @@ batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface)
hard_iface->name) || hard_iface->name) ||
nla_put(msg, BATADV_ATTR_HARD_ADDRESS, ETH_ALEN, nla_put(msg, BATADV_ATTR_HARD_ADDRESS, ETH_ALEN,
hard_iface->dev_addr)) hard_iface->dev_addr))
goto out; goto nla_put_failure;
} }
ret = 0; if (nla_put_u8(msg, BATADV_ATTR_AGGREGATED_OGMS_ENABLED,
!!atomic_read(&bat_priv->aggregated_ogms)))
goto nla_put_failure;
if (batadv_netlink_mesh_fill_ap_isolation(msg, bat_priv))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_ISOLATION_MARK,
bat_priv->isolation_mark))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_ISOLATION_MASK,
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;
#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 */
#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 (nla_put_u8(msg, BATADV_ATTR_FRAGMENTATION_ENABLED,
!!atomic_read(&bat_priv->fragmentation)))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_GW_BANDWIDTH_DOWN,
atomic_read(&bat_priv->gw.bandwidth_down)))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_GW_BANDWIDTH_UP,
atomic_read(&bat_priv->gw.bandwidth_up)))
goto nla_put_failure;
if (nla_put_u8(msg, BATADV_ATTR_GW_MODE,
atomic_read(&bat_priv->gw.mode)))
goto nla_put_failure;
if (bat_priv->algo_ops->gw.get_best_gw_node &&
bat_priv->algo_ops->gw.is_eligible) {
/* GW selection class is not available if the routing algorithm
* in use does not implement the GW API
*/
if (nla_put_u32(msg, BATADV_ATTR_GW_SEL_CLASS,
atomic_read(&bat_priv->gw.sel_class)))
goto nla_put_failure;
}
if (nla_put_u8(msg, BATADV_ATTR_HOP_PENALTY,
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 */
#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 */
#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 (nla_put_u32(msg, BATADV_ATTR_ORIG_INTERVAL,
atomic_read(&bat_priv->orig_interval)))
goto nla_put_failure;
out:
if (primary_if) if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
genlmsg_end(msg, hdr);
return 0;
nla_put_failure:
if (primary_if)
batadv_hardif_put(primary_if);
genlmsg_cancel(msg, hdr);
return -EMSGSIZE;
}
/**
* batadv_netlink_notify_mesh() - send softif attributes to listener
* @bat_priv: the bat priv with all the soft interface information
*
* Return: 0 on success, < 0 on error
*/
int batadv_netlink_notify_mesh(struct batadv_priv *bat_priv)
{
struct sk_buff *msg;
int ret;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
ret = batadv_netlink_mesh_fill(msg, bat_priv, BATADV_CMD_SET_MESH,
0, 0, 0);
if (ret < 0) {
nlmsg_free(msg);
return ret; return ret;
}
genlmsg_multicast_netns(&batadv_netlink_family,
dev_net(bat_priv->soft_iface), msg, 0,
BATADV_NL_MCGRP_CONFIG, GFP_KERNEL);
return 0;
} }
/** /**
* batadv_netlink_get_mesh_info() - handle incoming BATADV_CMD_GET_MESH_INFO * batadv_netlink_get_mesh() - Get softif attributes
* netlink request * @skb: Netlink message with request data
* @skb: received netlink message
* @info: receiver information * @info: receiver information
* *
* Return: 0 on success, < 0 on error * Return: 0 on success or negative error number in case of failure
*/ */
static int static int batadv_netlink_get_mesh(struct sk_buff *skb, struct genl_info *info)
batadv_netlink_get_mesh_info(struct sk_buff *skb, struct genl_info *info)
{ {
struct net *net = genl_info_net(info); struct batadv_priv *bat_priv = info->user_ptr[0];
struct net_device *soft_iface; struct sk_buff *msg;
struct sk_buff *msg = NULL;
void *msg_head;
int ifindex;
int ret; int ret;
if (!info->attrs[BATADV_ATTR_MESH_IFINDEX]) msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
return -EINVAL; if (!msg)
return -ENOMEM;
ifindex = nla_get_u32(info->attrs[BATADV_ATTR_MESH_IFINDEX]); ret = batadv_netlink_mesh_fill(msg, bat_priv, BATADV_CMD_GET_MESH,
if (!ifindex) info->snd_portid, info->snd_seq, 0);
return -EINVAL; if (ret < 0) {
nlmsg_free(msg);
return ret;
}
soft_iface = dev_get_by_index(net, ifindex); ret = genlmsg_reply(msg, info);
if (!soft_iface || !batadv_softif_is_valid(soft_iface)) {
ret = -ENODEV; return ret;
goto out; }
/**
* batadv_netlink_set_mesh() - Set softif attributes
* @skb: Netlink message with request data
* @info: receiver information
*
* Return: 0 on success or negative error number in case of failure
*/
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));
} }
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (info->attrs[BATADV_ATTR_AP_ISOLATION_ENABLED]) {
if (!msg) { attr = info->attrs[BATADV_ATTR_AP_ISOLATION_ENABLED];
ret = -ENOMEM;
goto out; batadv_netlink_set_mesh_ap_isolation(attr, bat_priv);
} }
msg_head = genlmsg_put(msg, info->snd_portid, info->snd_seq, if (info->attrs[BATADV_ATTR_ISOLATION_MARK]) {
&batadv_netlink_family, 0, attr = info->attrs[BATADV_ATTR_ISOLATION_MARK];
BATADV_CMD_GET_MESH_INFO);
if (!msg_head) { bat_priv->isolation_mark = nla_get_u32(attr);
ret = -ENOBUFS;
goto out;
} }
ret = batadv_netlink_mesh_info_put(msg, soft_iface); if (info->attrs[BATADV_ATTR_ISOLATION_MASK]) {
attr = info->attrs[BATADV_ATTR_ISOLATION_MASK];
out: bat_priv->isolation_mark_mask = nla_get_u32(attr);
if (soft_iface) }
dev_put(soft_iface);
if (ret) { if (info->attrs[BATADV_ATTR_BONDING_ENABLED]) {
if (msg) attr = info->attrs[BATADV_ATTR_BONDING_ENABLED];
nlmsg_free(msg);
return ret; atomic_set(&bat_priv->bonding, !!nla_get_u8(attr));
} }
genlmsg_end(msg, msg_head); #ifdef CONFIG_BATMAN_ADV_BLA
return genlmsg_reply(msg, info); 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 */
#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 */
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);
}
if (info->attrs[BATADV_ATTR_GW_BANDWIDTH_DOWN]) {
attr = info->attrs[BATADV_ATTR_GW_BANDWIDTH_DOWN];
atomic_set(&bat_priv->gw.bandwidth_down, nla_get_u32(attr));
batadv_gw_tvlv_container_update(bat_priv);
}
if (info->attrs[BATADV_ATTR_GW_BANDWIDTH_UP]) {
attr = info->attrs[BATADV_ATTR_GW_BANDWIDTH_UP];
atomic_set(&bat_priv->gw.bandwidth_up, nla_get_u32(attr));
batadv_gw_tvlv_container_update(bat_priv);
}
if (info->attrs[BATADV_ATTR_GW_MODE]) {
u8 gw_mode;
attr = info->attrs[BATADV_ATTR_GW_MODE];
gw_mode = nla_get_u8(attr);
if (gw_mode <= BATADV_GW_MODE_SERVER) {
/* Invoking batadv_gw_reselect() is not enough to really
* de-select the current GW. It will only instruct the
* gateway client code to perform a re-election the next
* time that this is needed.
*
* When gw client mode is being switched off the current
* GW must be de-selected explicitly otherwise no GW_ADD
* uevent is thrown on client mode re-activation. This
* is operation is performed in
* batadv_gw_check_client_stop().
*/
batadv_gw_reselect(bat_priv);
/* always call batadv_gw_check_client_stop() before
* changing the gateway state
*/
batadv_gw_check_client_stop(bat_priv);
atomic_set(&bat_priv->gw.mode, gw_mode);
batadv_gw_tvlv_container_update(bat_priv);
}
}
if (info->attrs[BATADV_ATTR_GW_SEL_CLASS] &&
bat_priv->algo_ops->gw.get_best_gw_node &&
bat_priv->algo_ops->gw.is_eligible) {
/* setting the GW selection class is allowed only if the routing
* algorithm in use implements the GW API
*/
u32 sel_class_max = 0xffffffffu;
u32 sel_class;
attr = info->attrs[BATADV_ATTR_GW_SEL_CLASS];
sel_class = nla_get_u32(attr);
if (!bat_priv->algo_ops->gw.store_sel_class)
sel_class_max = BATADV_TQ_MAX_VALUE;
if (sel_class >= 1 && sel_class <= sel_class_max) {
atomic_set(&bat_priv->gw.sel_class, sel_class);
batadv_gw_reselect(bat_priv);
}
}
if (info->attrs[BATADV_ATTR_HOP_PENALTY]) {
attr = info->attrs[BATADV_ATTR_HOP_PENALTY];
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 */
#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 */
#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 */
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;
} }
/** /**
...@@ -329,40 +709,24 @@ int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst, ...@@ -329,40 +709,24 @@ int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst,
static int static int
batadv_netlink_tp_meter_start(struct sk_buff *skb, struct genl_info *info) batadv_netlink_tp_meter_start(struct sk_buff *skb, struct genl_info *info)
{ {
struct net *net = genl_info_net(info); struct batadv_priv *bat_priv = info->user_ptr[0];
struct net_device *soft_iface;
struct batadv_priv *bat_priv;
struct sk_buff *msg = NULL; struct sk_buff *msg = NULL;
u32 test_length; u32 test_length;
void *msg_head; void *msg_head;
int ifindex;
u32 cookie; u32 cookie;
u8 *dst; u8 *dst;
int ret; int ret;
if (!info->attrs[BATADV_ATTR_MESH_IFINDEX])
return -EINVAL;
if (!info->attrs[BATADV_ATTR_ORIG_ADDRESS]) if (!info->attrs[BATADV_ATTR_ORIG_ADDRESS])
return -EINVAL; return -EINVAL;
if (!info->attrs[BATADV_ATTR_TPMETER_TEST_TIME]) if (!info->attrs[BATADV_ATTR_TPMETER_TEST_TIME])
return -EINVAL; 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]); dst = nla_data(info->attrs[BATADV_ATTR_ORIG_ADDRESS]);
test_length = nla_get_u32(info->attrs[BATADV_ATTR_TPMETER_TEST_TIME]); 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); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) { if (!msg) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -377,15 +741,11 @@ batadv_netlink_tp_meter_start(struct sk_buff *skb, struct genl_info *info) ...@@ -377,15 +741,11 @@ batadv_netlink_tp_meter_start(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
bat_priv = netdev_priv(soft_iface);
batadv_tp_start(bat_priv, dst, test_length, &cookie); batadv_tp_start(bat_priv, dst, test_length, &cookie);
ret = batadv_netlink_tp_meter_put(msg, cookie); ret = batadv_netlink_tp_meter_put(msg, cookie);
out: out:
if (soft_iface)
dev_put(soft_iface);
if (ret) { if (ret) {
if (msg) if (msg)
nlmsg_free(msg); nlmsg_free(msg);
...@@ -406,66 +766,54 @@ batadv_netlink_tp_meter_start(struct sk_buff *skb, struct genl_info *info) ...@@ -406,66 +766,54 @@ batadv_netlink_tp_meter_start(struct sk_buff *skb, struct genl_info *info)
static int static int
batadv_netlink_tp_meter_cancel(struct sk_buff *skb, struct genl_info *info) batadv_netlink_tp_meter_cancel(struct sk_buff *skb, struct genl_info *info)
{ {
struct net *net = genl_info_net(info); struct batadv_priv *bat_priv = info->user_ptr[0];
struct net_device *soft_iface;
struct batadv_priv *bat_priv;
int ifindex;
u8 *dst; u8 *dst;
int ret = 0; int ret = 0;
if (!info->attrs[BATADV_ATTR_MESH_IFINDEX])
return -EINVAL;
if (!info->attrs[BATADV_ATTR_ORIG_ADDRESS]) if (!info->attrs[BATADV_ATTR_ORIG_ADDRESS])
return -EINVAL; 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]); 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); batadv_tp_stop(bat_priv, dst, BATADV_TP_REASON_CANCEL);
out:
if (soft_iface)
dev_put(soft_iface);
return ret; return ret;
} }
/** /**
* batadv_netlink_dump_hardif_entry() - Dump one hard interface into a message * batadv_netlink_hardif_fill() - Fill message with hardif attributes
* @msg: Netlink message to dump into * @msg: Netlink message to dump into
* @bat_priv: the bat priv with all the soft interface information
* @hard_iface: hard interface which was modified
* @cmd: type of message to generate
* @portid: Port making netlink request * @portid: Port making netlink request
* @seq: sequence number for message
* @flags: Additional flags for message
* @cb: Control block containing additional options * @cb: Control block containing additional options
* @hard_iface: Hard interface to dump
* *
* Return: error code, or 0 on success * Return: 0 on success or negative error number in case of failure
*/ */
static int static int batadv_netlink_hardif_fill(struct sk_buff *msg,
batadv_netlink_dump_hardif_entry(struct sk_buff *msg, u32 portid, struct batadv_priv *bat_priv,
struct netlink_callback *cb, struct batadv_hard_iface *hard_iface,
struct batadv_hard_iface *hard_iface) enum batadv_nl_commands cmd,
u32 portid, u32 seq, int flags,
struct netlink_callback *cb)
{ {
struct net_device *net_dev = hard_iface->net_dev; struct net_device *net_dev = hard_iface->net_dev;
void *hdr; void *hdr;
hdr = genlmsg_put(msg, portid, cb->nlh->nlmsg_seq, hdr = genlmsg_put(msg, portid, seq, &batadv_netlink_family, flags, cmd);
&batadv_netlink_family, NLM_F_MULTI,
BATADV_CMD_GET_HARDIFS);
if (!hdr) if (!hdr)
return -EMSGSIZE; return -ENOBUFS;
if (cb)
genl_dump_check_consistent(cb, hdr); genl_dump_check_consistent(cb, hdr);
if (nla_put_u32(msg, BATADV_ATTR_MESH_IFINDEX,
bat_priv->soft_iface->ifindex))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX, if (nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
net_dev->ifindex) || net_dev->ifindex) ||
nla_put_string(msg, BATADV_ATTR_HARD_IFNAME, nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
...@@ -479,27 +827,137 @@ batadv_netlink_dump_hardif_entry(struct sk_buff *msg, u32 portid, ...@@ -479,27 +827,137 @@ batadv_netlink_dump_hardif_entry(struct sk_buff *msg, u32 portid,
goto nla_put_failure; 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;
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); genlmsg_end(msg, hdr);
return 0; return 0;
nla_put_failure: nla_put_failure:
genlmsg_cancel(msg, hdr); genlmsg_cancel(msg, hdr);
return -EMSGSIZE; return -EMSGSIZE;
} }
/** /**
* batadv_netlink_dump_hardifs() - Dump all hard interface into a messages * batadv_netlink_notify_hardif() - send hardif attributes to listener
* @bat_priv: the bat priv with all the soft interface information
* @hard_iface: hard interface which was modified
*
* Return: 0 on success, < 0 on error
*/
int batadv_netlink_notify_hardif(struct batadv_priv *bat_priv,
struct batadv_hard_iface *hard_iface)
{
struct sk_buff *msg;
int ret;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
ret = batadv_netlink_hardif_fill(msg, bat_priv, hard_iface,
BATADV_CMD_SET_HARDIF, 0, 0, 0, NULL);
if (ret < 0) {
nlmsg_free(msg);
return ret;
}
genlmsg_multicast_netns(&batadv_netlink_family,
dev_net(bat_priv->soft_iface), msg, 0,
BATADV_NL_MCGRP_CONFIG, GFP_KERNEL);
return 0;
}
/**
* batadv_netlink_get_hardif() - Get hardif attributes
* @skb: Netlink message with request data
* @info: receiver information
*
* Return: 0 on success or negative error number in case of failure
*/
static int batadv_netlink_get_hardif(struct sk_buff *skb,
struct genl_info *info)
{
struct batadv_hard_iface *hard_iface = info->user_ptr[1];
struct batadv_priv *bat_priv = info->user_ptr[0];
struct sk_buff *msg;
int ret;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
ret = batadv_netlink_hardif_fill(msg, bat_priv, hard_iface,
BATADV_CMD_GET_HARDIF,
info->snd_portid, info->snd_seq, 0,
NULL);
if (ret < 0) {
nlmsg_free(msg);
return ret;
}
ret = genlmsg_reply(msg, info);
return ret;
}
/**
* batadv_netlink_set_hardif() - Set hardif attributes
* @skb: Netlink message with request data
* @info: receiver information
*
* Return: 0 on success or negative error number in case of failure
*/
static int batadv_netlink_set_hardif(struct sk_buff *skb,
struct genl_info *info)
{
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));
}
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);
return 0;
}
/**
* batadv_netlink_dump_hardif() - Dump all hard interface into a messages
* @msg: Netlink message to dump into * @msg: Netlink message to dump into
* @cb: Parameters from query * @cb: Parameters from query
* *
* Return: error code, or length of reply message on success * Return: error code, or length of reply message on success
*/ */
static int static int
batadv_netlink_dump_hardifs(struct sk_buff *msg, struct netlink_callback *cb) batadv_netlink_dump_hardif(struct sk_buff *msg, struct netlink_callback *cb)
{ {
struct net *net = sock_net(cb->skb->sk); struct net *net = sock_net(cb->skb->sk);
struct net_device *soft_iface; struct net_device *soft_iface;
struct batadv_hard_iface *hard_iface; struct batadv_hard_iface *hard_iface;
struct batadv_priv *bat_priv;
int ifindex; int ifindex;
int portid = NETLINK_CB(cb->skb).portid; int portid = NETLINK_CB(cb->skb).portid;
int skip = cb->args[0]; int skip = cb->args[0];
...@@ -519,6 +977,8 @@ batadv_netlink_dump_hardifs(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -519,6 +977,8 @@ batadv_netlink_dump_hardifs(struct sk_buff *msg, struct netlink_callback *cb)
return -ENODEV; return -ENODEV;
} }
bat_priv = netdev_priv(soft_iface);
rtnl_lock(); rtnl_lock();
cb->seq = batadv_hardif_generation << 1 | 1; cb->seq = batadv_hardif_generation << 1 | 1;
...@@ -529,8 +989,10 @@ batadv_netlink_dump_hardifs(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -529,8 +989,10 @@ batadv_netlink_dump_hardifs(struct sk_buff *msg, struct netlink_callback *cb)
if (i++ < skip) if (i++ < skip)
continue; continue;
if (batadv_netlink_dump_hardif_entry(msg, portid, cb, if (batadv_netlink_hardif_fill(msg, bat_priv, hard_iface,
hard_iface)) { BATADV_CMD_GET_HARDIF,
portid, cb->nlh->nlmsg_seq,
NLM_F_MULTI, cb)) {
i--; i--;
break; break;
} }
...@@ -545,24 +1007,361 @@ batadv_netlink_dump_hardifs(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -545,24 +1007,361 @@ batadv_netlink_dump_hardifs(struct sk_buff *msg, struct netlink_callback *cb)
return msg->len; return msg->len;
} }
/**
* batadv_netlink_vlan_fill() - Fill message with vlan attributes
* @msg: Netlink message to dump into
* @bat_priv: the bat priv with all the soft interface information
* @vlan: vlan which was modified
* @cmd: type of message to generate
* @portid: Port making netlink request
* @seq: sequence number for message
* @flags: Additional flags for message
*
* Return: 0 on success or negative error number in case of failure
*/
static int batadv_netlink_vlan_fill(struct sk_buff *msg,
struct batadv_priv *bat_priv,
struct batadv_softif_vlan *vlan,
enum batadv_nl_commands cmd,
u32 portid, u32 seq, int flags)
{
void *hdr;
hdr = genlmsg_put(msg, portid, seq, &batadv_netlink_family, flags, cmd);
if (!hdr)
return -ENOBUFS;
if (nla_put_u32(msg, BATADV_ATTR_MESH_IFINDEX,
bat_priv->soft_iface->ifindex))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_VLANID, vlan->vid & VLAN_VID_MASK))
goto nla_put_failure;
if (nla_put_u8(msg, BATADV_ATTR_AP_ISOLATION_ENABLED,
!!atomic_read(&vlan->ap_isolation)))
goto nla_put_failure;
genlmsg_end(msg, hdr);
return 0;
nla_put_failure:
genlmsg_cancel(msg, hdr);
return -EMSGSIZE;
}
/**
* batadv_netlink_notify_vlan() - send vlan attributes to listener
* @bat_priv: the bat priv with all the soft interface information
* @vlan: vlan which was modified
*
* Return: 0 on success, < 0 on error
*/
int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv,
struct batadv_softif_vlan *vlan)
{
struct sk_buff *msg;
int ret;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
ret = batadv_netlink_vlan_fill(msg, bat_priv, vlan,
BATADV_CMD_SET_VLAN, 0, 0, 0);
if (ret < 0) {
nlmsg_free(msg);
return ret;
}
genlmsg_multicast_netns(&batadv_netlink_family,
dev_net(bat_priv->soft_iface), msg, 0,
BATADV_NL_MCGRP_CONFIG, GFP_KERNEL);
return 0;
}
/**
* batadv_netlink_get_vlan() - Get vlan attributes
* @skb: Netlink message with request data
* @info: receiver information
*
* Return: 0 on success or negative error number in case of failure
*/
static int batadv_netlink_get_vlan(struct sk_buff *skb, struct genl_info *info)
{
struct batadv_softif_vlan *vlan = info->user_ptr[1];
struct batadv_priv *bat_priv = info->user_ptr[0];
struct sk_buff *msg;
int ret;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
ret = batadv_netlink_vlan_fill(msg, bat_priv, vlan, BATADV_CMD_GET_VLAN,
info->snd_portid, info->snd_seq, 0);
if (ret < 0) {
nlmsg_free(msg);
return ret;
}
ret = genlmsg_reply(msg, info);
return ret;
}
/**
* batadv_netlink_set_vlan() - Get vlan attributes
* @skb: Netlink message with request data
* @info: receiver information
*
* Return: 0 on success or negative error number in case of failure
*/
static int batadv_netlink_set_vlan(struct sk_buff *skb, struct genl_info *info)
{
struct batadv_softif_vlan *vlan = info->user_ptr[1];
struct batadv_priv *bat_priv = info->user_ptr[0];
struct nlattr *attr;
if (info->attrs[BATADV_ATTR_AP_ISOLATION_ENABLED]) {
attr = info->attrs[BATADV_ATTR_AP_ISOLATION_ENABLED];
atomic_set(&vlan->ap_isolation, !!nla_get_u8(attr));
}
batadv_netlink_notify_vlan(bat_priv, vlan);
return 0;
}
/**
* 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_get_hardif_from_info() - Retrieve hardif from genl attributes
* @bat_priv: the bat priv with all the soft interface information
* @net: the applicable net namespace
* @info: receiver information
*
* Return: Pointer to hard interface (with increased refcnt) on success, error
* pointer on error
*/
static struct batadv_hard_iface *
batadv_get_hardif_from_info(struct batadv_priv *bat_priv, struct net *net,
struct genl_info *info)
{
struct batadv_hard_iface *hard_iface;
struct net_device *hard_dev;
unsigned int hardif_index;
if (!info->attrs[BATADV_ATTR_HARD_IFINDEX])
return ERR_PTR(-EINVAL);
hardif_index = nla_get_u32(info->attrs[BATADV_ATTR_HARD_IFINDEX]);
hard_dev = dev_get_by_index(net, hardif_index);
if (!hard_dev)
return ERR_PTR(-ENODEV);
hard_iface = batadv_hardif_get_by_netdev(hard_dev);
if (!hard_iface)
goto err_put_harddev;
if (hard_iface->soft_iface != bat_priv->soft_iface)
goto err_put_hardif;
/* hard_dev is referenced by hard_iface and not needed here */
dev_put(hard_dev);
return hard_iface;
err_put_hardif:
batadv_hardif_put(hard_iface);
err_put_harddev:
dev_put(hard_dev);
return ERR_PTR(-EINVAL);
}
/**
* batadv_get_vlan_from_info() - Retrieve vlan from genl attributes
* @bat_priv: the bat priv with all the soft interface information
* @net: the applicable net namespace
* @info: receiver information
*
* Return: Pointer to vlan on success (with increased refcnt), error pointer
* on error
*/
static struct batadv_softif_vlan *
batadv_get_vlan_from_info(struct batadv_priv *bat_priv, struct net *net,
struct genl_info *info)
{
struct batadv_softif_vlan *vlan;
u16 vid;
if (!info->attrs[BATADV_ATTR_VLANID])
return ERR_PTR(-EINVAL);
vid = nla_get_u16(info->attrs[BATADV_ATTR_VLANID]);
vlan = batadv_softif_vlan_get(bat_priv, vid | BATADV_VLAN_HAS_TAG);
if (!vlan)
return ERR_PTR(-ENOENT);
return vlan;
}
/**
* 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 batadv_hard_iface *hard_iface;
struct batadv_priv *bat_priv = NULL;
struct batadv_softif_vlan *vlan;
struct net_device *soft_iface;
u8 user_ptr1_flags;
u8 mesh_dep_flags;
int ret;
user_ptr1_flags = BATADV_FLAG_NEED_HARDIF | BATADV_FLAG_NEED_VLAN;
if (WARN_ON(hweight8(ops->internal_flags & user_ptr1_flags) > 1))
return -EINVAL;
mesh_dep_flags = BATADV_FLAG_NEED_HARDIF | BATADV_FLAG_NEED_VLAN;
if (WARN_ON((ops->internal_flags & mesh_dep_flags) &&
(~ops->internal_flags & BATADV_FLAG_NEED_MESH)))
return -EINVAL;
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;
}
if (ops->internal_flags & BATADV_FLAG_NEED_HARDIF) {
hard_iface = batadv_get_hardif_from_info(bat_priv, net, info);
if (IS_ERR(hard_iface)) {
ret = PTR_ERR(hard_iface);
goto err_put_softif;
}
info->user_ptr[1] = hard_iface;
}
if (ops->internal_flags & BATADV_FLAG_NEED_VLAN) {
vlan = batadv_get_vlan_from_info(bat_priv, net, info);
if (IS_ERR(vlan)) {
ret = PTR_ERR(vlan);
goto err_put_softif;
}
info->user_ptr[1] = vlan;
}
return 0;
err_put_softif:
if (bat_priv)
dev_put(bat_priv->soft_iface);
return ret;
}
/**
* 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_hard_iface *hard_iface;
struct batadv_softif_vlan *vlan;
struct batadv_priv *bat_priv;
if (ops->internal_flags & BATADV_FLAG_NEED_HARDIF &&
info->user_ptr[1]) {
hard_iface = info->user_ptr[1];
batadv_hardif_put(hard_iface);
}
if (ops->internal_flags & BATADV_FLAG_NEED_VLAN && info->user_ptr[1]) {
vlan = info->user_ptr[1];
batadv_softif_vlan_put(vlan);
}
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[] = { static const struct genl_ops batadv_netlink_ops[] = {
{ {
.cmd = BATADV_CMD_GET_MESH_INFO, .cmd = BATADV_CMD_GET_MESH,
.flags = GENL_ADMIN_PERM, /* can be retrieved by unprivileged users */
.policy = batadv_netlink_policy, .policy = batadv_netlink_policy,
.doit = batadv_netlink_get_mesh_info, .doit = batadv_netlink_get_mesh,
.internal_flags = BATADV_FLAG_NEED_MESH,
}, },
{ {
.cmd = BATADV_CMD_TP_METER, .cmd = BATADV_CMD_TP_METER,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
.policy = batadv_netlink_policy, .policy = batadv_netlink_policy,
.doit = batadv_netlink_tp_meter_start, .doit = batadv_netlink_tp_meter_start,
.internal_flags = BATADV_FLAG_NEED_MESH,
}, },
{ {
.cmd = BATADV_CMD_TP_METER_CANCEL, .cmd = BATADV_CMD_TP_METER_CANCEL,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
.policy = batadv_netlink_policy, .policy = batadv_netlink_policy,
.doit = batadv_netlink_tp_meter_cancel, .doit = batadv_netlink_tp_meter_cancel,
.internal_flags = BATADV_FLAG_NEED_MESH,
}, },
{ {
.cmd = BATADV_CMD_GET_ROUTING_ALGOS, .cmd = BATADV_CMD_GET_ROUTING_ALGOS,
...@@ -571,10 +1370,13 @@ static const struct genl_ops batadv_netlink_ops[] = { ...@@ -571,10 +1370,13 @@ static const struct genl_ops batadv_netlink_ops[] = {
.dumpit = batadv_algo_dump, .dumpit = batadv_algo_dump,
}, },
{ {
.cmd = BATADV_CMD_GET_HARDIFS, .cmd = BATADV_CMD_GET_HARDIF,
.flags = GENL_ADMIN_PERM, /* can be retrieved by unprivileged users */
.policy = batadv_netlink_policy, .policy = batadv_netlink_policy,
.dumpit = batadv_netlink_dump_hardifs, .dumpit = batadv_netlink_dump_hardif,
.doit = batadv_netlink_get_hardif,
.internal_flags = BATADV_FLAG_NEED_MESH |
BATADV_FLAG_NEED_HARDIF,
}, },
{ {
.cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL, .cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL,
...@@ -630,7 +1432,37 @@ static const struct genl_ops batadv_netlink_ops[] = { ...@@ -630,7 +1432,37 @@ static const struct genl_ops batadv_netlink_ops[] = {
.policy = batadv_netlink_policy, .policy = batadv_netlink_policy,
.dumpit = batadv_mcast_flags_dump, .dumpit = batadv_mcast_flags_dump,
}, },
{
.cmd = BATADV_CMD_SET_MESH,
.flags = GENL_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_set_mesh,
.internal_flags = BATADV_FLAG_NEED_MESH,
},
{
.cmd = BATADV_CMD_SET_HARDIF,
.flags = GENL_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_set_hardif,
.internal_flags = BATADV_FLAG_NEED_MESH |
BATADV_FLAG_NEED_HARDIF,
},
{
.cmd = BATADV_CMD_GET_VLAN,
/* can be retrieved by unprivileged users */
.policy = batadv_netlink_policy,
.doit = batadv_netlink_get_vlan,
.internal_flags = BATADV_FLAG_NEED_MESH |
BATADV_FLAG_NEED_VLAN,
},
{
.cmd = BATADV_CMD_SET_VLAN,
.flags = GENL_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_set_vlan,
.internal_flags = BATADV_FLAG_NEED_MESH |
BATADV_FLAG_NEED_VLAN,
},
}; };
struct genl_family batadv_netlink_family __ro_after_init = { struct genl_family batadv_netlink_family __ro_after_init = {
...@@ -639,6 +1471,8 @@ struct genl_family batadv_netlink_family __ro_after_init = { ...@@ -639,6 +1471,8 @@ struct genl_family batadv_netlink_family __ro_after_init = {
.version = 1, .version = 1,
.maxattr = BATADV_ATTR_MAX, .maxattr = BATADV_ATTR_MAX,
.netnsok = true, .netnsok = true,
.pre_doit = batadv_pre_doit,
.post_doit = batadv_post_doit,
.module = THIS_MODULE, .module = THIS_MODULE,
.ops = batadv_netlink_ops, .ops = batadv_netlink_ops,
.n_ops = ARRAY_SIZE(batadv_netlink_ops), .n_ops = ARRAY_SIZE(batadv_netlink_ops),
......
...@@ -34,6 +34,12 @@ int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst, ...@@ -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, u8 result, u32 test_time, u64 total_bytes,
u32 cookie); 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; extern struct genl_family batadv_netlink_family;
#endif /* _NET_BATMAN_ADV_NETLINK_H_ */ #endif /* _NET_BATMAN_ADV_NETLINK_H_ */
...@@ -50,13 +50,13 @@ ...@@ -50,13 +50,13 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/types.h> #include <linux/types.h>
#include <uapi/linux/batadv_packet.h> #include <uapi/linux/batadv_packet.h>
#include <uapi/linux/batman_adv.h>
#include "bat_algo.h" #include "bat_algo.h"
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
#include "debugfs.h" #include "debugfs.h"
#include "distributed-arp-table.h" #include "distributed-arp-table.h"
#include "gateway_client.h" #include "gateway_client.h"
#include "gateway_common.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "multicast.h" #include "multicast.h"
#include "network-coding.h" #include "network-coding.h"
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <uapi/linux/batadv_packet.h> #include <uapi/linux/batadv_packet.h>
#include <uapi/linux/batman_adv.h>
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
#include "distributed-arp-table.h" #include "distributed-arp-table.h"
...@@ -47,6 +48,7 @@ ...@@ -47,6 +48,7 @@
#include "gateway_common.h" #include "gateway_common.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "log.h" #include "log.h"
#include "netlink.h"
#include "network-coding.h" #include "network-coding.h"
#include "soft-interface.h" #include "soft-interface.h"
...@@ -153,9 +155,14 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \ ...@@ -153,9 +155,14 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
{ \ { \
struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
struct batadv_priv *bat_priv = netdev_priv(net_dev); \ struct batadv_priv *bat_priv = netdev_priv(net_dev); \
ssize_t length; \
\ \
return __batadv_store_bool_attr(buff, count, _post_func, attr, \ length = __batadv_store_bool_attr(buff, count, _post_func, attr,\
&bat_priv->_name, net_dev); \ &bat_priv->_name, net_dev); \
\
batadv_netlink_notify_mesh(bat_priv); \
\
return length; \
} }
#define BATADV_ATTR_SIF_SHOW_BOOL(_name) \ #define BATADV_ATTR_SIF_SHOW_BOOL(_name) \
...@@ -185,11 +192,16 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \ ...@@ -185,11 +192,16 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
{ \ { \
struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
struct batadv_priv *bat_priv = netdev_priv(net_dev); \ struct batadv_priv *bat_priv = netdev_priv(net_dev); \
ssize_t length; \
\ \
return __batadv_store_uint_attr(buff, count, _min, _max, \ length = __batadv_store_uint_attr(buff, count, _min, _max, \
_post_func, attr, \ _post_func, attr, \
&bat_priv->_var, net_dev, \ &bat_priv->_var, net_dev, \
NULL); \ NULL); \
\
batadv_netlink_notify_mesh(bat_priv); \
\
return length; \
} }
#define BATADV_ATTR_SIF_SHOW_UINT(_name, _var) \ #define BATADV_ATTR_SIF_SHOW_UINT(_name, _var) \
...@@ -222,6 +234,11 @@ ssize_t batadv_store_vlan_##_name(struct kobject *kobj, \ ...@@ -222,6 +234,11 @@ ssize_t batadv_store_vlan_##_name(struct kobject *kobj, \
attr, &vlan->_name, \ attr, &vlan->_name, \
bat_priv->soft_iface); \ bat_priv->soft_iface); \
\ \
if (vlan->vid) \
batadv_netlink_notify_vlan(bat_priv, vlan); \
else \
batadv_netlink_notify_mesh(bat_priv); \
\
batadv_softif_vlan_put(vlan); \ batadv_softif_vlan_put(vlan); \
return res; \ return res; \
} }
...@@ -255,6 +272,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \ ...@@ -255,6 +272,7 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
{ \ { \
struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
struct batadv_hard_iface *hard_iface; \ struct batadv_hard_iface *hard_iface; \
struct batadv_priv *bat_priv; \
ssize_t length; \ ssize_t length; \
\ \
hard_iface = batadv_hardif_get_by_netdev(net_dev); \ hard_iface = batadv_hardif_get_by_netdev(net_dev); \
...@@ -267,6 +285,11 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \ ...@@ -267,6 +285,11 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \
hard_iface->soft_iface, \ hard_iface->soft_iface, \
net_dev); \ net_dev); \
\ \
if (hard_iface->soft_iface) { \
bat_priv = netdev_priv(hard_iface->soft_iface); \
batadv_netlink_notify_hardif(bat_priv, hard_iface); \
} \
\
batadv_hardif_put(hard_iface); \ batadv_hardif_put(hard_iface); \
return length; \ return length; \
} }
...@@ -536,6 +559,9 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj, ...@@ -536,6 +559,9 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
batadv_gw_check_client_stop(bat_priv); batadv_gw_check_client_stop(bat_priv);
atomic_set(&bat_priv->gw.mode, (unsigned int)gw_mode_tmp); atomic_set(&bat_priv->gw.mode, (unsigned int)gw_mode_tmp);
batadv_gw_tvlv_container_update(bat_priv); batadv_gw_tvlv_container_update(bat_priv);
batadv_netlink_notify_mesh(bat_priv);
return count; return count;
} }
...@@ -562,6 +588,7 @@ static ssize_t batadv_store_gw_sel_class(struct kobject *kobj, ...@@ -562,6 +588,7 @@ static ssize_t batadv_store_gw_sel_class(struct kobject *kobj,
size_t count) size_t count)
{ {
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
ssize_t length;
/* setting the GW selection class is allowed only if the routing /* setting the GW selection class is allowed only if the routing
* algorithm in use implements the GW API * algorithm in use implements the GW API
...@@ -577,10 +604,14 @@ static ssize_t batadv_store_gw_sel_class(struct kobject *kobj, ...@@ -577,10 +604,14 @@ static ssize_t batadv_store_gw_sel_class(struct kobject *kobj,
return bat_priv->algo_ops->gw.store_sel_class(bat_priv, buff, return bat_priv->algo_ops->gw.store_sel_class(bat_priv, buff,
count); count);
return __batadv_store_uint_attr(buff, count, 1, BATADV_TQ_MAX_VALUE, length = __batadv_store_uint_attr(buff, count, 1, BATADV_TQ_MAX_VALUE,
batadv_post_gw_reselect, attr, batadv_post_gw_reselect, attr,
&bat_priv->gw.sel_class, &bat_priv->gw.sel_class,
bat_priv->soft_iface, NULL); bat_priv->soft_iface, NULL);
batadv_netlink_notify_mesh(bat_priv);
return length;
} }
static ssize_t batadv_show_gw_bwidth(struct kobject *kobj, static ssize_t batadv_show_gw_bwidth(struct kobject *kobj,
...@@ -600,12 +631,18 @@ static ssize_t batadv_store_gw_bwidth(struct kobject *kobj, ...@@ -600,12 +631,18 @@ static ssize_t batadv_store_gw_bwidth(struct kobject *kobj,
struct attribute *attr, char *buff, struct attribute *attr, char *buff,
size_t count) size_t count)
{ {
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
struct net_device *net_dev = batadv_kobj_to_netdev(kobj); struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
ssize_t length;
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
return batadv_gw_bandwidth_set(net_dev, buff, count); length = batadv_gw_bandwidth_set(net_dev, buff, count);
batadv_netlink_notify_mesh(bat_priv);
return length;
} }
/** /**
...@@ -673,6 +710,8 @@ static ssize_t batadv_store_isolation_mark(struct kobject *kobj, ...@@ -673,6 +710,8 @@ static ssize_t batadv_store_isolation_mark(struct kobject *kobj,
"New skb mark for extended isolation: %#.8x/%#.8x\n", "New skb mark for extended isolation: %#.8x/%#.8x\n",
bat_priv->isolation_mark, bat_priv->isolation_mark_mask); bat_priv->isolation_mark, bat_priv->isolation_mark_mask);
batadv_netlink_notify_mesh(bat_priv);
return count; return count;
} }
...@@ -1077,6 +1116,7 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj, ...@@ -1077,6 +1116,7 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj,
struct attribute *attr, struct attribute *attr,
char *buff, size_t count) char *buff, size_t count)
{ {
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
struct net_device *net_dev = batadv_kobj_to_netdev(kobj); struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
struct batadv_hard_iface *hard_iface; struct batadv_hard_iface *hard_iface;
u32 tp_override; u32 tp_override;
...@@ -1107,6 +1147,8 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj, ...@@ -1107,6 +1147,8 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj,
atomic_set(&hard_iface->bat_v.throughput_override, tp_override); atomic_set(&hard_iface->bat_v.throughput_override, tp_override);
batadv_netlink_notify_hardif(bat_priv, hard_iface);
out: out:
batadv_hardif_put(hard_iface); batadv_hardif_put(hard_iface);
return count; return count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment