The following commit has been merged in the master branch: commit 8af58b4f2ff2612b66a9321c468f03ffb62a06c5 Merge: 26c6ecc73ed62dd693c02a55e687bdbabad3d953 8bd9620303eee333e3915853ca64e722c57495dd Author: Sven Eckelmann sven@narfation.org Date: Fri May 20 14:22:29 2011 +0200
Merge branch 'next'
diff --combined compat.h index c11f6cd,2e3f062..2bd9e0a --- a/compat.h +++ b/compat.h @@@ -265,8 -265,6 +265,8 @@@ int bat_seq_printf(struct seq_file *m, pos && ({ prefetch(pos->next); 1; }); \ pos = rcu_dereference(hlist_next_rcu(pos)))
+#define rcu_dereference_protected(p, c) (p) + #endif /* < KERNEL_VERSION(2, 6, 34) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) @@@ -275,4 -273,14 +275,14 @@@
#endif /* < KERNEL_VERSION(2, 6, 36) */
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 40) + + #define kfree_rcu(ptr, rcu_head) call_rcu(&ptr->rcu_head, free_rcu_##ptr) + + void free_rcu_gw_node(struct rcu_head *rcu); + void free_rcu_neigh_node(struct rcu_head *rcu); + void free_rcu_softif_neigh(struct rcu_head *rcu); + + #endif /* < KERNEL_VERSION(2, 6, 40) */ + #endif /* _NET_BATMAN_ADV_COMPAT_H_ */ diff --combined gateway_client.c index 9fc475f,61605a0..ab597c4 --- a/gateway_client.c +++ b/gateway_client.c @@@ -29,18 -29,10 +29,10 @@@ #include <linux/udp.h> #include <linux/if_vlan.h>
static void gw_node_free_ref(struct gw_node *gw_node) { if (atomic_dec_and_test(&gw_node->refcount)) - call_rcu(&gw_node->rcu, gw_node_free_rcu); + kfree_rcu(gw_node, rcu); }
static struct gw_node *gw_get_selected_gw_node(struct bat_priv *bat_priv) @@@ -94,7 -86,7 +86,7 @@@ static void gw_select(struct bat_priv * if (new_gw_node && !atomic_inc_not_zero(&new_gw_node->refcount)) new_gw_node = NULL;
- curr_gw_node = bat_priv->curr_gw; + curr_gw_node = rcu_dereference_protected(bat_priv->curr_gw, 1); rcu_assign_pointer(bat_priv->curr_gw, new_gw_node);
if (curr_gw_node) @@@ -281,10 -273,11 +273,10 @@@ static void gw_node_add(struct bat_pri struct gw_node *gw_node; int down, up;
- gw_node = kmalloc(sizeof(struct gw_node), GFP_ATOMIC); + gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC); if (!gw_node) return;
- memset(gw_node, 0, sizeof(struct gw_node)); INIT_HLIST_NODE(&gw_node->list); gw_node->orig_node = orig_node; atomic_set(&gw_node->refcount, 1); @@@ -401,8 -394,8 +393,8 @@@ void gw_node_purge(struct bat_priv *bat /** * fails if orig_node has no router */ -static int _write_buffer_text(struct bat_priv *bat_priv, - struct seq_file *seq, struct gw_node *gw_node) +static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq, + const struct gw_node *gw_node) { struct gw_node *curr_gw; struct neigh_node *router; @@@ -516,7 -509,7 +508,7 @@@ int gw_is_target(struct bat_priv *bat_p /* check for ip header */ switch (ntohs(ethhdr->h_proto)) { case ETH_P_IP: - if (!pskb_may_pull(skb, header_len + sizeof(struct iphdr))) + if (!pskb_may_pull(skb, header_len + sizeof(*iphdr))) return 0; iphdr = (struct iphdr *)(skb->data + header_len); header_len += iphdr->ihl * 4; @@@ -527,10 -520,10 +519,10 @@@
break; case ETH_P_IPV6: - if (!pskb_may_pull(skb, header_len + sizeof(struct ipv6hdr))) + if (!pskb_may_pull(skb, header_len + sizeof(*ipv6hdr))) return 0; ipv6hdr = (struct ipv6hdr *)(skb->data + header_len); - header_len += sizeof(struct ipv6hdr); + header_len += sizeof(*ipv6hdr);
/* check for udp header */ if (ipv6hdr->nexthdr != IPPROTO_UDP) @@@ -541,10 -534,10 +533,10 @@@ return 0; }
- if (!pskb_may_pull(skb, header_len + sizeof(struct udphdr))) + if (!pskb_may_pull(skb, header_len + sizeof(*udphdr))) return 0; udphdr = (struct udphdr *)(skb->data + header_len); - header_len += sizeof(struct udphdr); + header_len += sizeof(*udphdr);
/* check for bootp port */ if ((ntohs(ethhdr->h_proto) == ETH_P_IP) && diff --combined originator.c index 083954a,40a30bb..a6c35d4 --- a/originator.c +++ b/originator.c @@@ -54,18 -54,10 +54,10 @@@ err return 0; }
void neigh_node_free_ref(struct neigh_node *neigh_node) { if (atomic_dec_and_test(&neigh_node->refcount)) - call_rcu(&neigh_node->rcu, neigh_node_free_rcu); + kfree_rcu(neigh_node, rcu); }
/* increases the refcounter of a found router */ @@@ -85,7 -77,7 +77,7 @@@ struct neigh_node *orig_node_get_router
struct neigh_node *create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, - uint8_t *neigh, + const uint8_t *neigh, struct hard_iface *if_incoming) { struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); @@@ -94,7 -86,7 +86,7 @@@ bat_dbg(DBG_BATMAN, bat_priv, "Creating new last-hop neighbor of originator\n");
- neigh_node = kzalloc(sizeof(struct neigh_node), GFP_ATOMIC); + neigh_node = kzalloc(sizeof(*neigh_node), GFP_ATOMIC); if (!neigh_node) return NULL;
@@@ -191,7 -183,7 +183,7 @@@ void originator_free(struct bat_priv *b
/* this function finds or creates an originator entry for the given * address if it does not exits */ -struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) +struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) { struct orig_node *orig_node; int size; @@@ -204,7 -196,7 +196,7 @@@ bat_dbg(DBG_BATMAN, bat_priv, "Creating new originator: %pM\n", addr);
- orig_node = kzalloc(sizeof(struct orig_node), GFP_ATOMIC); + orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC); if (!orig_node) return NULL;
@@@ -567,7 -559,7 +559,7 @@@ static int orig_node_del_if(struct orig memcpy(data_ptr, orig_node->bcast_own, del_if_num * chunk_size);
/* copy second part */ - memcpy(data_ptr + del_if_num * chunk_size, + memcpy((char *)data_ptr + del_if_num * chunk_size, orig_node->bcast_own + ((del_if_num + 1) * chunk_size), (max_if_num - del_if_num) * chunk_size);
@@@ -587,7 -579,7 +579,7 @@@ free_bcast_own memcpy(data_ptr, orig_node->bcast_own_sum, del_if_num * sizeof(uint8_t));
- memcpy(data_ptr + del_if_num * sizeof(uint8_t), + memcpy((char *)data_ptr + del_if_num * sizeof(uint8_t), orig_node->bcast_own_sum + ((del_if_num + 1) * sizeof(uint8_t)), (max_if_num - del_if_num) * sizeof(uint8_t));
diff --combined soft-interface.c index 56f1908,d5aa609..b8d3f24 --- a/soft-interface.c +++ b/soft-interface.c @@@ -72,18 -72,10 +72,10 @@@ int my_skb_head_push(struct sk_buff *sk return 0; }
static void softif_neigh_free_ref(struct softif_neigh *softif_neigh) { if (atomic_dec_and_test(&softif_neigh->refcount)) - call_rcu(&softif_neigh->rcu, softif_neigh_free_rcu); + kfree_rcu(softif_neigh, rcu); }
static void softif_neigh_vid_free_rcu(struct rcu_head *rcu) @@@ -131,7 -123,8 +123,7 @@@ static struct softif_neigh_vid *softif_ goto out; }
- softif_neigh_vid = kzalloc(sizeof(struct softif_neigh_vid), - GFP_ATOMIC); + softif_neigh_vid = kzalloc(sizeof(*softif_neigh_vid), GFP_ATOMIC); if (!softif_neigh_vid) goto out;
@@@ -153,7 -146,7 +145,7 @@@ out }
static struct softif_neigh *softif_neigh_get(struct bat_priv *bat_priv, - uint8_t *addr, short vid) + const uint8_t *addr, short vid) { struct softif_neigh_vid *softif_neigh_vid; struct softif_neigh *softif_neigh = NULL; @@@ -177,7 -170,7 +169,7 @@@ goto unlock; }
- softif_neigh = kzalloc(sizeof(struct softif_neigh), GFP_ATOMIC); + softif_neigh = kzalloc(sizeof(*softif_neigh), GFP_ATOMIC); if (!softif_neigh) goto unlock;
@@@ -249,8 -242,7 +241,8 @@@ static void softif_neigh_vid_select(str if (new_neigh && !atomic_inc_not_zero(&new_neigh->refcount)) new_neigh = NULL;
- curr_neigh = softif_neigh_vid->softif_neigh; + curr_neigh = rcu_dereference_protected(softif_neigh_vid->softif_neigh, + 1); rcu_assign_pointer(softif_neigh_vid->softif_neigh, new_neigh);
if ((curr_neigh) && (!new_neigh)) @@@ -619,7 -611,7 +611,7 @@@ int interface_tx(struct sk_buff *skb, s if (!primary_if) goto dropped;
- if (my_skb_head_push(skb, sizeof(struct bcast_packet)) < 0) + if (my_skb_head_push(skb, sizeof(*bcast_packet)) < 0) goto dropped;
bcast_packet = (struct bcast_packet *)skb->data; @@@ -798,16 -790,17 +790,16 @@@ static void interface_setup(struct net_
SET_ETHTOOL_OPS(dev, &bat_ethtool_ops);
- memset(priv, 0, sizeof(struct bat_priv)); + memset(priv, 0, sizeof(*priv)); }
-struct net_device *softif_create(char *name) +struct net_device *softif_create(const 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); + soft_iface = alloc_netdev(sizeof(*bat_priv), name, interface_setup);
if (!soft_iface) { pr_err("Unable to allocate the batman interface: %s\n", name); @@@ -879,7 -872,7 +871,7 @@@ void softif_destroy(struct net_device * unregister_netdevice(soft_iface); }
-int softif_is_valid(struct net_device *net_dev) +int softif_is_valid(const struct net_device *net_dev) { #ifdef HAVE_NET_DEVICE_OPS if (net_dev->netdev_ops->ndo_start_xmit == interface_tx) @@@ -931,3 -924,4 +923,3 @@@ static u32 bat_get_link(struct net_devi { return 1; } -