mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-30 13:34:44 +08:00
batman-adv: Drop per algo GW section class code
This code was only used in the past for the sysfs interface. But since this was replace with netlink, it was never executed. The function pointer was only checked to figure out whether the limit 255 (B.A.T.M.A.N. IV) or 2**32-1 (B.A.T.M.A.N. V) should be used as limit. So instead of keeping the function pointer, just store the limits directly in struct batadv_algo_gw_ops. Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
This commit is contained in:
parent
02e61f06a9
commit
6f96d46f9a
@ -2516,6 +2516,7 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
|
||||
},
|
||||
.gw = {
|
||||
.init_sel_class = batadv_iv_init_sel_class,
|
||||
.sel_class_max = BATADV_TQ_MAX_VALUE,
|
||||
.get_best_gw_node = batadv_iv_gw_get_best_gw_node,
|
||||
.is_eligible = batadv_iv_gw_is_eligible,
|
||||
.dump = batadv_iv_gw_dump,
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/kref.h>
|
||||
#include <linux/limits.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/minmax.h>
|
||||
#include <linux/netdevice.h>
|
||||
@ -34,7 +35,6 @@
|
||||
#include "bat_v_elp.h"
|
||||
#include "bat_v_ogm.h"
|
||||
#include "gateway_client.h"
|
||||
#include "gateway_common.h"
|
||||
#include "hard-interface.h"
|
||||
#include "hash.h"
|
||||
#include "log.h"
|
||||
@ -512,25 +512,6 @@ static void batadv_v_init_sel_class(struct batadv_priv *bat_priv)
|
||||
atomic_set(&bat_priv->gw.sel_class, 50);
|
||||
}
|
||||
|
||||
static ssize_t batadv_v_store_sel_class(struct batadv_priv *bat_priv,
|
||||
char *buff, size_t count)
|
||||
{
|
||||
u32 old_class, class;
|
||||
|
||||
if (!batadv_parse_throughput(bat_priv->soft_iface, buff,
|
||||
"B.A.T.M.A.N. V GW selection class",
|
||||
&class))
|
||||
return -EINVAL;
|
||||
|
||||
old_class = atomic_read(&bat_priv->gw.sel_class);
|
||||
atomic_set(&bat_priv->gw.sel_class, class);
|
||||
|
||||
if (old_class != class)
|
||||
batadv_gw_reselect(bat_priv);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* batadv_v_gw_throughput_get() - retrieve the GW-bandwidth for a given GW
|
||||
* @gw_node: the GW to retrieve the metric for
|
||||
@ -818,7 +799,7 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
|
||||
},
|
||||
.gw = {
|
||||
.init_sel_class = batadv_v_init_sel_class,
|
||||
.store_sel_class = batadv_v_store_sel_class,
|
||||
.sel_class_max = U32_MAX,
|
||||
.get_best_gw_node = batadv_v_gw_get_best_gw_node,
|
||||
.is_eligible = batadv_v_gw_is_eligible,
|
||||
.dump = batadv_v_gw_dump,
|
||||
|
@ -9,86 +9,14 @@
|
||||
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/byteorder/generic.h>
|
||||
#include <linux/kstrtox.h>
|
||||
#include <linux/limits.h>
|
||||
#include <linux/math64.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/stddef.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/types.h>
|
||||
#include <uapi/linux/batadv_packet.h>
|
||||
#include <uapi/linux/batman_adv.h>
|
||||
|
||||
#include "gateway_client.h"
|
||||
#include "log.h"
|
||||
#include "tvlv.h"
|
||||
|
||||
/**
|
||||
* batadv_parse_throughput() - parse supplied string buffer to extract
|
||||
* throughput information
|
||||
* @net_dev: the soft interface net device
|
||||
* @buff: string buffer to parse
|
||||
* @description: text shown when throughput string cannot be parsed
|
||||
* @throughput: pointer holding the returned throughput information
|
||||
*
|
||||
* Return: false on parse error and true otherwise.
|
||||
*/
|
||||
bool batadv_parse_throughput(struct net_device *net_dev, char *buff,
|
||||
const char *description, u32 *throughput)
|
||||
{
|
||||
enum batadv_bandwidth_units bw_unit_type = BATADV_BW_UNIT_KBIT;
|
||||
u64 lthroughput;
|
||||
char *tmp_ptr;
|
||||
int ret;
|
||||
|
||||
if (strlen(buff) > 4) {
|
||||
tmp_ptr = buff + strlen(buff) - 4;
|
||||
|
||||
if (strncasecmp(tmp_ptr, "mbit", 4) == 0)
|
||||
bw_unit_type = BATADV_BW_UNIT_MBIT;
|
||||
|
||||
if (strncasecmp(tmp_ptr, "kbit", 4) == 0 ||
|
||||
bw_unit_type == BATADV_BW_UNIT_MBIT)
|
||||
*tmp_ptr = '\0';
|
||||
}
|
||||
|
||||
ret = kstrtou64(buff, 10, <hroughput);
|
||||
if (ret) {
|
||||
batadv_err(net_dev,
|
||||
"Invalid throughput speed for %s: %s\n",
|
||||
description, buff);
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (bw_unit_type) {
|
||||
case BATADV_BW_UNIT_MBIT:
|
||||
/* prevent overflow */
|
||||
if (U64_MAX / 10 < lthroughput) {
|
||||
batadv_err(net_dev,
|
||||
"Throughput speed for %s too large: %s\n",
|
||||
description, buff);
|
||||
return false;
|
||||
}
|
||||
|
||||
lthroughput *= 10;
|
||||
break;
|
||||
case BATADV_BW_UNIT_KBIT:
|
||||
default:
|
||||
lthroughput = div_u64(lthroughput, 100);
|
||||
break;
|
||||
}
|
||||
|
||||
if (lthroughput > U32_MAX) {
|
||||
batadv_err(net_dev,
|
||||
"Throughput speed for %s too large: %s\n",
|
||||
description, buff);
|
||||
return false;
|
||||
}
|
||||
|
||||
*throughput = lthroughput;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* batadv_gw_tvlv_container_update() - update the gw tvlv container after
|
||||
* gateway setting change
|
||||
|
@ -9,9 +9,6 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
/**
|
||||
* enum batadv_bandwidth_units - bandwidth unit types
|
||||
*/
|
||||
@ -30,7 +27,5 @@ enum batadv_bandwidth_units {
|
||||
void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv);
|
||||
void batadv_gw_init(struct batadv_priv *bat_priv);
|
||||
void batadv_gw_free(struct batadv_priv *bat_priv);
|
||||
bool batadv_parse_throughput(struct net_device *net_dev, char *buff,
|
||||
const char *description, u32 *throughput);
|
||||
|
||||
#endif /* _NET_BATMAN_ADV_GATEWAY_COMMON_H_ */
|
||||
|
@ -548,15 +548,12 @@ static int batadv_netlink_set_mesh(struct sk_buff *skb, struct genl_info *info)
|
||||
* algorithm in use implements the GW API
|
||||
*/
|
||||
|
||||
u32 sel_class_max = 0xffffffffu;
|
||||
u32 sel_class_max = bat_priv->algo_ops->gw.sel_class_max;
|
||||
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);
|
||||
|
@ -2191,11 +2191,10 @@ struct batadv_algo_gw_ops {
|
||||
void (*init_sel_class)(struct batadv_priv *bat_priv);
|
||||
|
||||
/**
|
||||
* @store_sel_class: parse and stores a new GW selection class
|
||||
* (optional)
|
||||
* @sel_class_max: maximum allowed GW selection class
|
||||
*/
|
||||
ssize_t (*store_sel_class)(struct batadv_priv *bat_priv, char *buff,
|
||||
size_t count);
|
||||
u32 sel_class_max;
|
||||
|
||||
/**
|
||||
* @get_best_gw_node: select the best GW from the list of available
|
||||
* nodes (optional)
|
||||
|
Loading…
Reference in New Issue
Block a user