[B.A.T.M.A.N.] [PATCHv7 0/7] Distributed ARP Table
by Antonio Quartulli
Hello people,
****
This is the **seventh** version of this patchset. The whole code has been
reviewed
after some discussions on irc with Marek regarding the DHT code.
The change applied in this patchset is that now a DHT message is always sent three
times, even if the sending node is part of the DHT candidates.
****
Cheers,
10 years, 4 months
[B.A.T.M.A.N.] [PATCH 1/2] batman-adv: print OGM seq numbers as unsigned long
by Antonio Quartulli
OGM sequence numbers are declared as uint32_t and so they have to printed
using %u instead of %d in order to avoid wrong representations.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
bat_iv_ogm.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 42c121d..c42e030 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -152,7 +152,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet,
"Sending own" :
"Forwarding"));
bat_dbg(DBG_BATMAN, bat_priv,
- "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d,"
+ "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d,"
" IDF %s, ttvn %d) on interface %s [%pM]\n",
fwd_str, (packet_num > 0 ? "aggregated " : ""),
batman_ogm_packet->orig,
@@ -213,7 +213,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
/* FIXME: what about aggregated packets ? */
bat_dbg(DBG_BATMAN, bat_priv,
- "%s packet (originator %pM, seqno %d, TTL %d) "
+ "%s packet (originator %pM, seqno %u, TTL %d) "
"on interface %s [%pM]\n",
(forw_packet->own ? "Sending own" : "Forwarding"),
batman_ogm_packet->orig,
@@ -900,7 +900,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
if (need_update) {
bat_dbg(DBG_BATMAN, bat_priv,
- "updating last_seqno: old %d, new %d\n",
+ "updating last_seqno: old %u, new %u\n",
orig_node->last_real_seqno, batman_ogm_packet->seqno);
orig_node->last_real_seqno = batman_ogm_packet->seqno;
}
@@ -954,7 +954,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
bat_dbg(DBG_BATMAN, bat_priv,
"Received BATMAN packet via NB: %pM, IF: %s [%pM] "
- "(from OG: %pM, via prev OG: %pM, seqno %d, ttvn %u, "
+ "(from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, "
"crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
ethhdr->h_source, if_incoming->net_dev->name,
if_incoming->net_dev->dev_addr, batman_ogm_packet->orig,
--
1.7.3.4
10 years, 4 months
[B.A.T.M.A.N.] [PATCH 1/2] batctl: restate missing sysfs folder error message
by Marek Lindner
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
---
functions.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/functions.c b/functions.c
index 0729f15..69a1385 100644
--- a/functions.c
+++ b/functions.c
@@ -113,7 +113,8 @@ static int check_sys_dir(char *dir)
return EXIT_SUCCESS;
printf("Error - the folder '%s' was not found within the sys filesystem\n", dir);
- printf("Please make sure that the batman-adv kernel module is loaded\n");
+ printf("Please make sure that the batman-adv kernel module is loaded and\n");
+ printf("that you have activated your mesh by adding interfaces to batman-adv\n");
return EXIT_FAILURE;
}
--
1.7.5.4
10 years, 4 months
[B.A.T.M.A.N.] mesh: received packet with own address as source address
by Filippo Sallemi
Hi all,
after upgrade of batman package on my nodes I see a very decerase of
performance of my mesh network. When I connect to some node i see
every time this message:
mesh: received packet with own address as source address
now in a gateway mode my network config is:
config 'interface' 'lan'
option 'macaddr' '02:15:6d:7c:f0:88'
option 'type' 'bridge'
option 'ifname' 'mesh'
option 'proto' 'static'
option 'ipaddr' '10.240.136.1'
option 'netmask' '255.0.0.0'
config 'interface' 'wan'
option 'ifname' 'eth0'
option 'proto' 'dhcp'
config 'interface' 'msh0'
option 'proto' 'none'
option 'mtu' '1528'
in client mode nodes the network config is:
config 'interface' 'loopback'
option 'ifname' 'lo'
option 'proto' 'static'
option 'ipaddr' '127.0.0.1'
option 'netmask' '255.0.0.0'
config 'interface' 'lan'
option 'macaddr' '02:15:6d:b0:19:48'
option 'type' 'bridge'
option 'ifname' 'eth0 mesh'
option 'proto' 'dhcp'
config 'interface' 'msh0'
option 'proto' 'none'
option 'mtu' '1528'
Someone can help me? I've 20 nodes crazy
--
Filippo Sallemi
10 years, 4 months
[B.A.T.M.A.N.] [PATCHv6 0/7] batman-adv: Distributed ARP Table
by Antonio Quartulli
Hello people,
again, this code is related to the GSOC2011 project: DAT: Distributed ARP Table
for B.A.T.M.A.N.-Advanced. For more details, please have a look at the related
wikipage[1]. A more detailed, formal and technical wikipage will be written
soon.
****
This is the **sixth** version of this patchset. The whole code has been
reviewed
after some discussions on irc and here in the ml in the previous threads.
Several bugs have been spotted and fixed. Thanks Marek, Sven, Simon, Andrew
and
all the others for the comments/feedbacks.
Major changes regards the UNICAST_4ADDR patch which has been moved at the
beginning of the patchset, so that the rest of the code is directly based
onto
it. The same patch has also been hardly modified in order to become cleaner and
reuse the already available code as much as possible, thus reducing the
replicated one.
* v6 Additions:
- handling code for UNICAST_4ADDR has been deeply modified
- README.external has been updated with the new compile option.
- initialisation code for dat has been enclosed into two functions in order to
avoid having #ifdefs around for the batman-adv code
- some minor fixes
- debugging output improved
****
[1] http://www.open-mesh.org/wiki/batman-adv/GSOC2011_DAT
10 years, 4 months
[B.A.T.M.A.N.] Fwd: mesh: received packet with own address as source address
by Filippo Sallemi
---------- Messaggio inoltrato ----------
Da: Filippo Sallemi <tonyputi(a)gmail.com>
Date: 20 febbraio 2012 10:50
Oggetto: Re: [B.A.T.M.A.N.] mesh: received packet with own address as
source address
A: Sven Eckelmann <sven(a)narfation.org>
Il 20 febbraio 2012 00:55, Sven Eckelmann <sven(a)narfation.org> ha scritto:
> On Monday 20 February 2012 00:45:01 Filippo Sallemi wrote:
>> Hi all,
>> after upgrade of batman package on my nodes I see a very decerase of
>> performance of my mesh network. When I connect to some node i see
>> every time this message:
>>
>> mesh: received packet with own address as source address
>
> What was the previous version and which version do you use now?
My previuous version was 2011.2.0 and now is 2012.0.0
Do you use
> bridge loop avoidance or bridge loop avoidance II?
no all nodes speak only via ath/wlan
What's your batman-adv
> configuration?
[for nodes in gw_mode server]
config 'mesh' 'mesh'
option 'interfaces' 'msh0'
option 'ap_isolation' '0'
option 'gw_mode' 'server'
option 'gw_bandwidth' '4096KBit/512KBit'
option 'vis_mode' 'server'
[for nodes in gw_mode client]
config 'mesh' 'mesh'
option 'interfaces' 'msh0'
option 'ap_isolation' '0'
option 'gw_mode' 'client'
option 'vis_mode' 'off'
Did you only upgrade batman-adv or also other packages?
Only batman-adv was upgrade
>
> Kind regards,
> Sven
Rgds
--
Filippo Sallemi
--
Filippo Sallemi
10 years, 4 months
[B.A.T.M.A.N.] [PATCH v2 00/10] Part 4: handle addr_assign_type for random addresses
by Danny Kukawka
The fourth part of my patch series to fix the handling of
addr_assign_type for random MAC addresses.
This most of the patches in this series are for slightly
more complex cases to handle addr_assign_type and the
reset to NET_ADDR_PERM as soon as the MAC get changed via
.ndo_set_mac_address where eth_mac_addr wasn't used.
Danny Kukawka (10):
au1000_eth: use eth_hw_addr_random() instead of random_ether_addr()
lantiq_etop: set addr_assign_type if random_ether_addr() used
davinci_emac: use eth_hw_addr_random() instead of random_ether_addr()
xilinx ll_temac: use eth_hw_addr_random() instead of
random_ether_addr()
igbvf: reset netdevice addr_assign_type if changed
batman-adv: use eth_hw_addr_random() instead of random_ether_addr()
cisco/enic: use eth_hw_addr_random() instead of random_ether_addr()
ethoc: set addr_assign_type if random_ether_addr() used
atheros eth: set addr_assign_type if random_ether_addr() used
UML net: set addr_assign_type if random_ether_addr() used
arch/um/drivers/net_kern.c | 11 ++++++++---
drivers/net/ethernet/amd/au1000_eth.c | 9 +++++----
drivers/net/ethernet/atheros/atl1c/atl1c_hw.c | 2 +-
drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 9 ++++-----
drivers/net/ethernet/atheros/atlx/atl1.c | 12 +++++++++---
drivers/net/ethernet/atheros/atlx/atlx.c | 1 +
drivers/net/ethernet/cisco/enic/enic_main.c | 14 ++++++++++++--
drivers/net/ethernet/ethoc.c | 20 ++++++++++++++++++--
drivers/net/ethernet/intel/igbvf/netdev.c | 1 +
drivers/net/ethernet/lantiq_etop.c | 7 +++++++
drivers/net/ethernet/ti/davinci_emac.c | 5 +++--
drivers/net/ethernet/xilinx/ll_temac_main.c | 4 +++-
net/batman-adv/soft-interface.c | 5 ++---
13 files changed, 74 insertions(+), 26 deletions(-)
--
1.7.8.3
10 years, 4 months
[B.A.T.M.A.N.] [PATCH] batman-adv: use ETH_HLEN instead of sizeof(struct ethhdr)
by Antonio Quartulli
Instead of using sizeof(struct ethhdr) it is strongly recommended to use the
kernel macro ETH_HLEN. This patch substitute each occurrence of the former
expressione with the latter one.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
bat_iv_ogm.c | 7 +++----
bridge_loop_avoidance.c | 8 +++-----
hard-interface.c | 3 +--
icmp_socket.c | 4 ++--
routing.c | 8 ++++----
soft-interface.c | 2 +-
types.h | 2 +-
vis.c | 8 ++++----
8 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index caa67e4..42c121d 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -358,10 +358,9 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
if ((atomic_read(&bat_priv->aggregated_ogms)) &&
(packet_len < MAX_AGGREGATION_BYTES))
forw_packet_aggr->skb = dev_alloc_skb(MAX_AGGREGATION_BYTES +
- sizeof(struct ethhdr));
+ ETH_HLEN);
else
- forw_packet_aggr->skb = dev_alloc_skb(packet_len +
- sizeof(struct ethhdr));
+ forw_packet_aggr->skb = dev_alloc_skb(packet_len + ETH_HLEN);
if (!forw_packet_aggr->skb) {
if (!own_packet)
@@ -369,7 +368,7 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
kfree(forw_packet_aggr);
goto out;
}
- skb_reserve(forw_packet_aggr->skb, sizeof(struct ethhdr));
+ skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
INIT_HLIST_NODE(&forw_packet_aggr->list);
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
index 99b0a8f..af93e5c 100644
--- a/bridge_loop_avoidance.c
+++ b/bridge_loop_avoidance.c
@@ -292,9 +292,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
goto out;
ethhdr = (struct ethhdr *)skb->data;
- hw_src = (uint8_t *) ethhdr +
- sizeof(struct ethhdr) +
- sizeof(struct arphdr);
+ hw_src = (uint8_t *) ethhdr + ETH_HLEN + sizeof(struct arphdr);
/* now we pretend that the client would have sent this ... */
switch (claimtype) {
@@ -346,7 +344,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
skb_reset_mac_header(skb);
skb->protocol = eth_type_trans(skb, soft_iface);
bat_priv->stats.rx_packets++;
- bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr);
+ bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
soft_iface->last_rx = jiffies;
netif_rx(skb);
@@ -1317,7 +1315,7 @@ int bla_is_backbone_gw(struct sk_buff *skb,
return 0;
/* first, find out the vid. */
- if (!pskb_may_pull(skb, hdr_size + sizeof(struct ethhdr)))
+ if (!pskb_may_pull(skb, hdr_size + ETH_HLEN))
return 0;
ethhdr = (struct ethhdr *) (((uint8_t *)skb->data) + hdr_size);
diff --git a/hard-interface.c b/hard-interface.c
index 30b1c07..dfa948b 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -587,8 +587,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
goto err_free;
/* expect a valid ethernet header here. */
- if (unlikely(skb->mac_len != sizeof(struct ethhdr)
- || !skb_mac_header(skb)))
+ if (unlikely(skb->mac_len != ETH_HLEN || !skb_mac_header(skb)))
goto err_free;
if (!hard_iface->soft_iface)
diff --git a/icmp_socket.c b/icmp_socket.c
index 9b755f9..3128920 100644
--- a/icmp_socket.c
+++ b/icmp_socket.c
@@ -177,13 +177,13 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
if (len >= sizeof(struct icmp_packet_rr))
packet_len = sizeof(struct icmp_packet_rr);
- skb = dev_alloc_skb(packet_len + sizeof(struct ethhdr));
+ skb = dev_alloc_skb(packet_len + ETH_HLEN);
if (!skb) {
len = -ENOMEM;
goto out;
}
- skb_reserve(skb, sizeof(struct ethhdr));
+ skb_reserve(skb, ETH_HLEN);
icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len);
if (copy_from_user(icmp_packet, buff, packet_len)) {
diff --git a/routing.c b/routing.c
index 92fe20b..a055386 100644
--- a/routing.c
+++ b/routing.c
@@ -313,7 +313,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
goto out;
/* create a copy of the skb, if needed, to modify it. */
- if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+ if (skb_cow(skb, ETH_HLEN) < 0)
goto out;
icmp_packet = (struct icmp_packet_rr *)skb->data;
@@ -369,7 +369,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
goto out;
/* create a copy of the skb, if needed, to modify it. */
- if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+ if (skb_cow(skb, ETH_HLEN) < 0)
goto out;
icmp_packet = (struct icmp_packet *)skb->data;
@@ -455,7 +455,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
goto out;
/* create a copy of the skb, if needed, to modify it. */
- if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+ if (skb_cow(skb, ETH_HLEN) < 0)
goto out;
icmp_packet = (struct icmp_packet_rr *)skb->data;
@@ -842,7 +842,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
goto out;
/* create a copy of the skb, if needed, to modify it. */
- if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+ if (skb_cow(skb, ETH_HLEN) < 0)
goto out;
unicast_packet = (struct unicast_packet *)skb->data;
diff --git a/soft-interface.c b/soft-interface.c
index 3750e9b..3297c40 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -291,7 +291,7 @@ void interface_rx(struct net_device *soft_iface,
/* skb->ip_summed = CHECKSUM_UNNECESSARY;*/
bat_priv->stats.rx_packets++;
- bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr);
+ bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
soft_iface->last_rx = jiffies;
diff --git a/types.h b/types.h
index 4d93aad..2f4848b 100644
--- a/types.h
+++ b/types.h
@@ -27,7 +27,7 @@
#include "packet.h"
#include "bitarray.h"
-#define BAT_HEADER_LEN (sizeof(struct ethhdr) + \
+#define BAT_HEADER_LEN (ETH_HLEN + \
((sizeof(struct unicast_packet) > sizeof(struct bcast_packet) ? \
sizeof(struct unicast_packet) : \
sizeof(struct bcast_packet))))
diff --git a/vis.c b/vis.c
index c4a5b8c..cec216f 100644
--- a/vis.c
+++ b/vis.c
@@ -434,12 +434,12 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
return NULL;
info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len +
- sizeof(struct ethhdr));
+ ETH_HLEN);
if (!info->skb_packet) {
kfree(info);
return NULL;
}
- skb_reserve(info->skb_packet, sizeof(struct ethhdr));
+ skb_reserve(info->skb_packet, ETH_HLEN);
packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet)
+ vis_info_len);
@@ -894,11 +894,11 @@ int vis_init(struct bat_priv *bat_priv)
bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) +
MAX_VIS_PACKET_SIZE +
- sizeof(struct ethhdr));
+ ETH_HLEN);
if (!bat_priv->my_vis_info->skb_packet)
goto free_info;
- skb_reserve(bat_priv->my_vis_info->skb_packet, sizeof(struct ethhdr));
+ skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN);
packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet,
sizeof(*packet));
--
1.7.3.4
10 years, 4 months
[B.A.T.M.A.N.] pull request: batman-adv 2012-02-17
by Marek Lindner
David,
this is the first patch set I'd like you to pull into net-next-2.6/3.4.
It mainly brings infrastructure to dynamically change the routing alorithm
and a couple of fixes / style improvements.
Following the "sign your git tag" trend this is our first pull request which
is signed with my key. Let me know if there any problems.
Thanks,
Marek
The following changes since commit dcd6c92267155e70a94b3927bce681ce74b80d1f:
Linux 3.3-rc1 (2012-01-19 15:04:48 -0800)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git batman-adv-for-davem
for you to fetch changes up to ea3d2fd1b11fb3ef8706a48ece0a49a61bcd08bc:
batman-adv: export used routing algorithm via sysfs (2012-02-17 02:50:20 +0800)
----------------------------------------------------------------
infrastructure to change routing algorithm at runtime & fixes
----------------------------------------------------------------
Antonio Quartulli (1):
batman-adv: add tt_initialised flag to the orig_node struct
Marek Lindner (6):
batman-adv: simplify bat_ogm_receive API call
batman-adv: warn if added interface is part of a bridge
batman-adv: add infrastructure to change routing algorithm at runtime
batman-adv: convert batman iv algorithm to use dynamic infrastructure
batman-adv: allowing changing the routing algorithm via module parameter
batman-adv: export used routing algorithm via sysfs
Martin Hundebøll (2):
batman-adv: Rm empty line from is_my_mac() in main.c
batman-adv: Move is_out_of_time() to main.h for general use
Sven Eckelmann (1):
batman-adv: Explicitly mark the common header structure
Documentation/ABI/testing/sysfs-class-net-mesh | 7 +
net/batman-adv/{bat_ogm.h => bat_algo.h} | 20 +--
net/batman-adv/bat_debugfs.c | 22 ++
net/batman-adv/bat_iv_ogm.c | 245 +++++++++++++-----------
net/batman-adv/bat_sysfs.c | 9 +
net/batman-adv/hard-interface.c | 24 ++-
net/batman-adv/icmp_socket.c | 6 +-
net/batman-adv/main.c | 107 ++++++++++
net/batman-adv/main.h | 15 ++
net/batman-adv/originator.c | 1 +
net/batman-adv/packet.h | 38 ++---
net/batman-adv/routing.c | 24 +--
net/batman-adv/send.c | 7 +-
net/batman-adv/soft-interface.c | 18 +-
net/batman-adv/translation-table.c | 67 +++----
net/batman-adv/types.h | 21 ++
net/batman-adv/unicast.c | 16 +-
net/batman-adv/vis.c | 14 +-
18 files changed, 426 insertions(+), 235 deletions(-)
rename net/batman-adv/{bat_ogm.h => bat_algo.h} (51%)
10 years, 4 months
[B.A.T.M.A.N.] [RFC] batman-adv: Add filtering of OGM messages
by Martin Hundebøll
For testing purposes, forcing specific paths in a network where all
nodes are within reach, can be useful. This patch allows the use to
enter addresses from which direct OGMs should be ignored.
An address is added by echoing it into
/sys/class/net/bat0/filter_add_addr and removed again by echoing the
same address into /sys/class/net/bat0/filter_del_addr. The list of
currently blocked direct OGM sources is available in
/sys/kernel/debug/batman-adv/bat0/filter_table.
The filtering is performed by checking the value of member
"orig_node->filter", where the orig_node struct is found using the
Ethernet source of the OGM message in question. If "orig_node->filter is
true (1), the OGM is simply dropped.
Signed-off-by: Martin Hundebøll <martin(a)hundeboll.net>
---
Makefile | 2 +
Makefile.kbuild | 1 +
bat_debugfs.c | 15 ++++++
bat_sysfs.c | 43 ++++++++++++++++++
filter.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++
filter.h | 53 ++++++++++++++++++++++
gen-compat-autoconf.sh | 1 +
originator.c | 2 +
routing.c | 5 ++
types.h | 1 +
10 files changed, 239 insertions(+), 0 deletions(-)
create mode 100644 filter.c
create mode 100644 filter.h
diff --git a/Makefile b/Makefile
index 08f8c39..42895f6 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,8 @@
export CONFIG_BATMAN_ADV_DEBUG=n
# B.A.T.M.A.N. bridge loop avoidance:
export CONFIG_BATMAN_ADV_BLA=y
+# B.A.T.M.A.N. OGM packet filtering:
+export CONFIG_BATMAN_ADV_FILTER=y
PWD:=$(shell pwd)
KERNELPATH ?= /lib/modules/$(shell uname -r)/build
diff --git a/Makefile.kbuild b/Makefile.kbuild
index 6d5c194..8bf515c 100644
--- a/Makefile.kbuild
+++ b/Makefile.kbuild
@@ -24,6 +24,7 @@ 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-$(CONFIG_BATMAN_ADV_FILTER) += filter.o
batman-adv-y += gateway_client.o
batman-adv-y += gateway_common.o
batman-adv-y += hard-interface.o
diff --git a/bat_debugfs.c b/bat_debugfs.c
index 916380c..3f8ef4f 100644
--- a/bat_debugfs.c
+++ b/bat_debugfs.c
@@ -33,6 +33,7 @@
#include "vis.h"
#include "icmp_socket.h"
#include "bridge_loop_avoidance.h"
+#include "filter.h"
static struct dentry *bat_debugfs;
@@ -253,6 +254,14 @@ static int bla_claim_table_open(struct inode *inode, struct file *file)
}
#endif
+#ifdef CONFIG_BATMAN_ADV_FILTER
+static int filter_show_table_open(struct inode *inode, struct file *file)
+{
+ struct net_device *net_dev = (struct net_device *)inode->i_private;
+ return single_open(file, filter_show_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;
@@ -289,6 +298,9 @@ 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
+#ifdef CONFIG_BATMAN_ADV_FILTER
+static BAT_DEBUGINFO(filter_table, S_IRUGO, filter_show_table_open);
+#endif
static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open);
static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open);
@@ -299,6 +311,9 @@ static struct bat_debuginfo *mesh_debuginfos[] = {
#ifdef CONFIG_BATMAN_ADV_BLA
&bat_debuginfo_bla_claim_table,
#endif
+#ifdef CONFIG_BATMAN_ADV_FILTER
+ &bat_debuginfo_filter_table,
+#endif
&bat_debuginfo_transtable_local,
&bat_debuginfo_vis_data,
NULL,
diff --git a/bat_sysfs.c b/bat_sysfs.c
index 3adb183..0fc5e3e 100644
--- a/bat_sysfs.c
+++ b/bat_sysfs.c
@@ -27,6 +27,7 @@
#include "gateway_common.h"
#include "gateway_client.h"
#include "vis.h"
+#include "filter.h"
static struct net_device *kobj_to_netdev(struct kobject *obj)
{
@@ -384,11 +385,49 @@ static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr,
return gw_bandwidth_set(net_dev, buff, count);
}
+static ssize_t add_filter_addr(struct kobject *kobj, struct attribute *attr,
+ char *buff, size_t count)
+{
+ struct net_device *net_dev = kobj_to_netdev(kobj);
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ char mac[ETH_ALEN];
+ int res;
+
+ if ((res = filter_parse_addr_str(buff, count, mac)) < 0) {
+ bat_info(net_dev, "Address has invalid format: %s\n", buff);
+ return res;
+ }
+
+ filter_addr_add(bat_priv, mac);
+
+ return count;
+}
+
+static ssize_t del_filter_addr(struct kobject *kobj, struct attribute *attr,
+ char *buff, size_t count)
+{
+ struct net_device *net_dev = kobj_to_netdev(kobj);
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ char mac[ETH_ALEN];
+ int res;
+
+ if ((res = filter_parse_addr_str(buff, count, mac)) < 0)
+ return res;
+
+ filter_addr_del(bat_priv, mac);
+
+ return count;
+}
+
BAT_ATTR_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
BAT_ATTR_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
#ifdef CONFIG_BATMAN_ADV_BLA
BAT_ATTR_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
#endif
+#ifdef CONFIG_BATMAN_ADV_FILTER
+static BAT_ATTR(filter_add_addr, S_IRUGO | S_IWUSR, NULL, add_filter_addr);
+static BAT_ATTR(filter_del_addr, S_IRUGO | S_IWUSR, NULL, del_filter_addr);
+#endif
BAT_ATTR_BOOL(fragmentation, S_IRUGO | S_IWUSR, update_min_mtu);
BAT_ATTR_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
@@ -410,6 +449,10 @@ static struct bat_attribute *mesh_attrs[] = {
#ifdef CONFIG_BATMAN_ADV_BLA
&bat_attr_bridge_loop_avoidance,
#endif
+#ifdef CONFIG_BATMAN_ADV_FILTER
+ &bat_attr_filter_add_addr,
+ &bat_attr_filter_del_addr,
+#endif
&bat_attr_fragmentation,
&bat_attr_ap_isolation,
&bat_attr_vis_mode,
diff --git a/filter.c b/filter.c
new file mode 100644
index 0000000..844e10e
--- /dev/null
+++ b/filter.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
+ *
+ * Martin Hundebøll <martin(a)hundeboll.net>
+ *
+ * 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 "filter.h"
+#include "originator.h"
+
+bool filter_addr_drop(struct bat_priv *bat_priv, const uint8_t *addr)
+{
+ struct orig_node *orig_node = orig_hash_find(bat_priv, addr);
+
+ if (!orig_node)
+ return false;
+
+ if (atomic_read(&orig_node->filter))
+ return true;
+
+ orig_node_free_ref(orig_node);
+ return false;
+}
+
+void filter_addr_add(struct bat_priv *bat_priv, const uint8_t *addr)
+{
+ struct orig_node *orig_node = orig_hash_find(bat_priv, addr);
+
+ if (!orig_node)
+ return;
+
+ atomic_set(&orig_node->filter, FILTER_TRUE);
+ orig_node_free_ref(orig_node);
+}
+
+void filter_addr_del(struct bat_priv *bat_priv, const uint8_t *addr)
+{
+ struct orig_node *orig_node = orig_hash_find(bat_priv, addr);
+
+ if (!orig_node)
+ return;
+
+ atomic_set(&orig_node->filter, FILTER_FALSE);
+ orig_node_free_ref(orig_node);
+}
+
+int filter_parse_addr_str(char *buff, size_t count, char *addr)
+{
+ int i;
+
+ if (buff[count - 1] == '\n')
+ buff[count - 1] = '\0';
+
+ /* Validate if string has correct length */
+ if (count - 1 != PRETTY_MAC_ADDR_LEN)
+ return -EINVAL;
+
+ /* Validate if string has valid format */
+ for (i = 1; i <= ETH_ALEN - 1; i++)
+ if (buff[i*3-1] != ':')
+ return -EINVAL;
+
+ /* Convert string to bytes */
+ for (i = 0; i < ETH_ALEN; i++) {
+ unsigned long l;
+
+ l = simple_strtoul(&buff[i*3], (char **)NULL, 16);
+ addr[i] = (char)l;
+ }
+
+ return count;
+}
+
+int filter_show_table_seq_print_text(struct seq_file *seq, void *offset)
+{
+ struct net_device *net_dev = (struct net_device *)seq->private;
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ struct hashtable_t *hash = bat_priv->orig_hash;
+
+ struct hlist_node *node;
+ struct hlist_head *head;
+ struct orig_node *orig_node;
+ int i;
+
+ if (!hash)
+ return 0;
+
+ /* Traverse list of originators */
+ for (i = 0; i < hash->size; i++) {
+ head = &hash->table[i];
+
+ /* For each orig_node in this bin */
+ rcu_read_lock();
+ hlist_for_each_entry_rcu(orig_node, node, head, hash_entry)
+ if (atomic_read(&orig_node->filter))
+ seq_printf(seq, "%pM\n", orig_node->orig);
+ rcu_read_unlock();
+ }
+
+ return 0;
+}
diff --git a/filter.h b/filter.h
new file mode 100644
index 0000000..3b6cdf3
--- /dev/null
+++ b/filter.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
+ *
+ * Martin Hundebøll <martin(a)hundeboll.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+#ifndef _NET_BATMAN_ADV_NETWORK_FILTER_H
+#define _NET_BATMAN_ADV_NETWORK_FILTER_H
+
+#define FILTER_TRUE 1
+#define FILTER_FALSE 0
+
+#define PRETTY_MAC_ADDR_LEN 17
+
+#ifdef CONFIG_BATMAN_ADV_FILTER
+
+int filter_parse_addr_str(char *buff, size_t count, char *addr);
+int filter_show_table_seq_print_text(struct seq_file *seq, void *offset);
+void filter_addr_add(struct bat_priv *bat_priv, const uint8_t *addr);
+void filter_addr_del(struct bat_priv *bat_priv, const uint8_t *addr);
+bool filter_addr_drop(struct bat_priv *bat_priv, const uint8_t *addr);
+
+#else /* ifdef CONFIG_BATMAN_ADV_FILTER */
+
+#define filter_show_table_seq_print_text(...) (0)
+#define filter_parse_addr_str(...) (0)
+#define filter_addr_add(...) {}
+#define filter_addr_del(...) {}
+
+static inline bool filter_addr_drop(struct bat_priv *bat_priv,
+ const uint8_t *addr)
+{
+ return false
+}
+
+#endif /* ifdef CONFIG_BATMAN_ADV_FILTER */
+
+#endif /* _NET_BATMAN_ADV_NETWORK_FILTER_H */
diff --git a/gen-compat-autoconf.sh b/gen-compat-autoconf.sh
index 7cf621b..f2e7eae 100755
--- a/gen-compat-autoconf.sh
+++ b/gen-compat-autoconf.sh
@@ -38,6 +38,7 @@ gen_config() {
# write config variables
gen_config 'CONFIG_BATMAN_ADV_DEBUG' ${CONFIG_BATMAN_ADV_DEBUG:="n"} >> "${TMP}"
gen_config 'CONFIG_BATMAN_ADV_BLA' ${CONFIG_BATMAN_ADV_BLA:="y"} >> "${TMP}"
+gen_config 'CONFIG_BATMAN_ADV_FILTER' ${CONFIG_BATMAN_ADV_FILTER:="y"} >> "${TMP}"
# only regenerate compat-autoconf.h when config was changed
diff "${TMP}" "${TARGET}" > /dev/null 2>&1 || cp "${TMP}" "${TARGET}"
diff --git a/originator.c b/originator.c
index 2db4b53..a949856 100644
--- a/originator.c
+++ b/originator.c
@@ -29,6 +29,7 @@
#include "unicast.h"
#include "soft-interface.h"
#include "bridge_loop_avoidance.h"
+#include "filter.h"
static void purge_orig(struct work_struct *work);
@@ -236,6 +237,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr)
- msecs_to_jiffies(RESET_PROTECTION_MS);
atomic_set(&orig_node->bond_candidates, 0);
+ atomic_set(&orig_node->filter, FILTER_FALSE);
size = bat_priv->num_ifaces * sizeof(unsigned long) * NUM_WORDS;
diff --git a/routing.c b/routing.c
index 7b7fcbe..81c57b7 100644
--- a/routing.c
+++ b/routing.c
@@ -30,6 +30,7 @@
#include "vis.h"
#include "unicast.h"
#include "bridge_loop_avoidance.h"
+#include "filter.h"
static int route_unicast_packet(struct sk_buff *skb,
struct hard_iface *recv_if);
@@ -259,6 +260,10 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface)
ethhdr = (struct ethhdr *)skb_mac_header(skb);
+ /* Packet is filtered by user */
+ if (filter_addr_drop(bat_priv, ethhdr->h_source))
+ return NET_RX_DROP;
+
/* packet with broadcast indication but unicast recipient */
if (!is_broadcast_ether_addr(ethhdr->h_dest))
return NET_RX_DROP;
diff --git a/types.h b/types.h
index 7f7f610..29e632d 100644
--- a/types.h
+++ b/types.h
@@ -108,6 +108,7 @@ struct orig_node {
spinlock_t tt_list_lock; /* protects tt_list */
atomic_t bond_candidates;
struct list_head bond_list;
+ atomic_t filter; /* Boolean */
};
struct gw_node {
--
1.7.9
10 years, 4 months