Skip to contentSkip to conversation

pull request for net-next: batman-adv 2016-07-04

PATCH In review Simon Wunderlich 4 participants 15 messages Jul 4, 2016 – Jul 5, 2016 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover pull request for net-next: batman-adv 2016-07-04

Hi David,

this is our second and final feature pull request for batman-adv in this round.

Please pull or let me know of any problem!

Thank you,
Simon

The following changes since commit 4e3e823b5a503235630921287f130e1d8d22d200:

batman-adv: Add debugfs table for mcast flags (2016-06-30 10:29:43 +0200)

are available in the git repository at:

git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20160704

for you to fetch changes up to 29824a55c07cd79a530d4bc1020a529c402515b6:

batman-adv: split routing API data structure in subobjects (2016-07-04 12:37:19 +0200)

----------------------------------------------------------------
This feature patchset includes the following changes:

- Cleanup work by Markus Pargmann and Sven Eckelmann (six patches)

- Initial Netlink support by Matthias Schiffer (two patches)

- Throughput Meter implementation by Antonio Quartulli, a kernel-space traffic generator to estimate link speeds. This feature is useful on low-end WiFi APs where running iperf or netperf from userspace gives wrong results due to heavy userspace/kernelspace overhead. (two patches)

- API clean-up work by Antonio Quartulli (one patch)

----------------------------------------------------------------
Antonio Quartulli (3):
batman-adv: return netdev status in the TX path
batman-adv: throughput meter implementation
batman-adv: split routing API data structure in subobjects

Markus Pargmann (1):
batman-adv: split tvlv into a separate file

Matthias Schiffer (2):
batman-adv: add generic netlink family for batman-adv
batman-adv: add netlink command to query generic mesh information files

Sven Eckelmann (5):
batman-adv: Include main.h in bat_v_ogm.h
batman-adv: Keep includes ordered by filename
batman-adv: move bat_algo functions into a separate file
batman-adv: Consolidate logging related functions
batman-adv: Fix bat_(iv|v) function declaration header

 MAINTAINERS                            |    1 +
 include/uapi/linux/batman_adv.h        |  114 +++
 net/batman-adv/Makefile                |    5 +
 net/batman-adv/bat_algo.c              |  140 +++
 net/batman-adv/bat_algo.h              |   35 +-
 net/batman-adv/bat_iv_ogm.c            |   40 +-
 net/batman-adv/bat_iv_ogm.h            |   25 +
 net/batman-adv/bat_v.c                 |   29 +-
 net/batman-adv/bat_v.h                 |   52 ++
 net/batman-adv/bat_v_elp.c             |    3 +-
 net/batman-adv/bat_v_elp.h             |    4 +-
 net/batman-adv/bat_v_ogm.c             |    5 +-
 net/batman-adv/bat_v_ogm.h             |    4 +-
 net/batman-adv/bitarray.c              |    2 +
 net/batman-adv/bridge_loop_avoidance.c |    1 +
 net/batman-adv/debugfs.c               |  217 +----
 net/batman-adv/distributed-arp-table.c |    2 +
 net/batman-adv/fragmentation.c         |   41 +-
 net/batman-adv/fragmentation.h         |    6 +-
 net/batman-adv/gateway_client.c        |    1 +
 net/batman-adv/gateway_common.c        |    4 +-
 net/batman-adv/hard-interface.c        |   21 +-
 net/batman-adv/icmp_socket.c           |    1 +
 net/batman-adv/log.c                   |  231 +++++
 net/batman-adv/log.h                   |  111 +++
 net/batman-adv/main.c                  |  707 +--------------
 net/batman-adv/main.h                  |  121 +--
 net/batman-adv/multicast.c             |    2 +
 net/batman-adv/netlink.c               |  424 +++++++++
 net/batman-adv/netlink.h               |   32 +
 net/batman-adv/network-coding.c        |    2 +
 net/batman-adv/originator.c            |   51 +-
 net/batman-adv/packet.h                |   54 ++
 net/batman-adv/routing.c               |   43 +-
 net/batman-adv/send.c                  |   39 +-
 net/batman-adv/soft-interface.c        |    3 +
 net/batman-adv/sysfs.c                 |    7 +-
 net/batman-adv/tp_meter.c              | 1507 ++++++++++++++++++++++++++++++++
 net/batman-adv/tp_meter.h              |   34 +
 net/batman-adv/translation-table.c     |    8 +-
 net/batman-adv/tvlv.c                  |  632 ++++++++++++++
 net/batman-adv/tvlv.h                  |   61 ++
 net/batman-adv/types.h                 |  226 ++++-
 43 files changed, 3831 insertions(+), 1217 deletions(-)
 create mode 100644 include/uapi/linux/batman_adv.h
 create mode 100644 net/batman-adv/bat_algo.c
 create mode 100644 net/batman-adv/bat_iv_ogm.h
 create mode 100644 net/batman-adv/bat_v.h
 create mode 100644 net/batman-adv/log.c
 create mode 100644 net/batman-adv/log.h
 create mode 100644 net/batman-adv/netlink.c
 create mode 100644 net/batman-adv/netlink.h
 create mode 100644 net/batman-adv/tp_meter.c
 create mode 100644 net/batman-adv/tp_meter.h
 create mode 100644 net/batman-adv/tvlv.c
 create mode 100644 net/batman-adv/tvlv.h
#2 lore raw

PATCH 1/11 batman-adv: Include main.h in bat_v_ogm.h

In reply to a message not in the archive

From: Sven Eckelmann <[email protected]>

main.h includes statements which (re)define preprocessor variables which influence the compiled code. This makes it necessary to include it in all files. For example, it redefines pr_fmt used to the module as prefix for each pr_* message.

---
 net/batman-adv/bat_v_ogm.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/batman-adv/bat_v_ogm.h +2 -2
index d849c75..4c4d45c 100644
@@ -18,10 +18,10 @@
 #ifndef _BATMAN_ADV_BATADV_V_OGM_H_
 #define _BATMAN_ADV_BATADV_V_OGM_H_
 
+#include "main.h"
+
 #include <linux/types.h>
 
-struct batadv_hard_iface;
-struct batadv_priv;
 struct sk_buff;
 
 int batadv_v_ogm_init(struct batadv_priv *bat_priv);
Signature · 1 line
2.8.1
maintainer
#5 lore raw

PATCH 2/11 batman-adv: Keep includes ordered by filename

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

It is easier to detect if a include is already there for a used functionality when the includes are ordered. Using an alphabetic order together with the grouping in commit 1e2c2a4fe4a5 ("batman-adv: Add required includes to all files") makes includes better manageable.

---
 net/batman-adv/bat_iv_ogm.c     | 2 +-
 net/batman-adv/bat_v_elp.h      | 4 ++--
 net/batman-adv/gateway_common.c | 2 +-
 net/batman-adv/hard-interface.c | 2 +-
 net/batman-adv/main.h           | 6 +++---
 net/batman-adv/send.c           | 2 +-
 net/batman-adv/sysfs.c          | 4 ++--
 7 files changed, 11 insertions(+), 11 deletions(-)
net/batman-adv/bat_iv_ogm.c +1 -1
index 4815db9..6dc89b0 100644
@@ -31,8 +31,8 @@
 #include <linux/init.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
-#include <linux/list.h>
 #include <linux/kref.h>
+#include <linux/list.h>
 #include <linux/lockdep.h>
 #include <linux/netdevice.h>
 #include <linux/pkt_sched.h>
net/batman-adv/bat_v_elp.h +2 -2
index cc130b2..be17c0b 100644
@@ -15,11 +15,11 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "main.h"
-
 #ifndef _NET_BATMAN_ADV_BAT_V_ELP_H_
 #define _NET_BATMAN_ADV_BAT_V_ELP_H_
 
+#include "main.h"
+
 struct sk_buff;
 struct work_struct;
 
net/batman-adv/gateway_common.c +1 -1
index 3c26945..7754435 100644
@@ -19,8 +19,8 @@
 #include "main.h"
 
 #include <linux/atomic.h>
-#include <linux/errno.h>
 #include <linux/byteorder/generic.h>
+#include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/math64.h>
 #include <linux/netdevice.h>
net/batman-adv/hard-interface.c +1 -1
index 3696929..a3483f6 100644
@@ -23,9 +23,9 @@
 #include <linux/byteorder/generic.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
+#include <linux/if.h>
 #include <linux/if_arp.h>
 #include <linux/if_ether.h>
-#include <linux/if.h>
 #include <linux/kernel.h>
 #include <linux/kref.h>
 #include <linux/list.h>
net/batman-adv/main.h +3 -3
index cd83e28..38f9e55 100644
@@ -181,12 +181,12 @@ enum batadv_uev_type {
 #include <linux/cpumask.h>
 #include <linux/etherdevice.h>
 #include <linux/if_ether.h> /* for packet.h */
+#include <linux/if_vlan.h>
+#include <linux/jiffies.h>
 #include <linux/netdevice.h>
+#include <linux/percpu.h>
 #include <linux/printk.h>
 #include <linux/types.h>
-#include <linux/percpu.h>
-#include <linux/jiffies.h>
-#include <linux/if_vlan.h>
 
 #include "types.h"
 
net/batman-adv/send.c +1 -1
index 59e695b..4e49454 100644
@@ -22,8 +22,8 @@
 #include <linux/byteorder/generic.h>
 #include <linux/etherdevice.h>
 #include <linux/fs.h>
-#include <linux/if_ether.h>
 #include <linux/if.h>
+#include <linux/if_ether.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/kref.h>
net/batman-adv/sysfs.c +2 -2
index 233abcf..6244a9a 100644
@@ -25,8 +25,8 @@
 #include <linux/fs.h>
 #include <linux/if.h>
 #include <linux/if_vlan.h>
-#include <linux/kref.h>
 #include <linux/kernel.h>
+#include <linux/kref.h>
 #include <linux/netdevice.h>
 #include <linux/printk.h>
 #include <linux/rculist.h>
@@ -38,10 +38,10 @@
 #include <linux/string.h>
 #include <linux/stringify.h>
 
+#include "bridge_loop_avoidance.h"
 #include "distributed-arp-table.h"
 #include "gateway_client.h"
 #include "gateway_common.h"
-#include "bridge_loop_avoidance.h"
 #include "hard-interface.h"
 #include "network-coding.h"
 #include "packet.h"
Signature · 1 line
2.8.1
#3 lore raw

PATCH 3/11 batman-adv: split tvlv into a separate file

In reply to a message not in the archive

From: Markus Pargmann <[email protected]>

The tvlv functionality in main.c is mostly unrelated to the rest of the content. It still takes up a large portion of this source file (~45%, 588 lines). Moving it to a separate file makes it better visible as a main component of the batman-adv implementation and hides it less in the other helper functions in main.c

[[email protected]: fix conflicts with current version, fix includes, rewrote commit message]

---
 net/batman-adv/Makefile                |   1 +
 net/batman-adv/bat_iv_ogm.c            |   1 +
 net/batman-adv/bat_v_ogm.c             |   1 +
 net/batman-adv/distributed-arp-table.c |   1 +
 net/batman-adv/gateway_common.c        |   1 +
 net/batman-adv/main.c                  | 591 -------------------------------
 net/batman-adv/main.h                  |  34 --
 net/batman-adv/multicast.c             |   1 +
 net/batman-adv/network-coding.c        |   1 +
 net/batman-adv/routing.c               |   1 +
 net/batman-adv/translation-table.c     |   1 +
 net/batman-adv/tvlv.c                  | 630 +++++++++++++++++++++++++++++++++
 net/batman-adv/tvlv.h                  |  61 ++++
 13 files changed, 700 insertions(+), 625 deletions(-)
 create mode 100644 net/batman-adv/tvlv.c
 create mode 100644 net/batman-adv/tvlv.h
net/batman-adv/Makefile +1 -0
index 797cf2f..5c6ece0 100644
@@ -40,3 +40,4 @@ batman-adv-y += send.o
 batman-adv-y += soft-interface.o
 batman-adv-y += sysfs.o
 batman-adv-y += translation-table.o
+batman-adv-y += tvlv.o
net/batman-adv/bat_iv_ogm.c +1 -0
index 6dc89b0..948a5b4 100644
@@ -58,6 +58,7 @@
 #include "routing.h"
 #include "send.h"
 #include "translation-table.h"
+#include "tvlv.h"
 
 static void batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work);
 
net/batman-adv/bat_v_ogm.c +1 -0
index 23ea9bf..ca5a679 100644
@@ -46,6 +46,7 @@
 #include "routing.h"
 #include "send.h"
 #include "translation-table.h"
+#include "tvlv.h"
 
 /**
  * batadv_v_ogm_orig_get - retrieve and possibly create an originator node
net/batman-adv/distributed-arp-table.c +1 -0
index 278800a..584b827 100644
@@ -48,6 +48,7 @@
 #include "originator.h"
 #include "send.h"
 #include "translation-table.h"
+#include "tvlv.h"
 
 static void batadv_dat_purge(struct work_struct *work);
 
net/batman-adv/gateway_common.c +1 -0
index 7754435..6a6f2d4 100644
@@ -29,6 +29,7 @@
 
 #include "gateway_client.h"
 #include "packet.h"
+#include "tvlv.h"
 
 /**
  * batadv_parse_throughput - parse supplied string buffer to extract throughput
net/batman-adv/main.c +0 -591

610 lines not on this page · raw message

net/batman-adv/main.h +0 -34
index 38f9e55..3af6582 100644
@@ -190,7 +190,6 @@ enum batadv_uev_type {
 
 #include "types.h"
 
-struct batadv_ogm_packet;
 struct seq_file;
 struct sk_buff;
 
@@ -372,39 +371,6 @@ static inline u64 batadv_sum_counter(struct batadv_priv *bat_priv,  size_t idx)
  */
 #define BATADV_SKB_CB(__skb)       ((struct batadv_skb_cb *)&((__skb)->cb[0]))
 
-void batadv_tvlv_container_register(struct batadv_priv *bat_priv,
-				    u8 type, u8 version,
-				    void *tvlv_value, u16 tvlv_value_len);
-u16 batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv,
-				     unsigned char **packet_buff,
-				     int *packet_buff_len, int packet_min_len);
-void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv,
-			     struct batadv_ogm_packet *batadv_ogm_packet,
-			     struct batadv_orig_node *orig_node);
-void batadv_tvlv_container_unregister(struct batadv_priv *bat_priv,
-				      u8 type, u8 version);
-
-void batadv_tvlv_handler_register(struct batadv_priv *bat_priv,
-				  void (*optr)(struct batadv_priv *bat_priv,
-					       struct batadv_orig_node *orig,
-					       u8 flags,
-					       void *tvlv_value,
-					       u16 tvlv_value_len),
-				  int (*uptr)(struct batadv_priv *bat_priv,
-					      u8 *src, u8 *dst,
-					      void *tvlv_value,
-					      u16 tvlv_value_len),
-				  u8 type, u8 version, u8 flags);
-void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv,
-				    u8 type, u8 version);
-int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
-				   bool ogm_source,
-				   struct batadv_orig_node *orig_node,
-				   u8 *src, u8 *dst,
-				   void *tvlv_buff, u16 tvlv_buff_len);
-void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
-			      u8 *dst, u8 type, u8 version,
-			      void *tvlv_value, u16 tvlv_value_len);
 unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len);
 bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid);
 
net/batman-adv/multicast.c +1 -0
index d3222db..0e7d78f 100644
@@ -57,6 +57,7 @@
 #include "hash.h"
 #include "packet.h"
 #include "translation-table.h"
+#include "tvlv.h"
 
 /**
  * batadv_mcast_get_bridge - get the bridge on top of the softif if it exists
net/batman-adv/network-coding.c +1 -0
index 678f068..d0383de 100644
@@ -55,6 +55,7 @@
 #include "packet.h"
 #include "routing.h"
 #include "send.h"
+#include "tvlv.h"
 
 static struct lock_class_key batadv_nc_coding_hash_lock_class_key;
 static struct lock_class_key batadv_nc_decoding_hash_lock_class_key;
net/batman-adv/routing.c +1 -0
index 24fc753..8cb459a 100644
@@ -46,6 +46,7 @@
 #include "send.h"
 #include "soft-interface.h"
 #include "translation-table.h"
+#include "tvlv.h"
 
 static int batadv_route_unicast_packet(struct sk_buff *skb,
 				       struct batadv_hard_iface *recv_if);
net/batman-adv/translation-table.c +1 -0
index 87bb203..6c8d624 100644
@@ -51,6 +51,7 @@
 #include "originator.h"
 #include "packet.h"
 #include "soft-interface.h"
+#include "tvlv.h"
 
 /* hash class keys */
 static struct lock_class_key batadv_tt_local_hash_lock_class_key;
net/batman-adv/tvlv.c new file +630 -0

630 lines not on this page · raw message

net/batman-adv/tvlv.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.8.1
maintainer
#6 lore raw

PATCH 4/11 batman-adv: move bat_algo functions into a separate file

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The bat_algo functionality in main.c is mostly unrelated to the rest of the content. It still takes up a large portion of this source file (~15%, 103 lines). Moving it to a separate file makes it better visible as a main component of the batman-adv implementation and hides it less in the other helper functions in main.c.

---
 net/batman-adv/Makefile            |   1 +
 net/batman-adv/bat_algo.c          | 140 +++++++++++++++++++++++++++++++++++++
 net/batman-adv/bat_algo.h          |  12 ++++
 net/batman-adv/bat_v_ogm.c         |   1 +
 net/batman-adv/debugfs.c           |   1 +
 net/batman-adv/main.c              | 105 +---------------------------
 net/batman-adv/main.h              |   4 --
 net/batman-adv/originator.c        |   1 +
 net/batman-adv/routing.c           |   1 +
 net/batman-adv/soft-interface.c    |   1 +
 net/batman-adv/translation-table.c |   1 +
 11 files changed, 160 insertions(+), 108 deletions(-)
 create mode 100644 net/batman-adv/bat_algo.c
net/batman-adv/Makefile +1 -0
index 5c6ece0..5260c17 100644
@@ -17,6 +17,7 @@
 #
 
 obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
+batman-adv-y += bat_algo.o
 batman-adv-y += bat_iv_ogm.o
 batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v.o
 batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_elp.o
net/batman-adv/bat_algo.c new file +140 -0

140 lines not on this page · raw message

net/batman-adv/bat_algo.h +12 -0
index 3654296..8c7e761 100644
@@ -20,8 +20,20 @@
 
 #include "main.h"
 
+#include <linux/types.h>
+
+struct seq_file;
+
 int batadv_iv_init(void);
 
+extern char batadv_routing_algo[];
+extern struct list_head batadv_hardif_list;
+
+void batadv_algo_init(void);
+int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops);
+int batadv_algo_select(struct batadv_priv *bat_priv, char *name);
+int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
+
 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
 
 int batadv_v_init(void);
net/batman-adv/bat_v_ogm.c +1 -0
index ca5a679..93e3d76 100644
@@ -39,6 +39,7 @@
 #include <linux/types.h>
 #include <linux/workqueue.h>
 
+#include "bat_algo.h"
 #include "hard-interface.h"
 #include "hash.h"
 #include "originator.h"
net/batman-adv/debugfs.c +1 -0
index f187a8f..227c84b 100644
@@ -44,6 +44,7 @@
 #include <linux/wait.h>
 #include <stdarg.h>
 
+#include "bat_algo.h"
 #include "bridge_loop_avoidance.h"
 #include "distributed-arp-table.h"
 #include "gateway_client.h"
net/batman-adv/main.c +1 -104

135 lines not on this page · raw message

net/batman-adv/main.h +0 -4
index 3af6582..3ec6285 100644
@@ -196,7 +196,6 @@ struct sk_buff;
 #define BATADV_PRINT_VID(vid) ((vid & BATADV_VLAN_HAS_TAG) ? \
 			       (int)(vid & VLAN_VID_MASK) : -1)
 
-extern char batadv_routing_algo[];
 extern struct list_head batadv_hardif_list;
 
 extern unsigned char batadv_broadcast_addr[];
@@ -217,9 +216,6 @@ batadv_recv_handler_register(u8 packet_type,
 			     int (*recv_handler)(struct sk_buff *,
 						 struct batadv_hard_iface *));
 void batadv_recv_handler_unregister(u8 packet_type);
