The following commit has been merged in the merge/master branch: commit e2ce130c5402f64c5be5962d74c04f6313dc17b7 Merge: 5409baf56e1c58c331ade23ab79f94cc66eaea6c b08dc3d9452d28944e7db09c2005c633b63f55e9 Author: Antonio Quartulli antonio@meshcoding.com Date: Fri Mar 21 23:39:44 2014 +0100
Merge commit 'b08dc3d9452d28944e7db09c2005c633b63f55e9' into merge/master
Signed-off-by: Antonio Quartulli antonio@meshcoding.com
Conflicts: net/batman-adv/compat.h
diff --combined net/batman-adv/multicast.c index 998b429,8c7ca81..8c7ca81 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@@ -10,6 -10,9 +10,9 @@@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. */
#include "main.h" @@@ -27,7 -30,7 +30,7 @@@ * Collect multicast addresses of the local multicast listeners * on the given soft interface, dev, in the given mcast_list. * - * Return -ENOMEM on memory allocation error or the number of + * Returns -ENOMEM on memory allocation error or the number of * items added to the mcast_list otherwise. */ static int batadv_mcast_mla_softif_get(struct net_device *dev, @@@ -59,7 -62,7 +62,7 @@@ * @mcast_addr: the multicast address to check * @mcast_list: the list with multicast addresses to search in * - * Return true if the given address is already in the given list. + * Returns true if the given address is already in the given list. * Otherwise returns false. */ static bool batadv_mcast_mla_is_duplicate(uint8_t *mcast_addr, @@@ -78,7 -81,7 +81,7 @@@ * batadv_mcast_mla_list_free - free a list of multicast addresses * @mcast_list: the list to free * - * Remove and free all items in the given mcast_list. + * Removes and frees all items in the given mcast_list. */ static void batadv_mcast_mla_list_free(struct hlist_head *mcast_list) { @@@ -96,7 -99,7 +99,7 @@@ * @bat_priv: the bat priv with all the soft interface information * @mcast_list: a list of addresses which should _not_ be removed * - * Retract the announcement of any multicast listener from the + * Retracts the announcement of any multicast listener from the * translation table except the ones listed in the given mcast_list. * * If mcast_list is NULL then all are retracted. @@@ -128,7 -131,7 +131,7 @@@ static void batadv_mcast_mla_tt_retract * @bat_priv: the bat priv with all the soft interface information * @mcast_list: a list of addresses which are going to get added * - * Add multicast listener announcements from the given mcast_list to the + * Adds multicast listener announcements from the given mcast_list to the * translation table if they have not been added yet. */ static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv, @@@ -156,61 -159,34 +159,34 @@@ }
/** - * batadv_mcast_get_bridge - get the bridge interface on our soft interface + * batadv_mcast_has_bridge - check whether the soft-iface is bridged * @bat_priv: the bat priv with all the soft interface information * - * Return the next bridge interface on top of our soft interface and increase - * its refcount. If no such bridge interface exists, then return NULL. + * Checks whether there is a bridge on top of our soft interface. Returns + * true if so, false otherwise. */ - static struct net_device * - batadv_mcast_get_bridge(struct batadv_priv *bat_priv) + static bool batadv_mcast_has_bridge(struct batadv_priv *bat_priv) { struct net_device *upper = bat_priv->soft_iface;
rcu_read_lock(); do { upper = netdev_master_upper_dev_get_rcu(upper); } while (upper && !(upper->priv_flags & IFF_EBRIDGE)); - - if (upper) - dev_hold(upper); - rcu_read_unlock();
return upper; }
/** * batadv_mcast_mla_tvlv_update - update multicast tvlv * @bat_priv: the bat priv with all the soft interface information * - * Update the own multicast tvlv with our current multicast related settings, + * Updates the own multicast tvlv with our current multicast related settings, * capabilities and inabilities. * - * Return true if the tvlv container is registered afterwards. Otherwise return - * false. + * Returns true if the tvlv container is registered afterwards. Otherwise + * returns false. */ static bool batadv_mcast_mla_tvlv_update(struct batadv_priv *bat_priv) { @@@ -247,7 -223,7 +223,7 @@@ * batadv_mcast_mla_update - update the own MLAs * @bat_priv: the bat priv with all the soft interface information * - * Update the own multicast listener announcements in the translation + * Updates the own multicast listener announcements in the translation * table as well as the own, announced multicast tvlv container. */ void batadv_mcast_mla_update(struct batadv_priv *bat_priv) @@@ -277,11 -253,11 +253,11 @@@ out * @skb: the IPv4 packet to check * @is_unsnoopable: stores whether the destination is snoopable * - * Check whether the given IPv4 packet has the potential to - * be forwarded with a mode more optimal than classic flooding. + * Checks whether the given IPv4 packet has the potential to be forwarded with a + * mode more optimal than classic flooding. * - * If so then return 0. Otherwise -EINVAL is returned or -ENOMEM if we are - * out of memory. + * If so then returns 0. Otherwise -EINVAL is returned or -ENOMEM in case of + * memory allocation failure. */ static int batadv_mcast_forw_mode_check_ipv4(struct batadv_priv *bat_priv, struct sk_buff *skb, @@@ -315,11 -291,11 +291,11 @@@ * @skb: the IPv6 packet to check * @is_unsnoopable: stores whether the destination is snoopable * - * Check whether the given IPv6 packet has the potential to - * be forwarded with a mode more optimal than classic flooding. + * Checks whether the given IPv6 packet has the potential to be forwarded with a + * mode more optimal than classic flooding. * - * If so then return 0. Otherwise -EINVAL is returned or -ENOMEM if we are - * out of memory. + * If so then returns 0. Otherwise -EINVAL is returned or -ENOMEM if we are out + * of memory. */ static int batadv_mcast_forw_mode_check_ipv6(struct batadv_priv *bat_priv, struct sk_buff *skb, @@@ -336,8 -312,7 +312,7 @@@ /* TODO: Implement Multicast Router Discovery (RFC4286), * then allow scope > link local, too */ - if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) != - IPV6_ADDR_SCOPE_LINKLOCAL) + if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) != IPV6_ADDR_SCOPE_LINKLOCAL) return -EINVAL;
/* link-local-all-nodes multicast listeners behind a bridge are @@@ -355,11 -330,11 +330,11 @@@ * @skb: the multicast frame to check * @is_unsnoopable: stores whether the destination is snoopable * - * Check whether the given multicast ethernet frame has the potential to - * be forwarded with a mode more optimal than classic flooding. + * Checks whether the given multicast ethernet frame has the potential to be + * forwarded with a mode more optimal than classic flooding. * - * If so then return 0. Otherwise -EINVAL is returned or -ENOMEM if we are - * out of memory. + * If so then returns 0. Otherwise -EINVAL is returned or -ENOMEM if we are out + * of memory. */ static int batadv_mcast_forw_mode_check(struct batadv_priv *bat_priv, struct sk_buff *skb, @@@ -390,9 -365,9 +365,9 @@@ * @bat_priv: the bat priv with all the soft interface information * @ethhdr: ethernet header of a packet * - * Return the number of nodes which want all IPv4 multicast traffic if - * the given ethhdr is from an IPv4 packet or the number of nodes which want - * all IPv6 traffic if it matches an IPv6 packet. + * Returns the number of nodes which want all IPv4 multicast traffic if the + * given ethhdr is from an IPv4 packet or the number of nodes which want all + * IPv6 traffic if it matches an IPv6 packet. */ static int batadv_mcast_forw_want_all_ip_count(struct batadv_priv *bat_priv, struct ethhdr *ethhdr) @@@ -413,7 -388,7 +388,7 @@@ * @bat_priv: the bat priv with all the soft interface information * @ethhdr: the ether header containing the multicast destination * - * Return an orig_node matching the multicast address provided by ethhdr + * Returns an orig_node matching the multicast address provided by ethhdr * via a translation table lookup. This increases the returned nodes refcount. */ static struct batadv_orig_node * @@@ -428,26 -403,26 +403,26 @@@ batadv_mcast_forw_tt_node_get(struct ba * batadv_mcast_want_forw_ipv4_node_get - get a node with an ipv4 flag * @bat_priv: the bat priv with all the soft interface information * - * Return an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 flag set - * and increase its refcount. + * Returns an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 flag set and + * increases its refcount. */ static struct batadv_orig_node * batadv_mcast_forw_ipv4_node_get(struct batadv_priv *bat_priv) { - struct batadv_orig_node *orig_node; + struct batadv_orig_node *tmp_orig_node, *orig_node = NULL;
rcu_read_lock(); - hlist_for_each_entry_rcu(orig_node, + hlist_for_each_entry_rcu(tmp_orig_node, &bat_priv->mcast.want_all_ipv4_list, mcast_want_all_ipv4_node) { - if (atomic_inc_not_zero(&orig_node->refcount)) - goto unlock; - } - - orig_node = NULL; + if (!atomic_inc_not_zero(&orig_node->refcount)) + continue;
- unlock: + orig_node = tmp_orig_node; + break; + } rcu_read_unlock(); + return orig_node; }
@@@ -455,26 -430,26 +430,26 @@@ * batadv_mcast_want_forw_ipv6_node_get - get a node with an ipv6 flag * @bat_priv: the bat priv with all the soft interface information * - * Return an orig_node which has the BATADV_MCAST_WANT_ALL_IPV6 flag set - * and increase its refcount. + * Returns an orig_node which has the BATADV_MCAST_WANT_ALL_IPV6 flag set + * and increases its refcount. */ static struct batadv_orig_node * batadv_mcast_forw_ipv6_node_get(struct batadv_priv *bat_priv) { - struct batadv_orig_node *orig_node; + struct batadv_orig_node *tmp_orig_node, *orig_node = NULL;
rcu_read_lock(); - hlist_for_each_entry_rcu(orig_node, + hlist_for_each_entry_rcu(tmp_orig_node, &bat_priv->mcast.want_all_ipv6_list, mcast_want_all_ipv6_node) { - if (atomic_inc_not_zero(&orig_node->refcount)) - goto unlock; - } - - orig_node = NULL; + if (!atomic_inc_not_zero(&orig_node->refcount)) + continue;
- unlock: + orig_node = tmp_orig_node; + break; + } rcu_read_unlock(); + return orig_node; }
@@@ -483,9 -458,9 +458,9 @@@ * @bat_priv: the bat priv with all the soft interface information * @ethhdr: an ethernet header to determine the protocol family from * - * Return an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 or - * BATADV_MCAST_WANT_ALL_IPV6 flag, depending on the provided ethhdr, set - * and increase its refcount. + * Returns an orig_node which has the BATADV_MCAST_WANT_ALL_IPV4 or + * BATADV_MCAST_WANT_ALL_IPV6 flag, depending on the provided ethhdr, set and + * increases its refcount. */ static struct batadv_orig_node * batadv_mcast_forw_ip_node_get(struct batadv_priv *bat_priv, @@@ -506,26 -481,26 +481,26 @@@ * batadv_mcast_want_forw_unsnoop_node_get - get a node with an unsnoopable flag * @bat_priv: the bat priv with all the soft interface information * - * Return an orig_node which has the BATADV_MCAST_WANT_ALL_UNSNOOPABLES flag set - * and increase its refcount. + * Returns an orig_node which has the BATADV_MCAST_WANT_ALL_UNSNOOPABLES flag + * set and increases its refcount. */ static struct batadv_orig_node * batadv_mcast_forw_unsnoop_node_get(struct batadv_priv *bat_priv) { - struct batadv_orig_node *orig_node; + struct batadv_orig_node *tmp_orig_node, *orig_node = NULL;
rcu_read_lock(); - hlist_for_each_entry_rcu(orig_node, + hlist_for_each_entry_rcu(tmp_orig_node, &bat_priv->mcast.want_all_unsnoopables_list, mcast_want_all_unsnoopables_node) { - if (atomic_inc_not_zero(&orig_node->refcount)) - goto unlock; - } - - orig_node = NULL; + if (!atomic_inc_not_zero(&orig_node->refcount)) + continue;
- unlock: + orig_node = tmp_orig_node; + break; + } rcu_read_unlock(); + return orig_node; }
@@@ -535,7 -510,7 +510,7 @@@ * @skb: The multicast packet to check * @orig: an originator to be set to forward the skb to * - * Return the forwarding mode as enum batadv_forw_mode and in case of + * Returns the forwarding mode as enum batadv_forw_mode and in case of * BATADV_FORW_SINGLE set the orig to the single originator the skb * should be forwarded to. */ @@@ -543,9 -518,9 +518,9 @@@ enum batadv_forw_mod batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, struct batadv_orig_node **orig) { - struct ethhdr *ethhdr; - bool is_unsnoopable = false; int ret, tt_count, ip_count, unsnoop_count, total_count; + bool is_unsnoopable = false; + struct ethhdr *ethhdr;
ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable); if (ret == -ENOMEM) diff --combined net/batman-adv/multicast.h index a76bc3a,73b5d45..73b5d45 --- a/net/batman-adv/multicast.h +++ b/net/batman-adv/multicast.h @@@ -10,6 -10,9 +10,9 @@@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. */
#ifndef _NET_BATMAN_ADV_MULTICAST_H_ @@@ -17,10 -20,10 +20,10 @@@
/** * batadv_forw_mode - the way a packet should be forwarded as - * @BATADV_FORW_ALL: forward the packet to all nodes - * (currently via classic flooding) - * @BATADV_FORW_SINGLE: forward the packet to a single node - * (currently via the BATMAN unicast routing protocol) + * @BATADV_FORW_ALL: forward the packet to all nodes (currently via classic + * flooding) + * @BATADV_FORW_SINGLE: forward the packet to a single node (currently via the + * BATMAN unicast routing protocol) * @BATADV_FORW_NONE: don't forward, drop it */ enum batadv_forw_mode { diff --combined net/batman-adv/translation-table.c index dab5c39,d636bde..d636bde --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@@ -206,16 -206,15 +206,15 @@@ int batadv_tt_global_hash_count(struct const uint8_t *addr, unsigned short vid) { struct batadv_tt_global_entry *tt_global_entry; - int count = 0; + int count;
tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr, vid); if (!tt_global_entry) - goto out; + return 0;
count = atomic_read(&tt_global_entry->orig_list_count); batadv_tt_global_entry_free_ref(tt_global_entry);
- out: return count; }