-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'batadv-next-for-davem-20160704' of git://git.open-mesh.org…
…/linux-merge Simon Wunderlich says: ==================== 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) ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
43 changed files
with
3,831 additions
and
1,217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* Copyright (C) 2016 B.A.T.M.A.N. contributors: | ||
* | ||
* Matthias Schiffer | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#ifndef _UAPI_LINUX_BATMAN_ADV_H_ | ||
#define _UAPI_LINUX_BATMAN_ADV_H_ | ||
|
||
#define BATADV_NL_NAME "batadv" | ||
|
||
#define BATADV_NL_MCAST_GROUP_TPMETER "tpmeter" | ||
|
||
/** | ||
* 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_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 | ||
*/ | ||
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, | ||
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, | ||
BATADV_ATTR_MAX = __BATADV_ATTR_AFTER_LAST - 1 | ||
}; | ||
|
||
/** | ||
* 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_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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/* 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/>. | ||
*/ | ||
|
||
#include "main.h" | ||
|
||
#include <linux/errno.h> | ||
#include <linux/list.h> | ||
#include <linux/moduleparam.h> | ||
#include <linux/printk.h> | ||
#include <linux/seq_file.h> | ||
#include <linux/stddef.h> | ||
#include <linux/string.h> | ||
|
||
#include "bat_algo.h" | ||
|
||
char batadv_routing_algo[20] = "BATMAN_IV"; | ||
static struct hlist_head batadv_algo_list; | ||
|
||
/** | ||
* batadv_algo_init - Initialize batman-adv algorithm management data structures | ||
*/ | ||
void batadv_algo_init(void) | ||
{ | ||
INIT_HLIST_HEAD(&batadv_algo_list); | ||
} | ||
|
||
static struct batadv_algo_ops *batadv_algo_get(char *name) | ||
{ | ||
struct batadv_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp; | ||
|
||
hlist_for_each_entry(bat_algo_ops_tmp, &batadv_algo_list, list) { | ||
if (strcmp(bat_algo_ops_tmp->name, name) != 0) | ||
continue; | ||
|
||
bat_algo_ops = bat_algo_ops_tmp; | ||
break; | ||
} | ||
|
||
return bat_algo_ops; | ||
} | ||
|
||
int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops) | ||
{ | ||
struct batadv_algo_ops *bat_algo_ops_tmp; | ||
|
||
bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name); | ||
if (bat_algo_ops_tmp) { | ||
pr_info("Trying to register already registered routing algorithm: %s\n", | ||
bat_algo_ops->name); | ||
return -EEXIST; | ||
} | ||
|
||
/* all algorithms must implement all ops (for now) */ | ||
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; | ||
} | ||
|
||
INIT_HLIST_NODE(&bat_algo_ops->list); | ||
hlist_add_head(&bat_algo_ops->list, &batadv_algo_list); | ||
|
||
return 0; | ||
} | ||
|
||
int batadv_algo_select(struct batadv_priv *bat_priv, char *name) | ||
{ | ||
struct batadv_algo_ops *bat_algo_ops; | ||
|
||
bat_algo_ops = batadv_algo_get(name); | ||
if (!bat_algo_ops) | ||
return -EINVAL; | ||
|
||
bat_priv->algo_ops = bat_algo_ops; | ||
|
||
return 0; | ||
} | ||
|
||
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) | ||
{ | ||
struct batadv_algo_ops *bat_algo_ops; | ||
|
||
seq_puts(seq, "Available routing algorithms:\n"); | ||
|
||
hlist_for_each_entry(bat_algo_ops, &batadv_algo_list, list) { | ||
seq_printf(seq, " * %s\n", bat_algo_ops->name); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) | ||
{ | ||
struct batadv_algo_ops *bat_algo_ops; | ||
char *algo_name = (char *)val; | ||
size_t name_len = strlen(algo_name); | ||
|
||
if (name_len > 0 && algo_name[name_len - 1] == '\n') | ||
algo_name[name_len - 1] = '\0'; | ||
|
||
bat_algo_ops = batadv_algo_get(algo_name); | ||
if (!bat_algo_ops) { | ||
pr_err("Routing algorithm '%s' is not supported\n", algo_name); | ||
return -EINVAL; | ||
} | ||
|
||
return param_set_copystring(algo_name, kp); | ||
} | ||
|
||
static const struct kernel_param_ops batadv_param_ops_ra = { | ||
.set = batadv_param_set_ra, | ||
.get = param_get_string, | ||
}; | ||
|
||
static struct kparam_string batadv_param_string_ra = { | ||
.maxlen = sizeof(batadv_routing_algo), | ||
.string = batadv_routing_algo, | ||
}; | ||
|
||
module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra, | ||
0644); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.