-int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops);
-int batadv_algo_select(struct batadv_priv *bat_priv, char *name);
-int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
 __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr);
 
 /**
net/batman-adv/originator.c +1 -0
index 076d258..592cbda 100644
@@ -34,6 +34,7 @@
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 
+#include "bat_algo.h"
 #include "distributed-arp-table.h"
 #include "fragmentation.h"
 #include "gateway_client.h"
net/batman-adv/routing.c +1 -0
index 8cb459a..b9c7325 100644
@@ -34,6 +34,7 @@
 #include <linux/spinlock.h>
 #include <linux/stddef.h>
 
+#include "bat_algo.h"
 #include "bitarray.h"
 #include "bridge_loop_avoidance.h"
 #include "distributed-arp-table.h"
net/batman-adv/soft-interface.c +1 -0
index b60999d..f75631e 100644
@@ -48,6 +48,7 @@
 #include <linux/types.h>
 #include <linux/workqueue.h>
 
+#include "bat_algo.h"
 #include "bridge_loop_avoidance.h"
 #include "debugfs.h"
 #include "distributed-arp-table.h"
net/batman-adv/translation-table.c +1 -0
index 6c8d624..5c3cf7f 100644
@@ -44,6 +44,7 @@
 #include <linux/string.h>
 #include <linux/workqueue.h>
 
+#include "bat_algo.h"
 #include "bridge_loop_avoidance.h"
 #include "hard-interface.h"
 #include "hash.h"
Signature · 1 line
2.8.1
#4 lore raw

PATCH 5/11 batman-adv: Consolidate logging related functions

In reply to a message not in the archive

From: Sven Eckelmann <[email protected]>

There are several places in batman-adv which provide logging related functions. These should be grouped together in the log.* files to make them easier to find.

---
 net/batman-adv/Makefile                |   1 +
 net/batman-adv/bat_iv_ogm.c            |   1 +
 net/batman-adv/bat_v_elp.c             |   1 +
 net/batman-adv/bat_v_ogm.c             |   1 +
 net/batman-adv/bitarray.c              |   2 +
 net/batman-adv/bridge_loop_avoidance.c |   1 +
 net/batman-adv/debugfs.c               | 216 +-----------------------------
 net/batman-adv/distributed-arp-table.c |   1 +
 net/batman-adv/gateway_client.c        |   1 +
 net/batman-adv/gateway_common.c        |   1 +
 net/batman-adv/hard-interface.c        |   1 +
 net/batman-adv/icmp_socket.c           |   1 +
 net/batman-adv/log.c                   | 231 +++++++++++++++++++++++++++++++++
 net/batman-adv/log.h                   | 109 ++++++++++++++++
 net/batman-adv/main.c                  |   2 +
 net/batman-adv/main.h                  |  69 +---------
 net/batman-adv/multicast.c             |   1 +
 net/batman-adv/network-coding.c        |   1 +
 net/batman-adv/originator.c            |   1 +
 net/batman-adv/routing.c               |   1 +
 net/batman-adv/send.c                  |   1 +
 net/batman-adv/sysfs.c                 |   1 +
 net/batman-adv/translation-table.c     |   1 +
 23 files changed, 364 insertions(+), 282 deletions(-)
 create mode 100644 net/batman-adv/log.c
 create mode 100644 net/batman-adv/log.h
net/batman-adv/Makefile +1 -0
index 5260c17..a55f4ec 100644
@@ -32,6 +32,7 @@ batman-adv-y += gateway_common.o
 batman-adv-y += hard-interface.o
 batman-adv-y += hash.o
 batman-adv-y += icmp_socket.o
+batman-adv-$(CONFIG_BATMAN_ADV_DEBUG) += log.o
 batman-adv-y += main.o
 batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.o
 batman-adv-$(CONFIG_BATMAN_ADV_NC) += network-coding.o
net/batman-adv/bat_iv_ogm.c +1 -0
index 948a5b4..805532a 100644
@@ -52,6 +52,7 @@
 #include "bitarray.h"
 #include "hard-interface.h"
 #include "hash.h"
+#include "log.h"
 #include "network-coding.h"
 #include "originator.h"
 #include "packet.h"
net/batman-adv/bat_v_elp.c +1 -0
index cf0262b..15cf272 100644
@@ -43,6 +43,7 @@
 #include "bat_algo.h"
 #include "bat_v_ogm.h"
 #include "hard-interface.h"
+#include "log.h"
 #include "originator.h"
 #include "packet.h"
 #include "routing.h"
net/batman-adv/bat_v_ogm.c +1 -0
index 93e3d76..7ac9e0b 100644
@@ -42,6 +42,7 @@
 #include "bat_algo.h"
 #include "hard-interface.h"
 #include "hash.h"
+#include "log.h"
 #include "originator.h"
 #include "packet.h"
 #include "routing.h"
net/batman-adv/bitarray.c +2 -0
index a0c7913..0322714 100644
@@ -20,6 +20,8 @@
 
 #include <linux/bitmap.h>
 
+#include "log.h"
+
 /* shift the packet array by n places. */
 static void batadv_bitmap_shift_left(unsigned long *seq_bits, s32 n)
 {
net/batman-adv/bridge_loop_avoidance.c +1 -0
index 748a9ea..e4f7494 100644
@@ -48,6 +48,7 @@
 
 #include "hard-interface.h"
 #include "hash.h"
+#include "log.h"
 #include "originator.h"
 #include "packet.h"
 #include "sysfs.h"
net/batman-adv/debugfs.c +1 -215

247 lines not on this page · raw message

net/batman-adv/distributed-arp-table.c +1 -0
index 584b827..fa76465 100644
@@ -45,6 +45,7 @@
 
 #include "hard-interface.h"
 #include "hash.h"
+#include "log.h"
 #include "originator.h"
 #include "send.h"
 #include "translation-table.h"
net/batman-adv/gateway_client.c +1 -0
index 18c3715..63a805d 100644
@@ -42,6 +42,7 @@
 
 #include "gateway_common.h"
 #include "hard-interface.h"
+#include "log.h"
 #include "originator.h"
 #include "packet.h"
 #include "routing.h"
net/batman-adv/gateway_common.c +1 -0
index 6a6f2d4..d7bc6a8 100644
@@ -28,6 +28,7 @@
 #include <linux/string.h>
 
 #include "gateway_client.h"
+#include "log.h"
 #include "packet.h"
 #include "tvlv.h"
 
net/batman-adv/hard-interface.c +1 -0
index a3483f6..ad2c37c 100644
@@ -42,6 +42,7 @@
 #include "debugfs.h"
 #include "distributed-arp-table.h"
 #include "gateway_client.h"
+#include "log.h"
 #include "originator.h"
 #include "packet.h"
 #include "send.h"
net/batman-adv/icmp_socket.c +1 -0
index 777aea1..378cc11 100644
@@ -45,6 +45,7 @@
 #include <linux/wait.h>
 
 #include "hard-interface.h"
+#include "log.h"
 #include "originator.h"
 #include "packet.h"
 #include "send.h"
net/batman-adv/log.c new file +231 -0

231 lines not on this page · raw message

net/batman-adv/log.h new file +109 -0

109 lines not on this page · raw message

net/batman-adv/main.c +2 -0
index c5a7cab..05e559c 100644
@@ -33,6 +33,7 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
+#include <linux/printk.h>
 #include <linux/rculist.h>
 #include <linux/rcupdate.h>
 #include <linux/seq_file.h>
@@ -52,6 +53,7 @@
 #include "gateway_common.h"
 #include "hard-interface.h"
 #include "icmp_socket.h"
+#include "log.h"
 #include "multicast.h"
 #include "network-coding.h"
 #include "originator.h"
net/batman-adv/main.h +2 -67

92 lines not on this page · raw message

net/batman-adv/multicast.c +1 -0
index 0e7d78f..cc91507 100644
@@ -55,6 +55,7 @@
 
 #include "hard-interface.h"
 #include "hash.h"
+#include "log.h"
 #include "packet.h"
 #include "translation-table.h"
 #include "tvlv.h"
net/batman-adv/network-coding.c +1 -0
index d0383de..293ef4f 100644
@@ -51,6 +51,7 @@
 
 #include "hard-interface.h"
 #include "hash.h"
+#include "log.h"
 #include "originator.h"
 #include "packet.h"
 #include "routing.h"
net/batman-adv/originator.c +1 -0
index 592cbda..8ad17ad 100644
@@ -40,6 +40,7 @@
 #include "gateway_client.h"
 #include "hard-interface.h"
 #include "hash.h"
+#include "log.h"
 #include "multicast.h"
 #include "network-coding.h"
 #include "routing.h"
net/batman-adv/routing.c +1 -0
index b9c7325..a5b53a3 100644
@@ -41,6 +41,7 @@
 #include "fragmentation.h"
 #include "hard-interface.h"
 #include "icmp_socket.h"
+#include "log.h"
 #include "network-coding.h"
 #include "originator.h"
 #include "packet.h"
net/batman-adv/send.c +1 -0
index 4e49454..3a59df2 100644
@@ -42,6 +42,7 @@
 #include "fragmentation.h"
 #include "gateway_client.h"
 #include "hard-interface.h"
+#include "log.h"
 #include "network-coding.h"
 #include "originator.h"
 #include "routing.h"
net/batman-adv/sysfs.c +1 -0
index 6244a9a..1a7942d 100644
@@ -43,6 +43,7 @@
 #include "gateway_client.h"
 #include "gateway_common.h"
 #include "hard-interface.h"
+#include "log.h"
 #include "network-coding.h"
 #include "packet.h"
 #include "soft-interface.h"
net/batman-adv/translation-table.c +1 -0
index 5c3cf7f..53458d6 100644
@@ -48,6 +48,7 @@
 #include "bridge_loop_avoidance.h"
 #include "hard-interface.h"
 #include "hash.h"
+#include "log.h"
 #include "multicast.h"
 #include "originator.h"
 #include "packet.h"
Signature · 1 line
2.8.1
maintainer
#7 lore raw

PATCH 6/11 batman-adv: Fix bat_(iv|v) function declaration header

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The bat_algo.h had some functions declared which were not part of the bat_algo.c file. These are instead stored in bat_v.c and bat_iv_ogm.c. The declaration should therefore be also in bat_v.h and bat_iv_ogm,h to make them easier to find.

---
 net/batman-adv/bat_algo.h          | 31 -----------------------
 net/batman-adv/bat_iv_ogm.c        |  3 ++-
 net/batman-adv/bat_iv_ogm.h        | 25 ++++++++++++++++++
 net/batman-adv/bat_v.c             |  3 ++-
 net/batman-adv/bat_v.h             | 52 ++++++++++++++++++++++++++++++++++++++
 net/batman-adv/hard-interface.c    |  2 +-
 net/batman-adv/main.c              |  2 ++
 net/batman-adv/routing.c           |  1 -
 net/batman-adv/translation-table.c |  1 -
 9 files changed, 84 insertions(+), 36 deletions(-)
 create mode 100644 net/batman-adv/bat_iv_ogm.h
 create mode 100644 net/batman-adv/bat_v.h
net/batman-adv/bat_algo.h +0 -31
index 8c7e761..860d773 100644
@@ -24,8 +24,6 @@
 
 struct seq_file;
 
-int batadv_iv_init(void);
-
 extern char batadv_routing_algo[];
 extern struct list_head batadv_hardif_list;
 
@@ -34,33 +32,4 @@ int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops);
 int batadv_algo_select(struct batadv_priv *bat_priv, char *name);
 int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
 
