aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMartin Hundebøll <martin@hundeboll.net>2012-04-20 11:02:45 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-11-07 14:00:23 -0500
commit4046b24aface62f5647699e9af3260a486bc5f49 (patch)
tree82e7fe03be17690b109fb3fff82e83fb63ef28cd /net
parent33af49ad8ae44de52c0ac30b1a9707dad5e4c418 (diff)
batman-adv: Add get_ethtool_stats() support for DAT
Added additional counters for D.A.T. Signed-off-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/distributed-arp-table.c19
-rw-r--r--net/batman-adv/distributed-arp-table.h27
-rw-r--r--net/batman-adv/routing.c8
-rw-r--r--net/batman-adv/soft-interface.c7
-rw-r--r--net/batman-adv/types.h7
5 files changed, 65 insertions, 3 deletions
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index c1a74a126f58..8e1d89d2b1c1 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -601,9 +601,22 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
601 send_status = batadv_send_skb_packet(tmp_skb, 601 send_status = batadv_send_skb_packet(tmp_skb,
602 neigh_node->if_incoming, 602 neigh_node->if_incoming,
603 neigh_node->addr); 603 neigh_node->addr);
604 if (send_status == NET_XMIT_SUCCESS) 604 if (send_status == NET_XMIT_SUCCESS) {
605 /* count the sent packet */
606 switch (packet_subtype) {
607 case BATADV_P_DAT_DHT_GET:
608 batadv_inc_counter(bat_priv,
609 BATADV_CNT_DAT_GET_TX);
610 break;
611 case BATADV_P_DAT_DHT_PUT:
612 batadv_inc_counter(bat_priv,
613 BATADV_CNT_DAT_PUT_TX);
614 break;
615 }
616
605 /* packet sent to a candidate: return true */ 617 /* packet sent to a candidate: return true */
606 ret = true; 618 ret = true;
619 }
607free_neigh: 620free_neigh:
608 batadv_neigh_node_free_ref(neigh_node); 621 batadv_neigh_node_free_ref(neigh_node);
609free_orig: 622free_orig:
@@ -909,8 +922,10 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
909 else 922 else
910 err = batadv_unicast_send_skb(bat_priv, skb_new); 923 err = batadv_unicast_send_skb(bat_priv, skb_new);
911 924
912 if (!err) 925 if (!err) {
926 batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
913 ret = true; 927 ret = true;
928 }
914out: 929out:
915 if (dat_entry) 930 if (dat_entry)
916 batadv_dat_entry_free_ref(dat_entry); 931 batadv_dat_entry_free_ref(dat_entry);
diff --git a/net/batman-adv/distributed-arp-table.h b/net/batman-adv/distributed-arp-table.h
index fdb3522ad516..d060c033e7de 100644
--- a/net/batman-adv/distributed-arp-table.h
+++ b/net/batman-adv/distributed-arp-table.h
@@ -74,6 +74,28 @@ int batadv_dat_init(struct batadv_priv *bat_priv);
74void batadv_dat_free(struct batadv_priv *bat_priv); 74void batadv_dat_free(struct batadv_priv *bat_priv);
75int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset); 75int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset);
76 76
77/**
78 * batadv_dat_inc_counter - increment the correct DAT packet counter
79 * @bat_priv: the bat priv with all the soft interface information
80 * @subtype: the 4addr subtype of the packet to be counted
81 *
82 * Updates the ethtool statistics for the received packet if it is a DAT subtype
83 */
84static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
85 uint8_t subtype)
86{
87 switch (subtype) {
88 case BATADV_P_DAT_DHT_GET:
89 batadv_inc_counter(bat_priv,
90 BATADV_CNT_DAT_GET_RX);
91 break;
92 case BATADV_P_DAT_DHT_PUT:
93 batadv_inc_counter(bat_priv,
94 BATADV_CNT_DAT_PUT_RX);
95 break;
96 }
97}
98
77#else 99#else
78 100
79static inline bool 101static inline bool
@@ -135,6 +157,11 @@ static inline void batadv_dat_free(struct batadv_priv *bat_priv)
135{ 157{
136} 158}
137 159
160static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
161 uint8_t subtype)
162{
163}
164
138#endif /* CONFIG_BATMAN_ADV_DAT */ 165#endif /* CONFIG_BATMAN_ADV_DAT */
139 166
140#endif /* _NET_BATMAN_ADV_ARP_H_ */ 167#endif /* _NET_BATMAN_ADV_ARP_H_ */
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 1826699314b7..3f21c0905dde 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -985,15 +985,17 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
985{ 985{
986 struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); 986 struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
987 struct batadv_unicast_packet *unicast_packet; 987 struct batadv_unicast_packet *unicast_packet;
988 struct batadv_unicast_4addr_packet *unicast_4addr_packet;
988 int hdr_size = sizeof(*unicast_packet); 989 int hdr_size = sizeof(*unicast_packet);
989 bool is4addr; 990 bool is4addr;
990 991
991 unicast_packet = (struct batadv_unicast_packet *)skb->data; 992 unicast_packet = (struct batadv_unicast_packet *)skb->data;
993 unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
992 994
993 is4addr = unicast_packet->header.packet_type == BATADV_UNICAST_4ADDR; 995 is4addr = unicast_packet->header.packet_type == BATADV_UNICAST_4ADDR;
994 /* the caller function should have already pulled 2 bytes */ 996 /* the caller function should have already pulled 2 bytes */
995 if (is4addr) 997 if (is4addr)
996 hdr_size = sizeof(struct batadv_unicast_4addr_packet); 998 hdr_size = sizeof(*unicast_4addr_packet);
997 999
998 if (batadv_check_unicast_packet(skb, hdr_size) < 0) 1000 if (batadv_check_unicast_packet(skb, hdr_size) < 0)
999 return NET_RX_DROP; 1001 return NET_RX_DROP;
@@ -1003,6 +1005,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
1003 1005
1004 /* packet for me */ 1006 /* packet for me */
1005 if (batadv_is_my_mac(unicast_packet->dest)) { 1007 if (batadv_is_my_mac(unicast_packet->dest)) {
1008 if (is4addr)
1009 batadv_dat_inc_counter(bat_priv,
1010 unicast_4addr_packet->subtype);
1011
1006 if (batadv_dat_snoop_incoming_arp_request(bat_priv, skb, 1012 if (batadv_dat_snoop_incoming_arp_request(bat_priv, skb,
1007 hdr_size)) 1013 hdr_size))
1008 goto rx_success; 1014 goto rx_success;
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 7b4a3a3d9dd5..c283d87c4cce 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -625,6 +625,13 @@ static const struct {
625 { "tt_response_rx" }, 625 { "tt_response_rx" },
626 { "tt_roam_adv_tx" }, 626 { "tt_roam_adv_tx" },
627 { "tt_roam_adv_rx" }, 627 { "tt_roam_adv_rx" },
628#ifdef CONFIG_BATMAN_ADV_DAT
629 { "dat_get_tx" },
630 { "dat_get_rx" },
631 { "dat_put_tx" },
632 { "dat_put_rx" },
633 { "dat_cached_reply_tx" },
634#endif
628}; 635};
629 636
630static void batadv_get_strings(struct net_device *dev, uint32_t stringset, 637static void batadv_get_strings(struct net_device *dev, uint32_t stringset,
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 0afeb2b43f70..8ce16c1cbafb 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -186,6 +186,13 @@ enum batadv_counters {
186 BATADV_CNT_TT_RESPONSE_RX, 186 BATADV_CNT_TT_RESPONSE_RX,
187 BATADV_CNT_TT_ROAM_ADV_TX, 187 BATADV_CNT_TT_ROAM_ADV_TX,
188 BATADV_CNT_TT_ROAM_ADV_RX, 188 BATADV_CNT_TT_ROAM_ADV_RX,
189#ifdef CONFIG_BATMAN_ADV_DAT
190 BATADV_CNT_DAT_GET_TX,
191 BATADV_CNT_DAT_GET_RX,
192 BATADV_CNT_DAT_PUT_TX,
193 BATADV_CNT_DAT_PUT_RX,
194 BATADV_CNT_DAT_CACHED_REPLY_TX,
195#endif
189 BATADV_CNT_NUM, 196 BATADV_CNT_NUM,
190}; 197};
191 198