batman-adv: throughput meter implementation

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 <montik@autistici.org>

Signed-off-by: Antonio Quartulli <antonio.quartulli@open-mesh.com>
Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
This commit is contained in:
Antonio Quartulli 2016-05-05 13:09:43 +02:00 committed by Simon Wunderlich
parent f50ca95a69
commit 33a3bb4a33
13 changed files with 2021 additions and 10 deletions

View File

@ -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_ */

View File

@ -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

View File

@ -51,6 +51,7 @@ 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 {
@ -61,6 +62,7 @@ enum batadv_dbg_level {
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,
};

View File

@ -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)

View File

@ -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,

View File

@ -27,12 +27,14 @@
#include <linux/netlink.h>
#include <linux/printk.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <net/genetlink.h>
#include <net/netlink.h>
#include <uapi/linux/batman_adv.h>
#include "hard-interface.h"
#include "soft-interface.h"
#include "tp_meter.h"
struct sk_buff;
@ -44,6 +46,15 @@ static struct genl_family batadv_netlink_family = {
.maxattr = BATADV_ATTR_MAX,
};
/* multicast groups */
enum batadv_netlink_multicast_groups {
BATADV_NL_MCGRP_TPMETER,
};
static struct genl_multicast_group batadv_netlink_mcgrps[] = {
[BATADV_NL_MCGRP_TPMETER] = { .name = BATADV_NL_MCAST_GROUP_TPMETER },
};
static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = {
[BATADV_ATTR_VERSION] = { .type = NLA_STRING },
[BATADV_ATTR_ALGO_NAME] = { .type = NLA_STRING },
@ -53,6 +64,11 @@ static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = {
[BATADV_ATTR_HARD_IFINDEX] = { .type = NLA_U32 },
[BATADV_ATTR_HARD_IFNAME] = { .type = NLA_STRING },
[BATADV_ATTR_HARD_ADDRESS] = { .len = ETH_ALEN },
[BATADV_ATTR_ORIG_ADDRESS] = { .len = 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 },
};
/**
@ -163,6 +179,207 @@ batadv_netlink_get_mesh_info(struct sk_buff *skb, struct genl_info *info)
return genlmsg_reply(msg, info);
}
/**
* batadv_netlink_tp_meter_put - Fill information of started tp_meter session
* @msg: netlink message to be sent back
* @cookie: tp meter session cookie
*
* Return: 0 on success, < 0 on error
*/
static int
batadv_netlink_tp_meter_put(struct sk_buff *msg, u32 cookie)
{
if (nla_put_u32(msg, BATADV_ATTR_TPMETER_COOKIE, cookie))
return -ENOBUFS;
return 0;
}
/**
* batadv_netlink_tpmeter_notify - send tp_meter result via netlink to client
* @bat_priv: the bat priv with all the soft interface information
* @dst: destination of tp_meter session
* @result: reason for tp meter session stop
* @test_time: total time ot the tp_meter session
* @total_bytes: bytes acked to the receiver
* @cookie: cookie of tp_meter session
*
* Return: 0 on success, < 0 on error
*/
int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst,
u8 result, u32 test_time, u64 total_bytes,
u32 cookie)
{
struct sk_buff *msg;
void *hdr;
int ret;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
hdr = genlmsg_put(msg, 0, 0, &batadv_netlink_family, 0,
BATADV_CMD_TP_METER);
if (!hdr) {
ret = -ENOBUFS;
goto err_genlmsg;
}
if (nla_put_u32(msg, BATADV_ATTR_TPMETER_COOKIE, cookie))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_TPMETER_TEST_TIME, test_time))
goto nla_put_failure;
if (nla_put_u64_64bit(msg, BATADV_ATTR_TPMETER_BYTES, total_bytes,
BATADV_ATTR_PAD))
goto nla_put_failure;
if (nla_put_u8(msg, BATADV_ATTR_TPMETER_RESULT, result))
goto nla_put_failure;
if (nla_put(msg, BATADV_ATTR_ORIG_ADDRESS, ETH_ALEN, dst))
goto nla_put_failure;
genlmsg_end(msg, hdr);
genlmsg_multicast_netns(&batadv_netlink_family,
dev_net(bat_priv->soft_iface), msg, 0,
BATADV_NL_MCGRP_TPMETER, GFP_KERNEL);
return 0;
nla_put_failure:
genlmsg_cancel(msg, hdr);
ret = -EMSGSIZE;
err_genlmsg:
nlmsg_free(msg);
return ret;
}
/**
* batadv_netlink_tp_meter_start - Start a new tp_meter session
* @skb: received netlink message
* @info: receiver information
*
* Return: 0 on success, < 0 on error
*/
static int
batadv_netlink_tp_meter_start(struct sk_buff *skb, struct genl_info *info)
{
struct net *net = genl_info_net(info);
struct net_device *soft_iface;
struct batadv_priv *bat_priv;
struct sk_buff *msg = NULL;
u32 test_length;
void *msg_head;
int ifindex;
u32 cookie;
u8 *dst;
int ret;
if (!info->attrs[BATADV_ATTR_MESH_IFINDEX])
return -EINVAL;
if (!info->attrs[BATADV_ATTR_ORIG_ADDRESS])
return -EINVAL;
if (!info->attrs[BATADV_ATTR_TPMETER_TEST_TIME])
return -EINVAL;
ifindex = nla_get_u32(info->attrs[BATADV_ATTR_MESH_IFINDEX]);
if (!ifindex)
return -EINVAL;
dst = nla_data(info->attrs[BATADV_ATTR_ORIG_ADDRESS]);
test_length = nla_get_u32(info->attrs[BATADV_ATTR_TPMETER_TEST_TIME]);
soft_iface = dev_get_by_index(net, ifindex);
if (!soft_iface || !batadv_softif_is_valid(soft_iface)) {
ret = -ENODEV;
goto out;
}
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) {
ret = -ENOMEM;
goto out;
}
msg_head = genlmsg_put(msg, info->snd_portid, info->snd_seq,
&batadv_netlink_family, 0,
BATADV_CMD_TP_METER);
if (!msg_head) {
ret = -ENOBUFS;
goto out;
}
bat_priv = netdev_priv(soft_iface);
batadv_tp_start(bat_priv, dst, test_length, &cookie);
ret = batadv_netlink_tp_meter_put(msg, cookie);
out:
if (soft_iface)
dev_put(soft_iface);
if (ret) {
if (msg)
nlmsg_free(msg);
return ret;
}
genlmsg_end(msg, msg_head);
return genlmsg_reply(msg, info);
}
/**
* batadv_netlink_tp_meter_start - Cancel a running tp_meter session
* @skb: received netlink message
* @info: receiver information
*
* Return: 0 on success, < 0 on error
*/
static int
batadv_netlink_tp_meter_cancel(struct sk_buff *skb, struct genl_info *info)
{
struct net *net = genl_info_net(info);
struct net_device *soft_iface;
struct batadv_priv *bat_priv;
int ifindex;
u8 *dst;
int ret = 0;
if (!info->attrs[BATADV_ATTR_MESH_IFINDEX])
return -EINVAL;
if (!info->attrs[BATADV_ATTR_ORIG_ADDRESS])
return -EINVAL;
ifindex = nla_get_u32(info->attrs[BATADV_ATTR_MESH_IFINDEX]);
if (!ifindex)
return -EINVAL;
dst = nla_data(info->attrs[BATADV_ATTR_ORIG_ADDRESS]);
soft_iface = dev_get_by_index(net, ifindex);
if (!soft_iface || !batadv_softif_is_valid(soft_iface)) {
ret = -ENODEV;
goto out;
}
bat_priv = netdev_priv(soft_iface);
batadv_tp_stop(bat_priv, dst, BATADV_TP_REASON_CANCEL);
out:
if (soft_iface)
dev_put(soft_iface);
return ret;
}
static struct genl_ops batadv_netlink_ops[] = {
{
.cmd = BATADV_CMD_GET_MESH_INFO,
@ -170,6 +387,18 @@ static struct genl_ops batadv_netlink_ops[] = {
.policy = batadv_netlink_policy,
.doit = batadv_netlink_get_mesh_info,
},
{
.cmd = BATADV_CMD_TP_METER,
.flags = GENL_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_tp_meter_start,
},
{
.cmd = BATADV_CMD_TP_METER_CANCEL,
.flags = GENL_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_tp_meter_cancel,
},
};
/**
@ -179,8 +408,9 @@ void __init batadv_netlink_register(void)
{
int ret;
ret = genl_register_family_with_ops(&batadv_netlink_family,
batadv_netlink_ops);
ret = genl_register_family_with_ops_groups(&batadv_netlink_family,
batadv_netlink_ops,
batadv_netlink_mcgrps);
if (ret)
pr_warn("unable to register netlink family");
}

View File

@ -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_ */

View File

@ -21,6 +21,8 @@
#include <asm/byteorder.h>
#include <linux/types.h>
#define batadv_tp_is_error(n) ((u8)n > 127 ? 1 : 0)
/**
* enum batadv_packettype - types for batman-adv encapsulated packets
* @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
@ -93,6 +95,7 @@ enum batadv_icmp_packettype {
BATADV_ECHO_REQUEST = 8,
BATADV_TTL_EXCEEDED = 11,
BATADV_PARAMETER_PROBLEM = 12,
BATADV_TP = 15,
};
/**
@ -284,6 +287,16 @@ struct batadv_elp_packet {
#define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet)
/**
* enum batadv_icmp_user_cmd_type - types for batman-adv icmp cmd modes
* @BATADV_TP_START: start a throughput meter run
* @BATADV_TP_STOP: stop a throughput meter run
*/
enum batadv_icmp_user_cmd_type {
BATADV_TP_START = 0,
BATADV_TP_STOP = 2,
};
/**
* struct batadv_icmp_header - common members among all the ICMP packets
* @packet_type: batman-adv packet type, part of the general header
@ -334,6 +347,47 @@ struct batadv_icmp_packet {
__be16 seqno;
};
/**
* struct batadv_icmp_tp_packet - ICMP TP Meter packet
* @packet_type: batman-adv packet type, part of the general header
* @version: batman-adv protocol version, part of the genereal header
* @ttl: time to live for this packet, part of the genereal header
* @msg_type: ICMP packet type
* @dst: address of the destination node
* @orig: address of the source node
* @uid: local ICMP socket identifier
* @subtype: TP packet subtype (see batadv_icmp_tp_subtype)
* @session: TP session identifier
* @seqno: the TP sequence number
* @timestamp: time when the packet has been sent. This value is filled in a
* TP_MSG and echoed back in the next TP_ACK so that the sender can compute the
* RTT. Since it is read only by the host which wrote it, there is no need to
* store it using network order
*/
struct batadv_icmp_tp_packet {
u8 packet_type;
u8 version;
u8 ttl;
u8 msg_type; /* see ICMP message types above */
u8 dst[ETH_ALEN];
u8 orig[ETH_ALEN];
u8 uid;
u8 subtype;
u8 session[2];
__be32 seqno;
__be32 timestamp;
};
/**
* enum batadv_icmp_tp_subtype - ICMP TP Meter packet subtypes
* @BATADV_TP_MSG: Msg from sender to receiver
* @BATADV_TP_ACK: acknowledgment from receiver to sender
*/
enum batadv_icmp_tp_subtype {
BATADV_TP_MSG = 0,
BATADV_TP_ACK,
};
#define BATADV_RR_LEN 16
/**

View File

@ -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;

View File

@ -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;

1507
net/batman-adv/tp_meter.c Normal file

File diff suppressed because it is too large Load Diff

34
net/batman-adv/tp_meter.h Normal file
View File

@ -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_ */

View File

@ -33,6 +33,7 @@
#include <linux/types.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
#include <uapi/linux/batman_adv.h>
#include "packet.h"
@ -832,6 +833,111 @@ struct batadv_priv_nc {
struct batadv_hashtable *decoding_hash;
};
/**
* struct batadv_tp_unacked - unacked packet meta-information
* @seqno: seqno of the unacked packet
* @len: length of the packet
* @list: list node for batadv_tp_vars::unacked_list
*
* This struct is supposed to represent a buffer unacked packet. However, since
* the purpose of the TP meter is to count the traffic only, there is no need to
* store the entire sk_buff, the starting offset and the length are enough
*/
struct batadv_tp_unacked {
u32 seqno;
u16 len;
struct list_head list;
};
/**
* enum batadv_tp_meter_role - Modus in tp meter session
* @BATADV_TP_RECEIVER: Initialized as receiver
* @BATADV_TP_SENDER: Initialized as sender
*/
enum batadv_tp_meter_role {
BATADV_TP_RECEIVER,
BATADV_TP_SENDER
};
/**
* struct batadv_tp_vars - tp meter private variables per session
* @list: list node for bat_priv::tp_list
* @timer: timer for ack (receiver) and retry (sender)
* @bat_priv: pointer to the mesh object
* @start_time: start time in jiffies
* @other_end: mac address of remote
* @role: receiver/sender modi
* @sending: sending binary semaphore: 1 if sending, 0 is not
* @reason: reason for a stopped session
* @finish_work: work item for the finishing procedure
* @test_length: test length in milliseconds
* @session: TP session identifier
* @icmp_uid: local ICMP "socket" index
* @dec_cwnd: decimal part of the cwnd used during linear growth
* @cwnd: current size of the congestion window
* @cwnd_lock: lock do protect @cwnd & @dec_cwnd
* @ss_threshold: Slow Start threshold. Once cwnd exceeds this value the
* connection switches to the Congestion Avoidance state
* @last_acked: last acked byte
* @last_sent: last sent byte, not yet acked
* @tot_sent: amount of data sent/ACKed so far
* @dup_acks: duplicate ACKs counter
* @fast_recovery: true if in Fast Recovery mode
* @recover: last sent seqno when entering Fast Recovery
* @rto: sender timeout
* @srtt: smoothed RTT scaled by 2^3
* @rttvar: RTT variation scaled by 2^2
* @more_bytes: waiting queue anchor when waiting for more ack/retry timeout
* @prerandom_offset: offset inside the prerandom buffer
* @prerandom_lock: spinlock protecting access to prerandom_offset
* @last_recv: last in-order received packet
* @unacked_list: list of unacked packets (meta-info only)
* @unacked_lock: protect unacked_list
* @last_recv_time: time time (jiffies) a msg was received
* @refcount: number of context where the object is used
* @rcu: struct used for freeing in an RCU-safe manner
*/
struct batadv_tp_vars {
struct hlist_node list;
struct timer_list timer;
struct batadv_priv *bat_priv;
unsigned long start_time;
u8 other_end[ETH_ALEN];
enum batadv_tp_meter_role role;
atomic_t sending;
enum batadv_tp_meter_reason reason;
struct delayed_work finish_work;
u32 test_length;
u8 session[2];
u8 icmp_uid;
/* sender variables */
u16 dec_cwnd;
u32 cwnd;
spinlock_t cwnd_lock; /* Protects cwnd & dec_cwnd */
u32 ss_threshold;
atomic_t last_acked;
u32 last_sent;
atomic64_t tot_sent;
atomic_t dup_acks;
bool fast_recovery;
u32 recover;
u32 rto;
u32 srtt;
u32 rttvar;
wait_queue_head_t more_bytes;
u32 prerandom_offset;
spinlock_t prerandom_lock; /* Protects prerandom_offset */
/* receiver variables */
u32 last_recv;
struct list_head unacked_list;
spinlock_t unacked_lock; /* Protects unacked_list */
unsigned long last_recv_time;
struct kref refcount;
struct rcu_head rcu;
};
/**
* struct batadv_softif_vlan - per VLAN attributes set
* @bat_priv: pointer to the mesh object
@ -900,9 +1006,12 @@ struct batadv_priv_bat_v {
* @debug_dir: dentry for debugfs batman-adv subdirectory
* @forw_bat_list: list of aggregated OGMs that will be forwarded
* @forw_bcast_list: list of broadcast packets that will be rebroadcasted
* @tp_list: list of tp sessions
* @tp_num: number of currently active tp sessions
* @orig_hash: hash table containing mesh participants (orig nodes)
* @forw_bat_list_lock: lock protecting forw_bat_list
* @forw_bcast_list_lock: lock protecting forw_bcast_list
* @tp_list_lock: spinlock protecting @tp_list
* @orig_work: work queue callback item for orig node purging
* @cleanup_work: work queue callback item for soft-interface deinit
* @primary_if: one of the hard-interfaces assigned to this mesh interface
@ -956,9 +1065,12 @@ struct batadv_priv {
struct dentry *debug_dir;
struct hlist_head forw_bat_list;
struct hlist_head forw_bcast_list;
struct hlist_head tp_list;
struct batadv_hashtable *orig_hash;
spinlock_t forw_bat_list_lock; /* protects forw_bat_list */
spinlock_t forw_bcast_list_lock; /* protects forw_bcast_list */
spinlock_t tp_list_lock; /* protects tp_list */
atomic_t tp_num;
struct delayed_work orig_work;
struct work_struct cleanup_work;
struct batadv_hard_iface __rcu *primary_if; /* rcu protected pointer */