-#ifdef CONFIG_BATMAN_ADV_BATMAN_V
-
-int batadv_v_init(void);
-void batadv_v_hardif_init(struct batadv_hard_iface *hardif);
-int batadv_v_mesh_init(struct batadv_priv *bat_priv);
-void batadv_v_mesh_free(struct batadv_priv *bat_priv);
-
-#else
-
-static inline int batadv_v_init(void)
-{
-	return 0;
-}
-
-static inline void batadv_v_hardif_init(struct batadv_hard_iface *hardif)
-{
-}
-
-static inline int batadv_v_mesh_init(struct batadv_priv *bat_priv)
-{
-	return 0;
-}
-
-static inline void batadv_v_mesh_free(struct batadv_priv *bat_priv)
-{
-}
-
-#endif /* CONFIG_BATMAN_ADV_BATMAN_V */
-
 #endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */
net/batman-adv/bat_iv_ogm.c +2 -1
index 805532a..e2d8848 100644
@@ -15,7 +15,7 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "bat_algo.h"
+#include "bat_iv_ogm.h"
 #include "main.h"
 
 #include <linux/atomic.h>
@@ -49,6 +49,7 @@
 #include <linux/types.h>
 #include <linux/workqueue.h>
 
+#include "bat_algo.h"
 #include "bitarray.h"
 #include "hard-interface.h"
 #include "hash.h"
net/batman-adv/bat_iv_ogm.h new file +25 -0
new file mode 100644
index 0000000..b9f3550
@@ -0,0 +1,25 @@
+/* Copyright (C) 2007-2016  B.A.T.M.A.N. contributors:
+ *
+ * Marek Lindner, Simon Wunderlich
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * 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 _BATMAN_ADV_BATADV_IV_OGM_H_
+#define _BATMAN_ADV_BATADV_IV_OGM_H_
+
+#include "main.h"
+
+int batadv_iv_init(void);
+
+#endif /* _BATMAN_ADV_BATADV_IV_OGM_H_ */
net/batman-adv/bat_v.c +2 -1
index c2fea81..7231440 100644
@@ -15,7 +15,7 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "bat_algo.h"
+#include "bat_v.h"
 #include "main.h"
 
 #include <linux/atomic.h>
@@ -31,6 +31,7 @@
 #include <linux/types.h>
 #include <linux/workqueue.h>
 
+#include "bat_algo.h"
 #include "bat_v_elp.h"
 #include "bat_v_ogm.h"
 #include "hard-interface.h"
net/batman-adv/bat_v.h new file +52 -0

52 lines not on this page · raw message

net/batman-adv/hard-interface.c +1 -1
index ad2c37c..70841c1 100644
@@ -37,7 +37,7 @@
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 
-#include "bat_algo.h"
+#include "bat_v.h"
 #include "bridge_loop_avoidance.h"
 #include "debugfs.h"
 #include "distributed-arp-table.h"
net/batman-adv/main.c +2 -0
index 05e559c..eab9d1b 100644
@@ -46,6 +46,8 @@
 #include <net/rtnetlink.h>
 
 #include "bat_algo.h"
+#include "bat_iv_ogm.h"
+#include "bat_v.h"
 #include "bridge_loop_avoidance.h"
 #include "debugfs.h"
 #include "distributed-arp-table.h"
net/batman-adv/routing.c +0 -1
index a5b53a3..5833ab3 100644
@@ -34,7 +34,6 @@
 #include <linux/spinlock.h>
 #include <linux/stddef.h>
 
-#include "bat_algo.h"
 #include "bitarray.h"
 #include "bridge_loop_avoidance.h"
 #include "distributed-arp-table.h"
net/batman-adv/translation-table.c +0 -1
index 53458d6..48ce788 100644
@@ -44,7 +44,6 @@
 #include <linux/string.h>
 #include <linux/workqueue.h>
 
-#include "bat_algo.h"
 #include "bridge_loop_avoidance.h"
 #include "hard-interface.h"
 #include "hash.h"
Signature · 1 line
2.8.1
maintainer
#8 lore raw

PATCH 7/11 batman-adv: add generic netlink family for batman-adv

In reply to Simon Wunderlich

From: Matthias Schiffer <[email protected]>

debugfs is currently severely broken virtually everywhere in the kernel where files are dynamically added and removed (see
http://lkml.iu.edu/hypermail/linux/kernel/1506.1/02196.html for some details). In addition to that, debugfs is not namespace-aware.

Instead of adding new debugfs entries, the whole infrastructure should be moved to netlink. This will fix the long standing problem of large buffers for debug tables and hard to parse text files.

[[email protected]: Strip down patch to only add genl family, add missing kerneldoc]

---
 MAINTAINERS                     |  1 +
 include/uapi/linux/batman_adv.h | 53 ++++++++++++++++++++++++++++++++++++++
 net/batman-adv/Makefile         |  1 +
 net/batman-adv/main.c           |  3 +++
 net/batman-adv/netlink.c        | 57 +++++++++++++++++++++++++++++++++++++++++
 net/batman-adv/netlink.h        | 26 +++++++++++++++++++
 6 files changed, 141 insertions(+)
 create mode 100644 include/uapi/linux/batman_adv.h
 create mode 100644 net/batman-adv/netlink.c
 create mode 100644 net/batman-adv/netlink.h
MAINTAINERS +1 -0
index 0e26025..e25091f 100644
@@ -2291,6 +2291,7 @@ S:	Maintained
 F:	Documentation/ABI/testing/sysfs-class-net-batman-adv
 F:	Documentation/ABI/testing/sysfs-class-net-mesh
 F:	Documentation/networking/batman-adv.txt
+F:	include/uapi/linux/batman_adv.h
 F:	net/batman-adv/
 
 BAYCOM/HDLCDRV DRIVERS FOR AX.25
include/uapi/linux/batman_adv.h new file +53 -0

53 lines not on this page · raw message

net/batman-adv/Makefile +1 -0
index a55f4ec..7da5901 100644
@@ -35,6 +35,7 @@ batman-adv-y += icmp_socket.o
 batman-adv-$(CONFIG_BATMAN_ADV_DEBUG) += log.o
 batman-adv-y += main.o
 batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.o
+batman-adv-y += netlink.o
 batman-adv-$(CONFIG_BATMAN_ADV_NC) += network-coding.o
 batman-adv-y += originator.o
 batman-adv-y += routing.o
net/batman-adv/main.c +3 -0
index eab9d1b..275604b 100644
@@ -57,6 +57,7 @@
 #include "icmp_socket.h"
 #include "log.h"
 #include "multicast.h"
+#include "netlink.h"
 #include "network-coding.h"
 #include "originator.h"
 #include "packet.h"
@@ -99,6 +100,7 @@ static int __init batadv_init(void)
 
 	register_netdevice_notifier(&batadv_hard_if_notifier);
 	rtnl_link_register(&batadv_link_ops);
+	batadv_netlink_register();
 
 	pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
 		BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION);
