batman-adv: throughput meter
Subsystems (2)
v11 cover batman-adv: throughput meter
Hi,
Antonio had some extra suggestions about the tpmeter. All are now included in the patchset. I have also noticed some problems with the patches (net.git/net-next.git) scheduled for 4.7 which required some adjustments to the netlink code.
batman-adv:
* moved batadv_tp_meter_init to batadv_init (main.c)
* fixed missing space in kerneldoc between "<" and "0"
* port to nla_put_u64_64bit
* add compat code for nla_put_u64_64bit
* introduce attribute BATADV_ATTR_PAD which is used for alignment
* rename batadv_real_genl_register_family back to genl_register_family in compat-include
batctl:
* introduce new attribute BATADV_ATTR_PAD used for u64 alignment
Kind regards,
Sven
PATCH v11 1/2 batman-adv: return netdev status in the TX path
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.
---
v11:
* no changes
v10:
* no changes
v9:
* rebase on top of current master+"batman-adv: Include main.h in all files"+ "batman-adv: Keep includes ordered by filename"
v8:
* rebase on top of current master
--- net/batman-adv/fragmentation.c | 41 +++++++++++++++++++++++++---------------- net/batman-adv/fragmentation.h | 6 +++--- net/batman-adv/main.c | 4 +++- net/batman-adv/routing.c | 23 ++++++++++++++--------- net/batman-adv/send.c | 25 +++++++++++++------------ 5 files changed, 58 insertions(+), 41 deletions(-)
net/batman-adv/fragmentation.c +25 -16
@@ -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
@@ -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/main.c +3 -1
@@ -1194,6 +1194,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)
@@ -1226,7 +1227,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 &&dev_xmit_complete (res)))kfree_skb (skb); out:batadv_orig_node_put (orig_node);
net/batman-adv/routing.c +14 -9
@@ -268,7 +268,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 ) +if (res ==-1 ) + goto out; + +if (dev_xmit_complete (res)) ret =NET_RX_SUCCESS ;break ;
@@ -290,7 +293,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;
@@ -321,7 +324,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 &&dev_xmit_complete (res)) ret =NET_RX_SUCCESS ; out:
@@ -341,7 +345,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)))
@@ -407,7 +411,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 &&dev_xmit_complete (res)) ret =NET_RX_SUCCESS ; out:
@@ -644,6 +649,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 ) {
@@ -651,12 +658,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 ); + } +if (dev_xmit_complete (res)) ret =NET_RX_SUCCESS ; - }else if (res ==NET_XMIT_POLICED ) { -/* skb was buffered and consumed */ - ret =NET_RX_SUCCESS ; - } out:if (orig_node)
net/batman-adv/send.c +13 -12
@@ -155,8 +155,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 -* NET_XMIT_POLICED if the skb is buffered for later transmit. +* Return: -1 on failure (and the skb is not consumed), NET_XMIT_POLICED 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,
@@ -164,7 +167,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);
@@ -177,8 +180,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; }
@@ -187,12 +189,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 =NET_XMIT_POLICED ; - }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)
@@ -318,7 +318,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;
@@ -355,7 +355,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 &&dev_xmit_complete (res)) ret =NET_XMIT_SUCCESS ; out:
Signature · 1 line
2.8.1
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH v11 1/2] batman-adv: return netdev status in the TX path
Quoted 17 lines · On Wednesday, May 18, 2016 11:38:48 Sven Eckelmann wrote:
From: Antonio Quartulli <[email protected]>
Return the proper netdev TX status along the TX path so that the
tp_metercan understand when the queue is full and should stop sending packets.Signed-off-by Antonio Quartulli <[email protected]>Signed-off-by Sven Eckelmann <[email protected]>---
v11:
* no changes
v10:
* no changes
v9:
* rebase on top of current master+"batman-adv: Includemain.hin all
files"+ "batman-adv: Keep includes ordered by filename" v8:
* rebase on top of current master
Quoted 8 lines
--- net/batman-adv/fragmentation.c | 41 +++++++++++++++++++++++++---------------- net/batman-adv/fragmentation.h | 6 +++--- net/batman-adv/main.c | 4 +++- net/batman-adv/routing.c | 23 ++++++++++++++--------- net/batman-adv/send.c | 25 +++++++++++++------------ 5 files changed, 58 insertions(+), 41 deletions(-)
Applied in revision 53b6614.
Thanks,
Marek
PATCH v11 2/2 batman-adv: throughput meter implementation
In reply to Sven EckelmannFrom: 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]>
---
v11:
* moved batadv_tp_meter_init to batadv_init (main.c)
* fixed missing space in kerneldoc between "<" and "0"
* port to nla_put_u64_64bit
* add compat code for nla_put_u64_64bit
* introduce attribute BATADV_ATTR_PAD which is used for alignment
* rename batadv_real_genl_register_family back to genl_register_family in compat-include
v10:
* no changes
v9:
* rebase on top of current master+"batman-adv: Include main.h in all files"+ "batman-adv: Keep includes ordered by filename"
* adjust BATADV_DBG_TP_METER to bit 7 to avoid conflicts with mcast
* Renamed BATADV_TP_SIGINT to BATADV_TP_REASON_CANCEL
* Renamed batadv_tp_meter_reason enumerals to BATADV_TP_REASON*
* Remove unrelated patch chunk in batadv_iv_ogm_orig_add_if
* Re-add accidentally removed empty line from batadv_recv_my_icmp_packet
* define BATADV_TP_PLEN via BATADV_TP_PACKET_LEN (increases it to 1476)
* fixed whitespace problems in compat code
* remove double "a" in kerneldoc for batadv_tp_meter_reason
v8:
* rebase on top of current master
v7:
* add compatibility code for v3.13
* make batadv_netlink_mcgrps non-const because v3.12 needs it writable
v6:
* increase total_bytes to 64 bit to allow higher speeds/longer test times
--- compat-include/linux/netlink.h | 113 +++ compat-include/net/genetlink.h | 127 +++- include/uapi/linux/batman_adv.h | 43 ++ net/batman-adv/Makefile | 1 + net/batman-adv/main.c | 4 + net/batman-adv/main.h | 26 +- 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 | 1503 +++++++++++++++++++++++++++++++++++++++ net/batman-adv/tp_meter.h | 34 + net/batman-adv/types.h | 112 +++ 14 files changed, 2255 insertions(+), 12 deletions(-) create mode 100644 compat-include/linux/netlink.h create mode 100644 net/batman-adv/tp_meter.c create mode 100644 net/batman-adv/tp_meter.h
compat-include/linux/netlink.h new file +113 -0
@@ -0,0 +1,113 @@ +/* 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/>. +* +* This file contains macros for maintaining compatibility with older versions +* of the Linux kernel. +*/ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_NETLINK_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_NETLINK_H_ + +#include <linux/version.h> +#include_next <linux/netlink.h> + +#if LINUX_VERSION_CODE <KERNEL_VERSION (4 ,7 ,0 ) + +#include_next <net/netlink.h> + +static inline bool batadv_nla_need_padding_for_64bit (struct sk_buff *skb); + +static inline int batadv_nla_align_64bit (struct sk_buff *skb,int padattr) +{ +if (batadv_nla_need_padding_for_64bit (skb) && + !nla_reserve (skb, padattr,0 )) +return -EMSGSIZE ; + +return 0 ; +} + +static inline struct nlattr *batadv__nla_reserve_64bit (struct sk_buff *skb, +int attrtype, +int attrlen,int padattr) +{ +if (batadv_nla_need_padding_for_64bit (skb)) +batadv_nla_align_64bit (skb, padattr); + +return __nla_reserve (skb, attrtype, attrlen); +} + +static inline void batadv__nla_put_64bit (struct sk_buff *skb,int attrtype, +int attrlen,const void *data, +int padattr) +{ +struct nlattr *nla; + + nla =batadv__nla_reserve_64bit (skb, attrtype, attrlen, padattr); +memcpy (nla_data (nla), data, attrlen); +} + +static inline bool batadv_nla_need_padding_for_64bit (struct sk_buff *skb) +{ +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +/* The nlattr header is 4 bytes in size, that's why we test +* if the skb->data _is_ aligned. A NOP attribute, plus +* nlattr header for next attribute, will make nla_data() +* 8-byte aligned. +*/ +if (IS_ALIGNED ((unsigned long )skb_tail_pointer (skb),8 )) +return true; +#endif +return false; +} + +static inline int batadv_nla_total_size_64bit (int payload) +{ + return NLA_ALIGN(nla_attr_size(payload)) +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + + NLA_ALIGN(nla_attr_size(0)) +#endif + ; +} + +static inline int batadv_nla_put_64bit (struct sk_buff *skb,int attrtype, +int attrlen,const void *data, +int padattr) +{ +size_t len; + +if (batadv_nla_need_padding_for_64bit (skb)) + len =batadv_nla_total_size_64bit (attrlen); +else + len =nla_total_size (attrlen); +if (unlikely (skb_tailroom (skb) < len)) +return -EMSGSIZE ; + +batadv__nla_put_64bit (skb, attrtype, attrlen, data, padattr); +return 0 ; +} + +#define nla_put_u64_64bit (_skb, _attrtype, _value, _padattr) \ + batadv_nla_put_u64_64bit(_skb, _attrtype, _value, _padattr) +static inline int batadv_nla_put_u64_64bit (struct sk_buff *skb,int attrtype, +u64 value,int padattr) +{ +return batadv_nla_put_64bit (skb, attrtype,sizeof (u64), &value, + padattr); +} + +#endif /* < KERNEL_VERSION(4, 7, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_NETLINK_H_ */
compat-include/net/genetlink.h +125 -2
133 lines not on this page · raw message
include/uapi/linux/batman_adv.h +43 -0
76 lines not on this page · raw message
net/batman-adv/Makefile +1 -0
@@ -40,4 +40,5 @@ 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
net/batman-adv/main.c +4 -0
@@ -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,
@@ -91,6 +92,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" );
@@ -144,6 +146,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);
@@ -162,6 +165,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 +18 -8
@@ -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 ,
@@ -232,17 +240,19 @@ __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr);* @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/netlink.c +232 -2
276 lines not on this page · raw message
net/batman-adv/netlink.h +6 -0
@@ -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
@@ -45,6 +45,7 @@#include "packet.h" #include "send.h" #include "soft-interface.h" +#include "tp_meter.h" #include "translation-table.h" static int batadv_route_unicast_packet(struct sk_buff *skb,
@@ -275,6 +276,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
@@ -841,6 +841,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 +1503 -0
1,503 lines not on this page · raw message
net/batman-adv/tp_meter.h new file +34 -0
@@ -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
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH v11 2/2] batman-adv: throughput meter implementation
Quoted 58 lines · On Wednesday, May 18, 2016 11:38:49 Sven Eckelmann wrote:
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]>
Signed-off-by Antonio Quartulli <[email protected]>Signed-off-by Sven Eckelmann <[email protected]>---
v11:
* movedbatadv_tp_meter_inittobatadv_init(main.c)
* fixed missing space in kerneldoc between "<" and "0"
* port tonla_put_u64_64bit
* add compat code fornla_put_u64_64bit
* introduce attributeBATADV_ATTR_PADwhich is used for alignment
* renamebatadv_real_genl_register_familyback togenl_register_familyin compat-include
v10:
* no changes
v9:
* rebase on top of current master+"batman-adv: Includemain.hin all
files"+ "batman-adv: Keep includes ordered by filename"
* adjustBATADV_DBG_TP_METERto bit 7 to avoid conflicts with mcast
* RenamedBATADV_TP_SIGINTtoBATADV_TP_REASON_CANCEL
* Renamedbatadv_tp_meter_reasonenumerals to BATADV_TP_REASON*
* Remove unrelated patch chunk inbatadv_iv_ogm_orig_add_if
* Re-add accidentally removed empty line frombatadv_recv_my_icmp_packet
* defineBATADV_TP_PLENviaBATADV_TP_PACKET_LEN(increases it to 1476)
* fixed whitespace problems in compat code
* remove double "a" in kerneldoc forbatadv_tp_meter_reason
v8:
* rebase on top of current master
v7:
* add compatibility code for v3.13
* makebatadv_netlink_mcgrpsnon-const because v3.12 needs it writable
v6:
* increasetotal_bytesto 64 bit to allow higher speeds/longer test times--- compat-include/linux/netlink.h | 113 +++ compat-include/net/genetlink.h | 127 +++- include/uapi/linux/batman_adv.h | 43 ++ net/batman-adv/Makefile | 1 + net/batman-adv/main.c | 4 + net/batman-adv/main.h | 26 +- 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 +
Quoted 8 lines
net/batman-adv/tp_meter.c | 1503 +++++++++++++++++++++++++++++++++++++++ net/batman-adv/tp_meter.h | 34 + net/batman-adv/types.h | 112 +++ 14 files changed, 2255 insertions(+), 12 deletions(-) create mode 100644 compat-include/linux/netlink.h create mode 100644 net/batman-adv/tp_meter.c create mode 100644 net/batman-adv/tp_meter.h
Applied in revision 98d7a76.
Thanks,
Marek
PATCH v11 1/1 batctl: introduce throughput meter support
In reply to Sven EckelmannFrom: Antonio Quartulli <[email protected]>
Add command to launch the throughput meter test. The throughput meter is a batman kernelspace tool for throughput measurements. The syntax is:
batctl tp <MAC>
The test is interruptible with SIGINT or SIGTERM; if the test succeeds with no error the throughput and the elapsed time are printed to stdout, otherwise occurred an error message is displayed (on stdout) accordingly.
Based on a prototype from Edo Monticelli <[email protected]>
---
v11:
* introduce new attribute BATADV_ATTR_PAD used for u64 alignment
v10:
* fix "a a" typo in batman_adv.h
v9:
* rebase on top of current master
* added include guards to tp_meter.h
* imported newest batman_adv.h and packet.h from batman-adv
* move iw/genl.c functions into own file "genl.c"
* adjust result handling based on new BATADV_TP_REASON_* names
v8:
* rebase on top of current master
--- Makefile | 2 + batman_adv.h | 43 +++++ genl.c | 140 ++++++++++++++++ genl.h | 31 ++++ main.c | 6 + main.h | 2 + man/batctl.8 | 24 ++- netlink.c | 8 + packet.h | 54 ++++++ tcpdump.c | 14 +- tp_meter.c | 540 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tp_meter.h | 27 +++ 12 files changed, 888 insertions(+), 3 deletions(-) create mode 100644 genl.c create mode 100644 genl.h create mode 100644 tp_meter.c create mode 100644 tp_meter.h
Makefile +2 -0
@@ -28,6 +28,7 @@ OBJ += bat-hosts.o OBJ += debugfs.o OBJ += debug.o OBJ += functions.o +OBJ += genl.o OBJ += hash.o OBJ += ioctl.o OBJ += list-batman.o
@@ -36,6 +37,7 @@ OBJ += netlink.o OBJ += ping.o OBJ += sys.o OBJ += tcpdump.o +OBJ += tp_meter.o OBJ += traceroute.o OBJ += translate.o OBJ_BISECT = bisect_iv.o
batman_adv.h +43 -0
76 lines not on this page · raw message
genl.c new file +140 -0
140 lines not on this page · raw message
genl.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: +* +* Marek Lindner <[email protected]> +* +* 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, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA +* +*/ + +#ifndef _BATCTL_GENL_H +#define _BATCTL_GENL_H + +#include <netlink/genl/genl.h> +#include <netlink/genl/ctrl.h> + +int nl_get_multicast_id (struct nl_sock *sock,const char *family, +const char *group); + +#endif /* _BATCTL_GENL_H */
main.c +6 -0
@@ -33,6 +33,7 @@#include "translate.h" #include "traceroute.h" #include "tcpdump.h" +#include "tp_meter.h" #include "bisect_iv.h" #include "ioctl.h" #include "functions.h"
@@ -82,6 +83,7 @@ static void print_usage(void)fprintf (stderr," \tping|p <destination> \tping another batman adv host via layer 2\n" );fprintf (stderr," \ttraceroute|tr <destination> \ttraceroute another batman adv host via layer 2\n" );fprintf (stderr," \ttcpdump|td <interface> \ttcpdump layer 2 traffic on the given interface\n" ); +printf (" \tthroughputmeter|tp <destination> \tstart a throughput measurement\n" );fprintf (stderr," \ttranslate|t <destination> \ttranslate a destination to the originator responsible for it\n" );#ifdef BATCTL_BISECT fprintf (stderr," \tbisect_iv <file1> .. <fileN>\tanalyze given batman iv log files for routing stability\n" );
@@ -162,6 +164,10 @@ int main(int argc, char **argv) ret =ping (mesh_iface, argc -1 , argv +1 ); + }else if ((strcmp (argv[1 ],"throughputmeter" ) ==0 ) || (strcmp (argv[1 ],"tp" ) ==0 )) { + + ret =tp_meter (mesh_iface, argc -1 , argv +1 ); + }else if ((strcmp (argv[1 ],"traceroute" ) ==0 ) || (strcmp (argv[1 ],"tr" ) ==0 )) { ret =traceroute (mesh_iface, argc -1 , argv +1 );
main.h +2 -0
@@ -47,10 +47,12 @@#endif #define __packed __attribute((packed))/* linux kernel compat */ +#define __unused __attribute__((unused))#define BIT (nr) (1UL << (nr))/* linux kernel compat */ typedef uint8_t u8 ;/* linux kernel compat */ typedef uint16_t u16 ;/* linux kernel compat */ +typedef uint32_t u32 ;/* linux kernel compat */ extern char module_ver_path[];
man/batctl.8 +22 -2
@@ -36,9 +36,11 @@ B.A.T.M.A.N. advanced operates on layer 2. Thus all hosts participating in the v connected together for all protocols above layer 2. Therefore the common diagnosis tools do not work as expected. To overcome these problems batctl contains the commands \fBping\fP, \fBtraceroute\fP, \fBtcpdump\fP which provide similar functionality to the normal \fBping\fP(1), \fBtraceroute\fP(1), \fBtcpdump\fP(1) commands, but modified to layer 2 -behaviour or using the B.A.T.M.A.N. advanced protocol. -.PP +behaviour or using the B.A.T.M.A.N. advanced protocol. For similar reasons, \fBthroughputmeter\fP, a command to test network +performances, is also included. + .PP +.Pp .SH OPTIONS .TP .I \fBoptions:
@@ -322,6 +324,24 @@ for routing loops. Use "\-t" to trace OGMs of a host throughout the network. Use nodes. The option "\-s" can be used to limit the output to a range of sequence numbers, between min and max, or to one specific sequence number, min. Furthermore using "\-o" you can filter the output to a specified originator. If "\-n" is given batctl will not replace the MAC addresses with bat\-host names in the output. +.RE +.br +.IP "\fBthroughputmeter\fP|\fBtp\fP \fBMAC\fP" +This command starts a throughput test entirely controlled by batman module in +kernel space: the computational resources needed to align memory and copy data +between user and kernel space that are required by other user space tools may +represent a bootleneck on some low profile device. + +The test consist of the transfer of 14 MB of data between the two nodes. The +protocol used to transfer the data is somehow similar to TCP, but simpler: some +TCP features are still missing, thus protocol performances could be worst. Since +a fixed amount of data is transferred the experiment duration depends on the +network conditions. The experiment can be interrupted with CTRL + C. At the end +of a succesful experiment the throughput in KBytes per second is returned, +togheter with the experiment duration in millisecond and the amount of bytes +transferred. If too many packets are lost or the specified MAC address is not +reachable, a message notifing the error is returned instead of the result. +.RE .br .SH FILES .TP
netlink.c +8 -0
@@ -41,4 +41,12 @@ struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_HARD_ADDRESS ] = { .type =NLA_UNSPEC , .minlen =ETH_ALEN , .maxlen = ETH_ALEN }, + [BATADV_ATTR_ORIG_ADDRESS ] = { .type =NLA_UNSPEC , + .minlen =ETH_ALEN , + .maxlen = ETH_ALEN }, + [BATADV_ATTR_TPMETER_RESULT] = { .type = NLA_U8 }, + [BATADV_ATTR_TPMETER_TEST_TIME] = { .type = NLA_U32 }, + [BATADV_ATTR_TPMETER_BYTES] = { .type = NLA_U64 }, + [BATADV_ATTR_TPMETER_COOKIE] = { .type = NLA_U32 }, + [BATADV_ATTR_PAD] = { .type = NLA_UNSPEC }, };
packet.h +54 -0
78 lines not on this page · raw message
tcpdump.c +13 -1
@@ -808,11 +808,14 @@ static void dump_batman_elp(unsigned char *packet_buff, ssize_t buff_len,static void dump_batman_icmp (unsigned char *packet_buff,ssize_t buff_len,int read_opt,int time_printed) {struct batadv_icmp_packet *icmp_packet; +struct batadv_icmp_tp_packet *tp; +char *name;LEN_CHECK ((size_t )buff_len -sizeof (struct ether_header ),sizeof (struct batadv_icmp_packet ),"BAT ICMP" ); icmp_packet = (struct batadv_icmp_packet *)(packet_buff +sizeof (struct ether_header )); + tp = (struct batadv_icmp_tp_packet *)icmp_packet;if (!time_printed)print_time ();
@@ -820,7 +823,8 @@ static void dump_batman_icmp(unsigned char *packet_buff, ssize_t buff_len, int rprintf ("BAT %s > " ,get_name_by_macaddr ((struct ether_addr *)icmp_packet->orig, read_opt)); - name =get_name_by_macaddr ((struct ether_addr *)icmp_packet->dst, read_opt); + name =get_name_by_macaddr ((struct ether_addr *)icmp_packet->dst, + read_opt);switch (icmp_packet->msg_type) {case BATADV_ECHO_REPLY :
@@ -841,6 +845,14 @@ static void dump_batman_icmp(unsigned char *packet_buff, ssize_t buff_len, int r icmp_packet->ttl, icmp_packet->version, (size_t)buff_len - sizeof(struct ether_header));break ; +case BATADV_TP : +printf ("%s: ICMP TP type %s (%hhu), id %hhu, seq %u, ttl %2d, v %d, length %zu\n" , + name, tp->subtype ==BATADV_TP_MSG ?"MSG" : + tp->subtype ==BATADV_TP_ACK ?"ACK" :"N/A" , + tp->subtype, tp->uid,ntohl (tp->seqno), tp->ttl, + tp->version, + (size_t )buff_len -sizeof (struct ether_header )); +break ;default : printf("%s: ICMP type %hhu, length %zu\n", name, icmp_packet->msg_type,
tp_meter.c new file +540 -0
540 lines not on this page · raw message
tp_meter.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (C) 2013-2016 B.A.T.M.A.N. contributors: +* +* Antonio Quartulli <[email protected]> +* +* 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, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA +* +*/ + +#ifndef _BATCTL_TP_METER_H +#define _BATCTL_TP_METER_H + +int tp_meter (char *mesh_iface,int argc,char **argv); + +#endif /* _BATCTL_TP_METER_H */
Signature · 1 line
2.8.1
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH v11] batctl: introduce throughput meter support
Quoted 39 lines · On Wednesday, May 18, 2016 11:38:50 Sven Eckelmann wrote:
From: Antonio Quartulli <[email protected]>
Add command to launch the throughput meter test. The throughput meter is a batman kernelspace tool for throughput measurements. The syntax is:
batctl tp <MAC>
The test is interruptible with SIGINT or SIGTERM; if the test succeeds with no error the throughput and the elapsed time are printed to stdout, otherwise occurred an error message is displayed (on stdout) accordingly.
Based on a prototype from Edo Monticelli <[email protected]>
Signed-off-by Antonio Quartulli <[email protected]>Signed-off-by Sven Eckelmann <[email protected]>---
v11:
* introduce new attributeBATADV_ATTR_PADused for u64 alignment
v10:
* fix "a a" typo inbatman_adv.h
v9:
* rebase on top of current master
* added include guards totp_meter.h
* imported newestbatman_adv.handpacket.hfrom batman-adv
* moveiw/genl.cfunctions into own file "genl.c"
* adjust result handling based on new BATADV_TP_REASON_* names
v8:
* rebase on top of current master--- Makefile | 2 + batman_adv.h | 43 +++++ genl.c | 140 ++++++++++++++++ genl.h | 31 ++++ main.c | 6 + main.h | 2 + man/batctl.8 | 24 ++- netlink.c | 8 + packet.h | 54 ++++++ tcpdump.c | 14 +-
Quoted 8 lines
tp_meter.c | 540 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tp_meter.h | 27 +++ 12 files changed, 888 insertions(+), 3 deletions(-) create mode 100644 genl.c create mode 100644 genl.h create mode 100644 tp_meter.c create mode 100644 tp_meter.h
Applied in revision f109b34.
Thanks,
Marek