You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking changes from David S Miller:
1) Remove the ipv4 routing cache. Now lookups go directly into the FIB
trie and use prebuilt routes cached there.
No more garbage collection, no more rDOS attacks on the routing
cache. Instead we now get predictable and consistent performance,
no matter what the pattern of traffic we service.
This has been almost 2 years in the making. Special thanks to
Julian Anastasov, Eric Dumazet, Steffen Klassert, and others who
have helped along the way.
I'm sure that with a change of this magnitude there will be some
kind of fallout, but such things ought the be simple to fix at this
point. Luckily I'm not European so I'll be around all of August to
fix things :-)
The major stages of this work here are each fronted by a forced
merge commit whose commit message contains a top-level description
of the motivations and implementation issues.
2) Pre-demux of established ipv4 TCP sockets, saves a route demux on
input.
3) TCP SYN/ACK performance tweaks from Eric Dumazet.
4) Add namespace support for netfilter L4 conntrack helpers, from Gao
Feng.
5) Add config mechanism for Energy Efficient Ethernet to ethtool, from
Yuval Mintz.
6) Remove quadratic behavior from /proc/net/unix, from Eric Dumazet.
7) Support for connection tracker helpers in userspace, from Pablo
Neira Ayuso.
8) Allow userspace driven TX load balancing functions in TEAM driver,
from Jiri Pirko.
9) Kill off NLMSG_PUT and RTA_PUT macros, more gross stuff with
embedded gotos.
10) TCP Small Queues, essentially minimize the amount of TCP data queued
up in the packet scheduler layer. Whereas the existing BQL (Byte
Queue Limits) limits the pkt_sched --> netdevice queuing levels,
this controls the TCP --> pkt_sched queueing levels.
From Eric Dumazet.
11) Reduce the number of get_page/put_page ops done on SKB fragments,
from Alexander Duyck.
12) Implement protection against blind resets in TCP (RFC 5961), from
Eric Dumazet.
13) Support the client side of TCP Fast Open, basically the ability to
send data in the SYN exchange, from Yuchung Cheng.
Basically, the sender queues up data with a sendmsg() call using
MSG_FASTOPEN, then they do the connect() which emits the queued up
fastopen data.
14) Avoid all the problems we get into in TCP when timers or PMTU events
hit a locked socket. The TCP Small Queues changes added a
tcp_release_cb() that allows us to queue work up to the
release_sock() caller, and that's what we use here too. From Eric
Dumazet.
15) Zero copy on TX support for TUN driver, from Michael S. Tsirkin.
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1870 commits)
genetlink: define lockdep_genl_is_held() when CONFIG_LOCKDEP
r8169: revert "add byte queue limit support".
ipv4: Change rt->rt_iif encoding.
net: Make skb->skb_iif always track skb->dev
ipv4: Prepare for change of rt->rt_iif encoding.
ipv4: Remove all RTCF_DIRECTSRC handliing.
ipv4: Really ignore ICMP address requests/replies.
decnet: Don't set RTCF_DIRECTSRC.
net/ipv4/ip_vti.c: Fix __rcu warnings detected by sparse.
ipv4: Remove redundant assignment
rds: set correct msg_namelen
openvswitch: potential NULL deref in sample()
tcp: dont drop MTU reduction indications
bnx2x: Add new 57840 device IDs
tcp: avoid oops in tcp_metrics and reset tcpm_stamp
niu: Change niu_rbr_fill() to use unlikely() to check niu_rbr_add_page() return value
niu: Fix to check for dma mapping errors.
net: Fix references to out-of-scope variables in put_cmsg_compat()
net: ethernet: davinci_emac: add pm_runtime support
net: ethernet: davinci_emac: Remove unnecessary #include
...
This commit is contained in:
@@ -681,10 +681,7 @@ static int vlan_dev_netpoll_setup(struct net_device *dev, struct netpoll_info *n
|
||||
if (!netpoll)
|
||||
goto out;
|
||||
|
||||
netpoll->dev = real_dev;
|
||||
strlcpy(netpoll->dev_name, real_dev->name, IFNAMSIZ);
|
||||
|
||||
err = __netpoll_setup(netpoll);
|
||||
err = __netpoll_setup(netpoll, real_dev);
|
||||
if (err) {
|
||||
kfree(netpoll);
|
||||
goto out;
|
||||
|
||||
+1
-1
@@ -1548,7 +1548,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
|
||||
kernel_buf = 1;
|
||||
indata = data;
|
||||
} else
|
||||
indata = (char *)udata;
|
||||
indata = (__force char *)udata;
|
||||
/*
|
||||
* response header len is 11
|
||||
* PDU Header(7) + IO Size (4)
|
||||
|
||||
@@ -212,7 +212,7 @@ static int p9_virtio_cancel(struct p9_client *client, struct p9_req_t *req)
|
||||
* this takes a list of pages.
|
||||
* @sg: scatter/gather list to pack into
|
||||
* @start: which segment of the sg_list to start at
|
||||
* @**pdata: a list of pages to add into sg.
|
||||
* @pdata: a list of pages to add into sg.
|
||||
* @nr_pages: number of pages to pack into the scatter/gather list
|
||||
* @data: data to pack into scatter/gather list
|
||||
* @count: amount of data to pack into the scatter/gather list
|
||||
|
||||
+4
-4
@@ -129,8 +129,8 @@ found:
|
||||
|
||||
/**
|
||||
* atalk_find_or_insert_socket - Try to find a socket matching ADDR
|
||||
* @sk - socket to insert in the list if it is not there already
|
||||
* @sat - address to search for
|
||||
* @sk: socket to insert in the list if it is not there already
|
||||
* @sat: address to search for
|
||||
*
|
||||
* Try to find a socket matching ADDR in the socket list, if found then return
|
||||
* it. If not, insert SK into the socket list.
|
||||
@@ -1066,8 +1066,8 @@ static int atalk_release(struct socket *sock)
|
||||
|
||||
/**
|
||||
* atalk_pick_and_bind_port - Pick a source port when one is not given
|
||||
* @sk - socket to insert into the tables
|
||||
* @sat - address to search for
|
||||
* @sk: socket to insert into the tables
|
||||
* @sat: address to search for
|
||||
*
|
||||
* Pick a source port when one is not given. If we can find a suitable free
|
||||
* one, we insert the socket into the tables using it.
|
||||
|
||||
+5
-3
@@ -231,9 +231,11 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
|
||||
if (skb_headroom(skb) < 2) {
|
||||
pr_debug("reallocating skb\n");
|
||||
skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
|
||||
kfree_skb(skb);
|
||||
if (skb2 == NULL)
|
||||
if (unlikely(!skb2)) {
|
||||
kfree_skb(skb);
|
||||
return NETDEV_TX_OK;
|
||||
}
|
||||
consume_skb(skb);
|
||||
skb = skb2;
|
||||
}
|
||||
skb_push(skb, 2);
|
||||
@@ -1602,7 +1604,7 @@ static void lec_arp_expire_vcc(unsigned long data)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct lec_arp_table *to_remove = (struct lec_arp_table *)data;
|
||||
struct lec_priv *priv = (struct lec_priv *)to_remove->priv;
|
||||
struct lec_priv *priv = to_remove->priv;
|
||||
|
||||
del_timer(&to_remove->timer);
|
||||
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb)
|
||||
kfree_skb(n);
|
||||
goto nospace;
|
||||
}
|
||||
kfree_skb(skb);
|
||||
consume_skb(skb);
|
||||
skb = n;
|
||||
if (skb == NULL)
|
||||
return DROP_PACKET;
|
||||
|
||||
@@ -189,8 +189,10 @@ const unsigned char *ax25_addr_parse(const unsigned char *buf, int len,
|
||||
digi->ndigi = 0;
|
||||
|
||||
while (!(buf[-1] & AX25_EBIT)) {
|
||||
if (d >= AX25_MAX_DIGIS) return NULL; /* Max of 6 digis */
|
||||
if (len < 7) return NULL; /* Short packet */
|
||||
if (d >= AX25_MAX_DIGIS)
|
||||
return NULL;
|
||||
if (len < AX25_ADDR_LEN)
|
||||
return NULL;
|
||||
|
||||
memcpy(&digi->calls[d], buf, AX25_ADDR_LEN);
|
||||
digi->ndigi = d + 1;
|
||||
|
||||
+1
-1
@@ -350,7 +350,7 @@ void ax25_transmit_buffer(ax25_cb *ax25, struct sk_buff *skb, int type)
|
||||
if (skb->sk != NULL)
|
||||
skb_set_owner_w(skbn, skb->sk);
|
||||
|
||||
kfree_skb(skb);
|
||||
consume_skb(skb);
|
||||
skb = skbn;
|
||||
}
|
||||
|
||||
|
||||
@@ -474,7 +474,7 @@ struct sk_buff *ax25_rt_build_path(struct sk_buff *skb, ax25_address *src,
|
||||
if (skb->sk != NULL)
|
||||
skb_set_owner_w(skbn, skb->sk);
|
||||
|
||||
kfree_skb(skb);
|
||||
consume_skb(skb);
|
||||
|
||||
skb = skbn;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,10 @@
|
||||
#
|
||||
|
||||
obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
|
||||
batman-adv-y += bat_debugfs.o
|
||||
batman-adv-y += bat_iv_ogm.o
|
||||
batman-adv-y += bat_sysfs.o
|
||||
batman-adv-y += bitarray.o
|
||||
batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o
|
||||
batman-adv-y += debugfs.o
|
||||
batman-adv-y += gateway_client.o
|
||||
batman-adv-y += gateway_common.o
|
||||
batman-adv-y += hard-interface.o
|
||||
@@ -35,6 +34,7 @@ batman-adv-y += ring_buffer.o
|
||||
batman-adv-y += routing.o
|
||||
batman-adv-y += send.o
|
||||
batman-adv-y += soft-interface.o
|
||||
batman-adv-y += sysfs.o
|
||||
batman-adv-y += translation-table.o
|
||||
batman-adv-y += unicast.o
|
||||
batman-adv-y += vis.o
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
|
||||
/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
|
||||
*
|
||||
* Marek Lindner
|
||||
*
|
||||
@@ -16,12 +15,11 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NET_BATMAN_ADV_BAT_ALGO_H_
|
||||
#define _NET_BATMAN_ADV_BAT_ALGO_H_
|
||||
|
||||
int bat_iv_init(void);
|
||||
int batadv_iv_init(void);
|
||||
|
||||
#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */
|
||||
|
||||
@@ -1,388 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2012 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
#include "bat_debugfs.h"
|
||||
#include "translation-table.h"
|
||||
#include "originator.h"
|
||||
#include "hard-interface.h"
|
||||
#include "gateway_common.h"
|
||||
#include "gateway_client.h"
|
||||
#include "soft-interface.h"
|
||||
#include "vis.h"
|
||||
#include "icmp_socket.h"
|
||||
#include "bridge_loop_avoidance.h"
|
||||
|
||||
static struct dentry *bat_debugfs;
|
||||
|
||||
#ifdef CONFIG_BATMAN_ADV_DEBUG
|
||||
#define LOG_BUFF_MASK (log_buff_len-1)
|
||||
#define LOG_BUFF(idx) (debug_log->log_buff[(idx) & LOG_BUFF_MASK])
|
||||
|
||||
static int log_buff_len = LOG_BUF_LEN;
|
||||
|
||||
static void emit_log_char(struct debug_log *debug_log, char c)
|
||||
{
|
||||
LOG_BUFF(debug_log->log_end) = c;
|
||||
debug_log->log_end++;
|
||||
|
||||
if (debug_log->log_end - debug_log->log_start > log_buff_len)
|
||||
debug_log->log_start = debug_log->log_end - log_buff_len;
|
||||
}
|
||||
|
||||
__printf(2, 3)
|
||||
static int fdebug_log(struct 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++)
|
||||
emit_log_char(debug_log, *p);
|
||||
|
||||
spin_unlock_bh(&debug_log->lock);
|
||||
|
||||
wake_up(&debug_log->queue_wait);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int debug_log(struct bat_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);
|
||||
fdebug_log(bat_priv->debug_log, "[%10u] %s",
|
||||
jiffies_to_msecs(jiffies), tmp_log_buf);
|
||||
va_end(args);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int log_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
nonseekable_open(inode, file);
|
||||
file->private_data = inode->i_private;
|
||||
inc_module_count();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int log_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
dec_module_count();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t log_read(struct file *file, char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct bat_priv *bat_priv = file->private_data;
|
||||
struct debug_log *debug_log = bat_priv->debug_log;
|
||||
int error, i = 0;
|
||||
char c;
|
||||
|
||||
if ((file->f_flags & O_NONBLOCK) &&
|
||||
!(debug_log->log_end - debug_log->log_start))
|
||||
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,
|
||||
(debug_log->log_start - debug_log->log_end));
|
||||
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
spin_lock_bh(&debug_log->lock);
|
||||
|
||||
while ((!error) && (i < count) &&
|
||||
(debug_log->log_start != debug_log->log_end)) {
|
||||
c = LOG_BUFF(debug_log->log_start);
|
||||
|
||||
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 log_poll(struct file *file, poll_table *wait)
|
||||
{
|
||||
struct bat_priv *bat_priv = file->private_data;
|
||||
struct debug_log *debug_log = bat_priv->debug_log;
|
||||
|
||||
poll_wait(file, &debug_log->queue_wait, wait);
|
||||
|
||||
if (debug_log->log_end - debug_log->log_start)
|
||||
return POLLIN | POLLRDNORM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct file_operations log_fops = {
|
||||
.open = log_open,
|
||||
.release = log_release,
|
||||
.read = log_read,
|
||||
.poll = log_poll,
|
||||
.llseek = no_llseek,
|
||||
};
|
||||
|
||||
static int debug_log_setup(struct bat_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, &log_fops);
|
||||
if (d)
|
||||
goto err;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void debug_log_cleanup(struct bat_priv *bat_priv)
|
||||
{
|
||||
kfree(bat_priv->debug_log);
|
||||
bat_priv->debug_log = NULL;
|
||||
}
|
||||
#else /* CONFIG_BATMAN_ADV_DEBUG */
|
||||
static int debug_log_setup(struct bat_priv *bat_priv)
|
||||
{
|
||||
bat_priv->debug_log = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void debug_log_cleanup(struct bat_priv *bat_priv)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int bat_algorithms_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, bat_algo_seq_print_text, NULL);
|
||||
}
|
||||
|
||||
static int originators_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, orig_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
static int gateways_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, gw_client_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
static int transtable_global_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, tt_global_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BATMAN_ADV_BLA
|
||||
static int bla_claim_table_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, bla_claim_table_seq_print_text, net_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int transtable_local_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, tt_local_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
static int vis_data_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, vis_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
struct bat_debuginfo {
|
||||
struct attribute attr;
|
||||
const struct file_operations fops;
|
||||
};
|
||||
|
||||
#define BAT_DEBUGINFO(_name, _mode, _open) \
|
||||
struct bat_debuginfo bat_debuginfo_##_name = { \
|
||||
.attr = { .name = __stringify(_name), \
|
||||
.mode = _mode, }, \
|
||||
.fops = { .owner = THIS_MODULE, \
|
||||
.open = _open, \
|
||||
.read = seq_read, \
|
||||
.llseek = seq_lseek, \
|
||||
.release = single_release, \
|
||||
} \
|
||||
};
|
||||
|
||||
static BAT_DEBUGINFO(routing_algos, S_IRUGO, bat_algorithms_open);
|
||||
static BAT_DEBUGINFO(originators, S_IRUGO, originators_open);
|
||||
static BAT_DEBUGINFO(gateways, S_IRUGO, gateways_open);
|
||||
static BAT_DEBUGINFO(transtable_global, S_IRUGO, transtable_global_open);
|
||||
#ifdef CONFIG_BATMAN_ADV_BLA
|
||||
static BAT_DEBUGINFO(bla_claim_table, S_IRUGO, bla_claim_table_open);
|
||||
#endif
|
||||
static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open);
|
||||
static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open);
|
||||
|
||||
static struct bat_debuginfo *mesh_debuginfos[] = {
|
||||
&bat_debuginfo_originators,
|
||||
&bat_debuginfo_gateways,
|
||||
&bat_debuginfo_transtable_global,
|
||||
#ifdef CONFIG_BATMAN_ADV_BLA
|
||||
&bat_debuginfo_bla_claim_table,
|
||||
#endif
|
||||
&bat_debuginfo_transtable_local,
|
||||
&bat_debuginfo_vis_data,
|
||||
NULL,
|
||||
};
|
||||
|
||||
void debugfs_init(void)
|
||||
{
|
||||
struct bat_debuginfo *bat_debug;
|
||||
struct dentry *file;
|
||||
|
||||
bat_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL);
|
||||
if (bat_debugfs == ERR_PTR(-ENODEV))
|
||||
bat_debugfs = NULL;
|
||||
|
||||
if (!bat_debugfs)
|
||||
goto out;
|
||||
|
||||
bat_debug = &bat_debuginfo_routing_algos;
|
||||
file = debugfs_create_file(bat_debug->attr.name,
|
||||
S_IFREG | bat_debug->attr.mode,
|
||||
bat_debugfs, NULL, &bat_debug->fops);
|
||||
if (!file)
|
||||
pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name);
|
||||
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
||||
void debugfs_destroy(void)
|
||||
{
|
||||
if (bat_debugfs) {
|
||||
debugfs_remove_recursive(bat_debugfs);
|
||||
bat_debugfs = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int debugfs_add_meshif(struct net_device *dev)
|
||||
{
|
||||
struct bat_priv *bat_priv = netdev_priv(dev);
|
||||
struct bat_debuginfo **bat_debug;
|
||||
struct dentry *file;
|
||||
|
||||
if (!bat_debugfs)
|
||||
goto out;
|
||||
|
||||
bat_priv->debug_dir = debugfs_create_dir(dev->name, bat_debugfs);
|
||||
if (!bat_priv->debug_dir)
|
||||
goto out;
|
||||
|
||||
bat_socket_setup(bat_priv);
|
||||
debug_log_setup(bat_priv);
|
||||
|
||||
for (bat_debug = mesh_debuginfos; *bat_debug; ++bat_debug) {
|
||||
file = debugfs_create_file(((*bat_debug)->attr).name,
|
||||
S_IFREG | ((*bat_debug)->attr).mode,
|
||||
bat_priv->debug_dir,
|
||||
dev, &(*bat_debug)->fops);
|
||||
if (!file) {
|
||||
bat_err(dev, "Can't add debugfs file: %s/%s\n",
|
||||
dev->name, ((*bat_debug)->attr).name);
|
||||
goto rem_attr;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
rem_attr:
|
||||
debugfs_remove_recursive(bat_priv->debug_dir);
|
||||
bat_priv->debug_dir = NULL;
|
||||
out:
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
return -ENOMEM;
|
||||
#else
|
||||
return 0;
|
||||
#endif /* CONFIG_DEBUG_FS */
|
||||
}
|
||||
|
||||
void debugfs_del_meshif(struct net_device *dev)
|
||||
{
|
||||
struct bat_priv *bat_priv = netdev_priv(dev);
|
||||
|
||||
debug_log_cleanup(bat_priv);
|
||||
|
||||
if (bat_debugfs) {
|
||||
debugfs_remove_recursive(bat_priv->debug_dir);
|
||||
bat_priv->debug_dir = NULL;
|
||||
}
|
||||
}
|
||||
+558
-500
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+31
-34
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
|
||||
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
|
||||
*
|
||||
* Simon Wunderlich, Marek Lindner
|
||||
*
|
||||
@@ -16,7 +15,6 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
@@ -25,12 +23,12 @@
|
||||
#include <linux/bitops.h>
|
||||
|
||||
/* shift the packet array by n places. */
|
||||
static void bat_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
|
||||
static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
|
||||
{
|
||||
if (n <= 0 || n >= TQ_LOCAL_WINDOW_SIZE)
|
||||
if (n <= 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
|
||||
return;
|
||||
|
||||
bitmap_shift_left(seq_bits, seq_bits, n, TQ_LOCAL_WINDOW_SIZE);
|
||||
bitmap_shift_left(seq_bits, seq_bits, n, BATADV_TQ_LOCAL_WINDOW_SIZE);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,58 +38,57 @@ static void bat_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
|
||||
* 1 if the window was moved (either new or very old)
|
||||
* 0 if the window was not moved/shifted.
|
||||
*/
|
||||
int bit_get_packet(void *priv, unsigned long *seq_bits,
|
||||
int32_t seq_num_diff, int set_mark)
|
||||
int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
|
||||
int32_t seq_num_diff, int set_mark)
|
||||
{
|
||||
struct bat_priv *bat_priv = priv;
|
||||
struct batadv_priv *bat_priv = priv;
|
||||
|
||||
/* sequence number is slightly older. We already got a sequence number
|
||||
* higher than this one, so we just mark it. */
|
||||
|
||||
if ((seq_num_diff <= 0) && (seq_num_diff > -TQ_LOCAL_WINDOW_SIZE)) {
|
||||
* higher than this one, so we just mark it.
|
||||
*/
|
||||
if (seq_num_diff <= 0 && seq_num_diff > -BATADV_TQ_LOCAL_WINDOW_SIZE) {
|
||||
if (set_mark)
|
||||
bat_set_bit(seq_bits, -seq_num_diff);
|
||||
batadv_set_bit(seq_bits, -seq_num_diff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* sequence number is slightly newer, so we shift the window and
|
||||
* set the mark if required */
|
||||
|
||||
if ((seq_num_diff > 0) && (seq_num_diff < TQ_LOCAL_WINDOW_SIZE)) {
|
||||
bat_bitmap_shift_left(seq_bits, seq_num_diff);
|
||||
* set the mark if required
|
||||
*/
|
||||
if (seq_num_diff > 0 && seq_num_diff < BATADV_TQ_LOCAL_WINDOW_SIZE) {
|
||||
batadv_bitmap_shift_left(seq_bits, seq_num_diff);
|
||||
|
||||
if (set_mark)
|
||||
bat_set_bit(seq_bits, 0);
|
||||
batadv_set_bit(seq_bits, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* sequence number is much newer, probably missed a lot of packets */
|
||||
|
||||
if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) &&
|
||||
(seq_num_diff < EXPECTED_SEQNO_RANGE)) {
|
||||
bat_dbg(DBG_BATMAN, bat_priv,
|
||||
"We missed a lot of packets (%i) !\n",
|
||||
seq_num_diff - 1);
|
||||
bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE);
|
||||
if (seq_num_diff >= BATADV_TQ_LOCAL_WINDOW_SIZE &&
|
||||
seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) {
|
||||
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
|
||||
"We missed a lot of packets (%i) !\n",
|
||||
seq_num_diff - 1);
|
||||
bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
|
||||
if (set_mark)
|
||||
bat_set_bit(seq_bits, 0);
|
||||
batadv_set_bit(seq_bits, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* received a much older packet. The other host either restarted
|
||||
* or the old packet got delayed somewhere in the network. The
|
||||
* packet should be dropped without calling this function if the
|
||||
* seqno window is protected. */
|
||||
* seqno window is protected.
|
||||
*/
|
||||
if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
|
||||
seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
|
||||
|
||||
if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) ||
|
||||
(seq_num_diff >= EXPECTED_SEQNO_RANGE)) {
|
||||
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
|
||||
"Other host probably restarted!\n");
|
||||
|
||||
bat_dbg(DBG_BATMAN, bat_priv,
|
||||
"Other host probably restarted!\n");
|
||||
|
||||
bitmap_zero(seq_bits, TQ_LOCAL_WINDOW_SIZE);
|
||||
bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
|
||||
if (set_mark)
|
||||
bat_set_bit(seq_bits, 0);
|
||||
batadv_set_bit(seq_bits, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
+12
-12
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
|
||||
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors:
|
||||
*
|
||||
* Simon Wunderlich, Marek Lindner
|
||||
*
|
||||
@@ -16,39 +15,40 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NET_BATMAN_ADV_BITARRAY_H_
|
||||
#define _NET_BATMAN_ADV_BITARRAY_H_
|
||||
|
||||
/* returns true if the corresponding bit in the given seq_bits indicates true
|
||||
* and curr_seqno is within range of last_seqno */
|
||||
static inline int bat_test_bit(const unsigned long *seq_bits,
|
||||
uint32_t last_seqno, uint32_t curr_seqno)
|
||||
* and curr_seqno is within range of last_seqno
|
||||
*/
|
||||
static inline int batadv_test_bit(const unsigned long *seq_bits,
|
||||
uint32_t last_seqno, uint32_t curr_seqno)
|
||||
{
|
||||
int32_t diff;
|
||||
|
||||
diff = last_seqno - curr_seqno;
|
||||
if (diff < 0 || diff >= TQ_LOCAL_WINDOW_SIZE)
|
||||
if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE)
|
||||
return 0;
|
||||
else
|
||||
return test_bit(diff, seq_bits);
|
||||
}
|
||||
|
||||
/* turn corresponding bit on, so we can remember that we got the packet */
|
||||
static inline void bat_set_bit(unsigned long *seq_bits, int32_t n)
|
||||
static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n)
|
||||
{
|
||||
/* if too old, just drop it */
|
||||
if (n < 0 || n >= TQ_LOCAL_WINDOW_SIZE)
|
||||
if (n < 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
|
||||
return;
|
||||
|
||||
set_bit(n, seq_bits); /* turn the position on */
|
||||
}
|
||||
|
||||
/* receive and process one packet, returns 1 if received seq_num is considered
|
||||
* new, 0 if old */
|
||||
int bit_get_packet(void *priv, unsigned long *seq_bits,
|
||||
int32_t seq_num_diff, int set_mark);
|
||||
* new, 0 if old
|
||||
*/
|
||||
int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
|
||||
int32_t seq_num_diff, int set_mark);
|
||||
|
||||
#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
|
||||
/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors:
|
||||
*
|
||||
* Simon Wunderlich
|
||||
*
|
||||
@@ -16,81 +15,84 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NET_BATMAN_ADV_BLA_H_
|
||||
#define _NET_BATMAN_ADV_BLA_H_
|
||||
|
||||
#ifdef CONFIG_BATMAN_ADV_BLA
|
||||
int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid,
|
||||
bool is_bcast);
|
||||
int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid);
|
||||
int bla_is_backbone_gw(struct sk_buff *skb,
|
||||
struct orig_node *orig_node, int hdr_size);
|
||||
int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
|
||||
int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig);
|
||||
int bla_check_bcast_duplist(struct bat_priv *bat_priv,
|
||||
struct bcast_packet *bcast_packet, int hdr_size);
|
||||
void bla_update_orig_address(struct bat_priv *bat_priv,
|
||||
struct hard_iface *primary_if,
|
||||
struct hard_iface *oldif);
|
||||
int bla_init(struct bat_priv *bat_priv);
|
||||
void bla_free(struct bat_priv *bat_priv);
|
||||
int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid,
|
||||
bool is_bcast);
|
||||
int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid);
|
||||
int batadv_bla_is_backbone_gw(struct sk_buff *skb,
|
||||
struct batadv_orig_node *orig_node, int hdr_size);
|
||||
int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
|
||||
int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig);
|
||||
int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
|
||||
struct batadv_bcast_packet *bcast_packet,
|
||||
int hdr_size);
|
||||
void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
|
||||
struct batadv_hard_iface *primary_if,
|
||||
struct batadv_hard_iface *oldif);
|
||||
int batadv_bla_init(struct batadv_priv *bat_priv);
|
||||
void batadv_bla_free(struct batadv_priv *bat_priv);
|
||||
|
||||
#define BLA_CRC_INIT 0
|
||||
#define BATADV_BLA_CRC_INIT 0
|
||||
#else /* ifdef CONFIG_BATMAN_ADV_BLA */
|
||||
|
||||
static inline int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb,
|
||||
short vid, bool is_bcast)
|
||||
static inline int batadv_bla_rx(struct batadv_priv *bat_priv,
|
||||
struct sk_buff *skb, short vid,
|
||||
bool is_bcast)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb,
|
||||
short vid)
|
||||
static inline int batadv_bla_tx(struct batadv_priv *bat_priv,
|
||||
struct sk_buff *skb, short vid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int bla_is_backbone_gw(struct sk_buff *skb,
|
||||
struct orig_node *orig_node,
|
||||
int hdr_size)
|
||||
static inline int batadv_bla_is_backbone_gw(struct sk_buff *skb,
|
||||
struct batadv_orig_node *orig_node,
|
||||
int hdr_size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int bla_claim_table_seq_print_text(struct seq_file *seq,
|
||||
void *offset)
|
||||
static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
|
||||
void *offset)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int bla_is_backbone_gw_orig(struct bat_priv *bat_priv,
|
||||
uint8_t *orig)
|
||||
static inline int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
|
||||
uint8_t *orig)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int bla_check_bcast_duplist(struct bat_priv *bat_priv,
|
||||
struct bcast_packet *bcast_packet,
|
||||
int hdr_size)
|
||||
static inline int
|
||||
batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
|
||||
struct batadv_bcast_packet *bcast_packet,
|
||||
int hdr_size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void bla_update_orig_address(struct bat_priv *bat_priv,
|
||||
struct hard_iface *primary_if,
|
||||
struct hard_iface *oldif)
|
||||
static inline void
|
||||
batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
|
||||
struct batadv_hard_iface *primary_if,
|
||||
struct batadv_hard_iface *oldif)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int bla_init(struct bat_priv *bat_priv)
|
||||
static inline int batadv_bla_init(struct batadv_priv *bat_priv)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline void bla_free(struct bat_priv *bat_priv)
|
||||
static inline void batadv_bla_free(struct batadv_priv *bat_priv)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
/* Copyright (C) 2010-2012 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
#include "debugfs.h"
|
||||
#include "translation-table.h"
|
||||
#include "originator.h"
|
||||
#include "hard-interface.h"
|
||||
#include "gateway_common.h"
|
||||
#include "gateway_client.h"
|
||||
#include "soft-interface.h"
|
||||
#include "vis.h"
|
||||
#include "icmp_socket.h"
|
||||
#include "bridge_loop_avoidance.h"
|
||||
|
||||
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_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_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_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)
|
||||
{
|
||||
nonseekable_open(inode, file);
|
||||
file->private_data = inode->i_private;
|
||||
batadv_inc_module_count();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int batadv_log_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
batadv_dec_module_count();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int batadv_log_empty(struct batadv_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_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_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)
|
||||
{
|
||||
bat_priv->debug_log = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int batadv_algorithms_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, batadv_algo_seq_print_text, NULL);
|
||||
}
|
||||
|
||||
static int batadv_originators_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, batadv_orig_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
static int batadv_gateways_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, batadv_gw_client_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
static int batadv_transtable_global_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, batadv_tt_global_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BATMAN_ADV_BLA
|
||||
static int batadv_bla_claim_table_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, batadv_bla_claim_table_seq_print_text,
|
||||
net_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int batadv_transtable_local_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, batadv_tt_local_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
static int batadv_vis_data_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *net_dev = (struct net_device *)inode->i_private;
|
||||
return single_open(file, batadv_vis_seq_print_text, net_dev);
|
||||
}
|
||||
|
||||
struct batadv_debuginfo {
|
||||
struct attribute attr;
|
||||
const struct file_operations fops;
|
||||
};
|
||||
|
||||
#define BATADV_DEBUGINFO(_name, _mode, _open) \
|
||||
struct batadv_debuginfo batadv_debuginfo_##_name = { \
|
||||
.attr = { .name = __stringify(_name), \
|
||||
.mode = _mode, }, \
|
||||
.fops = { .owner = THIS_MODULE, \
|
||||
.open = _open, \
|
||||
.read = seq_read, \
|
||||
.llseek = seq_lseek, \
|
||||
.release = single_release, \
|
||||
} \
|
||||
};
|
||||
|
||||
static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open);
|
||||
static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open);
|
||||
static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open);
|
||||
static BATADV_DEBUGINFO(transtable_global, S_IRUGO,
|
||||
batadv_transtable_global_open);
|
||||
#ifdef CONFIG_BATMAN_ADV_BLA
|
||||
static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open);
|
||||
#endif
|
||||
static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
|
||||
batadv_transtable_local_open);
|
||||
static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
|
||||
|
||||
static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
|
||||
&batadv_debuginfo_originators,
|
||||
&batadv_debuginfo_gateways,
|
||||
&batadv_debuginfo_transtable_global,
|
||||
#ifdef CONFIG_BATMAN_ADV_BLA
|
||||
&batadv_debuginfo_bla_claim_table,
|
||||
#endif
|
||||
&batadv_debuginfo_transtable_local,
|
||||
&batadv_debuginfo_vis_data,
|
||||
NULL,
|
||||
};
|
||||
|
||||
void batadv_debugfs_init(void)
|
||||
{
|
||||
struct batadv_debuginfo *bat_debug;
|
||||
struct dentry *file;
|
||||
|
||||
batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL);
|
||||
if (batadv_debugfs == ERR_PTR(-ENODEV))
|
||||
batadv_debugfs = NULL;
|
||||
|
||||
if (!batadv_debugfs)
|
||||
goto out;
|
||||
|
||||
bat_debug = &batadv_debuginfo_routing_algos;
|
||||
file = debugfs_create_file(bat_debug->attr.name,
|
||||
S_IFREG | bat_debug->attr.mode,
|
||||
batadv_debugfs, NULL, &bat_debug->fops);
|
||||
if (!file)
|
||||
pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name);
|
||||
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
||||
void batadv_debugfs_destroy(void)
|
||||
{
|
||||
if (batadv_debugfs) {
|
||||
debugfs_remove_recursive(batadv_debugfs);
|
||||
batadv_debugfs = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int batadv_debugfs_add_meshif(struct net_device *dev)
|
||||
{
|
||||
struct batadv_priv *bat_priv = netdev_priv(dev);
|
||||
struct batadv_debuginfo **bat_debug;
|
||||
struct dentry *file;
|
||||
|
||||
if (!batadv_debugfs)
|
||||
goto out;
|
||||
|
||||
bat_priv->debug_dir = debugfs_create_dir(dev->name, batadv_debugfs);
|
||||
if (!bat_priv->debug_dir)
|
||||
goto out;
|
||||
|
||||
if (batadv_socket_setup(bat_priv) < 0)
|
||||
goto rem_attr;
|
||||
|
||||
if (batadv_debug_log_setup(bat_priv) < 0)
|
||||
goto rem_attr;
|
||||
|
||||
for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) {
|
||||
file = debugfs_create_file(((*bat_debug)->attr).name,
|
||||
S_IFREG | ((*bat_debug)->attr).mode,
|
||||
bat_priv->debug_dir,
|
||||
dev, &(*bat_debug)->fops);
|
||||
if (!file) {
|
||||
batadv_err(dev, "Can't add debugfs file: %s/%s\n",
|
||||
dev->name, ((*bat_debug)->attr).name);
|
||||
goto rem_attr;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
rem_attr:
|
||||
debugfs_remove_recursive(bat_priv->debug_dir);
|
||||
bat_priv->debug_dir = NULL;
|
||||
out:
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
return -ENOMEM;
|
||||
#else
|
||||
return 0;
|
||||
#endif /* CONFIG_DEBUG_FS */
|
||||
}
|
||||
|
||||
void batadv_debugfs_del_meshif(struct net_device *dev)
|
||||
{
|
||||
struct batadv_priv *bat_priv = netdev_priv(dev);
|
||||
|
||||
batadv_debug_log_cleanup(bat_priv);
|
||||
|
||||
if (batadv_debugfs) {
|
||||
debugfs_remove_recursive(bat_priv->debug_dir);
|
||||
bat_priv->debug_dir = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
|
||||
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors:
|
||||
*
|
||||
* Marek Lindner
|
||||
*
|
||||
@@ -16,18 +15,16 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _NET_BATMAN_ADV_DEBUGFS_H_
|
||||
#define _NET_BATMAN_ADV_DEBUGFS_H_
|
||||
|
||||
#define DEBUGFS_BAT_SUBDIR "batman_adv"
|
||||
#define BATADV_DEBUGFS_SUBDIR "batman_adv"
|
||||
|
||||
void debugfs_init(void);
|
||||
void debugfs_destroy(void);
|
||||
int debugfs_add_meshif(struct net_device *dev);
|
||||
void debugfs_del_meshif(struct net_device *dev);
|
||||
void batadv_debugfs_init(void);
|
||||
void batadv_debugfs_destroy(void);
|
||||
int batadv_debugfs_add_meshif(struct net_device *dev);
|
||||
void batadv_debugfs_del_meshif(struct net_device *dev);
|
||||
|
||||
#endif /* _NET_BATMAN_ADV_DEBUGFS_H_ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user