@@ -109,6 +111,7 @@ static int __init batadv_init(void)
 static void __exit batadv_exit(void)
 {
 	batadv_debugfs_destroy();
+	batadv_netlink_unregister();
 	rtnl_link_unregister(&batadv_link_ops);
 	unregister_netdevice_notifier(&batadv_hard_if_notifier);
 	batadv_hardif_remove_interfaces();
net/batman-adv/netlink.c new file +57 -0

57 lines not on this page · raw message

net/batman-adv/netlink.h new file +26 -0
new file mode 100644
index 0000000..39044cc
@@ -0,0 +1,26 @@
+/* Copyright (C) 2016 B.A.T.M.A.N. contributors:
+ *
+ * Matthias Schiffer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * 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_NETLINK_H_
+#define _NET_BATMAN_ADV_NETLINK_H_
+
+#include "main.h"
+
+void batadv_netlink_register(void);
+void batadv_netlink_unregister(void);
+
+#endif /* _NET_BATMAN_ADV_NETLINK_H_ */
Signature · 1 line
2.8.1
maintainer
#9 lore raw

PATCH 8/11 batman-adv: add netlink command to query generic mesh information files

In reply to Simon Wunderlich

From: Matthias Schiffer <[email protected]>

BATADV_CMD_GET_MESH_INFO is used to query basic information about a batman-adv softif (name, index and MAC address for both the softif and the primary hardif; routing algorithm; batman-adv version).

[[email protected]: Reduce the number of changes to BATADV_CMD_GET_MESH_INFO, add missing kerneldoc, add policy for attributes]

---
 include/uapi/linux/batman_adv.h |  18 ++++++
 net/batman-adv/netlink.c        | 137 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 155 insertions(+)
include/uapi/linux/batman_adv.h +18 -0
index 79f7972..c39623c7 100644
@@ -24,12 +24,28 @@
  * enum batadv_nl_attrs - batman-adv netlink attributes
  *
  * @BATADV_ATTR_UNSPEC: unspecified attribute to catch errors
+ * @BATADV_ATTR_VERSION: batman-adv version string
+ * @BATADV_ATTR_ALGO_NAME: name of routing algorithm
+ * @BATADV_ATTR_MESH_IFINDEX: index of the batman-adv interface
+ * @BATADV_ATTR_MESH_IFNAME: name of the batman-adv interface
+ * @BATADV_ATTR_MESH_ADDRESS: mac address of the batman-adv interface
+ * @BATADV_ATTR_HARD_IFINDEX: index of the non-batman-adv interface
+ * @BATADV_ATTR_HARD_IFNAME: name of the non-batman-adv interface
+ * @BATADV_ATTR_HARD_ADDRESS: mac address of the non-batman-adv interface
  * @__BATADV_ATTR_AFTER_LAST: internal use
  * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available
  * @BATADV_ATTR_MAX: highest attribute number currently defined
  */
 enum batadv_nl_attrs {
 	BATADV_ATTR_UNSPEC,
+	BATADV_ATTR_VERSION,
+	BATADV_ATTR_ALGO_NAME,
+	BATADV_ATTR_MESH_IFINDEX,
+	BATADV_ATTR_MESH_IFNAME,
+	BATADV_ATTR_MESH_ADDRESS,
+	BATADV_ATTR_HARD_IFINDEX,
+	BATADV_ATTR_HARD_IFNAME,
+	BATADV_ATTR_HARD_ADDRESS,
 	/* add attributes above here, update the policy in netlink.c */
 	__BATADV_ATTR_AFTER_LAST,
 	NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
@@ -40,11 +56,13 @@ enum batadv_nl_attrs {
  * enum batadv_nl_commands - supported batman-adv netlink commands
  *
  * @BATADV_CMD_UNSPEC: unspecified command to catch errors
+ * @BATADV_CMD_GET_MESH_INFO: Query basic information about batman-adv device
  * @__BATADV_CMD_AFTER_LAST: internal use
  * @BATADV_CMD_MAX: highest used command number
  */
 enum batadv_nl_commands {
 	BATADV_CMD_UNSPEC,
+	BATADV_CMD_GET_MESH_INFO,
 	/* add new commands above here */
 	__BATADV_CMD_AFTER_LAST,
 	BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST - 1
net/batman-adv/netlink.c +137 -0

156 lines not on this page · raw message

Signature · 1 line
2.8.1
maintainer
#10 lore raw

PATCH 9/11 batman-adv: return netdev status in the TX path

In reply to Simon Wunderlich

From: Antonio Quartulli <[email protected]>

Return the proper netdev TX status along the TX path so that the tp_meter can understand when the queue is full and should stop sending packets.

---
 net/batman-adv/fragmentation.c | 41 +++++++++++++++++++++++++----------------
 net/batman-adv/fragmentation.h |  6 +++---
 net/batman-adv/routing.c       | 25 ++++++++++++++-----------
 net/batman-adv/send.c          | 36 +++++++++++++++++++++++-------------
 net/batman-adv/tvlv.c          |  4 +++-
 5 files changed, 68 insertions(+), 44 deletions(-)
net/batman-adv/fragmentation.c +25 -16
index 9f41a0a..0934730 100644
@@ -433,11 +433,12 @@ err:
  * @orig_node: final destination of the created fragments
  * @neigh_node: next-hop of the created fragments
  *
- * Return: true on success, false otherwise.
+ * Return: the netdev tx status or -1 in case of error.
+ * When -1 is returned the skb is not consumed.
  */
-bool batadv_frag_send_packet(struct sk_buff *skb,
-			     struct batadv_orig_node *orig_node,
-			     struct batadv_neigh_node *neigh_node)
+int batadv_frag_send_packet(struct sk_buff *skb,
+			    struct batadv_orig_node *orig_node,
+			    struct batadv_neigh_node *neigh_node)
 {
 	struct batadv_priv *bat_priv;
 	struct batadv_hard_iface *primary_if = NULL;
@@ -446,7 +447,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
 	unsigned int mtu = neigh_node->if_incoming->net_dev->mtu;
 	unsigned int header_size = sizeof(frag_header);
 	unsigned int max_fragment_size, max_packet_size;
-	bool ret = false;
+	int ret = -1;
 
 	/* To avoid merge and refragmentation at next-hops we never send
 	 * fragments larger than BATADV_FRAG_MAX_FRAG_SIZE
@@ -457,12 +458,12 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
 
 	/* Don't even try to fragment, if we need more than 16 fragments */
 	if (skb->len > max_packet_size)
-		goto out_err;
+		goto out;
 
 	bat_priv = orig_node->bat_priv;
 	primary_if = batadv_primary_if_get_selected(bat_priv);
 	if (!primary_if)
-		goto out_err;
+		goto out;
 
 	/* Create one header to be copied to all fragments */
 	frag_header.packet_type = BATADV_UNICAST_FRAG;
@@ -488,23 +489,33 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
 	while (skb->len > max_fragment_size) {
 		skb_fragment = batadv_frag_create(skb, &frag_header, mtu);
 		if (!skb_fragment)
-			goto out_err;
+			goto out;
 
 		batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX);
 		batadv_add_counter(bat_priv, BATADV_CNT_FRAG_TX_BYTES,
 				   skb_fragment->len + ETH_HLEN);
-		batadv_send_unicast_skb(skb_fragment, neigh_node);
+		ret = batadv_send_unicast_skb(skb_fragment, neigh_node);
+		if (ret != NET_XMIT_SUCCESS) {
+			/* return -1 so that the caller can free the original
+			 * skb
+			 */
+			ret = -1;
+			goto out;
+		}
+
 		frag_header.no++;
 
 		/* The initial check in this function should cover this case */
-		if (frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1)
-			goto out_err;
+		if (frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1) {
+			ret = -1;
+			goto out;
+		}
 	}
 
 	/* Make room for the fragment header. */
 	if (batadv_skb_head_push(skb, header_size) < 0 ||
 	    pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 0)
-		goto out_err;
+		goto out;
 
 	memcpy(skb->data, &frag_header, header_size);
 
@@ -512,11 +523,9 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
 	batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX);
 	batadv_add_counter(bat_priv, BATADV_CNT_FRAG_TX_BYTES,
 			   skb->len + ETH_HLEN);
-	batadv_send_unicast_skb(skb, neigh_node);
+	ret = batadv_send_unicast_skb(skb, neigh_node);
 
-	ret = true;
-
-out_err:
+out:
 	if (primary_if)
 		batadv_hardif_put(primary_if);
 
net/batman-adv/fragmentation.h +3 -3
index 9ff77c7..3202fe3 100644
@@ -34,9 +34,9 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
 			 struct batadv_orig_node *orig_node_src);
 bool batadv_frag_skb_buffer(struct sk_buff **skb,
 			    struct batadv_orig_node *orig_node);
-bool batadv_frag_send_packet(struct sk_buff *skb,
-			     struct batadv_orig_node *orig_node,
-			     struct batadv_neigh_node *neigh_node);
+int batadv_frag_send_packet(struct sk_buff *skb,
+			    struct batadv_orig_node *orig_node,
+			    struct batadv_neigh_node *neigh_node);
 
 /**
  * batadv_frag_check_entry - check if a list of fragments has timed out
net/batman-adv/routing.c +14 -11
index 5833ab3..76de583 100644
@@ -270,8 +270,10 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
 		icmph->ttl = BATADV_TTL;
 
 		res = batadv_send_skb_to_orig(skb, orig_node, NULL);
-		if (res != NET_XMIT_DROP)
-			ret = NET_RX_SUCCESS;
+		if (res == -1)
+			goto out;
+
+		ret = NET_RX_SUCCESS;
 
 		break;
 	default:
@@ -292,7 +294,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
 	struct batadv_hard_iface *primary_if = NULL;
 	struct batadv_orig_node *orig_node = NULL;
 	struct batadv_icmp_packet *icmp_packet;
-	int ret = NET_RX_DROP;
+	int res, ret = NET_RX_DROP;
 
 	icmp_packet = (struct batadv_icmp_packet *)skb->data;
 
@@ -323,7 +325,8 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
 	icmp_packet->msg_type = BATADV_TTL_EXCEEDED;
 	icmp_packet->ttl = BATADV_TTL;
 
-	if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
+	res = batadv_send_skb_to_orig(skb, orig_node, NULL);
+	if (res != -1)
 		ret = NET_RX_SUCCESS;
 
 out:
@@ -343,7 +346,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
 	struct ethhdr *ethhdr;
 	struct batadv_orig_node *orig_node = NULL;
 	int hdr_size = sizeof(struct batadv_icmp_header);
-	int ret = NET_RX_DROP;
+	int res, ret = NET_RX_DROP;
 
 	/* drop packet if it has not necessary minimum size */
 	if (unlikely(!pskb_may_pull(skb, hdr_size)))
@@ -409,7 +412,8 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
 	icmph->ttl--;
 
 	/* route it */
-	if (batadv_send_skb_to_orig(skb, orig_node, recv_if) != NET_XMIT_DROP)
+	res = batadv_send_skb_to_orig(skb, orig_node, recv_if);
+	if (res != -1)
 		ret = NET_RX_SUCCESS;
 
 out:
@@ -646,6 +650,8 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
 
 	len = skb->len;
 	res = batadv_send_skb_to_orig(skb, orig_node, recv_if);
+	if (res == -1)
+		goto out;
 
 	/* translate transmit result into receive result */
 	if (res == NET_XMIT_SUCCESS) {
@@ -653,13 +659,10 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
 		batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
 		batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
 				   len + ETH_HLEN);
-
-		ret = NET_RX_SUCCESS;
-	} else if (res == -EINPROGRESS) {
-		/* skb was buffered and consumed */
-		ret = NET_RX_SUCCESS;
 	}
 
+	ret = NET_RX_SUCCESS;
+
 out:
 	if (orig_node)
 		batadv_orig_node_put(orig_node);
net/batman-adv/send.c +23 -13
index 3a59df2..3a10d87 100644
@@ -20,6 +20,7 @@
 
 #include <linux/atomic.h>
 #include <linux/byteorder/generic.h>
+#include <linux/errno.h>
 #include <linux/etherdevice.h>
 #include <linux/fs.h>
 #include <linux/if.h>
@@ -72,6 +73,7 @@ int batadv_send_skb_packet(struct sk_buff *skb,
 {
 	struct batadv_priv *bat_priv;
 	struct ethhdr *ethhdr;
+	int ret;
 
 	bat_priv = netdev_priv(hard_iface->soft_iface);
 
@@ -109,8 +111,15 @@ int batadv_send_skb_packet(struct sk_buff *skb,
 	/* dev_queue_xmit() returns a negative result on error.	 However on
 	 * congestion and traffic shaping, it drops and returns NET_XMIT_DROP
 	 * (which is > 0). This will not be treated as an error.
+	 *
+	 * a negative value cannot be returned because it could be interepreted
+	 * as not consumed skb by callers of batadv_send_skb_to_orig.
 	 */
-	return dev_queue_xmit(skb);
+	ret = dev_queue_xmit(skb);
+	if (ret < 0)
+		ret = NET_XMIT_DROP;
+
+	return ret;
 send_skb_err:
 	kfree_skb(skb);
 	return NET_XMIT_DROP;
@@ -156,8 +165,11 @@ int batadv_send_unicast_skb(struct sk_buff *skb,
  * host, NULL can be passed as recv_if and no interface alternating is
  * attempted.
  *
- * Return: NET_XMIT_SUCCESS on success, NET_XMIT_DROP on failure, or
- * -EINPROGRESS if the skb is buffered for later transmit.
+ * Return: -1 on failure (and the skb is not consumed), -EINPROGRESS if the
+ * skb is buffered for later transmit or the NET_XMIT status returned by the
+ * lower routine if the packet has been passed down.
+ *
+ * If the returning value is not -1 the skb has been consumed.
  */
 int batadv_send_skb_to_orig(struct sk_buff *skb,
 			    struct batadv_orig_node *orig_node,
@@ -165,7 +177,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb,
 {
 	struct batadv_priv *bat_priv = orig_node->bat_priv;
 	struct batadv_neigh_node *neigh_node;
-	int ret = NET_XMIT_DROP;
+	int ret = -1;
 
 	/* batadv_find_router() increases neigh_nodes refcount if found. */
 	neigh_node = batadv_find_router(bat_priv, orig_node, recv_if);
@@ -178,8 +190,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb,
 	if (atomic_read(&bat_priv->fragmentation) &&
 	    skb->len > neigh_node->if_incoming->net_dev->mtu) {
 		/* Fragment and send packet. */
-		if (batadv_frag_send_packet(skb, orig_node, neigh_node))
-			ret = NET_XMIT_SUCCESS;
+		ret = batadv_frag_send_packet(skb, orig_node, neigh_node);
 
 		goto out;
 	}
@@ -188,12 +199,10 @@ int batadv_send_skb_to_orig(struct sk_buff *skb,
 	 * (i.e. being forwarded). If the packet originates from this node or if
 	 * network coding fails, then send the packet as usual.
 	 */
-	if (recv_if && batadv_nc_skb_forward(skb, neigh_node)) {
+	if (recv_if && batadv_nc_skb_forward(skb, neigh_node))
 		ret = -EINPROGRESS;
-	} else {
-		batadv_send_unicast_skb(skb, neigh_node);
-		ret = NET_XMIT_SUCCESS;
-	}
+	else
+		ret = batadv_send_unicast_skb(skb, neigh_node);
 
 out:
 	if (neigh_node)
@@ -319,7 +328,7 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
 {
 	struct batadv_unicast_packet *unicast_packet;
 	struct ethhdr *ethhdr;
-	int ret = NET_XMIT_DROP;
+	int res, ret = NET_XMIT_DROP;
 
 	if (!orig_node)
 		goto out;
@@ -356,7 +365,8 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
 	if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest, vid))
 		unicast_packet->ttvn = unicast_packet->ttvn - 1;
 
-	if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
+	res = batadv_send_skb_to_orig(skb, orig_node, NULL);
+	if (res != -1)
 		ret = NET_XMIT_SUCCESS;
 
 out:
net/batman-adv/tvlv.c +3 -1
index 2fd542e..3d1cf0f 100644
@@ -591,6 +591,7 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
 	unsigned char *tvlv_buff;
 	unsigned int tvlv_len;
 	ssize_t hdr_len = sizeof(*unicast_tvlv_packet);
+	int res;
 
 	orig_node = batadv_orig_hash_find(bat_priv, dst);
 	if (!orig_node)
@@ -623,7 +624,8 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
 	tvlv_buff += sizeof(*tvlv_hdr);
 	memcpy(tvlv_buff, tvlv_value, tvlv_value_len);
 
-	if (batadv_send_skb_to_orig(skb, orig_node, NULL) == NET_XMIT_DROP)
+	res = batadv_send_skb_to_orig(skb, orig_node, NULL);
+	if (res == -1)
 		kfree_skb(skb);
 out:
 	batadv_orig_node_put(orig_node);
Signature · 1 line
2.8.1
maintainer
#11 lore raw

PATCH 10/11 batman-adv: throughput meter implementation

In reply to Simon Wunderlich

From: Antonio Quartulli <[email protected]>

The throughput meter module is a simple, kernel-space replacement for throughtput measurements tool like iperf and netperf. It is intended to approximate TCP behaviour.

It is invoked through batctl: the protocol is connection oriented, with cumulative acknowledgment and a dynamic-size sliding window.

The test *can* be interrupted by batctl. A receiver side timeout avoids unlimited waitings for sender packets: after one second of inactivity, the receiver abort the ongoing test.

Based on a prototype from Edo Monticelli <[email protected]>

---
 include/uapi/linux/batman_adv.h |   43 ++
 net/batman-adv/Makefile         |    1 +
 net/batman-adv/log.h            |   18 +-
 net/batman-adv/main.c           |    4 +
 net/batman-adv/main.h           |    8 +
 net/batman-adv/netlink.c        |  234 +++++-
 net/batman-adv/netlink.h        |    6 +
 net/batman-adv/packet.h         |   54 ++
 net/batman-adv/routing.c        |    8 +
 net/batman-adv/soft-interface.c |    2 +
 net/batman-adv/tp_meter.c       | 1507 +++++++++++++++++++++++++++++++++++++++
 net/batman-adv/tp_meter.h       |   34 +
 net/batman-adv/types.h          |  112 +++
 13 files changed, 2021 insertions(+), 10 deletions(-)
 create mode 100644 net/batman-adv/tp_meter.c
 create mode 100644 net/batman-adv/tp_meter.h
include/uapi/linux/batman_adv.h +43 -0
index c39623c7..0fbf6fd 100644
@@ -20,6 +20,8 @@
 
 #define BATADV_NL_NAME "batadv"
 
+#define BATADV_NL_MCAST_GROUP_TPMETER	"tpmeter"
+
 /**
  * enum batadv_nl_attrs - batman-adv netlink attributes
  *
@@ -32,6 +34,12 @@
  * @BATADV_ATTR_HARD_IFINDEX: index of the non-batman-adv interface
  * @BATADV_ATTR_HARD_IFNAME: name of the non-batman-adv interface
  * @BATADV_ATTR_HARD_ADDRESS: mac address of the non-batman-adv interface
+ * @BATADV_ATTR_ORIG_ADDRESS: originator mac address
+ * @BATADV_ATTR_TPMETER_RESULT: result of run (see batadv_tp_meter_status)
+ * @BATADV_ATTR_TPMETER_TEST_TIME: time (msec) the run took
+ * @BATADV_ATTR_TPMETER_BYTES: amount of acked bytes during run
+ * @BATADV_ATTR_TPMETER_COOKIE: session cookie to match tp_meter session
+ * @BATADV_ATTR_PAD: attribute used for padding for 64-bit alignment
  * @__BATADV_ATTR_AFTER_LAST: internal use
  * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available
  * @BATADV_ATTR_MAX: highest attribute number currently defined
@@ -46,6 +54,12 @@ enum batadv_nl_attrs {
 	BATADV_ATTR_HARD_IFINDEX,
 	BATADV_ATTR_HARD_IFNAME,
 	BATADV_ATTR_HARD_ADDRESS,
+	BATADV_ATTR_ORIG_ADDRESS,
+	BATADV_ATTR_TPMETER_RESULT,
+	BATADV_ATTR_TPMETER_TEST_TIME,
+	BATADV_ATTR_TPMETER_BYTES,
+	BATADV_ATTR_TPMETER_COOKIE,
+	BATADV_ATTR_PAD,
 	/* add attributes above here, update the policy in netlink.c */
 	__BATADV_ATTR_AFTER_LAST,
 	NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
@@ -57,15 +71,44 @@ enum batadv_nl_attrs {
  *
  * @BATADV_CMD_UNSPEC: unspecified command to catch errors
  * @BATADV_CMD_GET_MESH_INFO: Query basic information about batman-adv device
+ * @BATADV_CMD_TP_METER: Start a tp meter session
+ * @BATADV_CMD_TP_METER_CANCEL: Cancel a tp meter session
  * @__BATADV_CMD_AFTER_LAST: internal use
  * @BATADV_CMD_MAX: highest used command number
  */
 enum batadv_nl_commands {
 	BATADV_CMD_UNSPEC,
 	BATADV_CMD_GET_MESH_INFO,
+	BATADV_CMD_TP_METER,
+	BATADV_CMD_TP_METER_CANCEL,
 	/* add new commands above here */
 	__BATADV_CMD_AFTER_LAST,
 	BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST - 1
 };
 
+/**
+ * enum batadv_tp_meter_reason - reason of a tp meter test run stop
+ * @BATADV_TP_REASON_COMPLETE: sender finished tp run
+ * @BATADV_TP_REASON_CANCEL: sender was stopped during run
+ * @BATADV_TP_REASON_DST_UNREACHABLE: receiver could not be reached or didn't
+ *  answer
+ * @BATADV_TP_REASON_RESEND_LIMIT: (unused) sender retry reached limit
+ * @BATADV_TP_REASON_ALREADY_ONGOING: test to or from the same node already
+ *  ongoing
+ * @BATADV_TP_REASON_MEMORY_ERROR: test was stopped due to low memory
+ * @BATADV_TP_REASON_CANT_SEND: failed to send via outgoing interface
+ * @BATADV_TP_REASON_TOO_MANY: too many ongoing sessions
+ */
+enum batadv_tp_meter_reason {
+	BATADV_TP_REASON_COMPLETE		= 3,
+	BATADV_TP_REASON_CANCEL			= 4,
+	/* error status >= 128 */
+	BATADV_TP_REASON_DST_UNREACHABLE	= 128,
+	BATADV_TP_REASON_RESEND_LIMIT		= 129,
+	BATADV_TP_REASON_ALREADY_ONGOING	= 130,
+	BATADV_TP_REASON_MEMORY_ERROR		= 131,
+	BATADV_TP_REASON_CANT_SEND		= 132,
+	BATADV_TP_REASON_TOO_MANY		= 133,
+};
+
 #endif /* _UAPI_LINUX_BATMAN_ADV_H_ */
net/batman-adv/Makefile +1 -0
index 7da5901..a83fc6c 100644
@@ -42,5 +42,6 @@ batman-adv-y += routing.o
 batman-adv-y += send.o
 batman-adv-y += soft-interface.o
 batman-adv-y += sysfs.o
+batman-adv-y += tp_meter.o
 batman-adv-y += translation-table.o
 batman-adv-y += tvlv.o
net/batman-adv/log.h +10 -8
index 9948e56..e0e1a88 100644
@@ -51,17 +51,19 @@ static inline void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
  * @BATADV_DBG_DAT: ARP snooping and DAT related messages
  * @BATADV_DBG_NC: network coding related messages
  * @BATADV_DBG_MCAST: multicast related messages
+ * @BATADV_DBG_TP_METER: throughput meter messages
  * @BATADV_DBG_ALL: the union of all the above log levels
  */
 enum batadv_dbg_level {
-	BATADV_DBG_BATMAN = BIT(0),
-	BATADV_DBG_ROUTES = BIT(1),
-	BATADV_DBG_TT	  = BIT(2),
-	BATADV_DBG_BLA    = BIT(3),
-	BATADV_DBG_DAT    = BIT(4),
-	BATADV_DBG_NC	  = BIT(5),
-	BATADV_DBG_MCAST  = BIT(6),
-	BATADV_DBG_ALL    = 127,
+	BATADV_DBG_BATMAN	= BIT(0),
+	BATADV_DBG_ROUTES	= BIT(1),
+	BATADV_DBG_TT		= BIT(2),
+	BATADV_DBG_BLA		= BIT(3),
+	BATADV_DBG_DAT		= BIT(4),
+	BATADV_DBG_NC		= BIT(5),
+	BATADV_DBG_MCAST	= BIT(6),
+	BATADV_DBG_TP_METER	= BIT(7),
+	BATADV_DBG_ALL		= 127,
 };
 
 #ifdef CONFIG_BATMAN_ADV_DEBUG
net/batman-adv/main.c +4 -0
index 275604b..fe4c5e2 100644
@@ -64,6 +64,7 @@
 #include "routing.h"
 #include "send.h"
 #include "soft-interface.h"
+#include "tp_meter.h"
 #include "translation-table.h"
 
 /* List manipulations on hardif_list have to be rtnl_lock()'ed,
@@ -89,6 +90,7 @@ static int __init batadv_init(void)
 	batadv_v_init();
 	batadv_iv_init();
 	batadv_nc_init();
+	batadv_tp_meter_init();
 
 	batadv_event_workqueue = create_singlethread_workqueue("bat_events");
 
@@ -142,6 +144,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
 	spin_lock_init(&bat_priv->tvlv.container_list_lock);
 	spin_lock_init(&bat_priv->tvlv.handler_list_lock);
 	spin_lock_init(&bat_priv->softif_vlan_list_lock);
+	spin_lock_init(&bat_priv->tp_list_lock);
 
 	INIT_HLIST_HEAD(&bat_priv->forw_bat_list);
 	INIT_HLIST_HEAD(&bat_priv->forw_bcast_list);
@@ -160,6 +163,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
 	INIT_HLIST_HEAD(&bat_priv->tvlv.container_list);
 	INIT_HLIST_HEAD(&bat_priv->tvlv.handler_list);
 	INIT_HLIST_HEAD(&bat_priv->softif_vlan_list);
+	INIT_HLIST_HEAD(&bat_priv->tp_list);
 
 	ret = batadv_v_mesh_init(bat_priv);
 	if (ret < 0)
net/batman-adv/main.h +8 -0
index 857fb5a..06a8608 100644
@@ -100,6 +100,9 @@
 #define BATADV_NUM_BCASTS_WIRELESS 3
 #define BATADV_NUM_BCASTS_MAX 3
 
+/* length of the single packet used by the TP meter */
+#define BATADV_TP_PACKET_LEN ETH_DATA_LEN
+
 /* msecs after which an ARP_REQUEST is sent in broadcast as fallback */
 #define ARP_REQ_DELAY 250
 /* numbers of originator to contact for any PUT/GET DHT operation */
@@ -131,6 +134,11 @@
 
 #define BATADV_NC_NODE_TIMEOUT 10000 /* Milliseconds */
 
+/**
+ * BATADV_TP_MAX_NUM - maximum number of simultaneously active tp sessions
+ */
+#define BATADV_TP_MAX_NUM 5
+
 enum batadv_mesh_state {
 	BATADV_MESH_INACTIVE,
 	BATADV_MESH_ACTIVE,
net/batman-adv/netlink.c +232 -2

276 lines not on this page · raw message

net/batman-adv/netlink.h +6 -0
index 39044cc..945653a 100644
@@ -20,7 +20,13 @@
 
 #include "main.h"
 
+#include <linux/types.h>
+
 void batadv_netlink_register(void);
 void batadv_netlink_unregister(void);
 
+int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst,
+				  u8 result, u32 test_time, u64 total_bytes,
+				  u32 cookie);
+
 #endif /* _NET_BATMAN_ADV_NETLINK_H_ */
net/batman-adv/packet.h +54 -0

78 lines not on this page · raw message

net/batman-adv/routing.c +8 -0
index 76de583..7b5de40 100644
@@ -46,6 +46,7 @@
 #include "packet.h"
 #include "send.h"
 #include "soft-interface.h"
+#include "tp_meter.h"
 #include "translation-table.h"
 #include "tvlv.h"
 
@@ -276,6 +277,13 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
 		ret = NET_RX_SUCCESS;
 
 		break;
+	case BATADV_TP:
+		if (!pskb_may_pull(skb, sizeof(struct batadv_icmp_tp_packet)))
+			goto out;
+
+		batadv_tp_meter_recv(bat_priv, skb);
+		ret = NET_RX_SUCCESS;
+		goto out;
 	default:
 		/* drop unknown type */
 		goto out;
net/batman-adv/soft-interface.c +2 -0
index f75631e..18b6d07 100644
@@ -842,6 +842,8 @@ static int batadv_softif_init_late(struct net_device *dev)
 #ifdef CONFIG_BATMAN_ADV_BLA
 	atomic_set(&bat_priv->bla.num_requests, 0);
 #endif
+	atomic_set(&bat_priv->tp_num, 0);
+
 	bat_priv->tt.last_changeset = NULL;
 	bat_priv->tt.last_changeset_len = 0;
 	bat_priv->isolation_mark = 0;
net/batman-adv/tp_meter.c new file +1507 -0

1,507 lines not on this page · raw message

net/batman-adv/tp_meter.h new file +34 -0
new file mode 100644
index 0000000..ba922c4
@@ -0,0 +1,34 @@
+/* Copyright (C) 2012-2016 B.A.T.M.A.N. contributors:
+ *
+ * Edo Monticelli, Antonio Quartulli
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * 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_TP_METER_H_
+#define _NET_BATMAN_ADV_TP_METER_H_
+
+#include "main.h"
+
+#include <linux/types.h>
+
+struct sk_buff;
+
+void batadv_tp_meter_init(void);
+void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,
+		     u32 test_length, u32 *cookie);
+void batadv_tp_stop(struct batadv_priv *bat_priv, const u8 *dst,
+		    u8 return_value);
+void batadv_tp_meter_recv(struct batadv_priv *bat_priv, struct sk_buff *skb);
+
+#endif /* _NET_BATMAN_ADV_TP_METER_H_ */
net/batman-adv/types.h +112 -0

142 lines not on this page · raw message

Signature · 1 line
2.8.1
maintainer
#12 lore raw

PATCH 11/11 batman-adv: split routing API data structure in subobjects

In reply to Simon Wunderlich

From: Antonio Quartulli <[email protected]>

The routing API data structure contains several function pointers that can easily be grouped together based on the component they work with.

Split the API in subobjects in order to improve definition readability.

At the same time, remove the "bat_" prefix from the API object and its fields names. These are batman-adv private structs and there is no need to always prepend such prefix, which only makes function invocations much much longer.

---
 net/batman-adv/bat_algo.c          |  14 ++---
 net/batman-adv/bat_iv_ogm.c        |  33 ++++++-----
 net/batman-adv/bat_v.c             |  26 +++++----
 net/batman-adv/bat_v_elp.c         |   2 +-
 net/batman-adv/bat_v_ogm.c         |   2 +-
 net/batman-adv/hard-interface.c    |  16 +++---
 net/batman-adv/netlink.c           |   2 +-
 net/batman-adv/originator.c        |  49 ++++++++--------
 net/batman-adv/routing.c           |   8 +--
 net/batman-adv/sysfs.c             |   2 +-
 net/batman-adv/translation-table.c |   6 +-
 net/batman-adv/types.h             | 114 +++++++++++++++++++++----------------
 12 files changed, 150 insertions(+), 124 deletions(-)
net/batman-adv/bat_algo.c +7 -7
index 610d4de..81dbbf5 100644
@@ -65,12 +65,12 @@ int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
 	}
 
 	/* all algorithms must implement all ops (for now) */
-	if (!bat_algo_ops->bat_iface_enable ||
-	    !bat_algo_ops->bat_iface_disable ||
-	    !bat_algo_ops->bat_iface_update_mac ||
-	    !bat_algo_ops->bat_primary_iface_set ||
-	    !bat_algo_ops->bat_neigh_cmp ||
-	    !bat_algo_ops->bat_neigh_is_similar_or_better) {
+	if (!bat_algo_ops->iface.enable ||
+	    !bat_algo_ops->iface.disable ||
+	    !bat_algo_ops->iface.update_mac ||
+	    !bat_algo_ops->iface.primary_set ||
+	    !bat_algo_ops->neigh.cmp ||
+	    !bat_algo_ops->neigh.is_similar_or_better) {
 		pr_info("Routing algo '%s' does not implement required ops\n",
 			bat_algo_ops->name);
 		return -EINVAL;
@@ -90,7 +90,7 @@ int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
 	if (!bat_algo_ops)
 		return -EINVAL;
 
-	bat_priv->bat_algo_ops = bat_algo_ops;
+	bat_priv->algo_ops = bat_algo_ops;
 
 	return 0;
 }
net/batman-adv/bat_iv_ogm.c +19 -14
index e2d8848..19b0abd 100644
@@ -1853,8 +1853,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
 	/* 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 ?
 	 */
-	if (bat_priv->bat_algo_ops->bat_iface_enable !=
-	    batadv_iv_ogm_iface_enable)
+	if (bat_priv->algo_ops->iface.enable != batadv_iv_ogm_iface_enable)
 		return NET_RX_DROP;
 
 	batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX);
@@ -2120,18 +2119,24 @@ static void batadv_iv_iface_activate(struct batadv_hard_iface *hard_iface)
 
 static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
 	.name = "BATMAN_IV",
-	.bat_iface_activate = batadv_iv_iface_activate,
-	.bat_iface_enable = batadv_iv_ogm_iface_enable,
-	.bat_iface_disable = batadv_iv_ogm_iface_disable,
-	.bat_iface_update_mac = batadv_iv_ogm_iface_update_mac,
-	.bat_primary_iface_set = batadv_iv_ogm_primary_iface_set,
-	.bat_neigh_cmp = batadv_iv_ogm_neigh_cmp,
-	.bat_neigh_is_similar_or_better = batadv_iv_ogm_neigh_is_sob,
-	.bat_neigh_print = batadv_iv_neigh_print,
-	.bat_orig_print = batadv_iv_ogm_orig_print,
-	.bat_orig_free = batadv_iv_ogm_orig_free,
-	.bat_orig_add_if = batadv_iv_ogm_orig_add_if,
-	.bat_orig_del_if = batadv_iv_ogm_orig_del_if,
+	.iface = {
+		.activate = batadv_iv_iface_activate,
+		.enable = batadv_iv_ogm_iface_enable,
+		.disable = batadv_iv_ogm_iface_disable,
+		.update_mac = batadv_iv_ogm_iface_update_mac,
+		.primary_set = batadv_iv_ogm_primary_iface_set,
+	},
+	.neigh = {
+		.cmp = batadv_iv_ogm_neigh_cmp,
+		.is_similar_or_better = batadv_iv_ogm_neigh_is_sob,
+		.print = batadv_iv_neigh_print,
+	},
+	.orig = {
+		.print = batadv_iv_ogm_orig_print,
+		.free = batadv_iv_ogm_orig_free,
+		.add_if = batadv_iv_ogm_orig_add_if,
+		.del_if = batadv_iv_ogm_orig_del_if,
+	},
 };
 
 int __init batadv_iv_init(void)
net/batman-adv/bat_v.c +16 -10
index 7231440..0366cbf 100644
@@ -322,16 +322,22 @@ err_ifinfo1:
 
 static struct batadv_algo_ops batadv_batman_v __read_mostly = {
 	.name = "BATMAN_V",
-	.bat_iface_activate = batadv_v_iface_activate,
-	.bat_iface_enable = batadv_v_iface_enable,
-	.bat_iface_disable = batadv_v_iface_disable,
-	.bat_iface_update_mac = batadv_v_iface_update_mac,
-	.bat_primary_iface_set = batadv_v_primary_iface_set,
-	.bat_hardif_neigh_init = batadv_v_hardif_neigh_init,
-	.bat_orig_print = batadv_v_orig_print,
-	.bat_neigh_cmp = batadv_v_neigh_cmp,
-	.bat_neigh_is_similar_or_better = batadv_v_neigh_is_sob,
-	.bat_neigh_print = batadv_v_neigh_print,
+	.iface = {
+		.activate = batadv_v_iface_activate,
+		.enable = batadv_v_iface_enable,
+		.disable = batadv_v_iface_disable,
+		.update_mac = batadv_v_iface_update_mac,
+		.primary_set = batadv_v_primary_iface_set,
+	},
+	.neigh = {
+		.hardif_init = batadv_v_hardif_neigh_init,
+		.cmp = batadv_v_neigh_cmp,
+		.is_similar_or_better = batadv_v_neigh_is_sob,
+		.print = batadv_v_neigh_print,
+	},
+	.orig = {
+		.print = batadv_v_orig_print,
+	},
 };
 
 /**
net/batman-adv/bat_v_elp.c +1 -1
index 15cf272..7d17001 100644
@@ -504,7 +504,7 @@ int batadv_v_elp_packet_recv(struct sk_buff *skb,
 	/* did we receive a B.A.T.M.A.N. V ELP packet on an interface
 	 * that does not have B.A.T.M.A.N. V ELP enabled ?
 	 */
-	if (strcmp(bat_priv->bat_algo_ops->name, "BATMAN_V") != 0)
+	if (strcmp(bat_priv->algo_ops->name, "BATMAN_V") != 0)
 		return NET_RX_DROP;
 
 	elp_packet = (struct batadv_elp_packet *)skb->data;
net/batman-adv/bat_v_ogm.c +1 -1
index 7ac9e0b..6fbba4e 100644
@@ -754,7 +754,7 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb,
 	/* did we receive a OGM2 packet on an interface that does not have
 	 * B.A.T.M.A.N. V enabled ?
 	 */
-	if (strcmp(bat_priv->bat_algo_ops->name, "BATMAN_V") != 0)
+	if (strcmp(bat_priv->algo_ops->name, "BATMAN_V") != 0)
 		return NET_RX_DROP;
 
 	if (!batadv_check_management_packet(skb, if_incoming, BATADV_OGM2_HLEN))
net/batman-adv/hard-interface.c +8 -8
index 70841c1..1f90808 100644
@@ -247,7 +247,7 @@ static void batadv_primary_if_select(struct batadv_priv *bat_priv,
 	if (!new_hard_iface)
 		goto out;
 
-	bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface);
+	bat_priv->algo_ops->iface.primary_set(new_hard_iface);
 	batadv_primary_if_update_addr(bat_priv, curr_hard_iface);
 
 out:
@@ -394,7 +394,7 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
 
 	bat_priv = netdev_priv(hard_iface->soft_iface);
 
-	bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface);
+	bat_priv->algo_ops->iface.update_mac(hard_iface);
 	hard_iface->if_status = BATADV_IF_TO_BE_ACTIVATED;
 
 	/* the first active interface becomes our primary interface or
@@ -409,8 +409,8 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
 
 	batadv_update_min_mtu(hard_iface->soft_iface);
 
-	if (bat_priv->bat_algo_ops->bat_iface_activate)
-		bat_priv->bat_algo_ops->bat_iface_activate(hard_iface);
+	if (bat_priv->algo_ops->iface.activate)
+		bat_priv->algo_ops->iface.activate(hard_iface);
 
 out:
 	if (primary_if)
@@ -508,7 +508,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
 	if (ret)
 		goto err_dev;
 
-	ret = bat_priv->bat_algo_ops->bat_iface_enable(hard_iface);
+	ret = bat_priv->algo_ops->iface.enable(hard_iface);
 	if (ret < 0)
 		goto err_upper;
 
@@ -517,7 +517,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
 	hard_iface->if_status = BATADV_IF_INACTIVE;
 	ret = batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
 	if (ret < 0) {
-		bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
+		bat_priv->algo_ops->iface.disable(hard_iface);
 		bat_priv->num_ifaces--;
 		hard_iface->if_status = BATADV_IF_NOT_IN_USE;
 		goto err_upper;
@@ -598,7 +598,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
 			batadv_hardif_put(new_if);
 	}
 
-	bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
+	bat_priv->algo_ops->iface.disable(hard_iface);
 	hard_iface->if_status = BATADV_IF_NOT_IN_USE;
 
 	/* delete all references to this hard_iface */
@@ -783,7 +783,7 @@ static int batadv_hard_if_event(struct notifier_block *this,
 		batadv_check_known_mac_addr(hard_iface->net_dev);
 
 		bat_priv = netdev_priv(hard_iface->soft_iface);
-		bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface);
+		bat_priv->algo_ops->iface.update_mac(hard_iface);
 
 		primary_if = batadv_primary_if_get_selected(bat_priv);
 		if (!primary_if)
net/batman-adv/netlink.c +1 -1
index c25bbb8..231f8ea 100644
@@ -89,7 +89,7 @@ batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface)
 
 	if (nla_put_string(msg, BATADV_ATTR_VERSION, BATADV_SOURCE_VERSION) ||
 	    nla_put_string(msg, BATADV_ATTR_ALGO_NAME,
-			   bat_priv->bat_algo_ops->name) ||
+			   bat_priv->algo_ops->name) ||
 	    nla_put_u32(msg, BATADV_ATTR_MESH_IFINDEX, soft_iface->ifindex) ||
 	    nla_put_string(msg, BATADV_ATTR_MESH_IFNAME, soft_iface->name) ||
 	    nla_put(msg, BATADV_ATTR_MESH_ADDRESS, ETH_ALEN,
net/batman-adv/originator.c +23 -26

135 lines not on this page · raw message

net/batman-adv/routing.c +4 -4
index 7b5de40..0f8c0dd 100644
@@ -482,7 +482,7 @@ batadv_find_router(struct batadv_priv *bat_priv,
 		   struct batadv_orig_node *orig_node,
 		   struct batadv_hard_iface *recv_if)
 {
-	struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
+	struct batadv_algo_ops *bao = bat_priv->algo_ops;
 	struct batadv_neigh_node *first_candidate_router = NULL;
 	struct batadv_neigh_node *next_candidate_router = NULL;
 	struct batadv_neigh_node *router, *cand_router = NULL;
@@ -536,9 +536,9 @@ batadv_find_router(struct batadv_priv *bat_priv,
 		/* alternative candidate should be good enough to be
 		 * considered
 		 */
-		if (!bao->bat_neigh_is_similar_or_better(cand_router,
-							 cand->if_outgoing,
-							 router, recv_if))
+		if (!bao->neigh.is_similar_or_better(cand_router,
+						     cand->if_outgoing, router,
+						     recv_if))
 			goto next;
 
 		/* don't use the same router twice */
net/batman-adv/sysfs.c +1 -1
index 1a7942d..fe9ca94 100644
@@ -412,7 +412,7 @@ static ssize_t batadv_show_bat_algo(struct kobject *kobj,
 {
 	struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
 
-	return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name);
+	return sprintf(buff, "%s\n", bat_priv->algo_ops->name);
 }
 
 static void batadv_post_gw_reselect(struct net_device *net_dev)
net/batman-adv/translation-table.c +3 -3
index 48ce788..8bb82a3 100644
@@ -1546,7 +1546,7 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv,
 			    struct batadv_tt_global_entry *tt_global_entry)
 {
 	struct batadv_neigh_node *router, *best_router = NULL;
-	struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
+	struct batadv_algo_ops *bao = bat_priv->algo_ops;
 	struct hlist_head *head;
 	struct batadv_tt_orig_list_entry *orig_entry, *best_entry = NULL;
 
@@ -1558,8 +1558,8 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv,
 			continue;
 
 		if (best_router &&
-		    bao->bat_neigh_cmp(router, BATADV_IF_DEFAULT,
-				       best_router, BATADV_IF_DEFAULT) <= 0) {
+		    bao->neigh.cmp(router, BATADV_IF_DEFAULT, best_router,
+				   BATADV_IF_DEFAULT) <= 0) {
 			batadv_neigh_node_put(router);
 			continue;
 		}
net/batman-adv/types.h +66 -48

139 lines not on this page · raw message

Signature · 1 line
2.8.1
maintainer
#13 lore raw
In reply to Simon Wunderlich

From: Simon Wunderlich <[email protected]>
Date: Mon, 4 Jul 2016 15:02:48 +0200

Quoted 4 lines

this is our second and final feature pull request for batman-adv in this round.

Please pull or let me know of any problem!

Pulled, thanks.

I have no idea why you guys were using debugfs for anything that actually matters like configuration. :-/ debugfs should only be used for "debugging", such that if debugfs were not present the full functionality of the facility would still be present.

#15 lore raw
In reply to a message not in the archive

On Monday 04 July 2016 23:37:25 David Miller wrote:
[...]

Quoted 2 lines

I have no idea why you guys were using debugfs for anything that actually matters like configuration. :-/

It wasn't used for configuration. rtnl/sysfs is used for configuration.

Kind regards,
Sven

#16 lore raw
In reply to a message not in the archive

Hi David,

Quoted 6 lines · On Monday 04 July 2016 23:37:25 David Miller wrote:

From: Simon Wunderlich <[email protected]>
Date: Mon, 4 Jul 2016 15:02:48 +0200

Quoted 3 lines

this is our second and final feature pull request for batman-adv in this round.

Quoted 8 lines
Quoted 1 line

Please pull or let me know of any problem!

Pulled, thanks.

I have no idea why you guys were using debugfs for anything that actually matters like configuration. :-/ debugfs should only be used for "debugging", such that if debugfs were not present the full functionality of the facility would still be present.

as Sven pointed out, debugfs was not used for configuration (except for very deep tune parameters which are really for debugging anyway). We use sysfs (formerly) and now rtnl for configuration.

However, debugfs has quite some tables showing the current state of the mesh (read only) which are obviously interesting for many users as well. Therefore we want to change to a netlink based interface in the long run, similar to what the wireless stack and iw are doing. This will also enable new features like proper namespace support, which we are going to integrate soon.

Cheers,
Simon