Commit cf71f43e authored by David S. Miller's avatar David S. Miller

Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge

Antonio Quartulli says:

====================
pull request: batman-adv 20150603

here you have our second batch of patches intended for net-next.

In this patchset you won't find any new features, but quite some code
cleanup work, a bunch of code style fixes and also comments corrections
by Markus Pargmann.

Moreover you have a patch from Sven Eckelmann removing an unnecessary
NULL check in batadv_iv_ogm_update_seqnos().

Please pull or let me know of any problem!
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3349b0b7 f372d090
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
/** /**
* enum batadv_dup_status - duplicate status * enum batadv_dup_status - duplicate status
* @BATADV_NO_DUP: the packet is a duplicate * @BATADV_NO_DUP: the packet is no duplicate
* @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
* neighbor) * neighbor)
* @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
...@@ -55,7 +55,7 @@ static void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, ...@@ -55,7 +55,7 @@ static void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
} }
/** /**
* batadv_ring_buffer_set - compute the average of all non-zero values stored * batadv_ring_buffer_avg - compute the average of all non-zero values stored
* in the given ring buffer * in the given ring buffer
* @lq_recv: pointer to the ring buffer * @lq_recv: pointer to the ring buffer
* *
...@@ -64,7 +64,9 @@ static void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index, ...@@ -64,7 +64,9 @@ static void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
static uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[]) static uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
{ {
const uint8_t *ptr; const uint8_t *ptr;
uint16_t count = 0, i = 0, sum = 0; uint16_t count = 0;
uint16_t i = 0;
uint16_t sum = 0;
ptr = lq_recv; ptr = lq_recv;
...@@ -642,19 +644,16 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, ...@@ -642,19 +644,16 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
if (!batadv_atomic_dec_not_zero(&bat_priv->batman_queue_left)) { if (!batadv_atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"batman packet queue full\n"); "batman packet queue full\n");
goto out; goto out_free_outgoing;
} }
} }
forw_packet_aggr = kmalloc(sizeof(*forw_packet_aggr), GFP_ATOMIC); forw_packet_aggr = kmalloc(sizeof(*forw_packet_aggr), GFP_ATOMIC);
if (!forw_packet_aggr) { if (!forw_packet_aggr)
if (!own_packet) goto out_nomem;
atomic_inc(&bat_priv->batman_queue_left);
goto out;
}
if ((atomic_read(&bat_priv->aggregated_ogms)) && if (atomic_read(&bat_priv->aggregated_ogms) &&
(packet_len < BATADV_MAX_AGGREGATION_BYTES)) packet_len < BATADV_MAX_AGGREGATION_BYTES)
skb_size = BATADV_MAX_AGGREGATION_BYTES; skb_size = BATADV_MAX_AGGREGATION_BYTES;
else else
skb_size = packet_len; skb_size = packet_len;
...@@ -662,12 +661,8 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, ...@@ -662,12 +661,8 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
skb_size += ETH_HLEN; skb_size += ETH_HLEN;
forw_packet_aggr->skb = netdev_alloc_skb_ip_align(NULL, skb_size); forw_packet_aggr->skb = netdev_alloc_skb_ip_align(NULL, skb_size);
if (!forw_packet_aggr->skb) { if (!forw_packet_aggr->skb)
if (!own_packet) goto out_free_forw_packet;
atomic_inc(&bat_priv->batman_queue_left);
kfree(forw_packet_aggr);
goto out;
}
forw_packet_aggr->skb->priority = TC_PRIO_CONTROL; forw_packet_aggr->skb->priority = TC_PRIO_CONTROL;
skb_reserve(forw_packet_aggr->skb, ETH_HLEN); skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
...@@ -699,7 +694,12 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, ...@@ -699,7 +694,12 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
send_time - jiffies); send_time - jiffies);
return; return;
out: out_free_forw_packet:
kfree(forw_packet_aggr);
out_nomem:
if (!own_packet)
atomic_inc(&bat_priv->batman_queue_left);
out_free_outgoing:
batadv_hardif_free_ref(if_outgoing); batadv_hardif_free_ref(if_outgoing);
out_free_incoming: out_free_incoming:
batadv_hardif_free_ref(if_incoming); batadv_hardif_free_ref(if_incoming);
...@@ -752,13 +752,13 @@ static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv, ...@@ -752,13 +752,13 @@ static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv,
unsigned long max_aggregation_jiffies; unsigned long max_aggregation_jiffies;
batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff; batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff;
direct_link = batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0; direct_link = !!(batadv_ogm_packet->flags & BATADV_DIRECTLINK);
max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS); max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
/* find position for the packet in the forward queue */ /* find position for the packet in the forward queue */
spin_lock_bh(&bat_priv->forw_bat_list_lock); spin_lock_bh(&bat_priv->forw_bat_list_lock);
/* own packets are not to be aggregated */ /* own packets are not to be aggregated */
if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) { if (atomic_read(&bat_priv->aggregated_ogms) && !own_packet) {
hlist_for_each_entry(forw_packet_pos, hlist_for_each_entry(forw_packet_pos,
&bat_priv->forw_bat_list, list) { &bat_priv->forw_bat_list, list) {
if (batadv_iv_ogm_can_aggregate(batadv_ogm_packet, if (batadv_iv_ogm_can_aggregate(batadv_ogm_packet,
...@@ -1034,9 +1034,10 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, ...@@ -1034,9 +1034,10 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
batadv_orig_node_free_ref(orig_tmp); batadv_orig_node_free_ref(orig_tmp);
if (!neigh_node) if (!neigh_node)
goto unlock; goto unlock;
} else } else {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Updating existing last-hop neighbor of originator\n"); "Updating existing last-hop neighbor of originator\n");
}
rcu_read_unlock(); rcu_read_unlock();
neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing); neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing);
...@@ -1356,7 +1357,6 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, ...@@ -1356,7 +1357,6 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
out: out:
spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock); spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock);
batadv_orig_node_free_ref(orig_node); batadv_orig_node_free_ref(orig_node);
if (orig_ifinfo)
batadv_orig_ifinfo_free_ref(orig_ifinfo); batadv_orig_ifinfo_free_ref(orig_ifinfo);
return ret; return ret;
} }
......
...@@ -209,10 +209,13 @@ void batadv_mesh_free(struct net_device *soft_iface) ...@@ -209,10 +209,13 @@ void batadv_mesh_free(struct net_device *soft_iface)
* interfaces in the current mesh * interfaces in the current mesh
* @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information
* @addr: the address to check * @addr: the address to check
*
* Returns 'true' if the mac address was found, false otherwise.
*/ */
int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr) bool batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr)
{ {
const struct batadv_hard_iface *hard_iface; const struct batadv_hard_iface *hard_iface;
bool is_my_mac = false;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
...@@ -223,12 +226,12 @@ int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr) ...@@ -223,12 +226,12 @@ int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr)
continue; continue;
if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) { if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) {
rcu_read_unlock(); is_my_mac = true;
return 1; break;
} }
} }
rcu_read_unlock(); rcu_read_unlock();
return 0; return is_my_mac;
} }
/** /**
...@@ -510,14 +513,12 @@ static struct batadv_algo_ops *batadv_algo_get(char *name) ...@@ -510,14 +513,12 @@ static struct batadv_algo_ops *batadv_algo_get(char *name)
int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops) int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
{ {
struct batadv_algo_ops *bat_algo_ops_tmp; struct batadv_algo_ops *bat_algo_ops_tmp;
int ret;
bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name); bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name);
if (bat_algo_ops_tmp) { if (bat_algo_ops_tmp) {
pr_info("Trying to register already registered routing algorithm: %s\n", pr_info("Trying to register already registered routing algorithm: %s\n",
bat_algo_ops->name); bat_algo_ops->name);
ret = -EEXIST; return -EEXIST;
goto out;
} }
/* all algorithms must implement all ops (for now) */ /* all algorithms must implement all ops (for now) */
...@@ -531,32 +532,26 @@ int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops) ...@@ -531,32 +532,26 @@ int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
!bat_algo_ops->bat_neigh_is_equiv_or_better) { !bat_algo_ops->bat_neigh_is_equiv_or_better) {
pr_info("Routing algo '%s' does not implement required ops\n", pr_info("Routing algo '%s' does not implement required ops\n",
bat_algo_ops->name); bat_algo_ops->name);
ret = -EINVAL; return -EINVAL;
goto out;
} }
INIT_HLIST_NODE(&bat_algo_ops->list); INIT_HLIST_NODE(&bat_algo_ops->list);
hlist_add_head(&bat_algo_ops->list, &batadv_algo_list); hlist_add_head(&bat_algo_ops->list, &batadv_algo_list);
ret = 0;
out: return 0;
return ret;
} }
int batadv_algo_select(struct batadv_priv *bat_priv, char *name) int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
{ {
struct batadv_algo_ops *bat_algo_ops; struct batadv_algo_ops *bat_algo_ops;
int ret = -EINVAL;
bat_algo_ops = batadv_algo_get(name); bat_algo_ops = batadv_algo_get(name);
if (!bat_algo_ops) if (!bat_algo_ops)
goto out; return -EINVAL;
bat_priv->bat_algo_ops = bat_algo_ops; bat_priv->bat_algo_ops = bat_algo_ops;
ret = 0;
out: return 0;
return ret;
} }
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
......
...@@ -195,7 +195,7 @@ extern struct workqueue_struct *batadv_event_workqueue; ...@@ -195,7 +195,7 @@ extern struct workqueue_struct *batadv_event_workqueue;
int batadv_mesh_init(struct net_device *soft_iface); int batadv_mesh_init(struct net_device *soft_iface);
void batadv_mesh_free(struct net_device *soft_iface); void batadv_mesh_free(struct net_device *soft_iface);
int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr); bool batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr);
struct batadv_hard_iface * struct batadv_hard_iface *
batadv_seq_print_text_primary_if_get(struct seq_file *seq); batadv_seq_print_text_primary_if_get(struct seq_file *seq);
int batadv_max_header_len(void); int batadv_max_header_len(void);
...@@ -279,7 +279,7 @@ static inline void _batadv_dbg(int type __always_unused, ...@@ -279,7 +279,7 @@ static inline void _batadv_dbg(int type __always_unused,
* *
* note: can't use ether_addr_equal() as it requires aligned memory * note: can't use ether_addr_equal() as it requires aligned memory
*/ */
static inline int batadv_compare_eth(const void *data1, const void *data2) static inline bool batadv_compare_eth(const void *data1, const void *data2)
{ {
return ether_addr_equal_unaligned(data1, data2); return ether_addr_equal_unaligned(data1, data2);
} }
......
...@@ -183,9 +183,10 @@ struct batadv_orig_node_vlan { ...@@ -183,9 +183,10 @@ struct batadv_orig_node_vlan {
/** /**
* struct batadv_orig_bat_iv - B.A.T.M.A.N. IV private orig_node members * struct batadv_orig_bat_iv - B.A.T.M.A.N. IV private orig_node members
* @bcast_own: bitfield containing the number of our OGMs this orig_node * @bcast_own: set of bitfields (one per hard interface) where each one counts
* rebroadcasted "back" to us (relative to last_real_seqno) * the number of our OGMs this orig_node rebroadcasted "back" to us (relative
* @bcast_own_sum: counted result of bcast_own * to last_real_seqno). Every bitfield is BATADV_TQ_LOCAL_WINDOW_SIZE bits long.
* @bcast_own_sum: sum of bcast_own
* @ogm_cnt_lock: lock protecting bcast_own, bcast_own_sum, * @ogm_cnt_lock: lock protecting bcast_own, bcast_own_sum,
* neigh_node->bat_iv.real_bits & neigh_node->bat_iv.real_packet_count * neigh_node->bat_iv.real_bits & neigh_node->bat_iv.real_packet_count
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment