提交 b77af26a 编写于 作者: D David S. Miller

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: NDavid S. Miller <davem@davemloft.net>
...@@ -2297,6 +2297,7 @@ S: Maintained ...@@ -2297,6 +2297,7 @@ S: Maintained
F: Documentation/ABI/testing/sysfs-class-net-batman-adv F: Documentation/ABI/testing/sysfs-class-net-batman-adv
F: Documentation/ABI/testing/sysfs-class-net-mesh F: Documentation/ABI/testing/sysfs-class-net-mesh
F: Documentation/networking/batman-adv.txt F: Documentation/networking/batman-adv.txt
F: include/uapi/linux/batman_adv.h
F: net/batman-adv/ F: net/batman-adv/
BAYCOM/HDLCDRV DRIVERS FOR AX.25 BAYCOM/HDLCDRV DRIVERS FOR AX.25
......
/* 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_ */
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# #
obj-$(CONFIG_BATMAN_ADV) += batman-adv.o obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
batman-adv-y += bat_algo.o
batman-adv-y += bat_iv_ogm.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.o
batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_elp.o batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_elp.o
...@@ -31,12 +32,16 @@ batman-adv-y += gateway_common.o ...@@ -31,12 +32,16 @@ batman-adv-y += gateway_common.o
batman-adv-y += hard-interface.o batman-adv-y += hard-interface.o
batman-adv-y += hash.o batman-adv-y += hash.o
batman-adv-y += icmp_socket.o batman-adv-y += icmp_socket.o
batman-adv-$(CONFIG_BATMAN_ADV_DEBUG) += log.o
batman-adv-y += main.o batman-adv-y += main.o
batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.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-$(CONFIG_BATMAN_ADV_NC) += network-coding.o
batman-adv-y += originator.o batman-adv-y += originator.o
batman-adv-y += routing.o batman-adv-y += routing.o
batman-adv-y += send.o batman-adv-y += send.o
batman-adv-y += soft-interface.o batman-adv-y += soft-interface.o
batman-adv-y += sysfs.o batman-adv-y += sysfs.o
batman-adv-y += tp_meter.o
batman-adv-y += translation-table.o batman-adv-y += translation-table.o
batman-adv-y += tvlv.o
/* 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);
...@@ -20,35 +20,16 @@ ...@@ -20,35 +20,16 @@
#include "main.h" #include "main.h"
int batadv_iv_init(void); #include <linux/types.h>
#ifdef CONFIG_BATMAN_ADV_BATMAN_V struct seq_file;
int batadv_v_init(void); extern char batadv_routing_algo[];
void batadv_v_hardif_init(struct batadv_hard_iface *hardif); extern struct list_head batadv_hardif_list;
int batadv_v_mesh_init(struct batadv_priv *bat_priv);
void batadv_v_mesh_free(struct batadv_priv *bat_priv);
#else void batadv_algo_init(void);
int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops);
static inline int batadv_v_init(void) int batadv_algo_select(struct batadv_priv *bat_priv, char *name);
{ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
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_ */ #endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * 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 "main.h"
#include <linux/atomic.h> #include <linux/atomic.h>
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/list.h>
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h> #include <linux/lockdep.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/pkt_sched.h> #include <linux/pkt_sched.h>
...@@ -49,15 +49,18 @@ ...@@ -49,15 +49,18 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "bat_algo.h"
#include "bitarray.h" #include "bitarray.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "hash.h" #include "hash.h"
#include "log.h"
#include "network-coding.h" #include "network-coding.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "routing.h" #include "routing.h"
#include "send.h" #include "send.h"
#include "translation-table.h" #include "translation-table.h"
#include "tvlv.h"
static void batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work); static void batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work);
...@@ -1850,8 +1853,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb, ...@@ -1850,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 /* 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 ? * that does not have B.A.T.M.A.N. IV enabled ?
*/ */
if (bat_priv->bat_algo_ops->bat_iface_enable != if (bat_priv->algo_ops->iface.enable != batadv_iv_ogm_iface_enable)
batadv_iv_ogm_iface_enable)
return NET_RX_DROP; return NET_RX_DROP;
batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX); batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX);
...@@ -2117,18 +2119,24 @@ static void batadv_iv_iface_activate(struct batadv_hard_iface *hard_iface) ...@@ -2117,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 = { static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
.name = "BATMAN_IV", .name = "BATMAN_IV",
.bat_iface_activate = batadv_iv_iface_activate, .iface = {
.bat_iface_enable = batadv_iv_ogm_iface_enable, .activate = batadv_iv_iface_activate,
.bat_iface_disable = batadv_iv_ogm_iface_disable, .enable = batadv_iv_ogm_iface_enable,
.bat_iface_update_mac = batadv_iv_ogm_iface_update_mac, .disable = batadv_iv_ogm_iface_disable,
.bat_primary_iface_set = batadv_iv_ogm_primary_iface_set, .update_mac = batadv_iv_ogm_iface_update_mac,
.bat_neigh_cmp = batadv_iv_ogm_neigh_cmp, .primary_set = batadv_iv_ogm_primary_iface_set,
.bat_neigh_is_similar_or_better = batadv_iv_ogm_neigh_is_sob, },
.bat_neigh_print = batadv_iv_neigh_print, .neigh = {
.bat_orig_print = batadv_iv_ogm_orig_print, .cmp = batadv_iv_ogm_neigh_cmp,
.bat_orig_free = batadv_iv_ogm_orig_free, .is_similar_or_better = batadv_iv_ogm_neigh_is_sob,
.bat_orig_add_if = batadv_iv_ogm_orig_add_if, .print = batadv_iv_neigh_print,
.bat_orig_del_if = batadv_iv_ogm_orig_del_if, },
.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) int __init batadv_iv_init(void)
......
/* 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_ */
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "bat_algo.h" #include "bat_v.h"
#include "main.h" #include "main.h"
#include <linux/atomic.h> #include <linux/atomic.h>
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "bat_algo.h"
#include "bat_v_elp.h" #include "bat_v_elp.h"
#include "bat_v_ogm.h" #include "bat_v_ogm.h"
#include "hard-interface.h" #include "hard-interface.h"
...@@ -321,16 +322,22 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1, ...@@ -321,16 +322,22 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
static struct batadv_algo_ops batadv_batman_v __read_mostly = { static struct batadv_algo_ops batadv_batman_v __read_mostly = {
.name = "BATMAN_V", .name = "BATMAN_V",
.bat_iface_activate = batadv_v_iface_activate, .iface = {
.bat_iface_enable = batadv_v_iface_enable, .activate = batadv_v_iface_activate,
.bat_iface_disable = batadv_v_iface_disable, .enable = batadv_v_iface_enable,
.bat_iface_update_mac = batadv_v_iface_update_mac, .disable = batadv_v_iface_disable,
.bat_primary_iface_set = batadv_v_primary_iface_set, .update_mac = batadv_v_iface_update_mac,
.bat_hardif_neigh_init = batadv_v_hardif_neigh_init, .primary_set = batadv_v_primary_iface_set,
.bat_orig_print = batadv_v_orig_print, },
.bat_neigh_cmp = batadv_v_neigh_cmp, .neigh = {
.bat_neigh_is_similar_or_better = batadv_v_neigh_is_sob, .hardif_init = batadv_v_hardif_neigh_init,
.bat_neigh_print = batadv_v_neigh_print, .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,
},
}; };
/** /**
......
/* Copyright (C) 2011-2016 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Linus Lüssing
*
* 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_BAT_V_H_
#define _NET_BATMAN_ADV_BAT_V_H_
#include "main.h"
#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_V_H_ */
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "bat_algo.h" #include "bat_algo.h"
#include "bat_v_ogm.h" #include "bat_v_ogm.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "log.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "routing.h" #include "routing.h"
...@@ -503,7 +504,7 @@ int batadv_v_elp_packet_recv(struct sk_buff *skb, ...@@ -503,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 /* 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 ? * 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; return NET_RX_DROP;
elp_packet = (struct batadv_elp_packet *)skb->data; elp_packet = (struct batadv_elp_packet *)skb->data;
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "main.h"
#ifndef _NET_BATMAN_ADV_BAT_V_ELP_H_ #ifndef _NET_BATMAN_ADV_BAT_V_ELP_H_
#define _NET_BATMAN_ADV_BAT_V_ELP_H_ #define _NET_BATMAN_ADV_BAT_V_ELP_H_
#include "main.h"
struct sk_buff; struct sk_buff;
struct work_struct; struct work_struct;
......
...@@ -39,13 +39,16 @@ ...@@ -39,13 +39,16 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "bat_algo.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "hash.h" #include "hash.h"
#include "log.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "routing.h" #include "routing.h"
#include "send.h" #include "send.h"
#include "translation-table.h" #include "translation-table.h"
#include "tvlv.h"
/** /**
* batadv_v_ogm_orig_get - retrieve and possibly create an originator node * batadv_v_ogm_orig_get - retrieve and possibly create an originator node
...@@ -751,7 +754,7 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb, ...@@ -751,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 /* did we receive a OGM2 packet on an interface that does not have
* B.A.T.M.A.N. V enabled ? * 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; return NET_RX_DROP;
if (!batadv_check_management_packet(skb, if_incoming, BATADV_OGM2_HLEN)) if (!batadv_check_management_packet(skb, if_incoming, BATADV_OGM2_HLEN))
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
#ifndef _BATMAN_ADV_BATADV_V_OGM_H_ #ifndef _BATMAN_ADV_BATADV_V_OGM_H_
#define _BATMAN_ADV_BATADV_V_OGM_H_ #define _BATMAN_ADV_BATADV_V_OGM_H_
#include "main.h"
#include <linux/types.h> #include <linux/types.h>
struct batadv_hard_iface;
struct batadv_priv;
struct sk_buff; struct sk_buff;
int batadv_v_ogm_init(struct batadv_priv *bat_priv); int batadv_v_ogm_init(struct batadv_priv *bat_priv);
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include "log.h"
/* shift the packet array by n places. */ /* shift the packet array by n places. */
static void batadv_bitmap_shift_left(unsigned long *seq_bits, s32 n) static void batadv_bitmap_shift_left(unsigned long *seq_bits, s32 n)
{ {
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "hard-interface.h" #include "hard-interface.h"
#include "hash.h" #include "hash.h"
#include "log.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "sysfs.h" #include "sysfs.h"
......
...@@ -18,36 +18,26 @@ ...@@ -18,36 +18,26 @@
#include "debugfs.h" #include "debugfs.h"
#include "main.h" #include "main.h"
#include <linux/compiler.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/fcntl.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/poll.h>
#include <linux/printk.h> #include <linux/printk.h>
#include <linux/sched.h> /* for linux/wait.h */ #include <linux/sched.h> /* for linux/wait.h */
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/wait.h>
#include <stdarg.h>
#include "bat_algo.h"
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
#include "distributed-arp-table.h" #include "distributed-arp-table.h"
#include "gateway_client.h" #include "gateway_client.h"
#include "icmp_socket.h" #include "icmp_socket.h"
#include "log.h"
#include "multicast.h" #include "multicast.h"
#include "network-coding.h" #include "network-coding.h"
#include "originator.h" #include "originator.h"
...@@ -55,209 +45,6 @@ ...@@ -55,209 +45,6 @@
static struct dentry *batadv_debugfs; static struct dentry *batadv_debugfs;
#ifdef CONFIG_BATMAN_ADV_DEBUG
#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
static char *batadv_log_char_addr(struct batadv_priv_debug_log *debug_log,
size_t idx)
{
return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK];
}
static void batadv_emit_log_char(struct batadv_priv_debug_log *debug_log,
char c)
{
char *char_addr;
char_addr = batadv_log_char_addr(debug_log, debug_log->log_end);
*char_addr = c;
debug_log->log_end++;
if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len)
debug_log->log_start = debug_log->log_end - batadv_log_buff_len;
}
__printf(2, 3)
static int batadv_fdebug_log(struct batadv_priv_debug_log *debug_log,
const char *fmt, ...)
{
va_list args;
static char debug_log_buf[256];
char *p;
if (!debug_log)
return 0;
spin_lock_bh(&debug_log->lock);
va_start(args, fmt);
vscnprintf(debug_log_buf, sizeof(debug_log_buf), fmt, args);
va_end(args);
for (p = debug_log_buf; *p != 0; p++)
batadv_emit_log_char(debug_log, *p);
spin_unlock_bh(&debug_log->lock);
wake_up(&debug_log->queue_wait);
return 0;
}
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
{
va_list args;
char tmp_log_buf[256];
va_start(args, fmt);
vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
batadv_fdebug_log(bat_priv->debug_log, "[%10u] %s",
jiffies_to_msecs(jiffies), tmp_log_buf);
va_end(args);
return 0;
}
static int batadv_log_open(struct inode *inode, struct file *file)
{
if (!try_module_get(THIS_MODULE))
return -EBUSY;
nonseekable_open(inode, file);
file->private_data = inode->i_private;
return 0;
}
static int batadv_log_release(struct inode *inode, struct file *file)
{
module_put(THIS_MODULE);
return 0;
}
static bool batadv_log_empty(struct batadv_priv_debug_log *debug_log)
{
return !(debug_log->log_start - debug_log->log_end);
}
static ssize_t batadv_log_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct batadv_priv *bat_priv = file->private_data;
struct batadv_priv_debug_log *debug_log = bat_priv->debug_log;
int error, i = 0;
char *char_addr;
char c;
if ((file->f_flags & O_NONBLOCK) && batadv_log_empty(debug_log))
return -EAGAIN;
if (!buf)
return -EINVAL;
if (count == 0)
return 0;
if (!access_ok(VERIFY_WRITE, buf, count))
return -EFAULT;
error = wait_event_interruptible(debug_log->queue_wait,
(!batadv_log_empty(debug_log)));
if (error)
return error;
spin_lock_bh(&debug_log->lock);
while ((!error) && (i < count) &&
(debug_log->log_start != debug_log->log_end)) {
char_addr = batadv_log_char_addr(debug_log,
debug_log->log_start);
c = *char_addr;
debug_log->log_start++;
spin_unlock_bh(&debug_log->lock);
error = __put_user(c, buf);
spin_lock_bh(&debug_log->lock);
buf++;
i++;
}
spin_unlock_bh(&debug_log->lock);
if (!error)
return i;
return error;
}
static unsigned int batadv_log_poll(struct file *file, poll_table *wait)
{
struct batadv_priv *bat_priv = file->private_data;
struct batadv_priv_debug_log *debug_log = bat_priv->debug_log;
poll_wait(file, &debug_log->queue_wait, wait);
if (!batadv_log_empty(debug_log))
return POLLIN | POLLRDNORM;
return 0;
}
static const struct file_operations batadv_log_fops = {
.open = batadv_log_open,
.release = batadv_log_release,
.read = batadv_log_read,
.poll = batadv_log_poll,
.llseek = no_llseek,
};
static int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{
struct dentry *d;
if (!bat_priv->debug_dir)
goto err;
bat_priv->debug_log = kzalloc(sizeof(*bat_priv->debug_log), GFP_ATOMIC);
if (!bat_priv->debug_log)
goto err;
spin_lock_init(&bat_priv->debug_log->lock);
init_waitqueue_head(&bat_priv->debug_log->queue_wait);
d = debugfs_create_file("log", S_IFREG | S_IRUSR,
bat_priv->debug_dir, bat_priv,
&batadv_log_fops);
if (!d)
goto err;
return 0;
err:
return -ENOMEM;
}
static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
{
kfree(bat_priv->debug_log);
bat_priv->debug_log = NULL;
}
#else /* CONFIG_BATMAN_ADV_DEBUG */
static int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{
return 0;
}
static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
{
}
#endif
static int batadv_algorithms_open(struct inode *inode, struct file *file) static int batadv_algorithms_open(struct inode *inode, struct file *file)
{ {
return single_open(file, batadv_algo_seq_print_text, NULL); return single_open(file, batadv_algo_seq_print_text, NULL);
......
...@@ -45,9 +45,11 @@ ...@@ -45,9 +45,11 @@
#include "hard-interface.h" #include "hard-interface.h"
#include "hash.h" #include "hash.h"
#include "log.h"
#include "originator.h" #include "originator.h"
#include "send.h" #include "send.h"
#include "translation-table.h" #include "translation-table.h"
#include "tvlv.h"
static void batadv_dat_purge(struct work_struct *work); static void batadv_dat_purge(struct work_struct *work);
......
...@@ -433,11 +433,12 @@ static struct sk_buff *batadv_frag_create(struct sk_buff *skb, ...@@ -433,11 +433,12 @@ static struct sk_buff *batadv_frag_create(struct sk_buff *skb,
* @orig_node: final destination of the created fragments * @orig_node: final destination of the created fragments
* @neigh_node: next-hop 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, int batadv_frag_send_packet(struct sk_buff *skb,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
struct batadv_neigh_node *neigh_node) struct batadv_neigh_node *neigh_node)
{ {
struct batadv_priv *bat_priv; struct batadv_priv *bat_priv;
struct batadv_hard_iface *primary_if = NULL; struct batadv_hard_iface *primary_if = NULL;
...@@ -446,7 +447,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb, ...@@ -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 mtu = neigh_node->if_incoming->net_dev->mtu;
unsigned int header_size = sizeof(frag_header); unsigned int header_size = sizeof(frag_header);
unsigned int max_fragment_size, max_packet_size; 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 /* To avoid merge and refragmentation at next-hops we never send
* fragments larger than BATADV_FRAG_MAX_FRAG_SIZE * fragments larger than BATADV_FRAG_MAX_FRAG_SIZE
...@@ -457,12 +458,12 @@ bool batadv_frag_send_packet(struct sk_buff *skb, ...@@ -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 */ /* Don't even try to fragment, if we need more than 16 fragments */
if (skb->len > max_packet_size) if (skb->len > max_packet_size)
goto out_err; goto out;
bat_priv = orig_node->bat_priv; bat_priv = orig_node->bat_priv;
primary_if = batadv_primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out_err; goto out;
/* Create one header to be copied to all fragments */ /* Create one header to be copied to all fragments */
frag_header.packet_type = BATADV_UNICAST_FRAG; frag_header.packet_type = BATADV_UNICAST_FRAG;
...@@ -488,23 +489,33 @@ bool batadv_frag_send_packet(struct sk_buff *skb, ...@@ -488,23 +489,33 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
while (skb->len > max_fragment_size) { while (skb->len > max_fragment_size) {
skb_fragment = batadv_frag_create(skb, &frag_header, mtu); skb_fragment = batadv_frag_create(skb, &frag_header, mtu);
if (!skb_fragment) if (!skb_fragment)
goto out_err; goto out;
batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX); batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX);
batadv_add_counter(bat_priv, BATADV_CNT_FRAG_TX_BYTES, batadv_add_counter(bat_priv, BATADV_CNT_FRAG_TX_BYTES,
skb_fragment->len + ETH_HLEN); 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++; frag_header.no++;
/* The initial check in this function should cover this case */ /* The initial check in this function should cover this case */
if (frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1) if (frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1) {
goto out_err; ret = -1;
goto out;
}
} }
/* Make room for the fragment header. */ /* Make room for the fragment header. */
if (batadv_skb_head_push(skb, header_size) < 0 || if (batadv_skb_head_push(skb, header_size) < 0 ||
pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 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); memcpy(skb->data, &frag_header, header_size);
...@@ -512,11 +523,9 @@ bool batadv_frag_send_packet(struct sk_buff *skb, ...@@ -512,11 +523,9 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX); batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX);
batadv_add_counter(bat_priv, BATADV_CNT_FRAG_TX_BYTES, batadv_add_counter(bat_priv, BATADV_CNT_FRAG_TX_BYTES,
skb->len + ETH_HLEN); skb->len + ETH_HLEN);
batadv_send_unicast_skb(skb, neigh_node); ret = batadv_send_unicast_skb(skb, neigh_node);
ret = true; out:
out_err:
if (primary_if) if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
......
...@@ -34,9 +34,9 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, ...@@ -34,9 +34,9 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
struct batadv_orig_node *orig_node_src); struct batadv_orig_node *orig_node_src);
bool batadv_frag_skb_buffer(struct sk_buff **skb, bool batadv_frag_skb_buffer(struct sk_buff **skb,
struct batadv_orig_node *orig_node); struct batadv_orig_node *orig_node);
bool batadv_frag_send_packet(struct sk_buff *skb, int batadv_frag_send_packet(struct sk_buff *skb,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
struct batadv_neigh_node *neigh_node); struct batadv_neigh_node *neigh_node);
/** /**
* batadv_frag_check_entry - check if a list of fragments has timed out * batadv_frag_check_entry - check if a list of fragments has timed out
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "gateway_common.h" #include "gateway_common.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "log.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "routing.h" #include "routing.h"
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include "main.h" #include "main.h"
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/errno.h>
#include <linux/byteorder/generic.h> #include <linux/byteorder/generic.h>
#include <linux/errno.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/math64.h> #include <linux/math64.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include <linux/string.h> #include <linux/string.h>
#include "gateway_client.h" #include "gateway_client.h"
#include "log.h"
#include "packet.h" #include "packet.h"
#include "tvlv.h"
/** /**
* batadv_parse_throughput - parse supplied string buffer to extract throughput * batadv_parse_throughput - parse supplied string buffer to extract throughput
......
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
#include <linux/byteorder/generic.h> #include <linux/byteorder/generic.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/if.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/if.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -37,11 +37,12 @@ ...@@ -37,11 +37,12 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "bat_algo.h" #include "bat_v.h"
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
#include "debugfs.h" #include "debugfs.h"
#include "distributed-arp-table.h" #include "distributed-arp-table.h"
#include "gateway_client.h" #include "gateway_client.h"
#include "log.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "send.h" #include "send.h"
...@@ -246,7 +247,7 @@ static void batadv_primary_if_select(struct batadv_priv *bat_priv, ...@@ -246,7 +247,7 @@ static void batadv_primary_if_select(struct batadv_priv *bat_priv,
if (!new_hard_iface) if (!new_hard_iface)
goto out; 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); batadv_primary_if_update_addr(bat_priv, curr_hard_iface);
out: out:
...@@ -393,7 +394,7 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) ...@@ -393,7 +394,7 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
bat_priv = netdev_priv(hard_iface->soft_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; hard_iface->if_status = BATADV_IF_TO_BE_ACTIVATED;
/* the first active interface becomes our primary interface or /* the first active interface becomes our primary interface or
...@@ -408,8 +409,8 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) ...@@ -408,8 +409,8 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
batadv_update_min_mtu(hard_iface->soft_iface); batadv_update_min_mtu(hard_iface->soft_iface);
if (bat_priv->bat_algo_ops->bat_iface_activate) if (bat_priv->algo_ops->iface.activate)
bat_priv->bat_algo_ops->bat_iface_activate(hard_iface); bat_priv->algo_ops->iface.activate(hard_iface);
out: out:
if (primary_if) if (primary_if)
...@@ -507,7 +508,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, ...@@ -507,7 +508,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
if (ret) if (ret)
goto err_dev; 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) if (ret < 0)
goto err_upper; goto err_upper;
...@@ -516,7 +517,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, ...@@ -516,7 +517,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
hard_iface->if_status = BATADV_IF_INACTIVE; hard_iface->if_status = BATADV_IF_INACTIVE;
ret = batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces); ret = batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
if (ret < 0) { 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--; bat_priv->num_ifaces--;
hard_iface->if_status = BATADV_IF_NOT_IN_USE; hard_iface->if_status = BATADV_IF_NOT_IN_USE;
goto err_upper; goto err_upper;
...@@ -597,7 +598,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface, ...@@ -597,7 +598,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
batadv_hardif_put(new_if); 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; hard_iface->if_status = BATADV_IF_NOT_IN_USE;
/* delete all references to this hard_iface */ /* delete all references to this hard_iface */
...@@ -782,7 +783,7 @@ static int batadv_hard_if_event(struct notifier_block *this, ...@@ -782,7 +783,7 @@ static int batadv_hard_if_event(struct notifier_block *this,
batadv_check_known_mac_addr(hard_iface->net_dev); batadv_check_known_mac_addr(hard_iface->net_dev);
bat_priv = netdev_priv(hard_iface->soft_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);
primary_if = batadv_primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <linux/wait.h> #include <linux/wait.h>
#include "hard-interface.h" #include "hard-interface.h"
#include "log.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "send.h" #include "send.h"
......
/* Copyright (C) 2010-2016 B.A.T.M.A.N. contributors:
*
* Marek Lindner
*
* 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 "log.h"
#include "main.h"
#include <linux/compiler.h>
#include <linux/debugfs.h>
#include <linux/errno.h>
#include <linux/export.h>
#include <linux/fcntl.h>
#include <linux/fs.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/poll.h>
#include <linux/sched.h> /* for linux/wait.h */
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/stat.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/wait.h>
#include <stdarg.h>
#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
static char *batadv_log_char_addr(struct batadv_priv_debug_log *debug_log,
size_t idx)
{
return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK];
}
static void batadv_emit_log_char(struct batadv_priv_debug_log *debug_log,
char c)
{
char *char_addr;
char_addr = batadv_log_char_addr(debug_log, debug_log->log_end);
*char_addr = c;
debug_log->log_end++;
if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len)
debug_log->log_start = debug_log->log_end - batadv_log_buff_len;
}
__printf(2, 3)
static int batadv_fdebug_log(struct batadv_priv_debug_log *debug_log,
const char *fmt, ...)
{
va_list args;
static char debug_log_buf[256];
char *p;
if (!debug_log)
return 0;
spin_lock_bh(&debug_log->lock);
va_start(args, fmt);
vscnprintf(debug_log_buf, sizeof(debug_log_buf), fmt, args);
va_end(args);
for (p = debug_log_buf; *p != 0; p++)
batadv_emit_log_char(debug_log, *p);
spin_unlock_bh(&debug_log->lock);
wake_up(&debug_log->queue_wait);
return 0;
}
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
{
va_list args;
char tmp_log_buf[256];
va_start(args, fmt);
vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
batadv_fdebug_log(bat_priv->debug_log, "[%10u] %s",
jiffies_to_msecs(jiffies), tmp_log_buf);
va_end(args);
return 0;
}
static int batadv_log_open(struct inode *inode, struct file *file)
{
if (!try_module_get(THIS_MODULE))
return -EBUSY;
nonseekable_open(inode, file);
file->private_data = inode->i_private;
return 0;
}
static int batadv_log_release(struct inode *inode, struct file *file)
{
module_put(THIS_MODULE);
return 0;
}
static bool batadv_log_empty(struct batadv_priv_debug_log *debug_log)
{
return !(debug_log->log_start - debug_log->log_end);
}
static ssize_t batadv_log_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct batadv_priv *bat_priv = file->private_data;
struct batadv_priv_debug_log *debug_log = bat_priv->debug_log;
int error, i = 0;
char *char_addr;
char c;
if ((file->f_flags & O_NONBLOCK) && batadv_log_empty(debug_log))
return -EAGAIN;
if (!buf)
return -EINVAL;
if (count == 0)
return 0;
if (!access_ok(VERIFY_WRITE, buf, count))
return -EFAULT;
error = wait_event_interruptible(debug_log->queue_wait,
(!batadv_log_empty(debug_log)));
if (error)
return error;
spin_lock_bh(&debug_log->lock);
while ((!error) && (i < count) &&
(debug_log->log_start != debug_log->log_end)) {
char_addr = batadv_log_char_addr(debug_log,
debug_log->log_start);
c = *char_addr;
debug_log->log_start++;
spin_unlock_bh(&debug_log->lock);
error = __put_user(c, buf);
spin_lock_bh(&debug_log->lock);
buf++;
i++;
}
spin_unlock_bh(&debug_log->lock);
if (!error)
return i;
return error;
}
static unsigned int batadv_log_poll(struct file *file, poll_table *wait)
{
struct batadv_priv *bat_priv = file->private_data;
struct batadv_priv_debug_log *debug_log = bat_priv->debug_log;
poll_wait(file, &debug_log->queue_wait, wait);
if (!batadv_log_empty(debug_log))
return POLLIN | POLLRDNORM;
return 0;
}
static const struct file_operations batadv_log_fops = {
.open = batadv_log_open,
.release = batadv_log_release,
.read = batadv_log_read,
.poll = batadv_log_poll,
.llseek = no_llseek,
};
int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{
struct dentry *d;
if (!bat_priv->debug_dir)
goto err;
bat_priv->debug_log = kzalloc(sizeof(*bat_priv->debug_log), GFP_ATOMIC);
if (!bat_priv->debug_log)
goto err;
spin_lock_init(&bat_priv->debug_log->lock);
init_waitqueue_head(&bat_priv->debug_log->queue_wait);
d = debugfs_create_file("log", S_IFREG | S_IRUSR,
bat_priv->debug_dir, bat_priv,
&batadv_log_fops);
if (!d)
goto err;
return 0;
err:
return -ENOMEM;
}
void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
{
kfree(bat_priv->debug_log);
bat_priv->debug_log = NULL;
}
/* 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 _NET_BATMAN_ADV_LOG_H_
#define _NET_BATMAN_ADV_LOG_H_
#include "main.h"
#include <linux/bitops.h>
#include <linux/compiler.h>
#include <linux/printk.h>
#ifdef CONFIG_BATMAN_ADV_DEBUG
int batadv_debug_log_setup(struct batadv_priv *bat_priv);
void batadv_debug_log_cleanup(struct batadv_priv *bat_priv);
#else
static inline int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{
return 0;
}
static inline void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
{
}
#endif
/**
* enum batadv_dbg_level - available log levels
* @BATADV_DBG_BATMAN: OGM and TQ computations related messages
* @BATADV_DBG_ROUTES: route added / changed / deleted
* @BATADV_DBG_TT: translation table messages
* @BATADV_DBG_BLA: bridge loop avoidance messages
* @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_TP_METER = BIT(7),
BATADV_DBG_ALL = 127,
};
#ifdef CONFIG_BATMAN_ADV_DEBUG
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
__printf(2, 3);
/* possibly ratelimited debug output */
#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \
do { \
if (atomic_read(&bat_priv->log_level) & type && \
(!ratelimited || net_ratelimit())) \
batadv_debug_log(bat_priv, fmt, ## arg);\
} \
while (0)
#else /* !CONFIG_BATMAN_ADV_DEBUG */
__printf(4, 5)
static inline void _batadv_dbg(int type __always_unused,
struct batadv_priv *bat_priv __always_unused,
int ratelimited __always_unused,
const char *fmt __always_unused, ...)
{
}
#endif
#define batadv_dbg(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 0, ## arg)
#define batadv_dbg_ratelimited(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 1, ## arg)
#define batadv_info(net_dev, fmt, arg...) \
do { \
struct net_device *_netdev = (net_dev); \
struct batadv_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \
pr_info("%s: " fmt, _netdev->name, ## arg); \
} while (0)
#define batadv_err(net_dev, fmt, arg...) \
do { \
struct net_device *_netdev = (net_dev); \
struct batadv_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \
pr_err("%s: " fmt, _netdev->name, ## arg); \
} while (0)
#endif /* _NET_BATMAN_ADV_LOG_H_ */
此差异已折叠。
...@@ -100,6 +100,9 @@ ...@@ -100,6 +100,9 @@
#define BATADV_NUM_BCASTS_WIRELESS 3 #define BATADV_NUM_BCASTS_WIRELESS 3
#define BATADV_NUM_BCASTS_MAX 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 */ /* msecs after which an ARP_REQUEST is sent in broadcast as fallback */
#define ARP_REQ_DELAY 250 #define ARP_REQ_DELAY 250
/* numbers of originator to contact for any PUT/GET DHT operation */ /* numbers of originator to contact for any PUT/GET DHT operation */
...@@ -131,6 +134,11 @@ ...@@ -131,6 +134,11 @@
#define BATADV_NC_NODE_TIMEOUT 10000 /* Milliseconds */ #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 { enum batadv_mesh_state {
BATADV_MESH_INACTIVE, BATADV_MESH_INACTIVE,
BATADV_MESH_ACTIVE, BATADV_MESH_ACTIVE,
...@@ -175,29 +183,26 @@ enum batadv_uev_type { ...@@ -175,29 +183,26 @@ enum batadv_uev_type {
/* Kernel headers */ /* Kernel headers */
#include <linux/atomic.h>
#include <linux/bitops.h> /* for packet.h */ #include <linux/bitops.h> /* for packet.h */
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/if_ether.h> /* for packet.h */ #include <linux/if_ether.h> /* for packet.h */
#include <linux/netdevice.h>
#include <linux/printk.h>
#include <linux/types.h>
#include <linux/percpu.h>
#include <linux/jiffies.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <linux/jiffies.h>
#include <linux/percpu.h>
#include <linux/types.h>
#include "types.h" #include "types.h"
struct batadv_ogm_packet; struct net_device;
struct packet_type;
struct seq_file; struct seq_file;
struct sk_buff; struct sk_buff;
#define BATADV_PRINT_VID(vid) ((vid & BATADV_VLAN_HAS_TAG) ? \ #define BATADV_PRINT_VID(vid) ((vid & BATADV_VLAN_HAS_TAG) ? \
(int)(vid & VLAN_VID_MASK) : -1) (int)(vid & VLAN_VID_MASK) : -1)
extern char batadv_routing_algo[];
extern struct list_head batadv_hardif_list; extern struct list_head batadv_hardif_list;
extern unsigned char batadv_broadcast_addr[]; extern unsigned char batadv_broadcast_addr[];
...@@ -218,75 +223,8 @@ batadv_recv_handler_register(u8 packet_type, ...@@ -218,75 +223,8 @@ batadv_recv_handler_register(u8 packet_type,
int (*recv_handler)(struct sk_buff *, int (*recv_handler)(struct sk_buff *,
struct batadv_hard_iface *)); struct batadv_hard_iface *));
void batadv_recv_handler_unregister(u8 packet_type); 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); __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr);
/**
* enum batadv_dbg_level - available log levels
* @BATADV_DBG_BATMAN: OGM and TQ computations related messages
* @BATADV_DBG_ROUTES: route added / changed / deleted
* @BATADV_DBG_TT: translation table messages
* @BATADV_DBG_BLA: bridge loop avoidance messages
* @BATADV_DBG_DAT: ARP snooping and DAT related messages
* @BATADV_DBG_NC: network coding related messages
* @BATADV_DBG_MCAST: multicast related 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,
};
#ifdef CONFIG_BATMAN_ADV_DEBUG
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
__printf(2, 3);
/* possibly ratelimited debug output */
#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \
do { \
if (atomic_read(&bat_priv->log_level) & type && \
(!ratelimited || net_ratelimit())) \
batadv_debug_log(bat_priv, fmt, ## arg);\
} \
while (0)
#else /* !CONFIG_BATMAN_ADV_DEBUG */
__printf(4, 5)
static inline void _batadv_dbg(int type __always_unused,
struct batadv_priv *bat_priv __always_unused,
int ratelimited __always_unused,
const char *fmt __always_unused, ...)
{
}
#endif
#define batadv_dbg(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 0, ## arg)
#define batadv_dbg_ratelimited(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 1, ## arg)
#define batadv_info(net_dev, fmt, arg...) \
do { \
struct net_device *_netdev = (net_dev); \
struct batadv_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \
pr_info("%s: " fmt, _netdev->name, ## arg); \
} while (0)
#define batadv_err(net_dev, fmt, arg...) \
do { \
struct net_device *_netdev = (net_dev); \
struct batadv_priv *_batpriv = netdev_priv(_netdev); \
batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \
pr_err("%s: " fmt, _netdev->name, ## arg); \
} while (0)
/** /**
* batadv_compare_eth - Compare two not u16 aligned Ethernet addresses * batadv_compare_eth - Compare two not u16 aligned Ethernet addresses
* @data1: Pointer to a six-byte array containing the Ethernet address * @data1: Pointer to a six-byte array containing the Ethernet address
...@@ -372,39 +310,6 @@ static inline u64 batadv_sum_counter(struct batadv_priv *bat_priv, size_t idx) ...@@ -372,39 +310,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])) #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); 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); bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid);
......
...@@ -55,8 +55,10 @@ ...@@ -55,8 +55,10 @@
#include "hard-interface.h" #include "hard-interface.h"
#include "hash.h" #include "hash.h"
#include "log.h"
#include "packet.h" #include "packet.h"
#include "translation-table.h" #include "translation-table.h"
#include "tvlv.h"
/** /**
* batadv_mcast_get_bridge - get the bridge on top of the softif if it exists * batadv_mcast_get_bridge - get the bridge on top of the softif if it exists
......
/* 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/>.
*/
#include "netlink.h"
#include "main.h"
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/genetlink.h>
#include <linux/if_ether.h>
#include <linux/init.h>
#include <linux/netdevice.h>
#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;
static struct genl_family batadv_netlink_family = {
.id = GENL_ID_GENERATE,
.hdrsize = 0,
.name = BATADV_NL_NAME,
.version = 1,
.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 },
[BATADV_ATTR_MESH_IFINDEX] = { .type = NLA_U32 },
[BATADV_ATTR_MESH_IFNAME] = { .type = NLA_STRING },
[BATADV_ATTR_MESH_ADDRESS] = { .len = ETH_ALEN },
[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 },
};
/**
* batadv_netlink_mesh_info_put - fill in generic information about mesh
* interface
* @msg: netlink message to be sent back
* @soft_iface: interface for which the data should be taken
*
* Return: 0 on success, < 0 on error
*/
static int
batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface)
{
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
struct batadv_hard_iface *primary_if = NULL;
struct net_device *hard_iface;
int ret = -ENOBUFS;
if (nla_put_string(msg, BATADV_ATTR_VERSION, BATADV_SOURCE_VERSION) ||
nla_put_string(msg, BATADV_ATTR_ALGO_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,
soft_iface->dev_addr))
goto out;
primary_if = batadv_primary_if_get_selected(bat_priv);
if (primary_if && primary_if->if_status == BATADV_IF_ACTIVE) {
hard_iface = primary_if->net_dev;
if (nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
hard_iface->ifindex) ||
nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
hard_iface->name) ||
nla_put(msg, BATADV_ATTR_HARD_ADDRESS, ETH_ALEN,
hard_iface->dev_addr))
goto out;
}
ret = 0;
out:
if (primary_if)
batadv_hardif_put(primary_if);
return ret;
}
/**
* batadv_netlink_get_mesh_info - handle incoming BATADV_CMD_GET_MESH_INFO
* netlink request
* @skb: received netlink message
* @info: receiver information
*
* Return: 0 on success, < 0 on error
*/
static int
batadv_netlink_get_mesh_info(struct sk_buff *skb, struct genl_info *info)
{
struct net *net = genl_info_net(info);
struct net_device *soft_iface;
struct sk_buff *msg = NULL;
void *msg_head;
int ifindex;
int ret;
if (!info->attrs[BATADV_ATTR_MESH_IFINDEX])
return -EINVAL;
ifindex = nla_get_u32(info->attrs[BATADV_ATTR_MESH_IFINDEX]);
if (!ifindex)
return -EINVAL;
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_GET_MESH_INFO);
if (!msg_head) {
ret = -ENOBUFS;
goto out;
}
ret = batadv_netlink_mesh_info_put(msg, soft_iface);
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_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,
.flags = GENL_ADMIN_PERM,
.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,
},
};
/**
* batadv_netlink_register - register batadv genl netlink family
*/
void __init batadv_netlink_register(void)
{
int ret;
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");
}
/**
* batadv_netlink_unregister - unregister batadv genl netlink family
*/
void batadv_netlink_unregister(void)
{
genl_unregister_family(&batadv_netlink_family);
}
/* 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"
#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_ */
...@@ -51,10 +51,12 @@ ...@@ -51,10 +51,12 @@
#include "hard-interface.h" #include "hard-interface.h"
#include "hash.h" #include "hash.h"
#include "log.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "routing.h" #include "routing.h"
#include "send.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_coding_hash_lock_class_key;
static struct lock_class_key batadv_nc_decoding_hash_lock_class_key; static struct lock_class_key batadv_nc_decoding_hash_lock_class_key;
......
...@@ -34,11 +34,13 @@ ...@@ -34,11 +34,13 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "bat_algo.h"
#include "distributed-arp-table.h" #include "distributed-arp-table.h"
#include "fragmentation.h" #include "fragmentation.h"
#include "gateway_client.h" #include "gateway_client.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "hash.h" #include "hash.h"
#include "log.h"
#include "multicast.h" #include "multicast.h"
#include "network-coding.h" #include "network-coding.h"
#include "routing.h" #include "routing.h"
...@@ -532,8 +534,8 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface, ...@@ -532,8 +534,8 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
kref_init(&hardif_neigh->refcount); kref_init(&hardif_neigh->refcount);
if (bat_priv->bat_algo_ops->bat_hardif_neigh_init) if (bat_priv->algo_ops->neigh.hardif_init)
bat_priv->bat_algo_ops->bat_hardif_neigh_init(hardif_neigh); bat_priv->algo_ops->neigh.hardif_init(hardif_neigh);
hlist_add_head(&hardif_neigh->list, &hard_iface->neigh_list); hlist_add_head(&hardif_neigh->list, &hard_iface->neigh_list);
...@@ -704,17 +706,17 @@ int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset) ...@@ -704,17 +706,17 @@ int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset)
seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n", seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n",
BATADV_SOURCE_VERSION, primary_if->net_dev->name, BATADV_SOURCE_VERSION, primary_if->net_dev->name,
primary_if->net_dev->dev_addr, net_dev->name, primary_if->net_dev->dev_addr, net_dev->name,
bat_priv->bat_algo_ops->name); bat_priv->algo_ops->name);
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (!bat_priv->bat_algo_ops->bat_neigh_print) { if (!bat_priv->algo_ops->neigh.print) {
seq_puts(seq, seq_puts(seq,
"No printing function for this routing protocol\n"); "No printing function for this routing protocol\n");
return 0; return 0;
} }
bat_priv->bat_algo_ops->bat_neigh_print(bat_priv, seq); bat_priv->algo_ops->neigh.print(bat_priv, seq);
return 0; return 0;
} }
...@@ -765,8 +767,8 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu) ...@@ -765,8 +767,8 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
batadv_frag_purge_orig(orig_node, NULL); batadv_frag_purge_orig(orig_node, NULL);
if (orig_node->bat_priv->bat_algo_ops->bat_orig_free) if (orig_node->bat_priv->algo_ops->orig.free)
orig_node->bat_priv->bat_algo_ops->bat_orig_free(orig_node); orig_node->bat_priv->algo_ops->orig.free(orig_node);
kfree(orig_node->tt_buff); kfree(orig_node->tt_buff);
kfree(orig_node); kfree(orig_node);
...@@ -1095,12 +1097,12 @@ batadv_find_best_neighbor(struct batadv_priv *bat_priv, ...@@ -1095,12 +1097,12 @@ batadv_find_best_neighbor(struct batadv_priv *bat_priv,
struct batadv_hard_iface *if_outgoing) struct batadv_hard_iface *if_outgoing)
{ {
struct batadv_neigh_node *best = NULL, *neigh; struct batadv_neigh_node *best = NULL, *neigh;
struct batadv_algo_ops *bao = bat_priv->bat_algo_ops; struct batadv_algo_ops *bao = bat_priv->algo_ops;
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(neigh, &orig_node->neigh_list, list) { hlist_for_each_entry_rcu(neigh, &orig_node->neigh_list, list) {
if (best && (bao->bat_neigh_cmp(neigh, if_outgoing, if (best && (bao->neigh.cmp(neigh, if_outgoing, best,
best, if_outgoing) <= 0)) if_outgoing) <= 0))
continue; continue;
if (!kref_get_unless_zero(&neigh->refcount)) if (!kref_get_unless_zero(&neigh->refcount))
...@@ -1252,18 +1254,17 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1252,18 +1254,17 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n", seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n",
BATADV_SOURCE_VERSION, primary_if->net_dev->name, BATADV_SOURCE_VERSION, primary_if->net_dev->name,
primary_if->net_dev->dev_addr, net_dev->name, primary_if->net_dev->dev_addr, net_dev->name,
bat_priv->bat_algo_ops->name); bat_priv->algo_ops->name);
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (!bat_priv->bat_algo_ops->bat_orig_print) { if (!bat_priv->algo_ops->orig.print) {
seq_puts(seq, seq_puts(seq,
"No printing function for this routing protocol\n"); "No printing function for this routing protocol\n");
return 0; return 0;
} }
bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq, bat_priv->algo_ops->orig.print(bat_priv, seq, BATADV_IF_DEFAULT);
BATADV_IF_DEFAULT);
return 0; return 0;
} }
...@@ -1290,7 +1291,7 @@ int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1290,7 +1291,7 @@ int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset)
} }
bat_priv = netdev_priv(hard_iface->soft_iface); bat_priv = netdev_priv(hard_iface->soft_iface);
if (!bat_priv->bat_algo_ops->bat_orig_print) { if (!bat_priv->algo_ops->orig.print) {
seq_puts(seq, seq_puts(seq,
"No printing function for this routing protocol\n"); "No printing function for this routing protocol\n");
goto out; goto out;
...@@ -1304,9 +1305,9 @@ int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1304,9 +1305,9 @@ int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset)
seq_printf(seq, "[B.A.T.M.A.N. adv %s, IF/MAC: %s/%pM (%s %s)]\n", seq_printf(seq, "[B.A.T.M.A.N. adv %s, IF/MAC: %s/%pM (%s %s)]\n",
BATADV_SOURCE_VERSION, hard_iface->net_dev->name, BATADV_SOURCE_VERSION, hard_iface->net_dev->name,
hard_iface->net_dev->dev_addr, hard_iface->net_dev->dev_addr,
hard_iface->soft_iface->name, bat_priv->bat_algo_ops->name); hard_iface->soft_iface->name, bat_priv->algo_ops->name);
bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq, hard_iface); bat_priv->algo_ops->orig.print(bat_priv, seq, hard_iface);
out: out:
if (hard_iface) if (hard_iface)
...@@ -1318,7 +1319,7 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, ...@@ -1318,7 +1319,7 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
int max_if_num) int max_if_num)
{ {
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct batadv_algo_ops *bao = bat_priv->bat_algo_ops; struct batadv_algo_ops *bao = bat_priv->algo_ops;
struct batadv_hashtable *hash = bat_priv->orig_hash; struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_head *head; struct hlist_head *head;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
...@@ -1334,9 +1335,8 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, ...@@ -1334,9 +1335,8 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(orig_node, head, hash_entry) { hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
ret = 0; ret = 0;
if (bao->bat_orig_add_if) if (bao->orig.add_if)
ret = bao->bat_orig_add_if(orig_node, ret = bao->orig.add_if(orig_node, max_if_num);
max_if_num);
if (ret == -ENOMEM) if (ret == -ENOMEM)
goto err; goto err;
} }
...@@ -1358,7 +1358,7 @@ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, ...@@ -1358,7 +1358,7 @@ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
struct hlist_head *head; struct hlist_head *head;
struct batadv_hard_iface *hard_iface_tmp; struct batadv_hard_iface *hard_iface_tmp;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
struct batadv_algo_ops *bao = bat_priv->bat_algo_ops; struct batadv_algo_ops *bao = bat_priv->algo_ops;
u32 i; u32 i;
int ret; int ret;
...@@ -1371,10 +1371,9 @@ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, ...@@ -1371,10 +1371,9 @@ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
rcu_read_lock(); rcu_read_lock();
hlist_for_each_entry_rcu(orig_node, head, hash_entry) { hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
ret = 0; ret = 0;
if (bao->bat_orig_del_if) if (bao->orig.del_if)
ret = bao->bat_orig_del_if(orig_node, ret = bao->orig.del_if(orig_node, max_if_num,
max_if_num, hard_iface->if_num);
hard_iface->if_num);
if (ret == -ENOMEM) if (ret == -ENOMEM)
goto err; goto err;
} }
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <linux/types.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 * enum batadv_packettype - types for batman-adv encapsulated packets
* @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
...@@ -93,6 +95,7 @@ enum batadv_icmp_packettype { ...@@ -93,6 +95,7 @@ enum batadv_icmp_packettype {
BATADV_ECHO_REQUEST = 8, BATADV_ECHO_REQUEST = 8,
BATADV_TTL_EXCEEDED = 11, BATADV_TTL_EXCEEDED = 11,
BATADV_PARAMETER_PROBLEM = 12, BATADV_PARAMETER_PROBLEM = 12,
BATADV_TP = 15,
}; };
/** /**
...@@ -284,6 +287,16 @@ struct batadv_elp_packet { ...@@ -284,6 +287,16 @@ struct batadv_elp_packet {
#define BATADV_ELP_HLEN sizeof(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 * struct batadv_icmp_header - common members among all the ICMP packets
* @packet_type: batman-adv packet type, part of the general header * @packet_type: batman-adv packet type, part of the general header
...@@ -334,6 +347,47 @@ struct batadv_icmp_packet { ...@@ -334,6 +347,47 @@ struct batadv_icmp_packet {
__be16 seqno; __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 #define BATADV_RR_LEN 16
/** /**
......
...@@ -40,12 +40,15 @@ ...@@ -40,12 +40,15 @@
#include "fragmentation.h" #include "fragmentation.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "icmp_socket.h" #include "icmp_socket.h"
#include "log.h"
#include "network-coding.h" #include "network-coding.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "send.h" #include "send.h"
#include "soft-interface.h" #include "soft-interface.h"
#include "tp_meter.h"
#include "translation-table.h" #include "translation-table.h"
#include "tvlv.h"
static int batadv_route_unicast_packet(struct sk_buff *skb, static int batadv_route_unicast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if); struct batadv_hard_iface *recv_if);
...@@ -268,10 +271,19 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv, ...@@ -268,10 +271,19 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
icmph->ttl = BATADV_TTL; icmph->ttl = BATADV_TTL;
res = batadv_send_skb_to_orig(skb, orig_node, NULL); res = batadv_send_skb_to_orig(skb, orig_node, NULL);
if (res != NET_XMIT_DROP) if (res == -1)
ret = NET_RX_SUCCESS; goto out;
ret = NET_RX_SUCCESS;
break; 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: default:
/* drop unknown type */ /* drop unknown type */
goto out; goto out;
...@@ -290,7 +302,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv, ...@@ -290,7 +302,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if = NULL; struct batadv_hard_iface *primary_if = NULL;
struct batadv_orig_node *orig_node = NULL; struct batadv_orig_node *orig_node = NULL;
struct batadv_icmp_packet *icmp_packet; 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; icmp_packet = (struct batadv_icmp_packet *)skb->data;
...@@ -321,7 +333,8 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv, ...@@ -321,7 +333,8 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
icmp_packet->msg_type = BATADV_TTL_EXCEEDED; icmp_packet->msg_type = BATADV_TTL_EXCEEDED;
icmp_packet->ttl = BATADV_TTL; 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; ret = NET_RX_SUCCESS;
out: out:
...@@ -341,7 +354,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, ...@@ -341,7 +354,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
struct batadv_orig_node *orig_node = NULL; struct batadv_orig_node *orig_node = NULL;
int hdr_size = sizeof(struct batadv_icmp_header); 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 */ /* drop packet if it has not necessary minimum size */
if (unlikely(!pskb_may_pull(skb, hdr_size))) if (unlikely(!pskb_may_pull(skb, hdr_size)))
...@@ -408,7 +421,8 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, ...@@ -408,7 +421,8 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
icmph->ttl--; icmph->ttl--;
/* route it */ /* 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; ret = NET_RX_SUCCESS;
out: out:
...@@ -469,7 +483,7 @@ batadv_find_router(struct batadv_priv *bat_priv, ...@@ -469,7 +483,7 @@ batadv_find_router(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
struct batadv_hard_iface *recv_if) 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 *first_candidate_router = NULL;
struct batadv_neigh_node *next_candidate_router = NULL; struct batadv_neigh_node *next_candidate_router = NULL;
struct batadv_neigh_node *router, *cand_router = NULL; struct batadv_neigh_node *router, *cand_router = NULL;
...@@ -523,9 +537,9 @@ batadv_find_router(struct batadv_priv *bat_priv, ...@@ -523,9 +537,9 @@ batadv_find_router(struct batadv_priv *bat_priv,
/* alternative candidate should be good enough to be /* alternative candidate should be good enough to be
* considered * considered
*/ */
if (!bao->bat_neigh_is_similar_or_better(cand_router, if (!bao->neigh.is_similar_or_better(cand_router,
cand->if_outgoing, cand->if_outgoing, router,
router, recv_if)) recv_if))
goto next; goto next;
/* don't use the same router twice */ /* don't use the same router twice */
...@@ -645,6 +659,8 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, ...@@ -645,6 +659,8 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
len = skb->len; len = skb->len;
res = batadv_send_skb_to_orig(skb, orig_node, recv_if); res = batadv_send_skb_to_orig(skb, orig_node, recv_if);
if (res == -1)
goto out;
/* translate transmit result into receive result */ /* translate transmit result into receive result */
if (res == NET_XMIT_SUCCESS) { if (res == NET_XMIT_SUCCESS) {
...@@ -652,13 +668,10 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, ...@@ -652,13 +668,10 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD); batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES, batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
len + ETH_HLEN); 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: out:
if (orig_node) if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
......
...@@ -20,10 +20,11 @@ ...@@ -20,10 +20,11 @@
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/byteorder/generic.h> #include <linux/byteorder/generic.h>
#include <linux/errno.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/if_ether.h>
#include <linux/if.h> #include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/kref.h> #include <linux/kref.h>
...@@ -42,6 +43,7 @@ ...@@ -42,6 +43,7 @@
#include "fragmentation.h" #include "fragmentation.h"
#include "gateway_client.h" #include "gateway_client.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "log.h"
#include "network-coding.h" #include "network-coding.h"
#include "originator.h" #include "originator.h"
#include "routing.h" #include "routing.h"
...@@ -71,6 +73,7 @@ int batadv_send_skb_packet(struct sk_buff *skb, ...@@ -71,6 +73,7 @@ int batadv_send_skb_packet(struct sk_buff *skb,
{ {
struct batadv_priv *bat_priv; struct batadv_priv *bat_priv;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
int ret;
bat_priv = netdev_priv(hard_iface->soft_iface); bat_priv = netdev_priv(hard_iface->soft_iface);
...@@ -108,8 +111,15 @@ int batadv_send_skb_packet(struct sk_buff *skb, ...@@ -108,8 +111,15 @@ int batadv_send_skb_packet(struct sk_buff *skb,
/* dev_queue_xmit() returns a negative result on error. However on /* dev_queue_xmit() returns a negative result on error. However on
* congestion and traffic shaping, it drops and returns NET_XMIT_DROP * congestion and traffic shaping, it drops and returns NET_XMIT_DROP
* (which is > 0). This will not be treated as an error. * (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: send_skb_err:
kfree_skb(skb); kfree_skb(skb);
return NET_XMIT_DROP; return NET_XMIT_DROP;
...@@ -155,8 +165,11 @@ int batadv_send_unicast_skb(struct sk_buff *skb, ...@@ -155,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 * host, NULL can be passed as recv_if and no interface alternating is
* attempted. * attempted.
* *
* Return: NET_XMIT_SUCCESS on success, NET_XMIT_DROP on failure, or * Return: -1 on failure (and the skb is not consumed), -EINPROGRESS if the
* -EINPROGRESS if the skb is buffered for later transmit. * 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, int batadv_send_skb_to_orig(struct sk_buff *skb,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
...@@ -164,7 +177,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb, ...@@ -164,7 +177,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb,
{ {
struct batadv_priv *bat_priv = orig_node->bat_priv; struct batadv_priv *bat_priv = orig_node->bat_priv;
struct batadv_neigh_node *neigh_node; struct batadv_neigh_node *neigh_node;
int ret = NET_XMIT_DROP; int ret = -1;
/* batadv_find_router() increases neigh_nodes refcount if found. */ /* batadv_find_router() increases neigh_nodes refcount if found. */
neigh_node = batadv_find_router(bat_priv, orig_node, recv_if); neigh_node = batadv_find_router(bat_priv, orig_node, recv_if);
...@@ -177,8 +190,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb, ...@@ -177,8 +190,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb,
if (atomic_read(&bat_priv->fragmentation) && if (atomic_read(&bat_priv->fragmentation) &&
skb->len > neigh_node->if_incoming->net_dev->mtu) { skb->len > neigh_node->if_incoming->net_dev->mtu) {
/* Fragment and send packet. */ /* Fragment and send packet. */
if (batadv_frag_send_packet(skb, orig_node, neigh_node)) ret = batadv_frag_send_packet(skb, orig_node, neigh_node);
ret = NET_XMIT_SUCCESS;
goto out; goto out;
} }
...@@ -187,12 +199,10 @@ int batadv_send_skb_to_orig(struct sk_buff *skb, ...@@ -187,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 * (i.e. being forwarded). If the packet originates from this node or if
* network coding fails, then send the packet as usual. * 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; ret = -EINPROGRESS;
} else { else
batadv_send_unicast_skb(skb, neigh_node); ret = batadv_send_unicast_skb(skb, neigh_node);
ret = NET_XMIT_SUCCESS;
}
out: out:
if (neigh_node) if (neigh_node)
...@@ -318,7 +328,7 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv, ...@@ -318,7 +328,7 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
{ {
struct batadv_unicast_packet *unicast_packet; struct batadv_unicast_packet *unicast_packet;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
int ret = NET_XMIT_DROP; int res, ret = NET_XMIT_DROP;
if (!orig_node) if (!orig_node)
goto out; goto out;
...@@ -355,7 +365,8 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv, ...@@ -355,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)) if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest, vid))
unicast_packet->ttvn = unicast_packet->ttvn - 1; 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; ret = NET_XMIT_SUCCESS;
out: out:
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "bat_algo.h"
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
#include "debugfs.h" #include "debugfs.h"
#include "distributed-arp-table.h" #include "distributed-arp-table.h"
...@@ -841,6 +842,8 @@ static int batadv_softif_init_late(struct net_device *dev) ...@@ -841,6 +842,8 @@ static int batadv_softif_init_late(struct net_device *dev)
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
atomic_set(&bat_priv->bla.num_requests, 0); atomic_set(&bat_priv->bla.num_requests, 0);
#endif #endif
atomic_set(&bat_priv->tp_num, 0);
bat_priv->tt.last_changeset = NULL; bat_priv->tt.last_changeset = NULL;
bat_priv->tt.last_changeset_len = 0; bat_priv->tt.last_changeset_len = 0;
bat_priv->isolation_mark = 0; bat_priv->isolation_mark = 0;
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/if.h> #include <linux/if.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <linux/kref.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/printk.h> #include <linux/printk.h>
#include <linux/rculist.h> #include <linux/rculist.h>
...@@ -38,11 +38,12 @@ ...@@ -38,11 +38,12 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include "bridge_loop_avoidance.h"
#include "distributed-arp-table.h" #include "distributed-arp-table.h"
#include "gateway_client.h" #include "gateway_client.h"
#include "gateway_common.h" #include "gateway_common.h"
#include "bridge_loop_avoidance.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "log.h"
#include "network-coding.h" #include "network-coding.h"
#include "packet.h" #include "packet.h"
#include "soft-interface.h" #include "soft-interface.h"
...@@ -411,7 +412,7 @@ static ssize_t batadv_show_bat_algo(struct kobject *kobj, ...@@ -411,7 +412,7 @@ static ssize_t batadv_show_bat_algo(struct kobject *kobj,
{ {
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(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) static void batadv_post_gw_reselect(struct net_device *net_dev)
......
此差异已折叠。
/* 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_ */
...@@ -47,10 +47,12 @@ ...@@ -47,10 +47,12 @@
#include "bridge_loop_avoidance.h" #include "bridge_loop_avoidance.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "hash.h" #include "hash.h"
#include "log.h"
#include "multicast.h" #include "multicast.h"
#include "originator.h" #include "originator.h"
#include "packet.h" #include "packet.h"
#include "soft-interface.h" #include "soft-interface.h"
#include "tvlv.h"
/* hash class keys */ /* hash class keys */
static struct lock_class_key batadv_tt_local_hash_lock_class_key; static struct lock_class_key batadv_tt_local_hash_lock_class_key;
...@@ -1545,7 +1547,7 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv, ...@@ -1545,7 +1547,7 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv,
struct batadv_tt_global_entry *tt_global_entry) struct batadv_tt_global_entry *tt_global_entry)
{ {
struct batadv_neigh_node *router, *best_router = NULL; 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 hlist_head *head;
struct batadv_tt_orig_list_entry *orig_entry, *best_entry = NULL; struct batadv_tt_orig_list_entry *orig_entry, *best_entry = NULL;
...@@ -1557,8 +1559,8 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv, ...@@ -1557,8 +1559,8 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv,
continue; continue;
if (best_router && if (best_router &&
bao->bat_neigh_cmp(router, BATADV_IF_DEFAULT, bao->neigh.cmp(router, BATADV_IF_DEFAULT, best_router,
best_router, BATADV_IF_DEFAULT) <= 0) { BATADV_IF_DEFAULT) <= 0) {
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
continue; continue;
} }
......
此差异已折叠。
/* 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 _NET_BATMAN_ADV_TVLV_H_
#define _NET_BATMAN_ADV_TVLV_H_
#include "main.h"
#include <linux/types.h>
struct batadv_ogm_packet;
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);
#endif /* _NET_BATMAN_ADV_TVLV_H_ */
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册