提交 84d5e5e0 编写于 作者: S Sven Eckelmann 提交者: Antonio Quartulli

batman-adv: Prefix gateway-common non-static functions with batadv_

batman-adv can be compiled as part of the kernel instead of an module. In that
case the linker will see all non-static symbols of batman-adv and all other
non-static symbols of the kernel. This could lead to symbol collisions. A
prefix for the batman-adv symbols that defines their private namespace avoids
such a problem.
Reported-by: NDavid Miller <davem@davemloft.net>
Signed-off-by: NSven Eckelmann <sven@narfation.org>
上级 7cf06bc6
...@@ -409,7 +409,7 @@ static ssize_t show_gw_bwidth(struct kobject *kobj, struct attribute *attr, ...@@ -409,7 +409,7 @@ static ssize_t show_gw_bwidth(struct kobject *kobj, struct attribute *attr,
int down, up; int down, up;
int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth); int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth);
gw_bandwidth_to_kbit(gw_bandwidth, &down, &up); batadv_gw_bandwidth_to_kbit(gw_bandwidth, &down, &up);
return sprintf(buff, "%i%s/%i%s\n", return sprintf(buff, "%i%s/%i%s\n",
(down > 2048 ? down / 1024 : down), (down > 2048 ? down / 1024 : down),
(down > 2048 ? "MBit" : "KBit"), (down > 2048 ? "MBit" : "KBit"),
...@@ -425,7 +425,7 @@ static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr, ...@@ -425,7 +425,7 @@ static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr,
if (buff[count - 1] == '\n') if (buff[count - 1] == '\n')
buff[count - 1] = '\0'; buff[count - 1] = '\0';
return gw_bandwidth_set(net_dev, buff, count); return batadv_gw_bandwidth_set(net_dev, buff, count);
} }
BAT_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL); BAT_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
......
...@@ -116,13 +116,15 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv) ...@@ -116,13 +116,15 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
uint32_t max_gw_factor = 0, tmp_gw_factor = 0; uint32_t max_gw_factor = 0, tmp_gw_factor = 0;
uint8_t max_tq = 0; uint8_t max_tq = 0;
int down, up; int down, up;
struct orig_node *orig_node;
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) { hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) {
if (gw_node->deleted) if (gw_node->deleted)
continue; continue;
router = orig_node_get_router(gw_node->orig_node); orig_node = gw_node->orig_node;
router = orig_node_get_router(orig_node);
if (!router) if (!router)
continue; continue;
...@@ -131,8 +133,8 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv) ...@@ -131,8 +133,8 @@ static struct gw_node *gw_get_best_gw_node(struct bat_priv *bat_priv)
switch (atomic_read(&bat_priv->gw_sel_class)) { switch (atomic_read(&bat_priv->gw_sel_class)) {
case 1: /* fast connection */ case 1: /* fast connection */
gw_bandwidth_to_kbit(gw_node->orig_node->gw_flags, batadv_gw_bandwidth_to_kbit(orig_node->gw_flags,
&down, &up); &down, &up);
tmp_gw_factor = (router->tq_avg * router->tq_avg * tmp_gw_factor = (router->tq_avg * router->tq_avg *
down * 100 * 100) / down * 100 * 100) /
...@@ -319,7 +321,7 @@ static void gw_node_add(struct bat_priv *bat_priv, ...@@ -319,7 +321,7 @@ static void gw_node_add(struct bat_priv *bat_priv,
hlist_add_head_rcu(&gw_node->list, &bat_priv->gw_list); hlist_add_head_rcu(&gw_node->list, &bat_priv->gw_list);
spin_unlock_bh(&bat_priv->gw_list_lock); spin_unlock_bh(&bat_priv->gw_list_lock);
gw_bandwidth_to_kbit(new_gwflags, &down, &up); batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up);
bat_dbg(DBG_BATMAN, bat_priv, bat_dbg(DBG_BATMAN, bat_priv,
"Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n", "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n",
orig_node->orig, new_gwflags, orig_node->orig, new_gwflags,
...@@ -434,7 +436,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq, ...@@ -434,7 +436,7 @@ static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
struct neigh_node *router; struct neigh_node *router;
int down, up, ret = -1; int down, up, ret = -1;
gw_bandwidth_to_kbit(gw_node->orig_node->gw_flags, &down, &up); batadv_gw_bandwidth_to_kbit(gw_node->orig_node->gw_flags, &down, &up);
router = orig_node_get_router(gw_node->orig_node); router = orig_node_get_router(gw_node->orig_node);
if (!router) if (!router)
......
...@@ -59,7 +59,7 @@ static void kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class) ...@@ -59,7 +59,7 @@ static void kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class)
} }
/* returns the up and downspeeds in kbit, calculated from the class */ /* returns the up and downspeeds in kbit, calculated from the class */
void gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up) void batadv_gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
{ {
int sbit = (gw_srv_class & 0x80) >> 7; int sbit = (gw_srv_class & 0x80) >> 7;
int dpart = (gw_srv_class & 0x78) >> 3; int dpart = (gw_srv_class & 0x78) >> 3;
...@@ -136,7 +136,8 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, ...@@ -136,7 +136,8 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
return true; return true;
} }
ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count) ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
size_t count)
{ {
struct bat_priv *bat_priv = netdev_priv(net_dev); struct bat_priv *bat_priv = netdev_priv(net_dev);
long gw_bandwidth_tmp = 0; long gw_bandwidth_tmp = 0;
...@@ -160,7 +161,7 @@ ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count) ...@@ -160,7 +161,7 @@ ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count)
* speeds, hence we need to calculate it back to show the number * speeds, hence we need to calculate it back to show the number
* that is going to be propagated * that is going to be propagated
**/ **/
gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp, &down, &up); batadv_gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp, &down, &up);
if (atomic_read(&bat_priv->gw_bandwidth) == gw_bandwidth_tmp) if (atomic_read(&bat_priv->gw_bandwidth) == gw_bandwidth_tmp)
return count; return count;
......
...@@ -32,7 +32,8 @@ enum gw_modes { ...@@ -32,7 +32,8 @@ enum gw_modes {
#define GW_MODE_CLIENT_NAME "client" #define GW_MODE_CLIENT_NAME "client"
#define GW_MODE_SERVER_NAME "server" #define GW_MODE_SERVER_NAME "server"
void gw_bandwidth_to_kbit(uint8_t gw_class, int *down, int *up); void batadv_gw_bandwidth_to_kbit(uint8_t gw_class, int *down, int *up);
ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count); ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
size_t count);
#endif /* _NET_BATMAN_ADV_GATEWAY_COMMON_H_ */ #endif /* _NET_BATMAN_ADV_GATEWAY_COMMON_H_ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册