Author: marek Date: 2010-08-09 00:58:27 +0200 (Mon, 09 Aug 2010) New Revision: 1765
Modified: trunk/batman-adv/aggregation.c trunk/batman-adv/bat_sysfs.c trunk/batman-adv/bitarray.c trunk/batman-adv/bitarray.h trunk/batman-adv/gateway_client.c trunk/batman-adv/gateway_client.h trunk/batman-adv/hard-interface.c trunk/batman-adv/hard-interface.h trunk/batman-adv/hash.c trunk/batman-adv/hash.h trunk/batman-adv/icmp_socket.c trunk/batman-adv/main.c trunk/batman-adv/main.h trunk/batman-adv/originator.c trunk/batman-adv/originator.h trunk/batman-adv/routing.c trunk/batman-adv/routing.h trunk/batman-adv/send.c trunk/batman-adv/send.h trunk/batman-adv/soft-interface.c trunk/batman-adv/soft-interface.h trunk/batman-adv/translation-table.c trunk/batman-adv/translation-table.h trunk/batman-adv/types.h trunk/batman-adv/vis.c Log: batman-adv: attach each hard-interface to a soft-interface
This patch replaces the static bat0 interface with a dynamic/abstracted approach. It is now possible to create multiple batX interfaces by assigning hard interfaces to them. Each batX interface acts as an independent mesh network. A soft interface is removed once no hard interface references it any longer.
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
Modified: trunk/batman-adv/aggregation.c =================================================================== --- trunk/batman-adv/aggregation.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/aggregation.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -97,18 +97,15 @@
#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) /* create a new aggregated packet and add this packet to it */ -static void new_aggregated_packet(unsigned char *packet_buff, - int packet_len, - unsigned long send_time, - bool direct_link, - struct batman_if *if_incoming, - int own_packet) +static void new_aggregated_packet(unsigned char *packet_buff, int packet_len, + unsigned long send_time, bool direct_link, + struct batman_if *if_incoming, + int own_packet) { struct forw_packet *forw_packet_aggr; unsigned long flags; unsigned char *skb_buff; - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
/* own packet should always be scheduled */ if (!own_packet) {
Modified: trunk/batman-adv/bat_sysfs.c =================================================================== --- trunk/batman-adv/bat_sysfs.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/bat_sysfs.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -183,9 +183,7 @@ frag_enabled_tmp == 1 ? "enabled" : "disabled");
atomic_set(&bat_priv->frag_enabled, (unsigned)frag_enabled_tmp); - - update_min_mtu(); - + update_min_mtu(net_dev); return count; }
@@ -406,22 +404,6 @@ struct bat_attribute **bat_attr; int err;
- /* FIXME: should be done in the general mesh setup - routine as soon as we have it */ - atomic_set(&bat_priv->aggregation_enabled, 1); - atomic_set(&bat_priv->bonding_enabled, 0); - atomic_set(&bat_priv->frag_enabled, 1); - atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE); - atomic_set(&bat_priv->gw_mode, GW_MODE_OFF); - atomic_set(&bat_priv->gw_class, 0); - atomic_set(&bat_priv->orig_interval, 1000); - atomic_set(&bat_priv->log_level, 0); - atomic_set(&bat_priv->bcast_queue_left, BCAST_QUEUE_LEN); - atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN); - - bat_priv->primary_if = NULL; - bat_priv->num_ifaces = 0; - bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR, batif_kobject); if (!bat_priv->mesh_obj) { @@ -491,32 +473,34 @@ if (!batman_if) return count;
- if (strncmp(buff, "none", 4) == 0) - status_tmp = IF_NOT_IN_USE; + if (buff[count - 1] == '\n') + buff[count - 1] = '\0';
- if (strncmp(buff, "bat0", 4) == 0) - status_tmp = IF_I_WANT_YOU; - - if (status_tmp < 0) { - if (buff[count - 1] == '\n') - buff[count - 1] = '\0'; - + if (strlen(buff) >= IFNAMSIZ) { pr_err("Invalid parameter for 'mesh_iface' setting received: " - "%s\n", buff); + "interface name too long '%s'\n", buff); return -EINVAL; }
- if ((batman_if->if_status == status_tmp) || - ((status_tmp == IF_I_WANT_YOU) && - (batman_if->if_status != IF_NOT_IN_USE))) + if (strncmp(buff, "none", 4) == 0) + status_tmp = IF_NOT_IN_USE; + else + status_tmp = IF_I_WANT_YOU; + + if ((batman_if->if_status == status_tmp) || ((batman_if->soft_iface) && + (strncmp(batman_if->soft_iface->name, buff, IFNAMSIZ) == 0))) return count;
- if (status_tmp == IF_I_WANT_YOU) - status_tmp = hardif_enable_interface(batman_if); - else + if (status_tmp == IF_NOT_IN_USE) { hardif_disable_interface(batman_if); + return count; + }
- return (status_tmp < 0 ? status_tmp : count); + /* if the interface already is in use */ + if (batman_if->if_status != IF_NOT_IN_USE) + hardif_disable_interface(batman_if); + + return hardif_enable_interface(batman_if, buff); }
static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr,
Modified: trunk/batman-adv/bitarray.c =================================================================== --- trunk/batman-adv/bitarray.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/bitarray.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -127,11 +127,10 @@ * 1 if the window was moved (either new or very old) * 0 if the window was not moved/shifted. */ -char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff, - int8_t set_mark) +char bit_get_packet(void *priv, TYPE_OF_WORD *seq_bits, + int32_t seq_num_diff, int8_t set_mark) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = (struct bat_priv *)priv;
/* sequence number is slightly older. We already got a sequence number * higher than this one, so we just mark it. */
Modified: trunk/batman-adv/bitarray.h =================================================================== --- trunk/batman-adv/bitarray.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/bitarray.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -38,8 +38,8 @@
/* receive and process one packet, returns 1 if received seq_num is considered * new, 0 if old */ -char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff, - int8_t set_mark); +char bit_get_packet(void *priv, TYPE_OF_WORD *seq_bits, + int32_t seq_num_diff, int8_t set_mark);
/* count the hamming weight, how many good packets did we receive? */ int bit_packet_count(TYPE_OF_WORD *seq_bits);
Modified: trunk/batman-adv/gateway_client.c =================================================================== --- trunk/batman-adv/gateway_client.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/gateway_client.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -54,10 +54,8 @@ spin_unlock(&curr_gw_lock); }
-void gw_election(void) +void gw_election(struct bat_priv *bat_priv) { - /* FIXME: get bat_priv */ - struct bat_priv *bat_priv = netdev_priv(soft_device); struct gw_node *gw_node, *curr_gw_tmp = NULL; uint8_t max_tq = 0; uint32_t max_gw_factor = 0, tmp_gw_factor = 0; @@ -209,10 +207,9 @@ gw_deselect(); }
-static void gw_node_add(struct orig_node *orig_node, uint8_t new_gwflags) +static void gw_node_add(struct bat_priv *bat_priv, + struct orig_node *orig_node, uint8_t new_gwflags) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); struct gw_node *gw_node; int down, up;
@@ -236,10 +233,9 @@ (up > 2048 ? "MBit" : "KBit")); }
-void gw_node_update(struct orig_node *orig_node, uint8_t new_gwflags) +void gw_node_update(struct bat_priv *bat_priv, + struct orig_node *orig_node, uint8_t new_gwflags) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); struct gw_node *gw_node;
rcu_read_lock(); @@ -273,12 +269,12 @@ if (new_gwflags == 0) return;
- gw_node_add(orig_node, new_gwflags); + gw_node_add(bat_priv, orig_node, new_gwflags); }
-void gw_node_delete(struct orig_node *orig_node) +void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node) { - return gw_node_update(orig_node, 0); + return gw_node_update(bat_priv, orig_node, 0); }
static void gw_node_free(struct rcu_head *rcu)
Modified: trunk/batman-adv/gateway_client.h =================================================================== --- trunk/batman-adv/gateway_client.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/gateway_client.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -23,11 +23,12 @@ #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
void gw_deselect(void); -void gw_election(void); +void gw_election(struct bat_priv *bat_priv); void *gw_get_selected(void); void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node); -void gw_node_update(struct orig_node *orig_node, uint8_t new_gwflags); -void gw_node_delete(struct orig_node *orig_node); +void gw_node_update(struct bat_priv *bat_priv, + struct orig_node *orig_node, uint8_t new_gwflags); +void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node); void gw_node_purge_deleted(void); void gw_node_list_free(void); int gw_client_seq_print_text(struct seq_file *seq, void *offset);
Modified: trunk/batman-adv/hard-interface.c =================================================================== --- trunk/batman-adv/hard-interface.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/hard-interface.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -160,24 +160,28 @@ rcu_read_unlock(); }
-int hardif_min_mtu(void) +int hardif_min_mtu(struct net_device *soft_iface) { + struct bat_priv *bat_priv = netdev_priv(soft_iface); struct batman_if *batman_if; /* allow big frames if all devices are capable to do so * (have MTU > 1500 + BAT_HEADER_LEN) */ int min_mtu = ETH_DATA_LEN; - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device);
if (atomic_read(&bat_priv->frag_enabled)) goto out;
rcu_read_lock(); list_for_each_entry_rcu(batman_if, &if_list, list) { - if ((batman_if->if_status == IF_ACTIVE) || - (batman_if->if_status == IF_TO_BE_ACTIVATED)) - min_mtu = MIN(batman_if->net_dev->mtu - BAT_HEADER_LEN, - min_mtu); + if ((batman_if->if_status != IF_ACTIVE) && + (batman_if->if_status != IF_TO_BE_ACTIVATED)) + continue; + + if (batman_if->soft_iface != soft_iface) + continue; + + min_mtu = MIN(batman_if->net_dev->mtu - BAT_HEADER_LEN, + min_mtu); } rcu_read_unlock(); out: @@ -185,22 +189,23 @@ }
/* adjusts the MTU if a new interface with a smaller MTU appeared. */ -void update_min_mtu(void) +void update_min_mtu(struct net_device *soft_iface) { int min_mtu;
- min_mtu = hardif_min_mtu(); - if (soft_device->mtu != min_mtu) - soft_device->mtu = min_mtu; + min_mtu = hardif_min_mtu(soft_iface); + if (soft_iface->mtu != min_mtu) + soft_iface->mtu = min_mtu; }
-static void hardif_activate_interface(struct net_device *net_dev, - struct bat_priv *bat_priv, - struct batman_if *batman_if) +static void hardif_activate_interface(struct batman_if *batman_if) { + struct bat_priv *bat_priv; + if (batman_if->if_status != IF_INACTIVE) return;
+ bat_priv = netdev_priv(batman_if->soft_iface); dev_hold(batman_if->net_dev);
update_mac_addresses(batman_if); @@ -213,17 +218,17 @@ if (!bat_priv->primary_if) set_primary_if(bat_priv, batman_if);
- bat_info(net_dev, "Interface activated: %s\n", batman_if->dev); + bat_info(batman_if->soft_iface, "Interface activated: %s\n", + batman_if->dev);
if (atomic_read(&module_state) == MODULE_INACTIVE) activate_module();
- update_min_mtu(); + update_min_mtu(batman_if->soft_iface); return; }
-static void hardif_deactivate_interface(struct net_device *net_dev, - struct batman_if *batman_if) +static void hardif_deactivate_interface(struct batman_if *batman_if) { if ((batman_if->if_status != IF_ACTIVE) && (batman_if->if_status != IF_TO_BE_ACTIVATED)) @@ -233,26 +238,39 @@
batman_if->if_status = IF_INACTIVE;
- bat_info(net_dev, "Interface deactivated: %s\n", batman_if->dev); + bat_info(batman_if->soft_iface, "Interface deactivated: %s\n", + batman_if->dev);
- update_min_mtu(); + update_min_mtu(batman_if->soft_iface); }
-int hardif_enable_interface(struct batman_if *batman_if) +int hardif_enable_interface(struct batman_if *batman_if, char *iface_name) { - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv; struct batman_packet *batman_packet;
if (batman_if->if_status != IF_NOT_IN_USE) goto out;
+ batman_if->soft_iface = dev_get_by_name(&init_net, iface_name); + + if (!batman_if->soft_iface) { + batman_if->soft_iface = softif_create(iface_name); + + if (!batman_if->soft_iface) + goto err; + + /* dev_get_by_name() increases the reference counter for us */ + dev_hold(batman_if->soft_iface); + } + + bat_priv = netdev_priv(batman_if->soft_iface); batman_if->packet_len = BAT_PACKET_LEN; batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
if (!batman_if->packet_buff) { - bat_err(soft_device, "Can't add interface packet (%s): " - "out of memory\n", batman_if->dev); + bat_err(batman_if->soft_iface, "Can't add interface packet " + "(%s): out of memory\n", batman_if->dev); goto err; }
@@ -276,11 +294,12 @@
atomic_set(&batman_if->seqno, 1); atomic_set(&batman_if->frag_seqno, 1); - bat_info(soft_device, "Adding interface: %s\n", batman_if->dev); + bat_info(batman_if->soft_iface, "Adding interface: %s\n", + batman_if->dev);
if (atomic_read(&bat_priv->frag_enabled) && batman_if->net_dev->mtu < ETH_DATA_LEN + BAT_HEADER_LEN) - bat_info(soft_device, + bat_info(batman_if->soft_iface, "The MTU of interface %s is too small (%i) to handle " "the transport of batman-adv packets. Packets going " "over this interface will be fragmented on layer2 " @@ -291,7 +310,7 @@
if (!atomic_read(&bat_priv->frag_enabled) && batman_if->net_dev->mtu < ETH_DATA_LEN + BAT_HEADER_LEN) - bat_info(soft_device, + bat_info(batman_if->soft_iface, "The MTU of interface %s is too small (%i) to handle " "the transport of batman-adv packets. If you experience" " problems getting traffic through try increasing the " @@ -300,9 +319,9 @@ ETH_DATA_LEN + BAT_HEADER_LEN);
if (hardif_is_iface_up(batman_if)) - hardif_activate_interface(soft_device, bat_priv, batman_if); + hardif_activate_interface(batman_if); else - bat_err(soft_device, "Not using interface %s " + bat_err(batman_if->soft_iface, "Not using interface %s " "(retrying later): interface not active\n", batman_if->dev);
@@ -318,16 +337,16 @@
void hardif_disable_interface(struct batman_if *batman_if) { - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface);
if (batman_if->if_status == IF_ACTIVE) - hardif_deactivate_interface(soft_device, batman_if); + hardif_deactivate_interface(batman_if);
if (batman_if->if_status != IF_INACTIVE) return;
- bat_info(soft_device, "Removing interface: %s\n", batman_if->dev); + bat_info(batman_if->soft_iface, "Removing interface: %s\n", + batman_if->dev); dev_remove_pack(&batman_if->batman_adv_ptype);
bat_priv->num_ifaces--; @@ -339,10 +358,17 @@ kfree(batman_if->packet_buff); batman_if->packet_buff = NULL; batman_if->if_status = IF_NOT_IN_USE; + dev_put(batman_if->soft_iface);
- if ((atomic_read(&module_state) == MODULE_ACTIVE) && + /* nobody uses this interface anymore */ + if (!bat_priv->num_ifaces) + softif_destroy(batman_if->soft_iface); + + batman_if->soft_iface = NULL; + + /*if ((atomic_read(&module_state) == MODULE_ACTIVE) && (bat_priv->num_ifaces == 0)) - deactivate_module(); + deactivate_module();*/ }
static struct batman_if *hardif_add_interface(struct net_device *net_dev) @@ -371,6 +397,7 @@
batman_if->if_num = -1; batman_if->net_dev = net_dev; + batman_if->soft_iface = NULL; batman_if->if_status = IF_NOT_IN_USE; INIT_LIST_HEAD(&batman_if->list);
@@ -426,8 +453,7 @@ { struct net_device *net_dev = (struct net_device *)ptr; struct batman_if *batman_if = get_batman_if_by_netdev(net_dev); - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv;
if (!batman_if) batman_if = hardif_add_interface(net_dev); @@ -439,11 +465,11 @@ case NETDEV_REGISTER: break; case NETDEV_UP: - hardif_activate_interface(soft_device, bat_priv, batman_if); + hardif_activate_interface(batman_if); break; case NETDEV_GOING_DOWN: case NETDEV_DOWN: - hardif_deactivate_interface(soft_device, batman_if); + hardif_deactivate_interface(batman_if); break; case NETDEV_UNREGISTER: hardif_remove_interface(batman_if); @@ -451,8 +477,13 @@ case NETDEV_CHANGENAME: break; case NETDEV_CHANGEADDR: + if (batman_if->if_status == IF_NOT_IN_USE) + goto out; + check_known_mac_addr(batman_if->net_dev->dev_addr); update_mac_addresses(batman_if); + + bat_priv = netdev_priv(batman_if->soft_iface); if (batman_if == bat_priv->primary_if) set_primary_if(bat_priv, batman_if); break; @@ -474,8 +505,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype, struct net_device *orig_dev) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv; struct batman_packet *batman_packet; struct batman_if *batman_if; int ret; @@ -511,6 +541,7 @@ goto err_free;
batman_packet = (struct batman_packet *)skb->data; + bat_priv = netdev_priv(batman_if->soft_iface);
if (batman_packet->version != COMPAT_VERSION) { bat_dbg(DBG_BATMAN, bat_priv, @@ -530,7 +561,7 @@
/* batman icmp packet */ case BAT_ICMP: - ret = recv_icmp_packet(skb); + ret = recv_icmp_packet(skb, batman_if); break;
/* unicast packet */ @@ -545,12 +576,12 @@
/* broadcast packet */ case BAT_BCAST: - ret = recv_bcast_packet(skb); + ret = recv_bcast_packet(skb, batman_if); break;
/* vis packet */ case BAT_VIS: - ret = recv_vis_packet(skb); + ret = recv_vis_packet(skb, batman_if); break; default: ret = NET_RX_DROP;
Modified: trunk/batman-adv/hard-interface.h =================================================================== --- trunk/batman-adv/hard-interface.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/hard-interface.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -32,14 +32,14 @@ extern struct notifier_block hard_if_notifier;
struct batman_if *get_batman_if_by_netdev(struct net_device *net_dev); -int hardif_enable_interface(struct batman_if *batman_if); +int hardif_enable_interface(struct batman_if *batman_if, char *iface_name); void hardif_disable_interface(struct batman_if *batman_if); void hardif_remove_interfaces(void); int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype, struct net_device *orig_dev); -int hardif_min_mtu(void); -void update_min_mtu(void); +int hardif_min_mtu(struct net_device *soft_iface); +void update_min_mtu(struct net_device *soft_iface);
#endif /* _NET_BATMAN_ADV_HARD_INTERFACE_H_ */
Modified: trunk/batman-adv/hash.c =================================================================== --- trunk/batman-adv/hash.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/hash.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -36,7 +36,7 @@ /* remove the hash structure. if hashdata_free_cb != NULL, this function will be * called to remove the elements inside of the hash. if you don't remove the * elements, memory might be leaked. */ -void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb) +void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb, void *arg) { struct element_t *bucket, *last_bucket; int i; @@ -46,7 +46,7 @@
while (bucket != NULL) { if (free_cb != NULL) - free_cb(bucket->data); + free_cb(bucket->data, arg);
last_bucket = bucket; bucket = bucket->next; @@ -300,7 +300,7 @@
/* remove hash and eventual overflow buckets but not the content * itself. */ - hash_delete(hash, NULL); + hash_delete(hash, NULL, NULL);
return new_hash; }
Modified: trunk/batman-adv/hash.h =================================================================== --- trunk/batman-adv/hash.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/hash.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -30,7 +30,7 @@
typedef int (*hashdata_compare_cb)(void *, void *); typedef int (*hashdata_choose_cb)(void *, int); -typedef void (*hashdata_free_cb)(void *); +typedef void (*hashdata_free_cb)(void *, void *);
struct element_t { void *data; /* pointer to the data */ @@ -70,7 +70,7 @@ /* remove the hash structure. if hashdata_free_cb != NULL, this function will be * called to remove the elements inside of the hash. if you don't remove the * elements, memory might be leaked. */ -void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb); +void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb, void *arg);
/* free only the hashtable and the hash itself. */ void hash_destroy(struct hashtable_t *hash);
Modified: trunk/batman-adv/icmp_socket.c =================================================================== --- trunk/batman-adv/icmp_socket.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/icmp_socket.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -158,6 +158,7 @@ struct bat_priv *bat_priv = socket_client->bat_priv; struct sk_buff *skb; struct icmp_packet_rr *icmp_packet; + struct orig_node *orig_node; struct batman_if *batman_if; size_t packet_len = sizeof(struct icmp_packet);
Modified: trunk/batman-adv/main.c =================================================================== --- trunk/batman-adv/main.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/main.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -46,8 +46,6 @@
int16_t num_hna;
-struct net_device *soft_device; - unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; atomic_t module_state;
@@ -55,8 +53,6 @@
static int __init batman_init(void) { - int retval; - INIT_LIST_HEAD(&if_list); INIT_HLIST_HEAD(&forw_bat_list); INIT_HLIST_HEAD(&forw_bcast_list); @@ -73,32 +69,6 @@ bat_socket_init(); debugfs_init();
- /* initialize layer 2 interface */ - soft_device = alloc_netdev(sizeof(struct bat_priv) , "bat%d", - interface_setup); - - if (!soft_device) { - pr_err("Unable to allocate the batman interface\n"); - goto end; - } - - retval = register_netdev(soft_device); - - if (retval < 0) { - pr_err("Unable to register the batman interface: %i\n", retval); - goto free_soft_device; - } - - retval = sysfs_add_meshif(soft_device); - - if (retval < 0) - goto unreg_soft_device; - - retval = debugfs_add_meshif(soft_device); - - if (retval < 0) - goto unreg_sysfs; - register_netdevice_notifier(&hard_if_notifier);
pr_info("B.A.T.M.A.N. advanced %s%s (compatibility version %i) " @@ -106,19 +76,6 @@ COMPAT_VERSION);
return 0; - -unreg_sysfs: - sysfs_del_meshif(soft_device); -unreg_soft_device: - unregister_netdev(soft_device); - soft_device = NULL; - return -ENOMEM; - -free_soft_device: - free_netdev(soft_device); - soft_device = NULL; -end: - return -ENOMEM; }
static void __exit batman_exit(void) @@ -129,13 +86,6 @@ unregister_netdevice_notifier(&hard_if_notifier); hardif_remove_interfaces();
- if (soft_device) { - debugfs_del_meshif(soft_device); - sysfs_del_meshif(soft_device); - unregister_netdev(soft_device); - soft_device = NULL; - } - destroy_workqueue(bat_event_workqueue); bat_event_workqueue = NULL; } @@ -152,12 +102,12 @@ if (hna_global_init() < 1) goto err;
- hna_local_add(soft_device->dev_addr); + /*hna_local_add(soft_device->dev_addr);*/
if (vis_init() < 1) goto err;
- update_min_mtu(); + /*update_min_mtu();*/ atomic_set(&module_state, MODULE_ACTIVE); goto end;
Modified: trunk/batman-adv/main.h =================================================================== --- trunk/batman-adv/main.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/main.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -138,8 +138,6 @@
extern int16_t num_hna;
-extern struct net_device *soft_device; - extern unsigned char broadcast_addr[]; extern atomic_t module_state; extern struct workqueue_struct *bat_event_workqueue;
Modified: trunk/batman-adv/originator.c =================================================================== --- trunk/batman-adv/originator.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/originator.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -63,8 +63,7 @@ create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, uint8_t *neigh, struct batman_if *if_incoming) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct neigh_node *neigh_node;
bat_dbg(DBG_BATMAN, bat_priv, @@ -84,11 +83,12 @@ return neigh_node; }
-static void free_orig_node(void *data) +static void free_orig_node(void *data, void *arg) { struct list_head *list_pos, *list_pos_tmp; struct neigh_node *neigh_node; struct orig_node *orig_node = (struct orig_node *)data; + struct bat_priv *bat_priv = (struct bat_priv *)arg;
/* for all neighbors towards this originator ... */ list_for_each_safe(list_pos, list_pos_tmp, &orig_node->neigh_list) { @@ -99,7 +99,7 @@ }
frag_list_free(&orig_node->frag_list); - hna_global_del_orig(orig_node, "originator timed out"); + hna_global_del_orig(bat_priv, orig_node, "originator timed out");
kfree(orig_node->bcast_own); kfree(orig_node->bcast_own_sum); @@ -116,17 +116,15 @@ cancel_delayed_work_sync(&purge_orig_wq);
spin_lock_irqsave(&orig_hash_lock, flags); - hash_delete(orig_hash, free_orig_node); + /*hash_delete(orig_hash, free_orig_node, bat_priv);*/ orig_hash = NULL; spin_unlock_irqrestore(&orig_hash_lock, flags); }
/* this function finds or creates an originator entry for the given * address if it does not exits */ -struct orig_node *get_orig_node(uint8_t *addr) +struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) { - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); struct orig_node *orig_node; struct hashtable_t *swaphash; int size; @@ -175,7 +173,7 @@ swaphash = hash_resize(orig_hash, orig_hash->size * 2);
if (swaphash == NULL) - bat_err(soft_device, + bat_dbg(DBG_BATMAN, bat_priv, "Couldn't resize orig hash table\n"); else orig_hash = swaphash; @@ -191,11 +189,10 @@ return NULL; }
-static bool purge_orig_neighbors(struct orig_node *orig_node, +static bool purge_orig_neighbors(struct bat_priv *bat_priv, + struct orig_node *orig_node, struct neigh_node **best_neigh_node) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); struct list_head *list_pos, *list_pos_tmp; struct neigh_node *neigh_node; bool neigh_purged = false; @@ -237,10 +234,9 @@ return neigh_purged; }
-static bool purge_orig_node(struct orig_node *orig_node) +static bool purge_orig_node(struct bat_priv *bat_priv, + struct orig_node *orig_node) { - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); struct neigh_node *best_neigh_node;
if (time_after(jiffies, @@ -251,8 +247,10 @@ orig_node->orig, (orig_node->last_valid / HZ)); return true; } else { - if (purge_orig_neighbors(orig_node, &best_neigh_node)) { - update_routes(orig_node, best_neigh_node, + if (purge_orig_neighbors(bat_priv, orig_node, + &best_neigh_node)) { + update_routes(bat_priv, orig_node, + best_neigh_node, orig_node->hna_buff, orig_node->hna_buff_len); /* update bonding candidates, we could have lost @@ -275,22 +273,23 @@ /* for all origins... */ while (hash_iterate(orig_hash, &hashit)) { orig_node = hashit.bucket->data; - if (purge_orig_node(orig_node)) { + + /*if (purge_orig_node(bat_priv, orig_node)) { if (orig_node->gw_flags) - gw_node_delete(orig_node); + gw_node_delete(bat_priv, orig_node); hash_remove_bucket(orig_hash, &hashit); free_orig_node(orig_node); - } + }*/
if (time_after(jiffies, (orig_node->last_frag_packet + - msecs_to_jiffies(FRAG_TIMEOUT)))) + msecs_to_jiffies(FRAG_TIMEOUT)))) frag_list_free(&orig_node->frag_list); }
spin_unlock_irqrestore(&orig_hash_lock, flags);
gw_node_purge_deleted(); - gw_election(); + /*gw_election(bat_priv);*/
/* if work == NULL we were not called by the timer * and thus do not need to re-arm the timer */
Modified: trunk/batman-adv/originator.h =================================================================== --- trunk/batman-adv/originator.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/originator.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -25,7 +25,7 @@ int originator_init(void); void originator_free(void); void purge_orig(struct work_struct *work); -struct orig_node *get_orig_node(uint8_t *addr); +struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr); struct neigh_node * create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, uint8_t *neigh, struct batman_if *if_incoming);
Modified: trunk/batman-adv/routing.c =================================================================== --- trunk/batman-adv/routing.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/routing.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -40,6 +40,7 @@
void slide_own_bcast_window(struct batman_if *batman_if) { + struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface); HASHIT(hashit); struct orig_node *orig_node; TYPE_OF_WORD *word; @@ -51,7 +52,7 @@ orig_node = hashit.bucket->data; word = &(orig_node->bcast_own[batman_if->if_num * NUM_WORDS]);
- bit_get_packet(word, 1, 0); + bit_get_packet(bat_priv, word, 1, 0); orig_node->bcast_own_sum[batman_if->if_num] = bit_packet_count(word); } @@ -59,7 +60,7 @@ spin_unlock_irqrestore(&orig_hash_lock, flags); }
-static void update_HNA(struct orig_node *orig_node, +static void update_HNA(struct bat_priv *bat_priv, struct orig_node *orig_node, unsigned char *hna_buff, int hna_buff_len) { if ((hna_buff_len != orig_node->hna_buff_len) || @@ -68,27 +69,27 @@ (memcmp(orig_node->hna_buff, hna_buff, hna_buff_len) != 0))) {
if (orig_node->hna_buff_len > 0) - hna_global_del_orig(orig_node, + hna_global_del_orig(bat_priv, orig_node, "originator changed hna");
if ((hna_buff_len > 0) && (hna_buff != NULL)) - hna_global_add_orig(orig_node, hna_buff, hna_buff_len); + hna_global_add_orig(bat_priv, orig_node, + hna_buff, hna_buff_len); } }
-static void update_route(struct orig_node *orig_node, +static void update_route(struct bat_priv *bat_priv, + struct orig_node *orig_node, struct neigh_node *neigh_node, unsigned char *hna_buff, int hna_buff_len) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); - /* route deleted */ if ((orig_node->router != NULL) && (neigh_node == NULL)) {
bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", orig_node->orig); - hna_global_del_orig(orig_node, "originator timed out"); + hna_global_del_orig(bat_priv, orig_node, + "originator timed out");
/* route added */ } else if ((orig_node->router == NULL) && (neigh_node != NULL)) { @@ -96,7 +97,8 @@ bat_dbg(DBG_ROUTES, bat_priv, "Adding route towards: %pM (via %pM)\n", orig_node->orig, neigh_node->addr); - hna_global_add_orig(orig_node, hna_buff, hna_buff_len); + hna_global_add_orig(bat_priv, orig_node, + hna_buff, hna_buff_len);
/* route changed */ } else { @@ -111,19 +113,20 @@ }
-void update_routes(struct orig_node *orig_node, - struct neigh_node *neigh_node, - unsigned char *hna_buff, int hna_buff_len) +void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node, + struct neigh_node *neigh_node, unsigned char *hna_buff, + int hna_buff_len) {
if (orig_node == NULL) return;
if (orig_node->router != neigh_node) - update_route(orig_node, neigh_node, hna_buff, hna_buff_len); + update_route(bat_priv, orig_node, neigh_node, + hna_buff, hna_buff_len); /* may be just HNA changed */ else - update_HNA(orig_node, hna_buff, hna_buff_len); + update_HNA(bat_priv, orig_node, hna_buff, hna_buff_len); }
static int is_bidirectional_neigh(struct orig_node *orig_node, @@ -131,8 +134,7 @@ struct batman_packet *batman_packet, struct batman_if *if_incoming) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; unsigned char total_count;
@@ -236,14 +238,14 @@ return 0; }
-static void update_orig(struct orig_node *orig_node, struct ethhdr *ethhdr, +static void update_orig(struct bat_priv *bat_priv, + struct orig_node *orig_node, + struct ethhdr *ethhdr, struct batman_packet *batman_packet, struct batman_if *if_incoming, unsigned char *hna_buff, int hna_buff_len, char is_duplicate) { - /* FIXME: get bat_priv */ - struct bat_priv *bat_priv = netdev_priv(soft_device); struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; int tmp_hna_buff_len;
@@ -269,12 +271,11 @@ if (!neigh_node) { struct orig_node *orig_tmp;
- orig_tmp = get_orig_node(ethhdr->h_source); + orig_tmp = get_orig_node(bat_priv, ethhdr->h_source); if (!orig_tmp) return;
- neigh_node = create_neighbor(orig_node, - orig_tmp, + neigh_node = create_neighbor(orig_node, orig_tmp, ethhdr->h_source, if_incoming); if (!neigh_node) return; @@ -316,15 +317,17 @@ >= neigh_node->orig_node->bcast_own_sum[if_incoming->if_num]))) goto update_hna;
- update_routes(orig_node, neigh_node, hna_buff, tmp_hna_buff_len); + update_routes(bat_priv, orig_node, neigh_node, + hna_buff, tmp_hna_buff_len); goto update_gw;
update_hna: - update_routes(orig_node, orig_node->router, hna_buff, tmp_hna_buff_len); + update_routes(bat_priv, orig_node, orig_node->router, + hna_buff, tmp_hna_buff_len);
update_gw: if (orig_node->gw_flags != batman_packet->gw_flags) - gw_node_update(orig_node, batman_packet->gw_flags); + gw_node_update(bat_priv, orig_node, batman_packet->gw_flags);
orig_node->gw_flags = batman_packet->gw_flags;
@@ -338,12 +341,10 @@ * 0 if the packet is to be accepted * 1 if the packet is to be ignored. */ -static int window_protected(int32_t seq_num_diff, - unsigned long *last_reset) +static int window_protected(struct bat_priv *bat_priv, + int32_t seq_num_diff, + unsigned long *last_reset) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); - if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { if (time_after(jiffies, *last_reset + @@ -372,8 +373,7 @@ struct batman_packet *batman_packet, struct batman_if *if_incoming) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct orig_node *orig_node; struct neigh_node *tmp_neigh_node; char is_duplicate = 0; @@ -381,14 +381,15 @@ int need_update = 0; int set_mark;
- orig_node = get_orig_node(batman_packet->orig); + orig_node = get_orig_node(bat_priv, batman_packet->orig); if (orig_node == NULL) return 0;
seq_diff = batman_packet->seqno - orig_node->last_real_seqno;
/* signalize caller that the packet is to be dropped. */ - if (window_protected(seq_diff, &orig_node->batman_seqno_reset)) + if (window_protected(bat_priv, seq_diff, + &orig_node->batman_seqno_reset)) return -1;
list_for_each_entry(tmp_neigh_node, &orig_node->neigh_list, list) { @@ -404,8 +405,9 @@ set_mark = 0;
/* if the window moved, set the update flag. */ - need_update |= bit_get_packet(tmp_neigh_node->real_bits, - seq_diff, set_mark); + need_update |= bit_get_packet(bat_priv, + tmp_neigh_node->real_bits, + seq_diff, set_mark);
tmp_neigh_node->real_packet_count = bit_packet_count(tmp_neigh_node->real_bits); @@ -533,8 +535,7 @@ unsigned char *hna_buff, int hna_buff_len, struct batman_if *if_incoming) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct batman_if *batman_if; struct orig_node *orig_neigh_node, *orig_node; char has_directlink_flag; @@ -621,7 +622,7 @@ TYPE_OF_WORD *word; int offset;
- orig_neigh_node = get_orig_node(ethhdr->h_source); + orig_neigh_node = get_orig_node(bat_priv, ethhdr->h_source);
if (!orig_neigh_node) return; @@ -653,7 +654,7 @@ return; }
- orig_node = get_orig_node(batman_packet->orig); + orig_node = get_orig_node(bat_priv, batman_packet->orig); if (orig_node == NULL) return;
@@ -689,7 +690,8 @@ /* if sender is a direct neighbor the sender mac equals * originator mac */ orig_neigh_node = (is_single_hop_neigh ? - orig_node : get_orig_node(ethhdr->h_source)); + orig_node : + get_orig_node(bat_priv, ethhdr->h_source)); if (orig_neigh_node == NULL) return;
@@ -711,7 +713,7 @@ (!is_duplicate || ((orig_node->last_real_seqno == batman_packet->seqno) && (orig_node->last_ttl - 3 <= batman_packet->ttl)))) - update_orig(orig_node, ethhdr, batman_packet, + update_orig(bat_priv, orig_node, ethhdr, batman_packet, if_incoming, hna_buff, hna_buff_len, is_duplicate);
mark_bonding_address(bat_priv, orig_node, @@ -790,10 +792,11 @@ return NET_RX_SUCCESS; }
-static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len) +static int recv_my_icmp_packet(struct sk_buff *skb, + struct batman_if *recv_if, size_t icmp_len) { /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); struct orig_node *orig_node; struct icmp_packet_rr *icmp_packet; struct ethhdr *ethhdr; @@ -852,10 +855,11 @@ return ret; }
-static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len) +static int recv_icmp_ttl_exceeded(struct sk_buff *skb, + struct batman_if *recv_if, size_t icmp_len) { /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); struct orig_node *orig_node; struct icmp_packet *icmp_packet; struct ethhdr *ethhdr; @@ -916,7 +920,7 @@ }
-int recv_icmp_packet(struct sk_buff *skb) +int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if) { struct icmp_packet_rr *icmp_packet; struct ethhdr *ethhdr; @@ -963,11 +967,11 @@
/* packet for me */ if (is_my_mac(icmp_packet->dst)) - return recv_my_icmp_packet(skb, hdr_size); + return recv_my_icmp_packet(skb, recv_if, hdr_size);
/* TTL exceeded */ if (icmp_packet->ttl < 2) - return recv_icmp_ttl_exceeded(skb, hdr_size); + return recv_icmp_ttl_exceeded(skb, recv_if, hdr_size);
ret = NET_RX_DROP;
@@ -1008,10 +1012,9 @@ /* find a suitable router for this originator, and use * bonding if possible. */ struct neigh_node *find_router(struct orig_node *orig_node, - struct batman_if *recv_if) + struct batman_if *recv_if) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv; struct orig_node *primary_orig_node; struct orig_node *router_orig; struct neigh_node *router, *first_candidate, *best_router; @@ -1027,10 +1030,15 @@ /* without bonding, the first node should * always choose the default router. */
+ if (!recv_if) + return orig_node->router; + + bat_priv = netdev_priv(recv_if->soft_iface); bonding_enabled = atomic_read(&bat_priv->bonding_enabled); - if (!bonding_enabled && (recv_if == NULL)) - return orig_node->router;
+ if (!bonding_enabled) + return orig_node->router; + router_orig = orig_node->router->orig_node;
/* if we have something in the primary_addr, we can search @@ -1106,7 +1114,7 @@ if (unlikely(!pskb_may_pull(skb, hdr_size))) return -1;
- ethhdr = (struct ethhdr *) skb_mac_header(skb); + ethhdr = (struct ethhdr *)skb_mac_header(skb);
/* packet with unicast indication but broadcast recipient */ if (is_bcast(ethhdr->h_dest)) @@ -1123,18 +1131,25 @@ return 0; }
-static int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if, - int hdr_size) +static int route_unicast_packet(struct sk_buff *skb, + struct batman_if *recv_if, int hdr_size) { struct orig_node *orig_node; struct neigh_node *router; struct batman_if *batman_if; uint8_t dstaddr[ETH_ALEN]; unsigned long flags; - struct unicast_packet *unicast_packet = - (struct unicast_packet *) skb->data; - struct ethhdr *ethhdr = (struct ethhdr *) skb_mac_header(skb); + struct unicast_packet *unicast_packet; + struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb);
+ unicast_packet = (struct unicast_packet *)skb->data; + + /* packet for me */ + if (is_my_mac(unicast_packet->dest)) { + interface_rx(recv_if->soft_iface, skb, hdr_size); + return NET_RX_SUCCESS; + } + /* TTL exceeded */ if (unicast_packet->ttl < 2) { pr_warning("Warning - can't forward unicast packet from %pM to " @@ -1187,11 +1202,11 @@ if (check_unicast_packet(skb, hdr_size) < 0) return NET_RX_DROP;
- unicast_packet = (struct unicast_packet *) skb->data; + unicast_packet = (struct unicast_packet *)skb->data;
/* packet for me */ if (is_my_mac(unicast_packet->dest)) { - interface_rx(skb, hdr_size); + interface_rx(recv_if->soft_iface, skb, hdr_size); return NET_RX_SUCCESS; }
@@ -1246,18 +1261,20 @@ if (!skb) return NET_RX_DROP;
- interface_rx(skb, hdr_size); + interface_rx(recv_if->soft_iface, skb, hdr_size); return NET_RX_SUCCESS; }
return route_unicast_packet(skb, recv_if, hdr_size); }
-int recv_bcast_packet(struct sk_buff *skb) + +int recv_bcast_packet(struct sk_buff *skb, struct batman_if *batman_if) { struct orig_node *orig_node; struct bcast_packet *bcast_packet; struct ethhdr *ethhdr; + struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface); int hdr_size = sizeof(struct bcast_packet); int32_t seq_diff; unsigned long flags; @@ -1309,31 +1326,32 @@ seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno;
/* check whether the packet is old and the host just restarted. */ - if (window_protected(seq_diff, &orig_node->bcast_seqno_reset)) { + if (window_protected(bat_priv, seq_diff, + &orig_node->bcast_seqno_reset)) { spin_unlock_irqrestore(&orig_hash_lock, flags); return NET_RX_DROP; }
/* mark broadcast in flood history, update window position * if required. */ - if (bit_get_packet(orig_node->bcast_bits, seq_diff, 1)) + if (bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1)) orig_node->last_bcast_seqno = ntohl(bcast_packet->seqno);
spin_unlock_irqrestore(&orig_hash_lock, flags); /* rebroadcast packet */ - add_bcast_packet_to_list(skb); + add_bcast_packet_to_list(bat_priv, skb);
/* broadcast for me */ - interface_rx(skb, hdr_size); + interface_rx(batman_if->soft_iface, skb, hdr_size);
return NET_RX_SUCCESS; }
-int recv_vis_packet(struct sk_buff *skb) +int recv_vis_packet(struct sk_buff *skb, struct batman_if *batman_if) { struct vis_packet *vis_packet; struct ethhdr *ethhdr; - struct bat_priv *bat_priv; + struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface); int hdr_size = sizeof(struct vis_packet);
/* keep skb linear */ @@ -1343,7 +1361,7 @@ if (unlikely(!pskb_may_pull(skb, hdr_size))) return NET_RX_DROP;
- vis_packet = (struct vis_packet *) skb->data; + vis_packet = (struct vis_packet *)skb->data; ethhdr = (struct ethhdr *)skb_mac_header(skb);
/* not for me */ @@ -1357,9 +1375,6 @@ if (is_my_mac(vis_packet->sender_orig)) return NET_RX_DROP;
- /* FIXME: each batman_if will be attached to a softif */ - bat_priv = netdev_priv(soft_device); - switch (vis_packet->vis_type) { case VIS_TYPE_SERVER_SYNC: receive_server_sync_packet(bat_priv, vis_packet,
Modified: trunk/batman-adv/routing.h =================================================================== --- trunk/batman-adv/routing.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/routing.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -29,14 +29,14 @@ struct batman_packet *batman_packet, unsigned char *hna_buff, int hna_buff_len, struct batman_if *if_incoming); -void update_routes(struct orig_node *orig_node, - struct neigh_node *neigh_node, - unsigned char *hna_buff, int hna_buff_len); -int recv_icmp_packet(struct sk_buff *skb); +void update_routes(struct bat_priv *bat_priv, struct orig_node *orig_node, + struct neigh_node *neigh_node, unsigned char *hna_buff, + int hna_buff_len); +int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if); int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if); int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if); -int recv_bcast_packet(struct sk_buff *skb); -int recv_vis_packet(struct sk_buff *skb); +int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if); +int recv_vis_packet(struct sk_buff *skb, struct batman_if *recv_if); int recv_bat_packet(struct sk_buff *skb, struct batman_if *batman_if); struct neigh_node *find_router(struct orig_node *orig_node,
Modified: trunk/batman-adv/send.c =================================================================== --- trunk/batman-adv/send.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/send.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -109,8 +109,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet, struct batman_if *batman_if) { - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface); char *fwd_str; uint8_t packet_num; int16_t buff_pos; @@ -166,9 +165,9 @@ /* send a batman packet */ static void send_packet(struct forw_packet *forw_packet) { - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); struct batman_if *batman_if; + struct bat_priv *bat_priv = + netdev_priv(forw_packet->if_incoming->soft_iface); struct batman_packet *batman_packet = (struct batman_packet *)(forw_packet->skb->data); unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0); @@ -238,8 +237,7 @@
void schedule_own_packet(struct batman_if *batman_if) { - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface); unsigned long send_time; struct batman_packet *batman_packet; int vis_server; @@ -303,8 +301,7 @@ uint8_t directlink, int hna_buff_len, struct batman_if *if_incoming) { - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); unsigned char in_tq, in_ttl, tq_avg = 0; unsigned long send_time;
@@ -394,12 +391,10 @@ * * The skb is not consumed, so the caller should make sure that the * skb is freed. */ -int add_bcast_packet_to_list(struct sk_buff *skb) +int add_bcast_packet_to_list(struct bat_priv *bat_priv, struct sk_buff *skb) { struct forw_packet *forw_packet; struct bcast_packet *bcast_packet; - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device);
if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { bat_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n"); @@ -446,8 +441,7 @@ container_of(delayed_work, struct forw_packet, delayed_work); unsigned long flags; struct sk_buff *skb1; - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv;
spin_lock_irqsave(&forw_bcast_list_lock, flags); hlist_del(&forw_packet->list); @@ -476,6 +470,7 @@ }
out: + bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface); forw_packet_free(forw_packet); atomic_inc(&bat_priv->bcast_queue_left); } @@ -487,8 +482,7 @@ struct forw_packet *forw_packet = container_of(delayed_work, struct forw_packet, delayed_work); unsigned long flags; - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv;
spin_lock_irqsave(&forw_bat_list_lock, flags); hlist_del(&forw_packet->list); @@ -508,6 +502,8 @@ schedule_own_packet(forw_packet->if_incoming);
out: + bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface); + /* don't count own packet */ if (!forw_packet->own) atomic_inc(&bat_priv->batman_queue_left); @@ -517,20 +513,23 @@
void purge_outstanding_packets(struct batman_if *batman_if) { - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv; struct forw_packet *forw_packet; struct hlist_node *tmp_node, *safe_tmp_node; unsigned long flags;
- if (batman_if) - bat_dbg(DBG_BATMAN, bat_priv, - "purge_outstanding_packets(): %s\n", - batman_if->dev); - else - bat_dbg(DBG_BATMAN, bat_priv, - "purge_outstanding_packets()\n"); + if (batman_if->soft_iface) { + bat_priv = netdev_priv(batman_if->soft_iface);
+ if (batman_if) + bat_dbg(DBG_BATMAN, bat_priv, + "purge_outstanding_packets(): %s\n", + batman_if->dev); + else + bat_dbg(DBG_BATMAN, bat_priv, + "purge_outstanding_packets()\n"); + } + /* free bcast list */ spin_lock_irqsave(&forw_bcast_list_lock, flags); hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node,
Modified: trunk/batman-adv/send.h =================================================================== --- trunk/batman-adv/send.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/send.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -33,7 +33,7 @@ struct batman_packet *batman_packet, uint8_t directlink, int hna_buff_len, struct batman_if *if_outgoing); -int add_bcast_packet_to_list(struct sk_buff *skb); +int add_bcast_packet_to_list(struct bat_priv *bat_priv, struct sk_buff *skb); void send_outstanding_bat_packet(struct work_struct *work); void purge_outstanding_packets(struct batman_if *batman_if);
Modified: trunk/batman-adv/soft-interface.c =================================================================== --- trunk/batman-adv/soft-interface.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/soft-interface.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -22,7 +22,13 @@ #include "main.h" #include "soft-interface.h" #include "hard-interface.h" +#include "routing.h" +#include "send.h" +#include "bat_debugfs.h" #include "translation-table.h" +#include "types.h" +#include "hash.h" +#include "gateway_common.h" #include "gateway_client.h" #include "send.h" #include <linux/slab.h> @@ -94,12 +100,13 @@
static struct net_device_stats *interface_stats(struct net_device *dev) { - struct bat_priv *priv = netdev_priv(dev); - return &priv->stats; + struct bat_priv *bat_priv = netdev_priv(dev); + return &bat_priv->stats; }
static int interface_set_mac_addr(struct net_device *dev, void *p) { + struct bat_priv *bat_priv = netdev_priv(dev); struct sockaddr *addr = p;
if (!is_valid_ether_addr(addr->sa_data)) @@ -107,8 +114,9 @@
/* only modify hna-table if it has been initialised before */ if (atomic_read(&module_state) == MODULE_ACTIVE) { - hna_local_remove(dev->dev_addr, "mac address changed"); - hna_local_add(addr->sa_data); + hna_local_remove(bat_priv, dev->dev_addr, + "mac address changed"); + hna_local_add(dev, addr->sa_data); }
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); @@ -119,7 +127,7 @@ static int interface_change_mtu(struct net_device *dev, int new_mtu) { /* check ranges */ - if ((new_mtu < 68) || (new_mtu > hardif_min_mtu())) + if ((new_mtu < 68) || (new_mtu > hardif_min_mtu(dev))) return -EINVAL;
dev->mtu = new_mtu; @@ -127,10 +135,10 @@ return 0; }
-int interface_tx(struct sk_buff *skb, struct net_device *dev) +int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) { struct ethhdr *ethhdr = (struct ethhdr *)skb->data; - struct bat_priv *bat_priv = netdev_priv(dev); + struct bat_priv *bat_priv = netdev_priv(soft_iface); struct bcast_packet *bcast_packet; int data_len = skb->len, ret; bool bcast_dst = false, do_bcast = true; @@ -138,9 +146,10 @@ if (atomic_read(&module_state) != MODULE_ACTIVE) goto dropped;
- dev->trans_start = jiffies; + soft_iface->trans_start = jiffies; + /* TODO: check this for locks */ - hna_local_add(ethhdr->h_source); + hna_local_add(soft_iface, ethhdr->h_source);
if (is_bcast(ethhdr->h_dest) || is_mcast(ethhdr->h_dest)) bcast_dst = true; @@ -168,7 +177,7 @@ bcast_packet->seqno = htonl(bcast_seqno);
/* broadcast packet. on success, increase seqno. */ - if (add_bcast_packet_to_list(skb) == NETDEV_TX_OK) + if (add_bcast_packet_to_list(bat_priv, skb) == NETDEV_TX_OK) bcast_seqno++;
/* a copy is stored in the bcast list, therefore removing @@ -195,10 +204,10 @@ return NETDEV_TX_OK; }
-void interface_rx(struct sk_buff *skb, int hdr_size) +void interface_rx(struct net_device *soft_iface, + struct sk_buff *skb, int hdr_size) { - struct net_device *dev = soft_device; - struct bat_priv *priv = netdev_priv(dev); + struct bat_priv *priv = netdev_priv(soft_iface);
/* check if enough space is available for pulling, and pull */ if (!pskb_may_pull(skb, hdr_size)) { @@ -208,8 +217,8 @@ skb_pull_rcsum(skb, hdr_size); /* skb_set_mac_header(skb, -sizeof(struct ethhdr));*/
- skb->dev = dev; - skb->protocol = eth_type_trans(skb, dev); + skb->dev = soft_iface; + skb->protocol = eth_type_trans(skb, soft_iface);
/* should not be neccesary anymore as we use skb_pull_rcsum() * TODO: please verify this and remove this TODO @@ -223,7 +232,7 @@ priv->stats.rx_packets++; priv->stats.rx_bytes += skb->len;
- dev->last_rx = jiffies; + soft_iface->last_rx = jiffies;
netif_rx(skb); } @@ -240,7 +249,7 @@ }; #endif
-void interface_setup(struct net_device *dev) +static void interface_setup(struct net_device *dev) { struct bat_priv *priv = netdev_priv(dev); char dev_addr[ETH_ALEN]; @@ -259,9 +268,11 @@ #endif dev->destructor = free_netdev;
- dev->mtu = ETH_DATA_LEN; /* can't call min_mtu, because the - * needed variables have not been - * initialized yet */ + /** + * can't call min_mtu, because the needed variables + * have not been initialized yet + */ + dev->mtu = ETH_DATA_LEN; dev->hard_header_len = BAT_HEADER_LEN; /* reserve more space in the * skbuff for our header */
@@ -274,6 +285,75 @@ memset(priv, 0, sizeof(struct bat_priv)); }
+struct net_device *softif_create(char *name) +{ + struct net_device *soft_iface; + struct bat_priv *bat_priv; + int ret; + + soft_iface = alloc_netdev(sizeof(struct bat_priv) , name, + interface_setup); + + if (!soft_iface) { + pr_err("Unable to allocate the batman interface: %s\n", name); + goto out; + } + + ret = register_netdev(soft_iface); + + if (ret < 0) { + pr_err("Unable to register the batman interface '%s': %i\n", + name, ret); + goto free_soft_iface; + } + + bat_priv = netdev_priv(soft_iface); + + atomic_set(&bat_priv->aggregation_enabled, 1); + atomic_set(&bat_priv->bonding_enabled, 0); + atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE); + atomic_set(&bat_priv->gw_mode, GW_MODE_OFF); + atomic_set(&bat_priv->gw_class, 0); + atomic_set(&bat_priv->orig_interval, 1000); + atomic_set(&bat_priv->log_level, 0); + atomic_set(&bat_priv->frag_enabled, 1); + atomic_set(&bat_priv->bcast_queue_left, BCAST_QUEUE_LEN); + atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN); + + bat_priv->primary_if = NULL; + bat_priv->num_ifaces = 0; + + ret = sysfs_add_meshif(soft_iface); + + if (ret < 0) + goto unreg_soft_iface; + + ret = debugfs_add_meshif(soft_iface); + + if (ret < 0) + goto unreg_sysfs; + + return soft_iface; + +unreg_sysfs: + sysfs_del_meshif(soft_iface); +unreg_soft_iface: + unregister_netdev(soft_iface); + return NULL; + +free_soft_iface: + free_netdev(soft_iface); +out: + return NULL; +} + +void softif_destroy(struct net_device *soft_iface) +{ + debugfs_del_meshif(soft_iface); + sysfs_del_meshif(soft_iface); + unregister_netdev(soft_iface); +} + /* ethtool */ static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) {
Modified: trunk/batman-adv/soft-interface.h =================================================================== --- trunk/batman-adv/soft-interface.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/soft-interface.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -23,10 +23,12 @@ #define _NET_BATMAN_ADV_SOFT_INTERFACE_H_
void set_main_if_addr(uint8_t *addr); -void interface_setup(struct net_device *dev); -int interface_tx(struct sk_buff *skb, struct net_device *dev); -void interface_rx(struct sk_buff *skb, int hdr_size); int my_skb_head_push(struct sk_buff *skb, unsigned int len); +int interface_tx(struct sk_buff *skb, struct net_device *soft_iface); +void interface_rx(struct net_device *soft_iface, + struct sk_buff *skb, int hdr_size); +struct net_device *softif_create(char *name); +void softif_destroy(struct net_device *soft_iface);
extern unsigned char main_if_addr[];
Modified: trunk/batman-adv/translation-table.c =================================================================== --- trunk/batman-adv/translation-table.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/translation-table.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -35,7 +35,8 @@
static void hna_local_purge(struct work_struct *work); static DECLARE_DELAYED_WORK(hna_local_purge_wq, hna_local_purge); -static void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, +static void _hna_global_del_orig(struct bat_priv *bat_priv, + struct hna_global_entry *hna_global_entry, char *message);
static void hna_local_start_timer(void) @@ -59,10 +60,9 @@ return 1; }
-void hna_local_add(uint8_t *addr) +void hna_local_add(struct net_device *soft_iface, uint8_t *addr) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = netdev_priv(soft_iface); struct hna_local_entry *hna_local_entry; struct hna_global_entry *hna_global_entry; struct hashtable_t *swaphash; @@ -101,7 +101,7 @@ hna_local_entry->last_seen = jiffies;
/* the batman interface mac address should never be purged */ - if (compare_orig(addr, soft_device->dev_addr)) + if (compare_orig(addr, soft_iface->dev_addr)) hna_local_entry->never_purge = 1; else hna_local_entry->never_purge = 0; @@ -131,7 +131,8 @@ ((struct hna_global_entry *)hash_find(hna_global_hash, addr));
if (hna_global_entry != NULL) - _hna_global_del_orig(hna_global_entry, "local hna received"); + _hna_global_del_orig(bat_priv, hna_global_entry, + "local hna received");
spin_unlock_irqrestore(&hna_global_hash_lock, flags); } @@ -215,26 +216,26 @@ return 0; }
-static void _hna_local_del(void *data) +static void _hna_local_del(void *data, void *arg) { kfree(data); num_hna--; atomic_set(&hna_local_changed, 1); }
-static void hna_local_del(struct hna_local_entry *hna_local_entry, +static void hna_local_del(struct bat_priv *bat_priv, + struct hna_local_entry *hna_local_entry, char *message) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); bat_dbg(DBG_ROUTES, bat_priv, "Deleting local hna entry (%pM): %s\n", hna_local_entry->addr, message);
hash_remove(hna_local_hash, hna_local_entry->addr); - _hna_local_del(hna_local_entry); + _hna_local_del(hna_local_entry, bat_priv); }
-void hna_local_remove(uint8_t *addr, char *message) +void hna_local_remove(struct bat_priv *bat_priv, + uint8_t *addr, char *message) { struct hna_local_entry *hna_local_entry; unsigned long flags; @@ -244,7 +245,7 @@ hna_local_entry = (struct hna_local_entry *) hash_find(hna_local_hash, addr); if (hna_local_entry) - hna_local_del(hna_local_entry, message); + hna_local_del(bat_priv, hna_local_entry, message);
spin_unlock_irqrestore(&hna_local_hash_lock, flags); } @@ -262,9 +263,10 @@ hna_local_entry = hashit.bucket->data;
timeout = hna_local_entry->last_seen + LOCAL_HNA_TIMEOUT * HZ; - if ((!hna_local_entry->never_purge) && + /* if ((!hna_local_entry->never_purge) && time_after(jiffies, timeout)) - hna_local_del(hna_local_entry, "address timed out"); + hna_local_del(bat_priv, hna_local_entry, + "address timed out");*/ }
spin_unlock_irqrestore(&hna_local_hash_lock, flags); @@ -277,7 +279,7 @@ return;
cancel_delayed_work_sync(&hna_local_purge_wq); - hash_delete(hna_local_hash, _hna_local_del); + hash_delete(hna_local_hash, _hna_local_del, NULL); hna_local_hash = NULL; }
@@ -294,11 +296,10 @@ return 1; }
-void hna_global_add_orig(struct orig_node *orig_node, +void hna_global_add_orig(struct bat_priv *bat_priv, + struct orig_node *orig_node, unsigned char *hna_buff, int hna_buff_len) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); struct hna_global_entry *hna_global_entry; struct hna_local_entry *hna_local_entry; struct hashtable_t *swaphash; @@ -346,7 +347,8 @@ hash_find(hna_local_hash, hna_ptr);
if (hna_local_entry != NULL) - hna_local_del(hna_local_entry, "global hna received"); + hna_local_del(bat_priv, hna_local_entry, + "global hna received");
spin_unlock_irqrestore(&hna_local_hash_lock, flags);
@@ -430,11 +432,10 @@ return 0; }
-static void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, +static void _hna_global_del_orig(struct bat_priv *bat_priv, + struct hna_global_entry *hna_global_entry, char *message) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); bat_dbg(DBG_ROUTES, bat_priv, "Deleting global hna entry %pM (via %pM): %s\n", hna_global_entry->addr, hna_global_entry->orig_node->orig, @@ -444,7 +445,8 @@ kfree(hna_global_entry); }
-void hna_global_del_orig(struct orig_node *orig_node, char *message) +void hna_global_del_orig(struct bat_priv *bat_priv, + struct orig_node *orig_node, char *message) { struct hna_global_entry *hna_global_entry; int hna_buff_count = 0; @@ -463,7 +465,8 @@
if ((hna_global_entry != NULL) && (hna_global_entry->orig_node == orig_node)) - _hna_global_del_orig(hna_global_entry, message); + _hna_global_del_orig(bat_priv, hna_global_entry, + message);
hna_buff_count++; } @@ -475,7 +478,7 @@ orig_node->hna_buff = NULL; }
-static void hna_global_del(void *data) +static void hna_global_del(void *data, void *arg) { kfree(data); } @@ -485,7 +488,7 @@ if (!hna_global_hash) return;
- hash_delete(hna_global_hash, hna_global_del); + hash_delete(hna_global_hash, hna_global_del, NULL); hna_global_hash = NULL; }
Modified: trunk/batman-adv/translation-table.h =================================================================== --- trunk/batman-adv/translation-table.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/translation-table.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -25,16 +25,19 @@ #include "types.h"
int hna_local_init(void); -void hna_local_add(uint8_t *addr); -void hna_local_remove(uint8_t *addr, char *message); +void hna_local_add(struct net_device *soft_iface, uint8_t *addr); +void hna_local_remove(struct bat_priv *bat_priv, + uint8_t *addr, char *message); int hna_local_fill_buffer(unsigned char *buff, int buff_len); int hna_local_seq_print_text(struct seq_file *seq, void *offset); void hna_local_free(void); int hna_global_init(void); -void hna_global_add_orig(struct orig_node *orig_node, unsigned char *hna_buff, - int hna_buff_len); +void hna_global_add_orig(struct bat_priv *bat_priv, + struct orig_node *orig_node, + unsigned char *hna_buff, int hna_buff_len); int hna_global_seq_print_text(struct seq_file *seq, void *offset); -void hna_global_del_orig(struct orig_node *orig_node, char *message); +void hna_global_del_orig(struct bat_priv *bat_priv, + struct orig_node *orig_node, char *message); void hna_global_free(void); struct orig_node *transtable_search(uint8_t *addr);
Modified: trunk/batman-adv/types.h =================================================================== --- trunk/batman-adv/types.h 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/types.h 2010-08-08 22:58:27 UTC (rev 1765) @@ -47,6 +47,7 @@ struct kobject *hardif_obj; struct rcu_head rcu; struct packet_type batman_adv_ptype; + struct net_device *soft_iface; };
/**
Modified: trunk/batman-adv/vis.c =================================================================== --- trunk/batman-adv/vis.c 2010-08-08 13:01:11 UTC (rev 1764) +++ trunk/batman-adv/vis.c 2010-08-08 22:58:27 UTC (rev 1765) @@ -746,17 +746,16 @@ { struct vis_info *info, *temp; unsigned long flags; - /* FIXME: each batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + /* struct bat_priv *bat_priv = netdev_priv(soft_device); */
spin_lock_irqsave(&vis_hash_lock, flags);
purge_vis_packets();
- if (generate_vis_packet(bat_priv) == 0) { + /* if (generate_vis_packet(bat_priv) == 0) {*/ /* schedule if generation was successful */ - send_list_add(my_vis_info); - } + /*send_list_add(my_vis_info); + } */
list_for_each_entry_safe(info, temp, &send_list, send_list) {
@@ -843,7 +842,7 @@ }
/* Decrease the reference count on a hash item info */ -static void free_info_ref(void *data) +static void free_info_ref(void *data, void *arg) { struct vis_info *info = data;
@@ -862,7 +861,7 @@
spin_lock_irqsave(&vis_hash_lock, flags); /* properly remove, kill timers ... */ - hash_delete(vis_hash, free_info_ref); + hash_delete(vis_hash, free_info_ref, NULL); vis_hash = NULL; my_vis_info = NULL; spin_unlock_irqrestore(&vis_hash_lock, flags);