Skip to content

Commit

Permalink
batman-adv: Prefix main non-static functions with batadv_
Browse files Browse the repository at this point in the history
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: David Miller <davem@davemloft.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
  • Loading branch information
Sven Eckelmann authored and Antonio Quartulli committed Jun 20, 2012
1 parent d0f714f commit 3193e8f
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 97 deletions.
6 changes: 3 additions & 3 deletions net/batman-adv/bat_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ static int log_open(struct inode *inode, struct file *file)
{
nonseekable_open(inode, file);
file->private_data = inode->i_private;
inc_module_count();
batadv_inc_module_count();
return 0;
}

static int log_release(struct inode *inode, struct file *file)
{
dec_module_count();
batadv_dec_module_count();
return 0;
}

Expand Down Expand Up @@ -224,7 +224,7 @@ static void debug_log_cleanup(struct bat_priv *bat_priv)

static int bat_algorithms_open(struct inode *inode, struct file *file)
{
return single_open(file, bat_algo_seq_print_text, NULL);
return single_open(file, batadv_algo_seq_print_text, NULL);
}

static int originators_open(struct inode *inode, struct file *file)
Expand Down
16 changes: 8 additions & 8 deletions net/batman-adv/bat_iv_ogm.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
batadv_inc_counter(bat_priv, BAT_CNT_MGMT_TX);
batadv_add_counter(bat_priv, BAT_CNT_MGMT_TX_BYTES,
skb->len + ETH_HLEN);
batadv_send_skb_packet(skb, hard_iface, broadcast_addr);
batadv_send_skb_packet(skb, hard_iface, batadv_broadcast_addr);
}
}

Expand Down Expand Up @@ -255,15 +255,15 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
/* skb is only used once and than forw_packet is free'd */
batadv_send_skb_packet(forw_packet->skb,
forw_packet->if_incoming,
broadcast_addr);
batadv_broadcast_addr);
forw_packet->skb = NULL;

goto out;
}

/* broadcast on every interface */
rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->soft_iface != soft_iface)
continue;

Expand Down Expand Up @@ -425,7 +425,7 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
/* start timer for this packet */
INIT_DELAYED_WORK(&forw_packet_aggr->delayed_work,
batadv_send_outstanding_bat_ogm_packet);
queue_delayed_work(bat_event_workqueue,
queue_delayed_work(batadv_event_workqueue,
&forw_packet_aggr->delayed_work,
send_time - jiffies);

Expand Down Expand Up @@ -984,7 +984,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
batman_ogm_packet->header.version, has_directlink_flag);

rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->if_status != IF_ACTIVE)
continue;

Expand Down Expand Up @@ -1259,18 +1259,18 @@ int __init batadv_iv_init(void)
int ret;

/* batman originator packet */
ret = recv_handler_register(BAT_IV_OGM, bat_iv_ogm_receive);
ret = batadv_recv_handler_register(BAT_IV_OGM, bat_iv_ogm_receive);
if (ret < 0)
goto out;

ret = bat_algo_register(&batman_iv);
ret = batadv_algo_register(&batman_iv);
if (ret < 0)
goto handler_unregister;

goto out;

handler_unregister:
recv_handler_unregister(BAT_IV_OGM);
batadv_recv_handler_unregister(BAT_IV_OGM);
out:
return ret;
}
2 changes: 1 addition & 1 deletion net/batman-adv/bridge_loop_avoidance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
static void bla_start_timer(struct bat_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->bla_work, bla_periodic_work);
queue_delayed_work(bat_event_workqueue, &bat_priv->bla_work,
queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work,
msecs_to_jiffies(BLA_PERIOD_LENGTH));
}

Expand Down
14 changes: 7 additions & 7 deletions net/batman-adv/hard-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct hard_iface *batadv_hardif_get_by_netdev(const struct net_device *net_dev)
struct hard_iface *hard_iface;

rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->net_dev == net_dev &&
atomic_inc_not_zero(&hard_iface->refcount))
goto out;
Expand Down Expand Up @@ -86,7 +86,7 @@ static struct hard_iface *hardif_get_active(const struct net_device *soft_iface)
struct hard_iface *hard_iface;

rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->soft_iface != soft_iface)
continue;

Expand Down Expand Up @@ -161,7 +161,7 @@ static void check_known_mac_addr(const struct net_device *net_dev)
const struct hard_iface *hard_iface;

rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if ((hard_iface->if_status != IF_ACTIVE) &&
(hard_iface->if_status != IF_TO_BE_ACTIVATED))
continue;
Expand Down Expand Up @@ -192,7 +192,7 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
goto out;

rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if ((hard_iface->if_status != IF_ACTIVE) &&
(hard_iface->if_status != IF_TO_BE_ACTIVATED))
continue;
Expand Down Expand Up @@ -315,7 +315,7 @@ int batadv_hardif_enable_interface(struct hard_iface *hard_iface,
batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);

hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN);
hard_iface->batman_adv_ptype.func = batman_skb_recv;
hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv;
hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
dev_add_pack(&hard_iface->batman_adv_ptype);

Expand Down Expand Up @@ -436,7 +436,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
atomic_set(&hard_iface->refcount, 2);

check_known_mac_addr(hard_iface->net_dev);
list_add_tail_rcu(&hard_iface->list, &hardif_list);
list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);

/**
* This can't be called via a bat_priv callback because
Expand Down Expand Up @@ -477,7 +477,7 @@ void batadv_hardif_remove_interfaces(void)

rtnl_lock();
list_for_each_entry_safe(hard_iface, hard_iface_tmp,
&hardif_list, list) {
&batadv_hardif_list, list) {
list_del_rcu(&hard_iface->list);
hardif_remove_interface(hard_iface);
}
Expand Down
4 changes: 2 additions & 2 deletions net/batman-adv/icmp_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int bat_socket_open(struct inode *inode, struct file *file)

file->private_data = socket_client;

inc_module_count();
batadv_inc_module_count();
return 0;
}

Expand All @@ -98,7 +98,7 @@ static int bat_socket_release(struct inode *inode, struct file *file)
spin_unlock_bh(&socket_client->lock);

kfree(socket_client);
dec_module_count();
batadv_dec_module_count();

return 0;
}
Expand Down
57 changes: 29 additions & 28 deletions net/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@

/* List manipulations on hardif_list have to be rtnl_lock()'ed,
* list traversals just rcu-locked */
struct list_head hardif_list;
struct list_head batadv_hardif_list;
static int (*recv_packet_handler[256])(struct sk_buff *, struct hard_iface *);
char bat_routing_algo[20] = "BATMAN_IV";
char batadv_routing_algo[20] = "BATMAN_IV";
static struct hlist_head bat_algo_list;

unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
unsigned char batadv_broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};

struct workqueue_struct *bat_event_workqueue;
struct workqueue_struct *batadv_event_workqueue;

static void recv_handler_init(void);

static int __init batman_init(void)
{
INIT_LIST_HEAD(&hardif_list);
INIT_LIST_HEAD(&batadv_hardif_list);
INIT_HLIST_HEAD(&bat_algo_list);

recv_handler_init();
Expand All @@ -60,9 +60,9 @@ static int __init batman_init(void)

/* the name should not be longer than 10 chars - see
* http://lwn.net/Articles/23634/ */
bat_event_workqueue = create_singlethread_workqueue("bat_events");
batadv_event_workqueue = create_singlethread_workqueue("bat_events");

if (!bat_event_workqueue)
if (!batadv_event_workqueue)
return -ENOMEM;

batadv_socket_init();
Expand All @@ -82,14 +82,14 @@ static void __exit batman_exit(void)
unregister_netdevice_notifier(&batadv_hard_if_notifier);
batadv_hardif_remove_interfaces();

flush_workqueue(bat_event_workqueue);
destroy_workqueue(bat_event_workqueue);
bat_event_workqueue = NULL;
flush_workqueue(batadv_event_workqueue);
destroy_workqueue(batadv_event_workqueue);
batadv_event_workqueue = NULL;

rcu_barrier();
}

int mesh_init(struct net_device *soft_iface)
int batadv_mesh_init(struct net_device *soft_iface)
{
struct bat_priv *bat_priv = netdev_priv(soft_iface);
int ret;
Expand Down Expand Up @@ -135,11 +135,11 @@ int mesh_init(struct net_device *soft_iface)
return 0;

err:
mesh_free(soft_iface);
batadv_mesh_free(soft_iface);
return ret;
}

void mesh_free(struct net_device *soft_iface)
void batadv_mesh_free(struct net_device *soft_iface)
{
struct bat_priv *bat_priv = netdev_priv(soft_iface);

Expand All @@ -161,22 +161,22 @@ void mesh_free(struct net_device *soft_iface)
atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
}

void inc_module_count(void)
void batadv_inc_module_count(void)
{
try_module_get(THIS_MODULE);
}

void dec_module_count(void)
void batadv_dec_module_count(void)
{
module_put(THIS_MODULE);
}

int is_my_mac(const uint8_t *addr)
int batadv_is_my_mac(const uint8_t *addr)
{
const struct hard_iface *hard_iface;

rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->if_status != IF_ACTIVE)
continue;

Expand All @@ -198,8 +198,9 @@ static int recv_unhandled_packet(struct sk_buff *skb,
/* incoming packets with the batman ethertype received on any active hard
* interface
*/
int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct net_device *orig_dev)
int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
struct net_device *orig_dev)
{
struct bat_priv *bat_priv;
struct batman_ogm_packet *batman_ogm_packet;
Expand Down Expand Up @@ -287,9 +288,9 @@ static void recv_handler_init(void)
recv_packet_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv;
}

int recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct hard_iface *))
int batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct hard_iface *))
{
if (recv_packet_handler[packet_type] != &recv_unhandled_packet)
return -EBUSY;
Expand All @@ -298,7 +299,7 @@ int recv_handler_register(uint8_t packet_type,
return 0;
}

void recv_handler_unregister(uint8_t packet_type)
void batadv_recv_handler_unregister(uint8_t packet_type)
{
recv_packet_handler[packet_type] = recv_unhandled_packet;
}
Expand All @@ -319,7 +320,7 @@ static struct bat_algo_ops *bat_algo_get(char *name)
return bat_algo_ops;
}

int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
int batadv_algo_register(struct bat_algo_ops *bat_algo_ops)
{
struct bat_algo_ops *bat_algo_ops_tmp;
int ret;
Expand Down Expand Up @@ -353,7 +354,7 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
return ret;
}

int bat_algo_select(struct bat_priv *bat_priv, char *name)
int batadv_algo_select(struct bat_priv *bat_priv, char *name)
{
struct bat_algo_ops *bat_algo_ops;
int ret = -EINVAL;
Expand All @@ -369,7 +370,7 @@ int bat_algo_select(struct bat_priv *bat_priv, char *name)
return ret;
}

int bat_algo_seq_print_text(struct seq_file *seq, void *offset)
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
{
struct bat_algo_ops *bat_algo_ops;
struct hlist_node *node;
Expand Down Expand Up @@ -407,8 +408,8 @@ static const struct kernel_param_ops param_ops_ra = {
};

static struct kparam_string __param_string_ra = {
.maxlen = sizeof(bat_routing_algo),
.string = bat_routing_algo,
.maxlen = sizeof(batadv_routing_algo),
.string = batadv_routing_algo,
};

module_param_cb(routing_algo, &param_ops_ra, &__param_string_ra, 0644);
Expand Down
41 changes: 21 additions & 20 deletions net/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,27 @@ enum dbg_level {
#include <linux/seq_file.h>
#include "types.h"

extern char bat_routing_algo[];
extern struct list_head hardif_list;

extern unsigned char broadcast_addr[];
extern struct workqueue_struct *bat_event_workqueue;

int mesh_init(struct net_device *soft_iface);
void mesh_free(struct net_device *soft_iface);
void inc_module_count(void);
void dec_module_count(void);
int is_my_mac(const uint8_t *addr);
int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct net_device *orig_dev);
int recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct hard_iface *));
void recv_handler_unregister(uint8_t packet_type);
int bat_algo_register(struct bat_algo_ops *bat_algo_ops);
int bat_algo_select(struct bat_priv *bat_priv, char *name);
int bat_algo_seq_print_text(struct seq_file *seq, void *offset);
extern char batadv_routing_algo[];
extern struct list_head batadv_hardif_list;

extern unsigned char batadv_broadcast_addr[];
extern struct workqueue_struct *batadv_event_workqueue;

int batadv_mesh_init(struct net_device *soft_iface);
void batadv_mesh_free(struct net_device *soft_iface);
void batadv_inc_module_count(void);
void batadv_dec_module_count(void);
int batadv_is_my_mac(const uint8_t *addr);
int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
struct net_device *orig_dev);
int batadv_recv_handler_register(uint8_t packet_type,
int (*recv_handler)(struct sk_buff *,
struct hard_iface *));
void batadv_recv_handler_unregister(uint8_t packet_type);
int batadv_algo_register(struct bat_algo_ops *bat_algo_ops);
int batadv_algo_select(struct bat_priv *bat_priv, char *name);
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);

#ifdef CONFIG_BATMAN_ADV_DEBUG
int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
Expand Down
Loading

0 comments on commit 3193e8f

Please sign in to comment.