The following commit has been merged in the next branch: commit 0268bdbe7e0b6e63ff770f7515828cdacdb0883b Merge: 73cc7626aba1e2d35e2ad9a0a161e8bba187cba1 746e5dd81e4981d535d7100b414a78040522308f Author: Marek Lindner lindner_marek@yahoo.de Date: Fri May 11 15:38:02 2012 +0800
Merge branch 'next'
Conflicts: bat_iv_ogm.c
diff --combined bat_iv_ogm.c index bde28c3,92fad91..8b0ecf3 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@@ -34,11 -34,11 +34,12 @@@ static struct neigh_node *bat_iv_ogm_ne const uint8_t *neigh_addr, struct orig_node *orig_node, struct orig_node *orig_neigh, - uint32_t seqno) + __be32 seqno) { struct neigh_node *neigh_node;
- neigh_node = neigh_node_new(hard_iface, neigh_addr, ntohl(seqno)); - neigh_node = batadv_neigh_node_new(hard_iface, neigh_addr, seqno); ++ neigh_node = batadv_neigh_node_new(hard_iface, neigh_addr, ++ ntohl(seqno)); if (!neigh_node) goto out;
@@@ -196,12 -196,8 +197,12 @@@ static void bat_iv_ogm_send_to_if(struc
/* create clone because function is called more than once */ skb = skb_clone(forw_packet->skb, GFP_ATOMIC); - if (skb) + if (skb) { + inc_counter(bat_priv, BAT_CNT_MGMT_TX); + add_counter(bat_priv, BAT_CNT_MGMT_TX_BYTES, + skb->len + ETH_HLEN); send_skb_packet(skb, hard_iface, broadcast_addr); + } }
/* send a batman ogm packet */ @@@ -522,13 -518,12 +523,12 @@@ static void bat_iv_ogm_forward(struct o }
if (!is_from_best_next_hop) { - /** - * Mark the forwarded packet when it is not coming from our best - * next hop. We still need to forward the packet for our neighbor - * link quality detection to work in case the packet originated - * from a single hop neighbor. Otherwise we can simply drop the - * ogm. - */ + /* Mark the forwarded packet when it is not coming from our + * best next hop. We still need to forward the packet for our + * neighbor link quality detection to work in case the packet + * originated from a single hop neighbor. Otherwise we can + * simply drop the ogm. + */ if (is_single_hop_neigh) batman_ogm_packet->flags |= NOT_BEST_NEXT_HOP; else @@@ -547,6 -542,9 +547,6 @@@ "Forwarding packet: tq: %i, ttl: %i\n", batman_ogm_packet->tq, batman_ogm_packet->header.ttl);
- batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno); - batman_ogm_packet->tt_crc = htons(batman_ogm_packet->tt_crc); - /* switch of primaries first hop flag when forwarding */ batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP; if (is_single_hop_neigh) @@@ -577,7 -575,8 +577,7 @@@ static void bat_iv_ogm_schedule(struct htonl((uint32_t)atomic_read(&hard_iface->seqno));
batman_ogm_packet->ttvn = atomic_read(&bat_priv->ttvn); - batman_ogm_packet->tt_crc = htons((uint16_t) - atomic_read(&bat_priv->tt_crc)); + batman_ogm_packet->tt_crc = htons(bat_priv->tt_crc); if (tt_num_changes >= 0) batman_ogm_packet->tt_num_changes = tt_num_changes;
@@@ -722,7 -721,7 +722,7 @@@ update_tt tt_update_orig(bat_priv, orig_node, tt_buff, batman_ogm_packet->tt_num_changes, batman_ogm_packet->ttvn, - batman_ogm_packet->tt_crc); + ntohs(batman_ogm_packet->tt_crc));
if (orig_node->gw_flags != batman_ogm_packet->gw_flags) gw_node_update(bat_priv, orig_node, @@@ -869,14 -868,13 +869,14 @@@ static int bat_iv_ogm_update_seqnos(con int32_t seq_diff; int need_update = 0; int set_mark, ret = -1; + uint32_t seqno = ntohl(batman_ogm_packet->seqno);
orig_node = get_orig_node(bat_priv, batman_ogm_packet->orig); if (!orig_node) return 0;
spin_lock_bh(&orig_node->ogm_cnt_lock); - seq_diff = batman_ogm_packet->seqno - orig_node->last_real_seqno; + seq_diff = seqno - orig_node->last_real_seqno;
/* signalize caller that the packet is to be dropped. */ if (!hlist_empty(&orig_node->neigh_list) && @@@ -890,7 -888,7 +890,7 @@@
is_duplicate |= bat_test_bit(tmp_neigh_node->real_bits, orig_node->last_real_seqno, - batman_ogm_packet->seqno); + seqno);
if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && (tmp_neigh_node->if_incoming == if_incoming)) @@@ -912,8 -910,8 +912,8 @@@ if (need_update) { bat_dbg(DBG_BATMAN, bat_priv, "updating last_seqno: old %u, new %u\n", - orig_node->last_real_seqno, batman_ogm_packet->seqno); - orig_node->last_real_seqno = batman_ogm_packet->seqno; + orig_node->last_real_seqno, seqno); + orig_node->last_real_seqno = seqno; }
ret = is_duplicate; @@@ -969,8 -967,8 +969,8 @@@ static void bat_iv_ogm_process(const st "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", ethhdr->h_source, if_incoming->net_dev->name, if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, - batman_ogm_packet->prev_sender, batman_ogm_packet->seqno, - batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc, + batman_ogm_packet->prev_sender, ntohl(batman_ogm_packet->seqno), + batman_ogm_packet->ttvn, ntohs(batman_ogm_packet->tt_crc), batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, batman_ogm_packet->header.ttl, batman_ogm_packet->header.version, has_directlink_flag); @@@ -1041,7 -1039,7 +1041,7 @@@ word = &(orig_neigh_node->bcast_own[offset]); bat_set_bit(word, if_incoming_seqno - - batman_ogm_packet->seqno - 2); + ntohl(batman_ogm_packet->seqno) - 2); orig_neigh_node->bcast_own_sum[if_incoming->if_num] = bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); @@@ -1134,7 -1132,7 +1134,7 @@@ * seqno and similar ttl as the non-duplicate */ if (is_bidirectional && (!is_duplicate || - ((orig_node->last_real_seqno == batman_ogm_packet->seqno) && + ((orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno)) && (orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl)))) bat_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, batman_ogm_packet, if_incoming, @@@ -1201,13 -1199,11 +1201,14 @@@ static int bat_iv_ogm_receive(struct sk return NET_RX_DROP;
/* did we receive a B.A.T.M.A.N. IV OGM packet on an interface - * that does not have B.A.T.M.A.N. IV enabled ? */ + * that does not have B.A.T.M.A.N. IV enabled ? + */ if (bat_priv->bat_algo_ops->bat_ogm_emit != bat_iv_ogm_emit) return NET_RX_DROP;
+ inc_counter(bat_priv, BAT_CNT_MGMT_RX); + add_counter(bat_priv, BAT_CNT_MGMT_RX_BYTES, skb->len + ETH_HLEN); + packet_len = skb_headlen(skb); ethhdr = (struct ethhdr *)skb_mac_header(skb); packet_buff = skb->data; @@@ -1215,6 -1211,11 +1216,6 @@@
/* unpack the aggregated packets and process them one by one */ do { - /* network to host order for our 32bit seqno and the - orig_interval */ - batman_ogm_packet->seqno = ntohl(batman_ogm_packet->seqno); - batman_ogm_packet->tt_crc = ntohs(batman_ogm_packet->tt_crc); - tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN;
bat_iv_ogm_process(ethhdr, batman_ogm_packet, @@@ -1233,7 -1234,7 +1234,7 @@@ }
static struct bat_algo_ops batman_iv __read_mostly = { - .name = "BATMAN IV", + .name = "BATMAN_IV", .bat_iface_enable = bat_iv_ogm_iface_enable, .bat_iface_disable = bat_iv_ogm_iface_disable, .bat_iface_update_mac = bat_iv_ogm_iface_update_mac, diff --combined originator.c index 61e091d,c6a00b3..c17dc0c --- a/originator.c +++ b/originator.c @@@ -51,7 -51,7 +51,7 @@@ static int compare_orig(const struct hl int originator_init(struct bat_priv *bat_priv) { if (bat_priv->orig_hash) - return 1; + return 0;
bat_priv->orig_hash = hash_new(1024);
@@@ -59,10 -59,10 +59,10 @@@ goto err;
start_purge_timer(bat_priv); - return 1; + return 0;
err: - return 0; + return -ENOMEM; }
void neigh_node_free_ref(struct neigh_node *neigh_node) @@@ -86,8 -86,9 +86,9 @@@ struct neigh_node *orig_node_get_router return router; }
- struct neigh_node *neigh_node_new(struct hard_iface *hard_iface, - const uint8_t *neigh_addr, uint32_t seqno) + struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, + const uint8_t *neigh_addr, + uint32_t seqno) { struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); struct neigh_node *neigh_node; @@@ -489,7 -490,7 +490,7 @@@ static int orig_node_add_if(struct orig data_ptr = kmalloc(max_if_num * sizeof(unsigned long) * NUM_WORDS, GFP_ATOMIC); if (!data_ptr) - return -1; + return -ENOMEM;
memcpy(data_ptr, orig_node->bcast_own, (max_if_num - 1) * sizeof(unsigned long) * NUM_WORDS); @@@ -498,7 -499,7 +499,7 @@@
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); if (!data_ptr) - return -1; + return -ENOMEM;
memcpy(data_ptr, orig_node->bcast_own_sum, (max_if_num - 1) * sizeof(uint8_t)); @@@ -529,7 -530,7 +530,7 @@@ int orig_hash_add_if(struct hard_iface ret = orig_node_add_if(orig_node, max_if_num); spin_unlock_bh(&orig_node->ogm_cnt_lock);
- if (ret == -1) + if (ret == -ENOMEM) goto err; } rcu_read_unlock(); @@@ -555,7 -556,7 +556,7 @@@ static int orig_node_del_if(struct orig chunk_size = sizeof(unsigned long) * NUM_WORDS; data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); if (!data_ptr) - return -1; + return -ENOMEM;
/* copy first part */ memcpy(data_ptr, orig_node->bcast_own, del_if_num * chunk_size); @@@ -574,7 -575,7 +575,7 @@@ free_bcast_own
data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); if (!data_ptr) - return -1; + return -ENOMEM;
memcpy(data_ptr, orig_node->bcast_own_sum, del_if_num * sizeof(uint8_t)); @@@ -613,7 -614,7 +614,7 @@@ int orig_hash_del_if(struct hard_iface hard_iface->if_num); spin_unlock_bh(&orig_node->ogm_cnt_lock);
- if (ret == -1) + if (ret == -ENOMEM) goto err; } rcu_read_unlock(); diff --combined types.h index 41283e0,6474324..a23282d --- a/types.h +++ b/types.h @@@ -162,32 -162,9 +162,32 @@@ struct bcast_duplist_entry }; #endif
+enum bat_counters { + BAT_CNT_FORWARD, + BAT_CNT_FORWARD_BYTES, + BAT_CNT_MGMT_TX, + BAT_CNT_MGMT_TX_BYTES, + BAT_CNT_MGMT_RX, + BAT_CNT_MGMT_RX_BYTES, + BAT_CNT_TT_REQUEST_TX, + BAT_CNT_TT_REQUEST_RX, + BAT_CNT_TT_RESPONSE_TX, + BAT_CNT_TT_RESPONSE_RX, + BAT_CNT_TT_ROAM_ADV_TX, + BAT_CNT_TT_ROAM_ADV_RX, +#ifdef CONFIG_BATMAN_ADV_DAT + BAT_CNT_DAT_REQUEST_TX, + BAT_CNT_DAT_REQUEST_RX, + BAT_CNT_DAT_REPLY_TX, + BAT_CNT_DAT_REPLY_RX, +#endif + BAT_CNT_NUM, +}; + struct bat_priv { atomic_t mesh_state; struct net_device_stats stats; + uint64_t __percpu *bat_counters; /* Per cpu counters */ atomic_t aggregated_ogms; /* boolean */ atomic_t bonding; /* boolean */ atomic_t fragmentation; /* boolean */ @@@ -247,7 -224,7 +247,7 @@@ spinlock_t vis_list_lock; /* protects vis_info::recv_list */ atomic_t num_local_tt; /* Checksum of the local table, recomputed before sending a new OGM */ - atomic_t tt_crc; + uint16_t tt_crc; unsigned char *tt_buff; int16_t tt_buff_len; spinlock_t tt_buff_lock; /* protects tt_buff */ @@@ -422,7 -399,8 +422,8 @@@ struct bat_algo_ops /* de-init routing info when hard-interface is disabled */ void (*bat_iface_disable)(struct hard_iface *hard_iface); /* (re-)init mac addresses of the protocol information - * belonging to this hard-interface */ + * belonging to this hard-interface + */ void (*bat_iface_update_mac)(struct hard_iface *hard_iface); /* called when primary interface is selected / changed */ void (*bat_primary_iface_set)(struct hard_iface *hard_iface);