Introducing a new routing protocol: B.A.T.M.A.N. V
cover Introducing a new routing protocol: B.A.T.M.A.N. V
Hello list,
this is the first _RFC_ introducing a new routing protocol in the batman-adv kernel module, namely B.A.T.M.A.N. V.
Basically this is the result of three major ideas:
1) separate link cost estimation and routing information spreading (B.A.T.M.A.N. IV performs the two operations by using OGMs only)
2) introduce a throughput based metric (B.A.T.M.A.N. IV metric is mainly based on packet loss)
3) create a new protocol that groups all the knowledge gained so far
For what concerns point 1) in this patchset we introduce the Echo Locating Protocol (aka ELP), which is a standalone component aimed to only estimate link costs. ELP was originally written by Linus Lüssing.
For point 2) we have already proposed an extension of the cfg80211 module (not yet merged) which allows any kernel module to retrieve the expected throughput towards another peer over a wireless link. ELP is the component in charge of interacting with cfg80211 to retrieve the expected throughput. For wired connections ELP directly reads the bandwidth advertised by the Ethernet card (not optimal in case of complex topologies - but it is a first attempt).
Point 3) gets concrete under the new OGMv2 protocol, which is the core of B.A.T.M.A.N. V.
The documentation is not yet ready to be linked, because the draft we have on the wiki needs to be adapted to reflect the last changes (in particular about the metric change from TQ to expected throughput).
In the various patches some kerneldoc is still missing: I am working on that now. But I wanted to throw the patchset out as soon as possible to let anybody review this code (this is why this is an RFC).
Notes:
=======
1) yes,_this_patchset_is_not_yet_checkpatch_clean_
2) patch 1/23 is already pending on the ml as RFC but I am resending it here since it is part of the whole batman v picture.
Cheers,
Antonio Quartulli (18):
batman-adv: invoke ogm_schedule() only when the interface is activated
batman-adv: OGMv2 - add basic infrastructure
batman-adv: OGMv2 - implement originators logic
batman-adv: OGMv2 - purge obsolete potential routers
batman-adv: split name from variable for uint mesh attributes
batman-adv: add throughput attribute to hard_ifaces
batman-adv: add base throughput attribute
batman-adv: add last_unicast_tx to struct neigh_node_elp
batman-adv: ELP - compute the metric based on the estimated throughput
batman-adv: ELP - send unicast ELP packets for throughput sampling
batman-adv: ELP - read estimated throughput from cfg80211
batman-adv: ELP - implement dead neigh node detection
batman-adv: ELP - use phydev to determine link characteristics
batman-adv: add bat_neigh_free() API
batman-adv: B.A.T.M.A.N. V - implement bat_neigh_free() API
batman-adv: B.A.T.M.A.N. V - implement neigh_is_equiv_or_better API
batman-adv: B.A.T.M.A.N. V - implement bat_neigh_cmp API
batman-adv: B.A.T.M.A.N. V - implement bat_orig_print API
Linus Luessing (5):
batman-adv: Add hard_iface specific sysfs wrapper macros for UINT
batman-adv: ELP - adding basic infrastructure
batman-adv: ELP - creating neighbor structures
batman-adv: ELP - exporting neighbor list via debugfs
batman-adv: ELP - adding sysfs parameter for elp interval
Makefile | 2 + Makefile.kbuild | 3 + README.external | 1 + bat_algo.h | 26 +- bat_iv_ogm.c | 2 +- bat_v.c | 266 +++++++++++++++++ bat_v_elp.c | 718 +++++++++++++++++++++++++++++++++++++++++++++ bat_v_elp.h | 39 +++ bat_v_ogm.c | 716 ++++++++++++++++++++++++++++++++++++++++++++ bat_v_ogm.h | 32 ++ compat.h | 20 ++ debugfs.c | 17 ++ distributed-arp-table.c | 4 +- fragmentation.c | 8 +- gen-compat-autoconf.sh | 1 + hard-interface.c | 24 +- icmp_socket.c | 2 +- main.c | 32 +- main.h | 16 + network-coding.c | 20 +- originator.c | 69 +++-- originator.h | 2 + packet.h | 50 ++++ send.c | 46 ++- send.h | 10 +- sysfs-class-net-batman-adv | 8 +- sysfs.c | 87 +++++- types.h | 113 +++++++ 28 files changed, 2260 insertions(+), 74 deletions(-) create mode 100644 bat_v.c create mode 100644 bat_v_elp.c create mode 100644 bat_v_elp.h create mode 100644 bat_v_ogm.c create mode 100644 bat_v_ogm.h
Signature · 1 line
1.8.5.3
RFC 1/23 batman-adv: invoke ogm_schedule() only when the interface is activated
From: Antonio Quartulli <[email protected]>
In the current implementation the first OGM is scheduled when a new hard-interface is enabled, no matter if it is active (thus ready for sending packets) or not.
However, the B.A.T.M.A.N. IV OGM scheduling mechanism works in a way that reschedules the task forever even if the interface is not yet ready and therefore everything works as expected.
Unfortunately this behaviour is not fine in general and other algorithms may pretend the interface to be active before scheduling the first OGM.
Change this behaviour by scheduling the first OGM upon interface activation.
--- hard-interface.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hard-interface.c +2 -3
@@ -320,6 +320,8 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)batadv_update_min_mtu (hard_iface->soft_iface); +/* begin scheduling originator messages on that interface */ +batadv_schedule_bat_ogm (hard_iface); out:if (primary_if)batadv_hardif_free_ref (primary_if);
@@ -459,9 +461,6 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,"Not using interface %s (retrying later): interface not active\n" , hard_iface->net_dev->name); -/* begin scheduling originator messages on that interface */ -batadv_schedule_bat_ogm (hard_iface); - out:return 0 ;
Signature · 1 line
1.8.5.3
RFC 2/23 batman-adv: Add hard_iface specific sysfs wrapper macros for UINT
In reply to Antonio QuartulliFrom: Linus Luessing <[email protected]>
This allows us to easily add a sysfs parameter for an unsigned int later, which is not for a batman mesh interface (e.g. bat0), but for a common interface instead. It allows reading and writing an atomic_t in hard_iface (instead of bat_priv compared to the mesh variant).
Developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
--- sysfs.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
sysfs.c +49 -0
@@ -213,6 +213,55 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \ static BATADV_ATTR_VLAN(_name, _mode, batadv_show_vlan_##_name, \ batadv_store_vlan_##_name) +#define BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min, _max, _post_func) \ +ssize_t batadv_store_##_name(struct kobject *kobj, \ + struct attribute *attr, char *buff, \ + size_t count) \ +{ \ + struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ +struct batadv_hard_iface *hard_iface; \ +ssize_t length; \ + \ + hard_iface = batadv_hardif_get_by_netdev(net_dev); \ + if (!hard_iface) \ + return 0; \ + \ + length = __batadv_store_uint_attr(buff, count, _min, _max, \ + _post_func, attr, \ + &hard_iface->_var, net_dev); \ + \ +batadv_hardif_free_ref (hard_iface); \ + return length; \ +} + +#define BATADV_ATTR_HIF_SHOW_UINT(_name, _var) \ +ssize_t batadv_show_##_name(struct kobject *kobj, \ + struct attribute *attr, char *buff) \ +{ \ +struct net_device *net_dev =batadv_kobj_to_netdev (kobj); \ +struct batadv_hard_iface *hard_iface; \ +ssize_t length; \ + \ + hard_iface =batadv_hardif_get_by_netdev (net_dev); \ +if (!hard_iface) \ +return 0 ; \ + \ + length =sprintf (buff,"%i\n" ,atomic_read (&hard_iface->_var)); \ + \ +batadv_hardif_free_ref (hard_iface); \ +return length; \ +} + +/* Use this, if you are going to set [name] in hard_iface to an +* unsigned integer value +*/ +#define BATADV_ATTR_HIF_UINT (_name, _var, _mode, _min, _max, _post_func)\ + static BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min, \ + _max, _post_func) \ + static BATADV_ATTR_HIF_SHOW_UINT(_name, _var) \ + static BATADV_ATTR(_name, _mode, batadv_show_##_name, \ + batadv_store_##_name) +static int batadv_store_bool_attr (char *buff,size_t count,struct net_device *net_dev,const char *attr_name,atomic_t *attr)
Signature · 1 line
1.8.5.3
RFC 3/23 batman-adv: ELP - adding basic infrastructure
In reply to Antonio QuartulliFrom: Linus Luessing <[email protected]>
The B.A.T.M.A.N. protocol originally only used a single message type (called OGM) to determine the link qualities to the direct neighbors and spreading these link quality information through the whole mesh. This procedure is summarized on the BATMAN concept page and explained in details in the RFC draft published in 2008.
This approach was chosen for its simplicity during the protocol design phase and the implementation. However, it also bears some drawbacks:
* Wireless interfaces usually come with some packet loss, therefore a higher broadcast rate is desirable to allow a fast reaction on flaky connections.
Other interfaces of the same host might be connected to Ethernet LANs / VPNs / etc which rarely exhibit packet loss would benefit from a lower broadcast rate to reduce overhead.
* It generally is more desirable to detect local link quality changes at a faster rate than propagating all these changes through the entire mesh (the far end of the mesh does not need to care about local link quality changes that much). Other optimizations strategies, like reducing overhead, might be possible if OGMs weren't used for all tasks in the mesh at the same time.
As a result detecting local link qualities shall be handled by an independent message type, ELP, whereas the OGM message type remains responsible for flooding the mesh with these link quality information and determining the overall path transmit qualities.
Developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
--- Makefile | 2 + Makefile.kbuild | 2 + README.external | 1 + bat_algo.h | 15 ++++- bat_v.c | 65 ++++++++++++++++++ bat_v_elp.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++++ bat_v_elp.h | 30 +++++++++ gen-compat-autoconf.sh | 1 + main.c | 1 + packet.h | 25 +++++++ types.h | 18 +++++ 11 files changed, 338 insertions(+), 1 deletion(-) create mode 100644 bat_v.c create mode 100644 bat_v_elp.c create mode 100644 bat_v_elp.h
Makefile +2 -0
@@ -25,6 +25,8 @@ export CONFIG_BATMAN_ADV_BLA=y export CONFIG_BATMAN_ADV_DAT=y # B.A.T.M.A.N network coding (catwoman): export CONFIG_BATMAN_ADV_NC=n +# B.A.T.M.A.N. V routing algorithm (experimental): +# export CONFIG_BATMAN_ADV_BATMAN_V=y PWD:=$(shell pwd) KERNELPATH ?= /lib/modules/$(shell uname -r)/build
Makefile.kbuild +2 -0
@@ -18,6 +18,8 @@ obj-$(CONFIG_BATMAN_ADV) += batman-adv.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_elp.o batman-adv-y += bitarray.o batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o batman-adv-y += debugfs.o
README.external +1 -0
@@ -39,6 +39,7 @@ module). Available options and their possible values are * CONFIG_BATMAN_ADV_BLA=[y*|n] (B.A.T.M.A.N. bridge loop avoidance) * CONFIG_BATMAN_ADV_DAT=[y*|n] (B.A.T.M.A.N. Distributed ARP Table) * CONFIG_BATMAN_ADV_NC=[y|n*] (B.A.T.M.A.N. Network Coding) + * CONFIG_BATMAN_ADV_BATMAN_V=[y|n*] (B.A.T.M.A.N. V routing algorithm) e.g., debugging can be enabled by
bat_algo.h +14 -1
@@ -1,6 +1,6 @@/* Copyright (C) 2011-2014 B.A.T.M.A.N. contributors: * -* Marek Lindner +* Marek Lindner, 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
@@ -20,4 +20,17 @@int batadv_iv_init (void ); +#ifdef CONFIG_BATMAN_ADV_BATMAN_V + +int batadv_v_init (void ); + +#else + +static inline int batadv_v_init (void ) +{ +return 0 ; +} + +#endif /* CONFIG_BATMAN_ADV_BATMAN_V */ +#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */
bat_v.c new file +65 -0
65 lines not on this page · raw message
bat_v_elp.c new file +179 -0
179 lines not on this page · raw message
bat_v_elp.h new file +30 -0
@@ -0,0 +1,30 @@ +/* Copyright (C) 2013-2014 B.A.T.M.A.N. contributors: +* +* 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, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA +* +*/ + +#include "main.h" + +#ifndef _NET_BATMAN_ADV_BAT_V_ELP_H_ +#define _NET_BATMAN_ADV_BAT_V_ELP_H_ + +int batadv_v_elp_iface_enable (struct batadv_hard_iface *hard_iface); +void batadv_v_elp_iface_disable (struct batadv_hard_iface *hard_iface); +void batadv_v_elp_primary_iface_set (struct batadv_hard_iface *hard_iface); + +#endif /* _NET_BATMAN_ADV_BAT_V_ELP_H_ */
gen-compat-autoconf.sh +1 -0
@@ -40,6 +40,7 @@ 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_DAT' ${CONFIG_BATMAN_ADV_DAT:="y"} >> "${TMP}" gen_config 'CONFIG_BATMAN_ADV_NC' ${CONFIG_BATMAN_ADV_NC:="n"} >> "${TMP}" +gen_config 'CONFIG_BATMAN_ADV_BATMAN_V' ${CONFIG_BATMAN_ADV_BATMAN_V:="n"} >> "${TMP}" # only regenerate compat-autoconf.h when config was changed diff "${TMP}" "${TARGET}" > /dev/null 2>&1 || cp "${TMP}" "${TARGET}"
main.c +1 -0
@@ -63,6 +63,7 @@ static int __init batadv_init(void)batadv_recv_handler_init (); +batadv_v_init ();batadv_iv_init ();batadv_nc_init ();
packet.h +25 -0
@@ -37,6 +37,7 @@ enum batadv_packettype {BATADV_IV_OGM =0x00 ,BATADV_BCAST =0x01 ,BATADV_CODED =0x02 , +BATADV_ELP =0x03 ,/* 0x40 - 0x7f: unicast */ #define BATADV_UNICAST_MIN 0x40 BATADV_UNICAST = 0x40,
@@ -192,6 +193,30 @@ struct batadv_ogm_packet {#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)/** +* struct batadv_elp_packet - elp (neighbor discovery) 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 +* @num_neighbors: number of already discovered neighbors +* @seqno: sequence number +* @elp_interval: currently used ELP sending interval +* @orig: originator mac address +* @align: not used - useful for alignment purposes only +*/ +struct batadv_elp_packet { +uint8_t packet_type; +uint8_t version; +uint8_t ttl; +uint8_t num_neighbors; +__be32 seqno; +__be32 elp_interval; +uint8_t orig[ETH_ALEN ]; +uint8_t align[2 ]; +}; + +#define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet) + +/** * batadv_icmp_header - common members among all the ICMP packets * @packet_type: batman-adv packet type, part of the general header * @version: batman-adv protocol version, part of the genereal header
types.h +18 -0
@@ -70,6 +70,20 @@ struct batadv_hard_iface_bat_iv { };/** +* struct batadv_hard_iface_bat_v - per hard interface B.A.T.M.A.N. V data +* @elp_interval: time interval between two ELP transmissions +* @elp_seqno: current ELP sequence number +* @elp_skb: base skb containing the ELP message to send +* @elp_wq: workqueue used to schedule ELP transmissions +*/ +struct batadv_hard_iface_bat_v { +atomic_t elp_interval; +atomic_t elp_seqno; +struct sk_buff *elp_skb; +struct delayed_work elp_wq; +}; + +/** * struct batadv_hard_iface - network device known to batman-adv * @list: list node for batadv_hardif_list * @if_num: identificator of the interface
@@ -83,6 +97,7 @@ struct batadv_hard_iface_bat_iv {* @soft_iface: the batman-adv interface which uses this network interface * @rcu: struct used for freeing in an RCU-safe manner * @bat_iv: BATMAN IV specific per hard interface data +* @bat_v: BATMAN V specific per hard interface data * @cleanup_work: work queue callback item for hard interface deinit * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs */
@@ -98,6 +113,9 @@ struct batadv_hard_iface {struct net_device *soft_iface;struct rcu_head rcu;struct batadv_hard_iface_bat_iv bat_iv; +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +struct batadv_hard_iface_bat_v bat_v; +#endif struct work_struct cleanup_work;struct dentry *debug_dir; };
Signature · 1 line
1.8.5.3
RFC 4/23 batman-adv: ELP - creating neighbor structures
In reply to Antonio QuartulliFrom: Linus Luessing <[email protected]>
Initially developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
--- bat_v.c | 18 +++++- bat_v_elp.c | 204 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- bat_v_elp.h | 6 ++ main.h | 2 + types.h | 53 ++++++++++++++++ 5 files changed, 281 insertions(+), 2 deletions(-)
bat_v.c +17 -1
@@ -61,5 +61,21 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {int __init batadv_v_init (void ) { -return batadv_algo_register (&batadv_batman_v); +int ret; + +/* batman v echo location protocol packet */ + ret =batadv_recv_handler_register (BATADV_ELP , + batadv_v_elp_packet_recv); +if (ret <0 ) + goto elp_unregister; + + ret =batadv_algo_register (&batadv_batman_v); + +return ret; + +elp_unregister: +if (ret <0 ) +batadv_recv_handler_unregister (BATADV_ELP ); + +return ret; }
bat_v_elp.c +203 -1
245 lines not on this page · raw message
bat_v_elp.h +6 -0
@@ -23,8 +23,14 @@#ifndef _NET_BATMAN_ADV_BAT_V_ELP_H_#define _NET_BATMAN_ADV_BAT_V_ELP_H_ +struct batadv_elp_neigh_node * +batadv_v_elp_neigh_get (struct batadv_hard_iface *hard_iface, +uint8_t *neigh_addr); +void batadv_elp_neigh_node_free_ref (struct batadv_elp_neigh_node *neigh);int batadv_v_elp_iface_enable (struct batadv_hard_iface *hard_iface);void batadv_v_elp_iface_disable (struct batadv_hard_iface *hard_iface);void batadv_v_elp_primary_iface_set (struct batadv_hard_iface *hard_iface); +int batadv_v_elp_packet_recv (struct sk_buff *skb, +struct batadv_hard_iface *if_incoming);#endif /* _NET_BATMAN_ADV_BAT_V_ELP_H_ */
main.h +2 -0
@@ -45,6 +45,7 @@#define BATADV_TT_WORK_PERIOD 5000/* 5 seconds */ #define BATADV_ORIG_WORK_PERIOD 1000/* 1 second */ #define BATADV_DAT_ENTRY_TIMEOUT (5*60000)/* 5 mins in milliseconds */ +#define BATADV_ELP_OUTDATED_MAX 4/* sliding packet range of received originator messages in sequence numbers * (should be a multiple of our word size) */
@@ -180,6 +181,7 @@ enum batadv_uev_type {#include <linux/jiffies.h> #include <linux/seq_file.h> #include <linux/if_vlan.h> +#include <linux/average.h> /* ewma */ #include "compat.h" #include "types.h"
types.h +53 -0
95 lines not on this page · raw message
Signature · 1 line
1.8.5.3
RFC 5/23 batman-adv: ELP - exporting neighbor list via debugfs
In reply to Antonio QuartulliFrom: Linus Luessing <[email protected]>
Lists all neighbours detected by the Echo Locating Protocol (ELP) and their metric values.
Initially Developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
--- bat_v_elp.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bat_v_elp.h | 1 + debugfs.c | 17 +++++++++++++ 3 files changed, 98 insertions(+)
bat_v_elp.c +80 -0
@@ -379,3 +379,83 @@ out:consume_skb (skb);return NET_RX_SUCCESS ; } + +/** +* batadv_v_elp_seq_print_neigh - print a single ELP neighbour node +* @seq: neighbour table seq_file struct +* @hard_iface: interface the neighbour is connected to +* @neigh: the neighbour node to print +*/ +static void batadv_v_elp_seq_print_neigh (struct seq_file *seq, +struct batadv_hard_iface *hard_iface, +struct batadv_elp_neigh_node *neigh) +{ +int last_secs, last_msecs; +uint32_t metric; + + last_secs =jiffies_to_msecs (jiffies - neigh->last_seen) /1000 ; + last_msecs =jiffies_to_msecs (jiffies - neigh->last_seen) %1000 ; + metric =ewma_read (&neigh->metric); + +seq_printf (seq,"%pM %4i.%03is (%9u.%1u) [%10s]\n" , + neigh->addr, last_secs, last_msecs, metric /10 , + metric %10 , hard_iface->net_dev->name); +} + +/** +* batadv_v_elp_seq_print_text - print the neighbour table +* @seq: neighbour table seq_file struct +* @offset: not used +* +* Returns always 0. +*/ +int batadv_v_elp_seq_print_text (struct seq_file *seq,void *offset) +{ +struct net_device *net_dev = (struct net_device *)seq->private; +struct batadv_priv *bat_priv =netdev_priv (net_dev); +struct batadv_hard_iface *hard_iface, *primary_if; +struct batadv_elp_neigh_node *neigh; +int batman_count =0 ; + + primary_if =batadv_primary_if_get_selected (bat_priv); + +if (!primary_if) { +seq_printf (seq, +"BATMAN mesh %s disabled - please specify interfaces to enable it\n" , + net_dev->name); + goto out; + } + +if (primary_if->if_status !=BATADV_IF_ACTIVE ) { +seq_printf (seq, +"BATMAN mesh %s disabled - primary interface not active\n" , + net_dev->name); + goto out; + } + +seq_printf (seq,"[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n" , +BATADV_SOURCE_VERSION , primary_if->net_dev->name, + primary_if->net_dev->dev_addr, net_dev->name); +seq_printf (seq," %-15s %s (%11s) [%10s]\n" ,"Neighbor" , +"last-seen" ,"metric" ,"IF" ); + +rcu_read_lock (); +list_for_each_entry_rcu (hard_iface, &batadv_hardif_list, list) { +if (hard_iface->soft_iface != net_dev) +continue ; + +hlist_for_each_entry_rcu (neigh, &hard_iface->bat_v.neigh_list, list) { +batadv_v_elp_seq_print_neigh (seq, hard_iface, neigh); + batman_count++; + } + } +rcu_read_unlock (); + +if (batman_count ==0 ) +seq_printf (seq,"No batman nodes in range ...\n" ); + +out: +if (primary_if) +batadv_hardif_free_ref (primary_if); +return 0 ; +}
bat_v_elp.h +1 -0
@@ -32,5 +32,6 @@ void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface);void batadv_v_elp_primary_iface_set (struct batadv_hard_iface *hard_iface);int batadv_v_elp_packet_recv (struct sk_buff *skb,struct batadv_hard_iface *if_incoming); +int batadv_v_elp_seq_print_text (struct seq_file *seq,void *offset);#endif /* _NET_BATMAN_ADV_BAT_V_ELP_H_ */
debugfs.c +17 -0
@@ -20,6 +20,7 @@#include <linux/debugfs.h> #include "debugfs.h" +#include "bat_v_elp.h" #include "translation-table.h" #include "originator.h" #include "hard-interface.h"
@@ -242,6 +243,16 @@ static int batadv_algorithms_open(struct inode *inode, struct file *file)return single_open (file, batadv_algo_seq_print_text,NULL ); } +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +int batadv_v_elp_seq_print_text (struct seq_file *seq,void *offset); + +static int neighbors_open (struct inode *inode,struct file *file) +{ +struct net_device *net_dev = (struct net_device *)inode->i_private; +return single_open (file, batadv_v_elp_seq_print_text, net_dev); +} +#endif +static int batadv_originators_open (struct inode *inode,struct file *file) {struct net_device *net_dev = (struct net_device *)inode->i_private;
@@ -346,6 +357,9 @@ static struct batadv_debuginfo *batadv_general_debuginfos[] = { };/* The following attributes are per soft interface */ +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +static BATADV_DEBUGINFO(neighbors, S_IRUGO, neighbors_open); +#endif 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,
@@ -365,6 +379,9 @@ static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open);#endif static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { +#ifdef CONFIG_BATMAN_ADV_BATMAN_V + &batadv_debuginfo_neighbors, +#endif &batadv_debuginfo_originators, &batadv_debuginfo_gateways, &batadv_debuginfo_transtable_global,
Signature · 1 line
1.8.5.3
RFC 6/23 batman-adv: ELP - adding sysfs parameter for elp interval
In reply to Antonio QuartulliFrom: Linus Luessing <[email protected]>
This parameter can be set individually on each interface and allows the configuration of the ndp interval for the link quality measurements during runtime. Usually it is desirable to set it to a higher (= slower) value on interfaces which have a more static characteristic (e.g. wired interfaces) or very dense neighbourhoods to reduce overhead.
Developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
--- sysfs-class-net-batman-adv | 8 +++++++- sysfs.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
sysfs-class-net-batman-adv +7 -1
@@ -1,4 +1,11 @@ +What: /sys/class/net/<mesh_iface>/batman-adv/elp_interval +Date: Mar 2012 +Contact: Linus Lüssing <[email protected]> +Description: + Defines the interval in milliseconds in which batman + sends its probing packets for link quality measurements. + What: /sys/class/net/<iface>/batman-adv/iface_status Date: May 2010 Contact: Marek Lindner <[email protected]>
@@ -12,4 +19,3 @@ Description: The /sys/class/net/<iface>/batman-adv/mesh_iface file displays the batman mesh interface this <iface> currently is associated with. -
sysfs.c +7 -0
@@ -877,10 +877,17 @@ static ssize_t batadv_show_iface_status(struct kobject *kobj, static BATADV_ATTR(mesh_iface, S_IRUGO | S_IWUSR, batadv_show_mesh_iface, batadv_store_mesh_iface); static BATADV_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL); +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +BATADV_ATTR_HIF_UINT (elp_interval, bat_v.elp_interval,S_IRUGO |S_IWUSR , +2 *BATADV_JITTER ,INT_MAX ,NULL ); +#endif static struct batadv_attribute *batadv_batman_attrs[] = { &batadv_attr_mesh_iface, &batadv_attr_iface_status, +#ifdef CONFIG_BATMAN_ADV_BATMAN_V + &batadv_attr_elp_interval, +#endifNULL , };
Signature · 1 line
1.8.5.3
RFC 7/23 batman-adv: OGMv2 - add basic infrastructure
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
This is the initial implementation of the new OGM protocol (version 2). It has been designed to work on top of the newly added ELP.
In the previous version the OGM protocol was used to both measure link qualities and flood the network with the metric information. In this version the protocol is in charge of the latter task only, leaving the former to ELP.
This means being able to decouple the interval used by the neighbor discovery from the OGM broadcasting, which revealed to be costly in dense networks and needed to be relaxed so leading to a less responsive routing protocol.
--- Makefile.kbuild | 1 + bat_algo.h | 11 +++ bat_v.c | 36 ++++++++- bat_v_elp.c | 11 ++- bat_v_ogm.c | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bat_v_ogm.h | 32 ++++++++ main.c | 31 +++++++- main.h | 1 + packet.h | 25 ++++++ types.h | 15 ++++ 10 files changed, 385 insertions(+), 8 deletions(-) create mode 100644 bat_v_ogm.c create mode 100644 bat_v_ogm.h
Makefile.kbuild +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_BATMAN_ADV) += batman-adv.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_elp.o +batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_ogm.o batman-adv-y += bitarray.o batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o batman-adv-y += debugfs.o
bat_algo.h +11 -0
@@ -23,6 +23,8 @@ int batadv_iv_init(void);#ifdef CONFIG_BATMAN_ADV_BATMAN_V int batadv_v_init (void ); +int batadv_v_mesh_init (struct batadv_priv *bat_priv); +void batadv_v_mesh_free (struct batadv_priv *bat_priv);#else
@@ -31,6 +33,15 @@ static inline int batadv_v_init(void)return 0 ; } +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_ */
bat_v.c +33 -3
@@ -20,10 +20,21 @@#include "main.h" #include "bat_algo.h" #include "bat_v_elp.h" +#include "bat_v_ogm.h" static int batadv_v_iface_enable (struct batadv_hard_iface *hard_iface) { -return batadv_v_elp_iface_enable (hard_iface); +int ret; + + ret =batadv_v_elp_iface_enable (hard_iface); +if (ret <0 ) +return ret; + + ret =batadv_v_ogm_iface_enable (hard_iface); +if (ret <0 ) +batadv_v_elp_iface_disable (hard_iface); + +return ret; }static void batadv_v_iface_disable (struct batadv_hard_iface *hard_iface)
@@ -38,6 +49,7 @@ static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface)static void batadv_v_primary_iface_set (struct batadv_hard_iface *hard_iface) {batadv_v_elp_primary_iface_set (hard_iface); +batadv_v_ogm_primary_iface_set (hard_iface); }static void batadv_v_ogm_schedule (struct batadv_hard_iface *hard_iface)
@@ -58,6 +70,15 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .bat_ogm_schedule = batadv_v_ogm_schedule, }; +int batadv_v_mesh_init (struct batadv_priv *bat_priv) +{ +return batadv_v_ogm_init (bat_priv); +} + +void batadv_v_mesh_free (struct batadv_priv *bat_priv) +{ +batadv_v_ogm_free (bat_priv); +}int __init batadv_v_init (void ) {
@@ -67,15 +88,24 @@ int __init batadv_v_init(void) ret =batadv_recv_handler_register (BATADV_ELP , batadv_v_elp_packet_recv);if (ret <0 ) +return ret; + + ret =batadv_recv_handler_register (BATADV_OGM2 , + batadv_v_ogm_packet_recv); +if (ret <0 ) goto elp_unregister; ret =batadv_algo_register (&batadv_batman_v); +if (ret <0 ) + goto ogm_unregister;return ret; +ogm_unregister: +batadv_recv_handler_unregister (BATADV_OGM2 ); + elp_unregister: -if (ret <0 ) -batadv_recv_handler_unregister (BATADV_ELP ); +batadv_recv_handler_unregister (BATADV_ELP );return ret; }
bat_v_elp.c +10 -1
@@ -25,6 +25,7 @@#include "bat_v_elp.h" #include "originator.h" #include "routing.h" +#include "translation-table.h" /** * batadv_v_elp_start_timer - restart timer for ELP periodic work
@@ -276,11 +277,15 @@ void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface)*/ void batadv_v_elp_primary_iface_set (struct batadv_hard_iface *hard_iface) { +struct batadv_priv *bat_priv =netdev_priv (hard_iface->soft_iface);struct batadv_hard_iface *hard_iface_tmp;struct batadv_elp_packet *elp_packet; +struct batadv_ogm2_packet *ogm2;struct sk_buff *skb; -/* update orig field of every elp iface belonging to this mesh */ +/* update orig field of every elp and ogm iface belonging to this +* mesh +*/ rcu_read_lock ();list_for_each_entry_rcu (hard_iface_tmp, &batadv_hardif_list, list) {if (hard_iface->soft_iface != hard_iface_tmp->soft_iface)
@@ -293,6 +298,9 @@ void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *hard_iface) elp_packet = (struct batadv_elp_packet *)skb->data;memcpy (elp_packet->orig, hard_iface->net_dev->dev_addr,ETH_ALEN ); + + ogm2 = (struct batadv_ogm2_packet *)bat_priv->bat_v.ogm_buff; +memcpy (ogm2->orig, hard_iface->net_dev->dev_addr,ETH_ALEN ); }rcu_read_unlock (); }
@@ -311,6 +319,7 @@ static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv,uint8_t *neigh_addr, struct batadv_hard_iface *if_incoming, struct batadv_elp_packet *elp_packet) + { struct batadv_elp_neigh_node *neigh;
bat_v_ogm.c new file +230 -0
230 lines not on this page · raw message
bat_v_ogm.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (C) 2013 B.A.T.M.A.N. contributors: +* +* 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, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA +* +*/ + +#ifndef _BATAMAN_ADV_BATADV_V_OGM_H_ +#define _BATAMAN_ADV_BATADV_V_OGM_H_ + +int batadv_v_ogm_init (struct batadv_priv *bat_priv); +void batadv_v_ogm_free (struct batadv_priv *bat_priv); +int batadv_v_ogm_iface_enable (struct batadv_hard_iface *hard_iface); +void batadv_v_ogm_primary_iface_set (struct batadv_hard_iface *hard_iface); +int batadv_v_ogm_packet_recv (struct sk_buff *skb, +struct batadv_hard_iface *if_incoming); + +#endif /* _BATAMAN_ADV_BATADV_V_OGM_H_ */
main.c +27 -4
@@ -35,6 +35,7 @@#include "bridge_loop_avoidance.h" #include "distributed-arp-table.h" #include "gateway_common.h" +#include "hard-interface.h" #include "hash.h" #include "bat_algo.h" #include "network-coding.h"
@@ -125,6 +126,10 @@ int batadv_mesh_init(struct net_device *soft_iface)INIT_HLIST_HEAD (&bat_priv->tvlv.handler_list);INIT_HLIST_HEAD (&bat_priv->softif_vlan_list); + ret =batadv_v_mesh_init (bat_priv); +if (ret <0 ) + goto err; + ret =batadv_originator_init (bat_priv);if (ret <0 ) goto err;
@@ -165,6 +170,8 @@ void batadv_mesh_free(struct net_device *soft_iface)batadv_purge_outstanding_packets (bat_priv,NULL ); +batadv_v_mesh_free (bat_priv); +batadv_gw_node_purge (bat_priv);batadv_nc_mesh_free (bat_priv);batadv_dat_free (bat_priv);
@@ -835,21 +842,32 @@ uint16_t batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv, {struct batadv_tvlv_container *tvlv;struct batadv_tvlv_hdr *tvlv_hdr; -uint16_t tvlv_value_len; +uint16_t tvlv_value_len =0 ;void *tvlv_value;bool ret; +struct batadv_hard_iface *primary_if; + + primary_if =batadv_primary_if_get_selected (bat_priv); +if (!primary_if) + goto end;spin_lock_bh (&bat_priv->tvlv.container_list_lock); tvlv_value_len =batadv_tvlv_container_list_size (bat_priv); +if (packet_min_len + tvlv_value_len > primary_if->net_dev->mtu) { +batadv_dbg (BATADV_DBG_BATMAN , bat_priv, +"OGM size too big to fit the primary_if mtu\n" ); + goto unlock; + } + ret =batadv_tvlv_realloc_packet_buff (packet_buff, packet_buff_len, packet_min_len, tvlv_value_len);if (!ret) - goto end; + goto unlock;if (!tvlv_value_len) - goto end; + goto unlock; tvlv_value = (*packet_buff) + packet_min_len;
@@ -863,8 +881,13 @@ uint16_t batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv, tvlv_value = (uint8_t *)tvlv_value +ntohs (tvlv->tvlv_hdr.len); } -end: +unlock:spin_unlock_bh (&bat_priv->tvlv.container_list_lock); + +end: +if (primary_if) +batadv_hardif_free_ref (primary_if); +return tvlv_value_len; }
main.h +1 -0
@@ -30,6 +30,7 @@/* B.A.T.M.A.N. parameters */ #define BATADV_TQ_MAX_VALUE 255 +#define BATADV_MAX_METRIC 0xFFFFFFFF#define BATADV_JITTER 20/* Time To Live of broadcast messages */
packet.h +25 -0
@@ -38,6 +38,7 @@ enum batadv_packettype {BATADV_BCAST =0x01 ,BATADV_CODED =0x02 ,BATADV_ELP =0x03 , +BATADV_OGM2 =0x0d ,/* 0x40 - 0x7f: unicast */ #define BATADV_UNICAST_MIN 0x40 BATADV_UNICAST = 0x40,
@@ -193,6 +194,30 @@ struct batadv_ogm_packet {#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)/** +* struct batadv_ogm2_packet - ogm2 (routing protocol) packet +* @packet_type: batman-adv packet type, part of the general header +* @version: batman-adv protocol version, part of the general header +* @ttl: time to live for this packet, part of the general header +* @flags: +* @seqno: sequence number +* @orig: originator mac address +* @tvlv_len: length of the appended tvlv buffer (in bytes) +* @metric: the currently flooded metric value +*/ +struct batadv_ogm2_packet { +uint8_t packet_type; +uint8_t version; +uint8_t ttl; +uint8_t flags; +__be32 seqno; +uint8_t orig[ETH_ALEN ]; +__be16 tvlv_len; +__be32 metric; +}; + +#define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet) + +/** * struct batadv_elp_packet - elp (neighbor discovery) packet * @packet_type: batman-adv packet type, part of the general header * @version: batman-adv protocol version, part of the genereal header
types.h +15 -0
@@ -728,6 +728,18 @@ struct batadv_softif_vlan { };/** +* struct batadv_priv_bat_v - +* @ogm_buff: +* @ogm_buff_len: +*/ +struct batadv_priv_bat_v { +unsigned char *ogm_buff; +int ogm_buff_len; +struct delayed_work ogm_wq; +atomic_t ogm_seqno; +}; + +/** * struct batadv_priv - per mesh interface data * @mesh_state: current status of the mesh (inactive/active/deactivating) * @soft_iface: net device which holds this struct as private data
@@ -834,6 +846,9 @@ struct batadv_priv {atomic_t network_coding;struct batadv_priv_nc nc;#endif /* CONFIG_BATMAN_ADV_NC */ +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +struct batadv_priv_bat_v bat_v; +#endif };/**
Signature · 1 line
1.8.5.3
RFC 8/23 batman-adv: OGMv2 - implement originators logic
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
Add the support for recognising new originators in the network and rebroadcast their OGMs.
--- bat_v_elp.c | 7 +- bat_v_ogm.c | 422 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 414 insertions(+), 15 deletions(-)
bat_v_elp.c +3 -4
@@ -63,7 +63,7 @@ void batadv_elp_neigh_node_free_ref(struct batadv_elp_neigh_node *neigh)*/ static struct batadv_elp_neigh_node *batadv_v_elp_neigh_new (struct batadv_hard_iface *hard_iface, -uint8_t *neigh_addr,uint8_t *orig_addr,uint32_t seqno) +uint8_t *neigh_addr,uint8_t *orig_addr) {struct batadv_elp_neigh_node *neigh;
@@ -73,7 +73,6 @@ batadv_v_elp_neigh_new(struct batadv_hard_iface *hard_iface,memcpy (neigh->orig, orig_addr,ETH_ALEN );memcpy (neigh->addr, neigh_addr,ETH_ALEN ); - neigh->last_recv_seqno = seqno -1 ; neigh->last_seen = jiffies;ewma_init (&neigh->metric,1024 ,8 );/* recount initialised to 2 to simplify the caller function */
@@ -326,13 +325,13 @@ static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv, neigh =batadv_v_elp_neigh_get (if_incoming, neigh_addr);if (!neigh) { neigh =batadv_v_elp_neigh_new (if_incoming, neigh_addr, - elp_packet->orig, -ntohl (elp_packet->seqno)); + elp_packet->orig);if (!neigh) goto out; } neigh->last_seen = jiffies; + neigh->last_recv_seqno =ntohl (elp_packet->seqno); out:if (neigh)
bat_v_ogm.c +411 -11
476 lines not on this page · raw message
Signature · 1 line
1.8.5.3
RFC 9/23 batman-adv: OGMv2 - purge obsolete potential routers
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
If a neighbor is not forwarding OGMs since OGM_SEQ_RANGE sequence numbers then it can be considered obsolete and removed from the potential routers list. This may lead to a route switch.
--- bat_v_ogm.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- main.h | 3 ++ originator.c | 63 +++++++++++++++++++++++------------------ originator.h | 2 ++ types.h | 2 ++ 5 files changed, 131 insertions(+), 31 deletions(-)
bat_v_ogm.c +89 -3
@@ -79,8 +79,6 @@ batadv_v_ogm_neigh_new(struct batadv_priv *bat_priv,return NULL ; } - neigh_node->bat_v.elp_neigh = elp_neigh; -spin_lock_bh (&orig_node->neigh_list_lock); tmp_neigh_node =batadv_neigh_node_get (orig_node, hard_iface, addr);if (!tmp_neigh_node) {
@@ -98,6 +96,8 @@ batadv_v_ogm_neigh_new(struct batadv_priv *bat_priv,"Creating new neighbor %pM for orig_node %pM on interface %s\n" , addr, orig_node->orig, hard_iface->net_dev->name); + neigh_node->bat_v.elp_neigh = elp_neigh; +return neigh_node; }
@@ -235,6 +235,86 @@ void batadv_v_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)rcu_read_unlock (); } +static bool batadv_ogm_deselect_router (struct batadv_priv *bat_priv, +struct batadv_orig_node *orig_node, +struct batadv_neigh_node *neigh) +{ +struct batadv_hard_iface *if_outgoing; +struct batadv_neigh_node *router; +bool removed = false; + + router =batadv_orig_router_get (orig_node,BATADV_IF_DEFAULT ); +if (router == neigh) +batadv_update_route (bat_priv, orig_node,BATADV_IF_DEFAULT , +NULL ); +if (router) +batadv_neigh_node_free_ref (router); + +rcu_read_lock (); +list_for_each_entry_rcu (if_outgoing, &batadv_hardif_list, list) { +if (if_outgoing->if_status !=BATADV_IF_ACTIVE ) +continue ; + +if (if_outgoing->soft_iface != bat_priv->soft_iface) +continue ; + + router =batadv_orig_router_get (orig_node, if_outgoing); +/* if this is the current router, unset it */ +if (router == neigh) { +batadv_update_route (bat_priv, orig_node, if_outgoing, +NULL ); + removed = true; + } +if (router) +batadv_neigh_node_free_ref (router); + } +rcu_read_unlock (); + +return removed; +} + +/** +* batadv_v_ogm_purge_neighs - purge obsolete potential routers +* @bat_priv: +* @orig_node: +* @seqno: +* +* Purge routers from which this node did not receive at least +* BATADV_OGM_SEQ_RANGE OGMs +*/ +static void batadv_v_ogm_purge_neighs (struct batadv_priv *bat_priv, +struct batadv_orig_node *orig_node, +uint32_t seqno) +{ +struct batadv_neigh_node *neigh; +struct hlist_node *node_tmp; +int32_t diff; + +rcu_read_lock (); +spin_lock_bh (&orig_node->neigh_list_lock); +hlist_for_each_entry_safe (neigh, node_tmp, &orig_node->neigh_list, + list) { + diff = seqno - neigh->bat_v.last_recv_seqno; +if (diff <BATADV_OGM_SEQ_RANGE ) +continue ; + +hlist_del_rcu (&neigh->list); +batadv_neigh_node_free_ref (neigh); + } +spin_unlock_bh (&orig_node->neigh_list_lock); + +/* check if this neighbour is a router for any outgoing +* interface and possibly deselect it +*/ +if (batadv_ogm_deselect_router (bat_priv, orig_node, neigh)) + goto out; + +batadv_router_selection (bat_priv, orig_node); +out: +rcu_read_unlock (); +return ; +} + static void batadv_v_ogm_orig_update(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node,
@@ -262,7 +342,7 @@ batadv_v_ogm_orig_update(struct batadv_priv *bat_priv,batadv_orig_ifinfo_free_ref (orig_ifinfo);/* if this neighbor already is our next hop there is nothing -* to change +* to change. The router may have been changed by the purge routine */ router =batadv_orig_router_get (orig_node, if_outgoing);if (router == neigh_node)
@@ -547,6 +627,7 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb,/* update the neigh_node information */ neigh_node->last_seen = jiffies; + neigh_node->bat_v.last_recv_seqno =ntohl (ogm2->seqno);/* update the received metric to match the node topology: if this node * is the first hop traversed by the OGM, then the metric is substituted
@@ -579,6 +660,11 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb, }rcu_read_unlock (); +/* purge potential neighs not forwarding OGMs anymore. +* This may lead to a router change +*/ +batadv_v_ogm_purge_neighs (bat_priv, orig_node,ntohl (ogm2->seqno)); + ret =NET_RX_SUCCESS ;consume_skb (skb);
main.h +3 -0
@@ -62,6 +62,9 @@/* number of OGMs sent with the last tt diff */ #define BATADV_TT_OGM_APPEND_MAX 3 +/* number of missing OGMs to wait before considering a router unusable */ +#define BATADV_OGM_SEQ_RANGE 5 +/* Time in which a client can roam at most ROAMING_MAX_COUNT times in * milliseconds */
originator.c +35 -28
81 lines not on this page · raw message
originator.h +2 -0
@@ -55,6 +55,8 @@ struct batadv_orig_ifinfo * batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node, struct batadv_hard_iface *if_outgoing);void batadv_orig_ifinfo_free_ref (struct batadv_orig_ifinfo *orig_ifinfo); +void batadv_router_selection (struct batadv_priv *bat_priv, +struct batadv_orig_node *orig_node);int batadv_orig_seq_print_text (struct seq_file *seq,void *offset);int batadv_orig_hardif_seq_print_text (struct seq_file *seq,void *offset);
types.h +2 -0
@@ -358,9 +358,11 @@ struct batadv_elp_neigh_node {/** * batadv_neigh_node_bat_v - B.A.T.M.A.N. V private neighbor information * @elp_neigh: ELP private neighbour data +* @last_recv_seqno: last OGM seqno received through this neighbour */ struct batadv_neigh_node_bat_v {struct batadv_elp_neigh_node *elp_neigh; +uint32_t last_recv_seqno; };/**
Signature · 1 line
1.8.5.3
RFC 10/23 batman-adv: split name from variable for uint mesh attributes
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
Some mesh attributes are behind substructs in the batadv_priv object and for this reason the name cannot be used anymore to refer to them.
This patch allows to specify the variable name where the attribute is stored inside batadv_priv instead of using the name
--- sysfs.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
sysfs.c +15 -6
@@ -148,7 +148,7 @@ ssize_t batadv_show_##_name(struct kobject *kobj, \ batadv_store_##_name) -#define BATADV_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func) \ +#define BATADV_ATTR_SIF_STORE_UINT(_name, _var, _min, _max, _post_func) \ ssize_t batadv_store_##_name(struct kobject *kobj, \ struct attribute *attr, char *buff, \ size_t count) \
@@ -157,23 +157,32 @@ ssize_t batadv_store_##_name(struct kobject *kobj, \struct batadv_priv *bat_priv =netdev_priv (net_dev); \return __batadv_store_uint_attr (buff, count, _min, _max, \ _post_func, attr, \ - &bat_priv->_name, net_dev); \ + &bat_priv->_var, net_dev); \ } -#define BATADV_ATTR_SIF_SHOW_UINT (_name) \ +#define BATADV_ATTR_SIF_SHOW_UINT (_name, _var) \ ssize_t batadv_show_##_name(struct kobject *kobj, \ struct attribute *attr, char *buff) \ { \ struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \ - return sprintf(buff, "%i\n", atomic_read(&bat_priv->_name)); \ + return sprintf(buff, "%i\n", atomic_read(&bat_priv->_var)); \ } \/* Use this, if you are going to set [name] in the soft-interface * (bat_priv) to an unsigned integer value */ #define BATADV_ATTR_SIF_UINT (_name, _mode, _min, _max, _post_func) \ - static BATADV_ATTR_SIF_STORE_UINT(_name, _min, _max, _post_func)\ - static BATADV_ATTR_SIF_SHOW_UINT(_name) \ + static BATADV_ATTR_SIF_STORE_UINT(_name, _name, _min, _max, _post_func)\ + static BATADV_ATTR_SIF_SHOW_UINT(_name, _name) \ + static BATADV_ATTR(_name, _mode, batadv_show_##_name, \ + batadv_store_##_name) + +/* Same as BATADV_ATTR_SIF_UINT, but allow to specify the variable name as +* second parameter so that it does not need to match the attribute name +*/ +#define BATADV_ATTR_SIF_UINT2 (_name, _var, _mode, _min, _max, _post_func)\ + static BATADV_ATTR_SIF_STORE_UINT(_name, _var, _min, _max, _post_func)\ + static BATADV_ATTR_SIF_SHOW_UINT(_name, _var) \ static BATADV_ATTR(_name, _mode, batadv_show_##_name, \ batadv_store_##_name)
Signature · 1 line
1.8.5.3
RFC 11/23 batman-adv: add throughput attribute to hard_ifaces
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
This attribute is exported to the user which can manually select its value. It is the throughput value to be used by default when batman-adv is trying to compute the link throughput towards a neighbour using this interface.
If the value is set to 0 then batman-adv will try to detect the throughput by itself.
--- bat_v.c | 3 +++ sysfs.c | 3 +++ types.h | 2 ++ 3 files changed, 8 insertions(+)
bat_v.c +3 -0
@@ -34,6 +34,9 @@ static int batadv_v_iface_enable(struct batadv_hard_iface *hard_iface)if (ret <0 )batadv_v_elp_iface_disable (hard_iface); +/* disable user customised throughput by default */ +atomic_set (&hard_iface->bat_v.user_throughput,0 ); +return ret; }
sysfs.c +3 -0
@@ -889,6 +889,8 @@ static BATADV_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL);#ifdef CONFIG_BATMAN_ADV_BATMAN_V BATADV_ATTR_HIF_UINT (elp_interval, bat_v.elp_interval,S_IRUGO |S_IWUSR ,2 *BATADV_JITTER ,INT_MAX ,NULL ); +BATADV_ATTR_HIF_UINT (throughput, bat_v.user_throughput,S_IRUGO |S_IWUSR , +0 ,UINT_MAX ,NULL );#endif static struct batadv_attribute *batadv_batman_attrs[] = {
@@ -896,6 +898,7 @@ static struct batadv_attribute *batadv_batman_attrs[] = { &batadv_attr_iface_status, #ifdef CONFIG_BATMAN_ADV_BATMAN_V &batadv_attr_elp_interval, + &batadv_attr_throughput, #endif NULL, };
types.h +2 -0
@@ -78,6 +78,7 @@ struct batadv_hard_iface_bat_iv {* @num_neighbours: number of neighbours in the neigh_list * @elp_skb: base skb containing the ELP message to send * @elp_wq: workqueue used to schedule ELP transmissions +* @user_throughput: user specified throughput */ struct batadv_hard_iface_bat_v {atomic_t elp_interval;
@@ -87,6 +88,7 @@ struct batadv_hard_iface_bat_v {atomic_t num_neighbors;struct sk_buff *elp_skb;struct delayed_work elp_wq; +atomic_t user_throughput; };/**
Signature · 1 line
1.8.5.3
RFC 12/23 batman-adv: add base throughput attribute
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
when batman-adv is asked to estimate/compute the throughput of an interface, but it fails for whatever reason, then the value in this attribute is used
--- bat_v.c | 3 +++ main.h | 7 +++++++ sysfs.c | 7 +++++++ types.h | 1 + 4 files changed, 18 insertions(+)
bat_v.c +3 -0
@@ -75,6 +75,9 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {int batadv_v_mesh_init (struct batadv_priv *bat_priv) { +atomic_set (&bat_priv->bat_v.base_throughput, +BATADV_DEFAULT_BASE_THROUGHPUT ); +return batadv_v_ogm_init (bat_priv); }
main.h +7 -0
@@ -33,6 +33,13 @@#define BATADV_MAX_METRIC 0xFFFFFFFF#define BATADV_JITTER 20 +/** +* BATADV_DEFAULT_BASE_THROUGHPUT - default value used as throughput for +* hard_ifaces for which it is not possible to measure/estimate the real one. +* Value is expressed in Mbps/10 +*/ +#define BATADV_DEFAULT_BASE_THROUGHPUT 10 +/* Time To Live of broadcast messages */ #define BATADV_TTL 50
sysfs.c +7 -0
@@ -606,6 +606,10 @@ BATADV_ATTR_SIF_BOOL(network_coding, S_IRUGO | S_IWUSR,#endif static BATADV_ATTR(isolation_mark, S_IRUGO | S_IWUSR, batadv_show_isolation_mark, batadv_store_isolation_mark); +#ifdef CONFIG_BATMAN_ADV_BATMAN_V +BATADV_ATTR_SIF_UINT2 (base_throughput, bat_v.base_throughput,S_IRUGO |S_IWUSR , +1 ,UINT_MAX ,NULL ); +#endif static struct batadv_attribute *batadv_mesh_attrs[] = { &batadv_attr_aggregated_ogms,
@@ -630,6 +634,9 @@ static struct batadv_attribute *batadv_mesh_attrs[] = { &batadv_attr_network_coding, #endif &batadv_attr_isolation_mark, +#ifdef CONFIG_BATMAN_ADV_BATMAN_V + &batadv_attr_base_throughput, +#endif NULL, };
types.h +1 -0
@@ -741,6 +741,7 @@ struct batadv_priv_bat_v {int ogm_buff_len;struct delayed_work ogm_wq;atomic_t ogm_seqno; +atomic_t base_throughput; };/**
Signature · 1 line
1.8.5.3
RFC 13/23 batman-adv: add last_unicast_tx to struct neigh_node_elp
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
This timestamp registers the last time a unicast packet was sent to a given neighbour
--- bat_iv_ogm.c | 2 +- bat_v_elp.c | 2 +- bat_v_ogm.c | 2 +- distributed-arp-table.c | 4 +--- fragmentation.c | 8 +++----- icmp_socket.c | 2 +- network-coding.c | 20 +++++++++----------- send.c | 46 +++++++++++++++++++++++++++++++++++++++------- send.h | 10 +++++++--- types.h | 2 ++ 10 files changed, 65 insertions(+), 33 deletions(-)
bat_iv_ogm.c +1 -1
@@ -469,7 +469,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,batadv_inc_counter (bat_priv,BATADV_CNT_MGMT_TX );batadv_add_counter (bat_priv,BATADV_CNT_MGMT_TX_BYTES , skb->len +ETH_HLEN ); -batadv_send_skb_packet (skb, hard_iface, batadv_broadcast_addr); +batadv_send_broadcast_skb (skb, hard_iface); } }
bat_v_elp.c +1 -1
@@ -200,7 +200,7 @@ static void batadv_v_elp_send_outstanding(struct work_struct *work) hard_iface->net_dev->name, atomic_read(&hard_iface->bat_v.elp_seqno)); -batadv_send_skb_packet (skb, hard_iface, batadv_broadcast_addr); +batadv_send_broadcast_skb (skb, hard_iface);atomic_inc (&hard_iface->bat_v.elp_seqno);
bat_v_ogm.c +1 -1
@@ -129,7 +129,7 @@ static void batadv_v_ogm_send_to_if(struct sk_buff *skb,batadv_add_counter (bat_priv,BATADV_CNT_MGMT_TX_BYTES , skb->len +ETH_HLEN ); -batadv_send_skb_packet (skb, hard_iface, batadv_broadcast_addr); +batadv_send_broadcast_skb (skb, hard_iface); }static void batadv_v_ogm_send (struct work_struct *work)
distributed-arp-table.c +1 -3
@@ -602,9 +602,7 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv, goto free_neigh; } - send_status =batadv_send_skb_packet (tmp_skb, - neigh_node->if_incoming, - neigh_node->addr); + send_status =batadv_send_unicast_skb (tmp_skb, neigh_node);if (send_status ==NET_XMIT_SUCCESS ) {/* count the sent packet */ switch (packet_subtype) {
fragmentation.c +3 -5
@@ -354,8 +354,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, skb->len + ETH_HLEN); packet->ttl--; -batadv_send_skb_packet (skb, neigh_node->if_incoming, - neigh_node->addr); +batadv_send_unicast_skb (skb, neigh_node); ret = true; }
@@ -461,8 +460,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,batadv_inc_counter (bat_priv,BATADV_CNT_FRAG_TX );batadv_add_counter (bat_priv,BATADV_CNT_FRAG_TX_BYTES , skb_fragment->len +ETH_HLEN ); -batadv_send_skb_packet (skb_fragment, neigh_node->if_incoming, - neigh_node->addr); +batadv_send_unicast_skb (skb_fragment, neigh_node); frag_header.no++;/* The initial check in this function should cover this case */
@@ -481,7 +479,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,batadv_inc_counter (bat_priv,BATADV_CNT_FRAG_TX );batadv_add_counter (bat_priv,BATADV_CNT_FRAG_TX_BYTES , skb->len +ETH_HLEN ); -batadv_send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr); +batadv_send_unicast_skb (skb, neigh_node);return true; out_err:
icmp_socket.c +1 -1
@@ -253,7 +253,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,ether_addr_copy (icmp_header->orig, primary_if->net_dev->dev_addr); -batadv_send_skb_packet (skb, neigh_node->if_incoming, neigh_node->addr); +batadv_send_unicast_skb (skb, neigh_node); goto out; dst_unreach:
network-coding.c +9 -11
@@ -535,9 +535,7 @@ batadv_nc_hash_find(struct batadv_hashtable *hash,*/ static void batadv_nc_send_packet (struct batadv_nc_packet *nc_packet) { -batadv_send_skb_packet (nc_packet->skb, - nc_packet->neigh_node->if_incoming, - nc_packet->nc_path->next_hop); +batadv_send_unicast_skb (nc_packet->skb, nc_packet->neigh_node); nc_packet->skb =NULL ;batadv_nc_packet_free (nc_packet); }
@@ -1018,11 +1016,11 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,struct batadv_unicast_packet *packet1;struct batadv_unicast_packet *packet2;struct batadv_coded_packet *coded_packet; -struct batadv_neigh_node *neigh_tmp, *router_neigh; -struct batadv_neigh_node *router_coding =NULL ; +struct batadv_neigh_node *neigh_tmp, *router_neigh, *first_dest; +struct batadv_neigh_node *router_coding =NULL , *second_dest;struct batadv_neigh_ifinfo *router_neigh_ifinfo =NULL ;struct batadv_neigh_ifinfo *router_coding_ifinfo =NULL ; -uint8_t *first_source, *first_dest, *second_source, *second_dest; +uint8_t *first_source, *second_source;__be32 packet_id1, packet_id2;size_t count;bool res = false;
@@ -1065,9 +1063,9 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,*/ if (tq_weighted_neigh >= tq_weighted_coding) {/* Destination from nc_packet is selected for MAC-header */ - first_dest = nc_packet->nc_path->next_hop; + first_dest = nc_packet->neigh_node; first_source = nc_packet->nc_path->prev_hop; - second_dest = neigh_node->addr; + second_dest = neigh_node; second_source = ethhdr->h_source; packet1 = (struct batadv_unicast_packet *)nc_packet->skb->data; packet2 = (struct batadv_unicast_packet *)skb->data;
@@ -1076,9 +1074,9 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, skb->data + sizeof(*packet2)); }else {/* Destination for skb is selected for MAC-header */ - first_dest = neigh_node->addr; + first_dest = neigh_node; first_source = ethhdr->h_source; - second_dest = nc_packet->nc_path->next_hop; + second_dest = nc_packet->neigh_node; second_source = nc_packet->nc_path->prev_hop; packet1 = (struct batadv_unicast_packet *)skb->data; packet2 = (struct batadv_unicast_packet *)nc_packet->skb->data;
@@ -1175,7 +1173,7 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,batadv_nc_packet_free (nc_packet);/* Send the coded packet and return true */ -batadv_send_skb_packet (skb_dest, neigh_node->if_incoming, first_dest); +batadv_send_unicast_skb (skb_dest, first_dest); res = true; out:if (router_neigh)
send.c +39 -7
77 lines not on this page · raw message
send.h +7 -3
@@ -18,12 +18,16 @@#ifndef _NET_BATMAN_ADV_SEND_H_#define _NET_BATMAN_ADV_SEND_H_ -int batadv_send_skb_packet (struct sk_buff *skb, -struct batadv_hard_iface *hard_iface, -const uint8_t *dst_addr);int batadv_send_skb_to_orig (struct sk_buff *skb,struct batadv_orig_node *orig_node,struct batadv_hard_iface *recv_if); +int batadv_send_skb_packet (struct sk_buff *skb, +struct batadv_hard_iface *hard_iface, +const uint8_t *dst_addr); +int batadv_send_broadcast_skb (struct sk_buff *skb, +struct batadv_hard_iface *hard_iface); +int batadv_send_unicast_skb (struct sk_buff *skb, +struct batadv_neigh_node *neigh_node);void batadv_schedule_bat_ogm (struct batadv_hard_iface *hard_iface); int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, const struct sk_buff *skb,
types.h +2 -0
@@ -342,6 +342,7 @@ struct batadv_gw_node {* @metric: ewma link metric towards this neighbor * @last_recv_seqno: last ELP received sequence number * @lest_seen: last time this neigh has been seen +* @last_unicast_tx: when the last unicast packet has been sent to this neighbor * @refcount: number of contexts the object is used * @rcu: struct used for freeing in an RCU-safe manner */
@@ -353,6 +354,7 @@ struct batadv_elp_neigh_node {uint32_t last_recv_seqno;unsigned long last_seen;uint32_t elp_interval; +unsigned long last_unicast_tx;atomic_t refcount;struct rcu_head rcu; };
Signature · 1 line
1.8.5.3
RFC 14/23 batman-adv: ELP - compute the metric based on the estimated throughput
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
Implement a stub get_throughput() function which returns the estimated throughput towards a given neighbour. Its result is then used to compute the metric value.
The metric is updated each time a new ELP packet is sent, this way it is possible to timely react to a metric variation which can imply (for example) a neighbour disconnection.
--- bat_v_elp.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ types.h | 2 ++ 2 files changed, 45 insertions(+), 6 deletions(-)
bat_v_elp.c +43 -6
@@ -53,6 +53,29 @@ void batadv_elp_neigh_node_free_ref(struct batadv_elp_neigh_node *neigh) }/** +* batadv_v_elp_get_throughput - get the throughput towards a neighbour +* @neigh: the neighbour for which the throughput has to be obtained +* +* Returns the throughput towards the given neighbour. +*/ +static uint32_t +batadv_v_elp_get_throughput (struct batadv_elp_neigh_node *neigh) +{ +struct batadv_hard_iface *hard_iface = neigh->hard_iface; +struct batadv_priv *bat_priv =netdev_priv (hard_iface->soft_iface); +uint32_t throughput; + +/* get the customised user value for the throughput */ + throughput =atomic_read (&hard_iface->bat_v.user_throughput); +/* if the user specified a value, let's return it */ +if (throughput !=0 ) +return throughput; + +/* throughput cannot be computed right now. Return base value */ +return atomic_read (&bat_priv->bat_v.base_throughput); +} + +/** * batadv_v_elp_neigh_new - create a new ELP neighbour node * @hard_iface: the interface the neighbour is connected to * @neigh_addr: the neighbour interface address
@@ -75,6 +98,7 @@ batadv_v_elp_neigh_new(struct batadv_hard_iface *hard_iface,memcpy (neigh->addr, neigh_addr,ETH_ALEN ); neigh->last_seen = jiffies;ewma_init (&neigh->metric,1024 ,8 ); + neigh->hard_iface = hard_iface;/* recount initialised to 2 to simplify the caller function */ atomic_set (&neigh->refcount,2 );
@@ -147,19 +171,20 @@ static void batadv_v_elp_neigh_purge(struct batadv_hard_iface *hard_iface) }/** -* batadv_v_elp_send_outstanding - ELP periodic broadcast sending +* batadv_v_elp_periodic_work - ELP periodic task per interface * @work: work queue item * -* Sends a broadcast ELP message over the interface that this work item belongs -* to. +* Sends a broadcast ELP message and reads the metric for all the neighbours +* connected to the interface that this work item belongs to. */ -static void batadv_v_elp_send_outstanding (struct work_struct *work) +static void batadv_v_elp_periodic_work (struct work_struct *work) {struct batadv_hard_iface *hard_iface;struct batadv_hard_iface_bat_v *bat_v;struct batadv_priv *bat_priv;struct batadv_elp_packet *elp_packet;uint32_t elp_interval; +struct batadv_elp_neigh_node *neigh;struct sk_buff *skb;uint8_t num_neighs;
@@ -181,7 +206,7 @@ static void batadv_v_elp_send_outstanding(struct work_struct *work) skb =skb_copy (hard_iface->bat_v.elp_skb,GFP_ATOMIC );if (!skb) - goto out; + goto update_metric;/* purge outdated entries first */ batadv_v_elp_neigh_purge (hard_iface);
@@ -204,6 +229,17 @@ static void batadv_v_elp_send_outstanding(struct work_struct *work)atomic_inc (&hard_iface->bat_v.elp_seqno); +update_metric: +/* Instead of updating the metric each "received" ELP packet, it is +* better to do it on each ELP sending. This way, if a node is dead and +* does not send packets anymore, batman-adv is still able to timely +* react to its death. +*/ +rcu_read_lock (); +hlist_for_each_entry_rcu (neigh, &hard_iface->bat_v.neigh_list, list) +ewma_add (&neigh->metric,batadv_v_elp_get_throughput (neigh)); +rcu_read_unlock (); + restart_timer:batadv_v_elp_start_timer (hard_iface); out:
@@ -247,7 +283,7 @@ int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)atomic_set (&hard_iface->bat_v.elp_interval,500 );INIT_DELAYED_WORK (&hard_iface->bat_v.elp_wq, - batadv_v_elp_send_outstanding); + batadv_v_elp_periodic_work);batadv_v_elp_start_timer (hard_iface); res =0 ;
@@ -332,6 +368,7 @@ static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv, neigh->last_seen = jiffies; neigh->last_recv_seqno =ntohl (elp_packet->seqno); +ewma_add (&neigh->metric,batadv_v_elp_get_throughput (neigh)); out:if (neigh)
types.h +2 -0
@@ -345,6 +345,7 @@ struct batadv_gw_node {* @last_unicast_tx: when the last unicast packet has been sent to this neighbor * @refcount: number of contexts the object is used * @rcu: struct used for freeing in an RCU-safe manner +* @hard_iface: the interface where this neighbor is connected to */ struct batadv_elp_neigh_node {struct hlist_node list;
@@ -357,6 +358,7 @@ struct batadv_elp_neigh_node {unsigned long last_unicast_tx;atomic_t refcount;struct rcu_head rcu; +struct batadv_hard_iface *hard_iface; };/**
Signature · 1 line
1.8.5.3
RFC 15/23 batman-adv: ELP - send unicast ELP packets for throughput sampling
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
In case of a unused link, the throughput estimation will get stuck to the last sampled value and therefore the reported metric will becomes obsolete.
Send unicast ELP packets to each neighbor to trigger throughput sampling on unused links.
These packets will fill an entire frame so that the measurement is as much reliable as possible
--- bat_v_elp.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- main.h | 3 +++ send.c | 4 +-- 3 files changed, 85 insertions(+), 8 deletions(-)
bat_v_elp.c +80 -6
@@ -25,6 +25,7 @@#include "bat_v_elp.h" #include "originator.h" #include "routing.h" +#include "soft-interface.h" #include "translation-table.h" /**
@@ -171,6 +172,67 @@ static void batadv_v_elp_neigh_purge(struct batadv_hard_iface *hard_iface) }/** +* batadv_v_elp_wifi_neigh_probe - send link probing packets to a neighbour +* @hard_iface: the interface to use while sending the probing packets +* @neigh: the neighbour to probe +* +* Sends a predefined number of unicast wifi packets to a given neighbour in +* order to trigger the throughput estimation on this link by the RC algorithm. +* Packets are sent only if there there is not enough payload unicast traffic +* towards this neighbour.. +* +* Returns 0 on success and -1 in case of error during skb preparation. +*/ +static int batadv_v_elp_wifi_neigh_probe (struct batadv_hard_iface *hard_iface, +struct batadv_elp_neigh_node *neigh) +{ +struct batadv_priv *bat_priv =netdev_priv (hard_iface->soft_iface); +unsigned long last_tx_diff; +struct sk_buff *skb; +int probe_len, i; + +/* this probing routine is for Wifi neighbours only */ +if (batadv_is_wifi_netdev (hard_iface->net_dev)) +return 0 ; + +/* probe the neighbor only if no unicast packets have been sent +* to it in the last 100 milliseconds: this is the rate control +* algorithm sampling interval (minstrel). In this way, if not +* enough traffic has been sent to the neighbor, batman-adv can +* generate 2 probe packets and push the RC algorithm to perform +* the sampling +*/ + last_tx_diff =jiffies_to_msecs (jiffies - neigh->last_unicast_tx); +if (last_tx_diff <=BATADV_ELP_PROBE_MAX_TX_DIFF ) +return 0 ; + + probe_len =max_t (int,sizeof (struct batadv_elp_packet ), +BATADV_ELP_MIN_PROBE_SIZE ); + +for (i =0 ; i <BATADV_ELP_PROBES_PER_NODE ; i++) { + skb =skb_copy_expand (hard_iface->bat_v.elp_skb,0 , + probe_len - hard_iface->bat_v.elp_skb->len, +GFP_ATOMIC ); +if (!skb) +return -1 ; + +/* Tell the skb to get as bigger as the allocated space (we want +* the packet to be exactly of that size to make the link +* throughput estimation effective. +*/ +skb_put (skb, probe_len - hard_iface->bat_v.elp_skb->len); + +batadv_dbg (BATADV_DBG_BATMAN , bat_priv, +"Sending unicast (probe) ELP packet on interface %s to %pM\n" , + hard_iface->net_dev->name, neigh->addr); + +batadv_send_skb_packet (skb, hard_iface, neigh->addr); + } + +return 0 ; +} + +/** * batadv_v_elp_periodic_work - ELP periodic task per interface * @work: work queue item *
@@ -181,11 +243,11 @@ static void batadv_v_elp_periodic_work(struct work_struct *work) {struct batadv_hard_iface *hard_iface;struct batadv_hard_iface_bat_v *bat_v; -struct batadv_priv *bat_priv;struct batadv_elp_packet *elp_packet; -uint32_t elp_interval;struct batadv_elp_neigh_node *neigh; +struct batadv_priv *bat_priv;struct sk_buff *skb; +uint32_t elp_interval;uint8_t num_neighs; bat_v = container_of(work, struct batadv_hard_iface_bat_v, elp_wq.work);
@@ -206,7 +268,7 @@ static void batadv_v_elp_periodic_work(struct work_struct *work) skb =skb_copy (hard_iface->bat_v.elp_skb,GFP_ATOMIC );if (!skb) - goto update_metric; + goto restart_timer;/* purge outdated entries first */ batadv_v_elp_neigh_purge (hard_iface);
@@ -221,7 +283,7 @@ static void batadv_v_elp_periodic_work(struct work_struct *work) elp_packet->elp_interval =htonl (elp_interval);batadv_dbg (BATADV_DBG_BATMAN , bat_priv, -"Sending ELP packet on interface %s, seqno %u\n" , +"Sending broadcast ELP packet on interface %s, seqno %u\n" , hard_iface->net_dev->name,atomic_read (&hard_iface->bat_v.elp_seqno));
@@ -229,15 +291,27 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)atomic_inc (&hard_iface->bat_v.elp_seqno); -update_metric:/* Instead of updating the metric each "received" ELP packet, it is * better to do it on each ELP sending. This way, if a node is dead and * does not send packets anymore, batman-adv is still able to timely * react to its death. +* +* The metric is updated by following these steps: +* 1) if the hard_iface if wifi => send a unicast ELP for +* probing/sampling to each neighbor +* 2) update the metric value of each neighbor +* */ rcu_read_lock (); -hlist_for_each_entry_rcu (neigh, &hard_iface->bat_v.neigh_list, list) +hlist_for_each_entry_rcu (neigh, &hard_iface->bat_v.neigh_list, list) { +if (batadv_v_elp_wifi_neigh_probe (hard_iface, neigh) <0 ) +/* if something goes wrong while probing, better to stop +* sending packets immediately and reschedule the task +*/ +break ; +ewma_add (&neigh->metric,batadv_v_elp_get_throughput (neigh)); + }rcu_read_unlock (); restart_timer:
main.h +3 -0
@@ -54,6 +54,9 @@#define BATADV_ORIG_WORK_PERIOD 1000/* 1 second */ #define BATADV_DAT_ENTRY_TIMEOUT (5*60000)/* 5 mins in milliseconds */ #define BATADV_ELP_OUTDATED_MAX 4 +#define BATADV_ELP_PROBES_PER_NODE 2 +#define BATADV_ELP_MIN_PROBE_SIZE 200/* bytes */ +#define BATADV_ELP_PROBE_MAX_TX_DIFF 100/* milliseconds */ /* sliding packet range of received originator messages in sequence numbers * (should be a multiple of our word size) */
send.c +2 -2
@@ -108,8 +108,8 @@ int batadv_send_unicast_skb(struct sk_buff *skb, ret =batadv_send_skb_packet (skb, neigh->if_incoming, neigh->addr);#ifdef CONFIG_BATMAN_ADV_BATMAN_V -if (ret !=NET_XMIT_DROP && neigh->elp_neigh) - neigh->elp_neigh->last_unicast_tx = jiffies; +if (ret !=NET_XMIT_DROP && neigh->bat_v.elp_neigh) + neigh->bat_v.elp_neigh->last_unicast_tx = jiffies;#endif return ret;
Signature · 1 line
1.8.5.3
RFC 16/23 batman-adv: ELP - read estimated throughput from cfg80211
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
In case of wireless interface retrieve the throughput by querying cfg80211. To perform this call a separate work must be scheduled because the function may sleep and this is not allowed within an RCU protected context (RCU in this case is used to iterate over all the neighbours).
--- bat_v_elp.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- compat.h | 20 ++++++++++++++++++++ types.h | 2 ++ 3 files changed, 76 insertions(+), 7 deletions(-)
bat_v_elp.c +54 -7
@@ -18,6 +18,8 @@* */ +#include <net/cfg80211.h> +#include "main.h" #include "hard-interface.h" #include "send.h"
@@ -64,19 +66,56 @@ batadv_v_elp_get_throughput(struct batadv_elp_neigh_node *neigh) {struct batadv_hard_iface *hard_iface = neigh->hard_iface;struct batadv_priv *bat_priv =netdev_priv (hard_iface->soft_iface); +struct station_info sinfo;uint32_t throughput; +int r; -/* get the customised user value for the throughput */ - throughput =atomic_read (&hard_iface->bat_v.user_throughput); -/* if the user specified a value, let's return it */ +/* if the user specified a customised value for this interface, then +* return it directly +*/ + throughput =atomic_read (&hard_iface->bat_v.user_throughput);if (throughput !=0 )return throughput; -/* throughput cannot be computed right now. Return base value */ +/* if this is a wireless device, then ask its throughput through +* cfg80211 API +*/ +if (hard_iface->net_dev->ieee80211_ptr) { + r =cfg80211_get_station (hard_iface->net_dev, neigh->addr, + &sinfo); +if (r == -ENOENT ) { +/* node is not associated anymore! it would be possible +* to delete this neighbor. for now set metric to 0 +*/ +return 0 ; + } +if (!r) +return sinfo.expected_throughput; + } + +/* if none of the above cases apply, return the base_throughput */ return atomic_read (&bat_priv->bat_v.base_throughput); }/** +* batadv_v_elp_metric_update - worker updating the metric of one neighbour +* @work: the work queue item +*/ +static void batadv_v_elp_metric_update (struct work_struct *work) +{ +struct batadv_elp_neigh_node *neigh; + + neigh = container_of(work, struct batadv_elp_neigh_node, metric_work); + +ewma_add (&neigh->metric,batadv_v_elp_get_throughput (neigh)); + +/* decrement refcounter to balance increment performed before scheduling +* this task +*/ +batadv_elp_neigh_node_free_ref (neigh); +} + +/** * batadv_v_elp_neigh_new - create a new ELP neighbour node * @hard_iface: the interface the neighbour is connected to * @neigh_addr: the neighbour interface address
@@ -108,6 +147,8 @@ batadv_v_elp_neigh_new(struct batadv_hard_iface *hard_iface,spin_unlock_bh (&hard_iface->bat_v.neigh_list_lock);atomic_inc (&hard_iface->bat_v.num_neighbors); +INIT_WORK (&neigh->metric_work, batadv_v_elp_metric_update); +return neigh; }
@@ -192,7 +233,7 @@ static int batadv_v_elp_wifi_neigh_probe(struct batadv_hard_iface *hard_iface,int probe_len, i;/* this probing routine is for Wifi neighbours only */ -if (batadv_is_wifi_netdev (hard_iface->net_dev)) +if (!batadv_is_wifi_netdev (hard_iface->net_dev))return 0 ;/* probe the neighbor only if no unicast packets have been sent
@@ -310,7 +351,14 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)*/ break ; -ewma_add (&neigh->metric,batadv_v_elp_get_throughput (neigh)); +if (!atomic_inc_not_zero (&neigh->refcount)) +continue ; + +/* reading the estimated throughput from cfg80211 is a task that +* may sleep and that is not allowed in an rcu protected +* context. Therefore schedule a task for that. +*/ +queue_work (batadv_event_workqueue, &neigh->metric_work); }rcu_read_unlock ();
@@ -442,7 +490,6 @@ static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv, neigh->last_seen = jiffies; neigh->last_recv_seqno =ntohl (elp_packet->seqno); -ewma_add (&neigh->metric,batadv_v_elp_get_throughput (neigh)); out:if (neigh)
compat.h +20 -0
@@ -407,4 +407,24 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\#endif /* < KERNEL_VERSION(3, 14, 0) */ +#if LINUX_VERSION_CODE <KERNEL_VERSION (3 ,15 ,0 ) + +/* NOTE: shall I put this ifndef outside of every #if block ? */ +#ifndef cfg80211_get_station + +/* the expected behaviour of this function is to return 0 on success, therefore +* it is possible to define it as 1 so that batman-adv thinks like something +* went wrong. It will then decide what to do. +*/ +#define cfg80211_get_station (_a, _b, _c) (1) +/* the following define substitute the expected_throughput field with a random +* one existing in the station_info struct. It can be random because due to the +* define above it will never be used. We need it only to make the code compile +*/ +#define expected_throughput filled + +#endif /* cfg80211_get_station */ + +#endif /* < KERNEL_VERSION(3, 15, 0) */ +#endif /* _NET_BATMAN_ADV_COMPAT_H_ */
types.h +2 -0
@@ -346,6 +346,7 @@ struct batadv_gw_node {* @refcount: number of contexts the object is used * @rcu: struct used for freeing in an RCU-safe manner * @hard_iface: the interface where this neighbor is connected to +* @metric_work: work queue callback item for metric update */ struct batadv_elp_neigh_node {struct hlist_node list;
@@ -359,6 +360,7 @@ struct batadv_elp_neigh_node {atomic_t refcount;struct rcu_head rcu;struct batadv_hard_iface *hard_iface; +struct work_struct metric_work; };/**
Signature · 1 line
1.8.5.3
RFC 17/23 batman-adv: ELP - implement dead neigh node detection
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
Improve the neighbour purging routine to timely detect when a neighbour is not sending data anymore without waiting for a real timeout. This detection system can be used by the B.A.T.M.A.N. V routing algorithm to trigger an on-demand route reconstruction.
--- bat_v.c | 7 +++++ bat_v_elp.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- bat_v_elp.h | 2 ++ types.h | 2 ++ 4 files changed, 98 insertions(+), 4 deletions(-)
bat_v.c +7 -0
@@ -75,14 +75,21 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {int batadv_v_mesh_init (struct batadv_priv *bat_priv) { +int r; +atomic_set (&bat_priv->bat_v.base_throughput,BATADV_DEFAULT_BASE_THROUGHPUT ); + r =batadv_v_elp_init (bat_priv); +if (r) +return r; +return batadv_v_ogm_init (bat_priv); }void batadv_v_mesh_free (struct batadv_priv *bat_priv) { +batadv_v_elp_free (bat_priv);batadv_v_ogm_free (bat_priv); }
bat_v_elp.c +87 -4
138 lines not on this page · raw message
bat_v_elp.h +2 -0
@@ -33,5 +33,7 @@ void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *hard_iface);int batadv_v_elp_packet_recv (struct sk_buff *skb,struct batadv_hard_iface *if_incoming);int batadv_v_elp_seq_print_text (struct seq_file *seq,void *offset); +int batadv_v_elp_init (struct batadv_priv *bat_priv); +void batadv_v_elp_free (struct batadv_priv *bat_priv);#endif /* _NET_BATMAN_ADV_BAT_V_ELP_H_ */
types.h +2 -0
@@ -748,6 +748,8 @@ struct batadv_priv_bat_v {struct delayed_work ogm_wq;atomic_t ogm_seqno;atomic_t base_throughput; +atomic_t neigh_interval; +struct delayed_work neigh_wq; };/**
Signature · 1 line
1.8.5.3
RFC 18/23 batman-adv: ELP - use phydev to determine link characteristics
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
The phydev member of a net_device can be used to get information about an ethernet link like HALF/FULL_DUPLEX and advertised bandwidth (e.g. 100/10Mbps).
This information are then stored in the hard_iface object to be used during the metric computation routine.
--- bat_v_elp.c | 8 ++++++++ bat_v_ogm.c | 4 ++-- hard-interface.c | 19 +++++++++++++++++++ types.h | 12 ++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-)
bat_v_elp.c +8 -0
@@ -78,6 +78,14 @@ batadv_v_elp_get_throughput(struct batadv_elp_neigh_node *neigh)if (throughput !=0 )return throughput; +/* In case of Ethernet interface, the throughput has already been +* obtained from the phydev object in the net_device struct (see +* batadv_hardif_activate_interface()). So return this value. +*/ + throughput = hard_iface->bat_v.eth_throughput; +if (throughput !=0 ) +return throughput; +/* if this is a wireless device, then ask its throughput through * cfg80211 API */
bat_v_ogm.c +2 -2
@@ -393,8 +393,8 @@ static uint32_t batadv_v_penalty(struct batadv_priv *bat_priv,/* proportion to use the same value used in batman iv (x * 128 / 256) */ hop_penalty = hop_penalty *100 /255 ; -if (batadv_is_wifi_netdev (if_incoming->net_dev) && - metric > link_metric /10 ) +if ((if_incoming->bat_v.flags &BATADV_FULL_DUPLEX ) && + (metric > link_metric /10 ))return metric /2 ;return metric * (100 - hop_penalty) /100 ;
hard-interface.c +19 -0
@@ -31,6 +31,8 @@#include <linux/if_arp.h> #include <linux/if_ether.h> +#include <linux/netdevice.h> +#include <linux/phy.h> void batadv_hardif_free_rcu (struct rcu_head *rcu) {
@@ -297,6 +299,7 @@ void batadv_update_min_mtu(struct net_device *soft_iface)static void batadv_hardif_activate_interface (struct batadv_hard_iface *hard_iface) { +struct net_device *dev = hard_iface->net_dev;struct batadv_priv *bat_priv;struct batadv_hard_iface *primary_if =NULL ;
@@ -315,6 +318,22 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)if (!primary_if)batadv_primary_if_select (bat_priv, hard_iface); +/* set the default values */ + hard_iface->bat_v.flags &= ~BATADV_FULL_DUPLEX ; + hard_iface->bat_v.eth_throughput =0 ; +if (dev->phydev) { +if (dev->phydev->duplex ==DUPLEX_FULL ) + hard_iface->bat_v.flags |=BATADV_FULL_DUPLEX ; + +/* set the speed according to the phydev setting. Store the +* value in Kbps (as done for the other throughput variables) +*/ +if (dev->phydev->speed !=SPEED_UNKNOWN ) { + hard_iface->bat_v.eth_throughput = dev->phydev->speed; + hard_iface->bat_v.eth_throughput *=10 ; + } + } +batadv_info (hard_iface->soft_iface,"Interface activated: %s\n" , hard_iface->net_dev->name);
types.h +12 -0
@@ -70,6 +70,14 @@ struct batadv_hard_iface_bat_iv { };/** +* enum batadv_v_hard_iface_flags - interface flags useful to B.A.T.M.A.N. V +* @BATADV_FULL_DUPLEX: tells if the connection over this link is full-duplex +*/ +enum batadv_v_hard_iface_flags { +BATADV_FULL_DUPLEX =BIT (0 ), +}; + +/** * struct batadv_hard_iface_bat_v - per hard interface B.A.T.M.A.N. V data * @elp_interval: time interval between two ELP transmissions * @elp_seqno: current ELP sequence number
@@ -79,6 +87,8 @@ struct batadv_hard_iface_bat_iv {* @elp_skb: base skb containing the ELP message to send * @elp_wq: workqueue used to schedule ELP transmissions * @user_throughput: user specified throughput +* @eth_throughput: throughput for wired interfaces (obtained from phydev) +* @flags: interface specific flags */ struct batadv_hard_iface_bat_v {atomic_t elp_interval;
@@ -89,6 +99,8 @@ struct batadv_hard_iface_bat_v {struct sk_buff *elp_skb;struct delayed_work elp_wq;atomic_t user_throughput; +uint32_t eth_throughput; +uint8_t flags; };/**
Signature · 1 line
1.8.5.3
RFC 19/23 batman-adv: add bat_neigh_free() API
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
This API has to be used to let any routing protocol free neighbor specific allocated resources
--- originator.c | 6 ++++++ types.h | 2 ++ 2 files changed, 8 insertions(+)
originator.c +6 -0
@@ -196,13 +196,19 @@ static void batadv_neigh_node_free_rcu(struct rcu_head *rcu)struct hlist_node *node_tmp;struct batadv_neigh_node *neigh_node;struct batadv_neigh_ifinfo *neigh_ifinfo; +struct batadv_algo_ops *bao; neigh_node = container_of(rcu, struct batadv_neigh_node, rcu); + bao = neigh_node->orig_node->bat_priv->bat_algo_ops;hlist_for_each_entry_safe (neigh_ifinfo, node_tmp, &neigh_node->ifinfo_list, list) {batadv_neigh_ifinfo_free_ref_now (neigh_ifinfo); } + +if (bao->bat_neigh_free) + bao->bat_neigh_free (neigh_node); +batadv_hardif_free_ref_now (neigh_node->if_incoming);kfree (neigh_node);
types.h +2 -0
@@ -1203,6 +1203,8 @@ struct batadv_algo_ops { int max_if_num);int (*bat_orig_del_if)(struct batadv_orig_node *orig_node,int max_if_num,int del_if_num); +/* neigh_node handling API */ +void (*bat_neigh_free)(struct batadv_neigh_node *neigh); };/**
Signature · 1 line
1.8.5.3
RFC 20/23 batman-adv: B.A.T.M.A.N. V - implement bat_neigh_free() API
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
--- bat_v.c | 7 +++++++ 1 file changed, 7 insertions(+)
bat_v.c +7 -0
@@ -63,6 +63,12 @@ static void batadv_v_ogm_emit(struct batadv_forw_packet *forw_packet) { } +static void batadv_v_neigh_free (struct batadv_neigh_node *neigh) +{ +batadv_elp_neigh_node_free_ref (neigh->bat_v.elp_neigh); + neigh->bat_v.elp_neigh =NULL ; +} +static struct batadv_algo_ops batadv_batman_v__read_mostly = { .name ="BATMAN_V" , .bat_iface_enable = batadv_v_iface_enable,
@@ -71,6 +77,7 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .bat_primary_iface_set = batadv_v_primary_iface_set, .bat_ogm_emit = batadv_v_ogm_emit, .bat_ogm_schedule = batadv_v_ogm_schedule, + .bat_neigh_free = batadv_v_neigh_free, };int batadv_v_mesh_init (struct batadv_priv *bat_priv)
Signature · 1 line
1.8.5.3
RFC 21/23 batman-adv: B.A.T.M.A.N. V - implement neigh_is_equiv_or_better API
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
--- bat_v.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
bat_v.c +19 -0
@@ -21,6 +21,7 @@#include "bat_algo.h" #include "bat_v_elp.h" #include "bat_v_ogm.h" +#include "originator.h" static int batadv_v_iface_enable (struct batadv_hard_iface *hard_iface) {
@@ -63,6 +64,23 @@ static void batadv_v_ogm_emit(struct batadv_forw_packet *forw_packet) { } +static bool batadv_v_neigh_is_eob (struct batadv_neigh_node *neigh1, +struct batadv_hard_iface *if_outgoing1, +struct batadv_neigh_node *neigh2, +struct batadv_hard_iface *if_outgoing2) +{ +struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2; +uint32_t threshold; + + ifinfo1 =batadv_neigh_ifinfo_get (neigh1, if_outgoing1); + ifinfo2 =batadv_neigh_ifinfo_get (neigh2, if_outgoing2); + + threshold = ifinfo1->bat_v.metric <<8 >>10 ; + threshold = ifinfo1->bat_v.metric - threshold; + +return ifinfo2->bat_v.metric > threshold; +} +static void batadv_v_neigh_free (struct batadv_neigh_node *neigh) {batadv_elp_neigh_node_free_ref (neigh->bat_v.elp_neigh);
@@ -77,6 +95,7 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .bat_primary_iface_set = batadv_v_primary_iface_set, .bat_ogm_emit = batadv_v_ogm_emit, .bat_ogm_schedule = batadv_v_ogm_schedule, + .bat_neigh_is_equiv_or_better = batadv_v_neigh_is_eob, .bat_neigh_free = batadv_v_neigh_free, };
Signature · 1 line
1.8.5.3
RFC 22/23 batman-adv: B.A.T.M.A.N. V - implement bat_neigh_cmp API
In reply to Antonio Quartulli--- bat_v.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
bat_v.c +18 -0
@@ -64,6 +64,23 @@ static void batadv_v_ogm_emit(struct batadv_forw_packet *forw_packet) { } +static int batadv_v_neigh_cmp (struct batadv_neigh_node *neigh1, +struct batadv_hard_iface *if_outgoing1, +struct batadv_neigh_node *neigh2, +struct batadv_hard_iface *if_outgoing2) +{ +struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2; + + ifinfo1 =batadv_neigh_ifinfo_get (neigh1, if_outgoing1); + ifinfo2 =batadv_neigh_ifinfo_get (neigh2, if_outgoing2); + +if (WARN_ON (!ifinfo1 || !ifinfo2)) +return 0 ; + +return ifinfo1->bat_v.metric - ifinfo2->bat_v.metric; + +} + static bool batadv_v_neigh_is_eob(struct batadv_neigh_node *neigh1, struct batadv_hard_iface *if_outgoing1, struct batadv_neigh_node *neigh2,
@@ -95,6 +112,7 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .bat_primary_iface_set = batadv_v_primary_iface_set, .bat_ogm_emit = batadv_v_ogm_emit, .bat_ogm_schedule = batadv_v_ogm_schedule, + .bat_neigh_cmp = batadv_v_neigh_cmp, .bat_neigh_is_equiv_or_better = batadv_v_neigh_is_eob, .bat_neigh_free = batadv_v_neigh_free, };
Signature · 1 line
1.8.5.3
RFC 23/23 batman-adv: B.A.T.M.A.N. V - implement bat_orig_print API
In reply to Antonio QuartulliFrom: Antonio Quartulli <[email protected]>
--- bat_v.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+)
bat_v.c +98 -0
@@ -64,6 +64,103 @@ static void batadv_v_ogm_emit(struct batadv_forw_packet *forw_packet) { } +/** +* batadv_v_orig_print_neigh - print neighbors for the originator table +* @orig_node: the orig_node for which the neighbors are printed +* @if_outgoing: outgoing interface for these entries +* @seq: debugfs table seq_file struct +* +* Must be called while holding an rcu lock. +*/ +static void +batadv_v_orig_print_neigh (struct batadv_orig_node *orig_node, +struct batadv_hard_iface *if_outgoing, +struct seq_file *seq) +{ +struct batadv_neigh_node *neigh_node; +struct batadv_neigh_ifinfo *n_ifinfo; + +hlist_for_each_entry_rcu (neigh_node, &orig_node->neigh_list, list) { + n_ifinfo =batadv_neigh_ifinfo_get (neigh_node, if_outgoing); +if (!n_ifinfo) +continue ; + +seq_printf (seq," %pM (%9u.%1u)" , + neigh_node->addr, + n_ifinfo->bat_v.metric /10 , + n_ifinfo->bat_v.metric %10 ); + +batadv_neigh_ifinfo_free_ref (n_ifinfo); + } +} + +/** +* batadv_v_orig_print - print the originator table +* @bat_priv: the bat priv with all the soft interface information +* @seq: debugfs table seq_file struct +* @if_outgoing: the outgoing interface for which this should be printed +*/ +static void batadv_v_orig_print (struct batadv_priv *bat_priv, +struct seq_file *seq, +struct batadv_hard_iface *if_outgoing) +{ +struct batadv_neigh_node *neigh_node; +struct batadv_hashtable *hash = bat_priv->orig_hash; +int last_seen_msecs, last_seen_secs; +struct batadv_orig_node *orig_node; +struct batadv_neigh_ifinfo *n_ifinfo; +unsigned long last_seen_jiffies; +struct hlist_head *head; +int batman_count =0 ; +uint32_t i; + +seq_printf (seq," %-15s %s (%11s) %17s [%10s]: %20s ...\n" , +"Originator" ,"last-seen" ,"metric" ,"Nexthop" , +"outgoingIF" ,"Potential nexthops" ); + +for (i =0 ; i < hash->size; i++) { + head = &hash->table[i]; + +rcu_read_lock (); +hlist_for_each_entry_rcu (orig_node, head, hash_entry) { + neigh_node =batadv_orig_router_get (orig_node, + if_outgoing); +if (!neigh_node) +continue ; + + n_ifinfo =batadv_neigh_ifinfo_get (neigh_node, + if_outgoing); +if (!n_ifinfo) + goto next; + + last_seen_jiffies = jiffies - orig_node->last_seen; + last_seen_msecs =jiffies_to_msecs (last_seen_jiffies); + last_seen_secs = last_seen_msecs /1000 ; + last_seen_msecs = last_seen_msecs %1000 ; + +seq_printf (seq,"%pM %4i.%03is (%9u.%1u) %pM [%10s]:" , + orig_node->orig, last_seen_secs, + last_seen_msecs, n_ifinfo->bat_v.metric /10 , + n_ifinfo->bat_v.metric %10 , + neigh_node->addr, + neigh_node->if_incoming->net_dev->name); + +batadv_v_orig_print_neigh (orig_node, if_outgoing, seq); +seq_puts (seq,"\n" ); + batman_count++; + +next: +batadv_neigh_node_free_ref (neigh_node); +if (n_ifinfo) +batadv_neigh_ifinfo_free_ref (n_ifinfo); + } +rcu_read_unlock (); + } + +if (batman_count ==0 ) +seq_puts (seq,"No batman nodes in range ...\n" ); +} + static int batadv_v_neigh_cmp(struct batadv_neigh_node *neigh1, struct batadv_hard_iface *if_outgoing1, struct batadv_neigh_node *neigh2,
@@ -112,6 +209,7 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .bat_primary_iface_set = batadv_v_primary_iface_set, .bat_ogm_emit = batadv_v_ogm_emit, .bat_ogm_schedule = batadv_v_ogm_schedule, + .bat_orig_print = batadv_v_orig_print, .bat_neigh_cmp = batadv_v_neigh_cmp, .bat_neigh_is_equiv_or_better = batadv_v_neigh_is_eob, .bat_neigh_free = batadv_v_neigh_free,
Signature · 1 line
1.8.5.3
Re: [B.A.T.M.A.N.] [RFC 04/23] batman-adv: ELP - creating neighbor structures
In reply to Antonio QuartulliQuoted 30 lines · Antonio Quartulli
From: Linus Luessing <[email protected]>
Initially developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
Signed-off-by Linus Luessing <[email protected]>Signed-off-by Marek Lindner <[email protected]>Signed-off-by Antonio Quartulli <[email protected]>--- bat_v.c | 18 +++++- bat_v_elp.c | 204 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- bat_v_elp.h | 6 ++ main.h | 2 + types.h | 53 ++++++++++++++++ 5 files changed, 281 insertions(+), 2 deletions(-)bat_v.c +5
-1@@ -61,5 +61,21 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {int __init batadv_v_init (void ) { -return batadv_algo_register (&batadv_batman_v); +int ret; + +/* batman v echo location protocol packet */ + ret =batadv_recv_handler_register (BATADV_ELP , + batadv_v_elp_packet_recv);
bat_v.c static struct batadv_algo_ops batadv_batman_v __read_mostly = { · line 78
Quoted 10 lines
bat_v.c +10
-0+if (ret <0 ) + goto elp_unregister; + + ret =batadv_algo_register (&batadv_batman_v); + +return ret; + +elp_unregister: +if (ret <0 ) +batadv_recv_handler_unregister (BATADV_ELP );
No need to check ret here. If we are here, it has to be < 0.
It also seems odd to me you are unregistering the handler when the registration of the handler fails!
I suspect the first if (ret < 0) should be followed by a plain return ret; and there should be a second test for the return value of batadv_algo_register() which should goto the label and unregister the handler.
Andrew
Re: [B.A.T.M.A.N.] [RFC 04/23] batman-adv: ELP - creating neighbor structures
Quoted 44 lines · Andrew Lunn
Quoted 30 lines · Antonio Quartulli
From: Linus Luessing <[email protected]>
Initially developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
Signed-off-by Linus Luessing <[email protected]>Signed-off-by Marek Lindner <[email protected]>Signed-off-by Antonio Quartulli <[email protected]>--- bat_v.c | 18 +++++- bat_v_elp.c | 204 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- bat_v_elp.h | 6 ++ main.h | 2 + types.h | 53 ++++++++++++++++ 5 files changed, 281 insertions(+), 2 deletions(-)bat_v.c +5
-1@@ -61,5 +61,21 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {int __init batadv_v_init (void ) { -return batadv_algo_register (&batadv_batman_v); +int ret; + +/* batman v echo location protocol packet */ + ret =batadv_recv_handler_register (BATADV_ELP , + batadv_v_elp_packet_recv);bat_v.c static struct batadv_algo_ops batadv_batman_v __read_mostly = { · line 78
Quoted 10 lines
bat_v.c +10
-0+if (ret <0 ) + goto elp_unregister; + + ret =batadv_algo_register (&batadv_batman_v); + +return ret; + +elp_unregister: +if (ret <0 ) +batadv_recv_handler_unregister (BATADV_ELP );No need to check ret here. If we are here, it has to be < 0.
Quoted 7 lines
It also seems odd to me you are unregistering the handler when the registration of the handler fails!
I suspect the first if (ret < 0) should be followed by a plain return ret; and there should be a second test for the return value of
batadv_algo_register()which should goto the label and unregister the handler.
I totally agree with what you said.
We should jump to elp_unregister if batadv_algo_register() fails.
Thanks!
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 04/23] batman-adv: ELP - creating neighbor structures
Quoted 7 lines · On Tuesday 11 February 2014 11:02:11 Antonio Quartulli wrote:
Quoted 6 lines · Andrew Lunn
Quoted 5 lines · Antonio Quartulli
From: Linus Luessing <[email protected]>
Initially developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signed-off-by Linus Luessing <[email protected]>Signed-off-by Marek Lindner <[email protected]>Signed-off-by Antonio Quartulli <[email protected]>--- bat_v.c | 18 +++++- bat_v_elp.c | 204
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Quoted 10 lines
Quoted 10 lines
bat_v.c static struct batadv_algo_ops batadv_batman_v
Quoted 10 lines
bat_v_elp.h | 6 ++ main.h | 2 + types.h | 53 ++++++++++++++++ 5 files changed, 281 insertions(+), 2 deletions(-)bat_v.c +0
-0@@ -61,5 +61,21 @@ static struct batadv_algo_ops batadv_batman_v
__read_mostly = {
Quoted 25 lines
Quoted 25 lines
Quoted 9 lines
bat_v.c +5
-1int __init batadv_v_init (void ) { -return batadv_algo_register (&batadv_batman_v); +int ret; + +/* batman v echo location protocol packet */ + ret =batadv_recv_handler_register (BATADV_ELP , + batadv_v_elp_packet_recv);bat_v.c static struct batadv_algo_ops batadv_batman_v __read_mostly = { · line 78
Quoted 10 lines
bat_v.c +10
-0+if (ret <0 ) + goto elp_unregister; + + ret =batadv_algo_register (&batadv_batman_v); + +return ret; + +elp_unregister: +if (ret <0 ) +batadv_recv_handler_unregister (BATADV_ELP );No need to check ret here. If we are here, it has to be < 0.
It also seems odd to me you are unregistering the handler when the registration of the handler fails!
Quoted 7 lines
Quoted 4 lines
I suspect the first if (ret < 0) should be followed by a plain return ret; and there should be a second test for the return value of
batadv_algo_register()which should goto the label and unregister the handler.I totally agree with what you said.
We should jump toelp_unregisterifbatadv_algo_register()fails.
Sorry to break in here, but the (ex) professional programmer in me just /has/ to comment.
Why not just
int __init batadv_v_init(void)
{
- return batadv_algo_register(&batadv_batman_v);
+ int ret;
+
+ /* batman v echo location protocol packet */
+ ret = batadv_recv_handler_register(BATADV_ELP,
+ batadv_v_elp_packet_recv);
+
+ if (ret >= 0)
+ ret = batadv_algo_register(&batadv_batman_v);
+ else
+ batadv_recv_handler_unregister(BATADV_ELP);
+
+ return ret;
?
Signature · 3 lines
Lew Pitcher "In Skills, We Trust" PGP public key available upon request
Re: [B.A.T.M.A.N.] [RFC 04/23] batman-adv: ELP - creating neighbor structures
Quoted 56 lines · Lew Pitcher
Quoted 7 lines · On Tuesday 11 February 2014 11:02:11 Antonio Quartulli wrote:
Quoted 6 lines · Andrew Lunn
Quoted 5 lines · Antonio Quartulli
From: Linus Luessing <[email protected]>
Initially developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signed-off-by Linus Luessing <[email protected]>Signed-off-by Marek Lindner <[email protected]>Signed-off-by Antonio Quartulli <[email protected]>--- bat_v.c | 18 +++++- bat_v_elp.c | 204+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Quoted 10 lines
Quoted 10 lines
bat_v.c static struct batadv_algo_ops batadv_batman_v
Quoted 10 lines
bat_v_elp.h | 6 ++ main.h | 2 + types.h | 53 ++++++++++++++++ 5 files changed, 281 insertions(+), 2 deletions(-)bat_v.c +0
-0@@ -61,5 +61,21 @@ static struct batadv_algo_ops batadv_batman_v
__read_mostly= {Quoted 30 lines
Quoted 29 lines
Quoted 9 lines
bat_v.c +5
-1int __init batadv_v_init (void ) { -return batadv_algo_register (&batadv_batman_v); +int ret; + +/* batman v echo location protocol packet */ + ret =batadv_recv_handler_register (BATADV_ELP , + batadv_v_elp_packet_recv);bat_v.c static struct batadv_algo_ops batadv_batman_v __read_mostly = { · line 78
Quoted 10 lines
bat_v.c +10
-0+if (ret <0 ) + goto elp_unregister; + + ret =batadv_algo_register (&batadv_batman_v); + +return ret; + +elp_unregister: +if (ret <0 ) +batadv_recv_handler_unregister (BATADV_ELP );No need to check ret here. If we are here, it has to be < 0.
It also seems odd to me you are unregistering the handler when the registration of the handler fails!
I suspect the first if (ret < 0) should be followed by a plain return ret; and there should be a second test for the return value of
batadv_algo_register()which should goto the label and unregister the handler.
Quoted 5 lines
Quoted 2 lines
I totally agree with what you said.
We should jump toelp_unregisterifbatadv_algo_register()fails.Sorry to break in here, but the (ex) professional programmer in me just /has/ to comment.
Everybody is welcome! :)
Quoted 10 lines
Why not just
int__initbatadv_v_init(void)
{
- returnbatadv_algo_register(&batadv_batman_v);
+ int ret;
+
+ /* batman v echo location protocol packet */
+ ret = batadv_recv_handler_register(BATADV_ELP,
+batadv_v_elp_packet_recv);
Quoted 9 lines
+
+ if (ret >= 0)
+ ret =batadv_algo_register(&batadv_batman_v);
+ else
+batadv_recv_handler_unregister(BATADV_ELP);
+
+ return ret;
?
Actually I already fixed it like this:
int __init batadv_v_init(void)
{
- return batadv_algo_register(&batadv_batman_v);
+ int ret;
+
+ /* batman v echo location protocol packet */
+ ret = batadv_recv_handler_register(BATADV_ELP,
+ batadv_v_elp_packet_recv);
+ if (ret < 0)
+ return ret;
+
+ ret = batadv_algo_register(&batadv_batman_v);
+ if (ret < 0)
+ batadv_recv_handler_unregister(BATADV_ELP);
+
+ return ret;
I think it is easier to read, no?
Anyway, this chunk is changed later b patch 7/23 because we add the OGM2 registration.
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 06/23] batman-adv: ELP - adding sysfs parameter for elp interval
In reply to Antonio QuartulliQuoted 4 lines · Antonio Quartulli
From: Linus Luessing <[email protected]>
This parameter can be set individually on each interface and allows the configuration of the ndp interval for the link
s/ndp/elp
Quoted 22 lines
quality measurements during runtime. Usually it is desirable to set it to a higher (= slower) value on interfaces which have a more static characteristic (e.g. wired interfaces) or very dense neighbourhoods to reduce overhead.
Developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
Signed-off-by Linus Luessing <[email protected]>Signed-off-by Marek Lindner <[email protected]>[[email protected]: respin on top of the latest master]Signed-off-by Antonio Quartulli <[email protected]>--- sysfs-class-net-batman-adv | 8 +++++++- sysfs.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)sysfs-class-net-batman-adv +0
-0
sysfs-class-net-batman-adv line 3
Quoted 3 lines
sysfs-class-net-batman-adv +2
-0@@ -1,4 +1,11 @@ +What: /sys/class/net/<mesh_iface>/batman-adv/elp_interval +Date: Mar 2012
Might make sense to update this to 2014?
Andrew
Re: [B.A.T.M.A.N.] [RFC 06/23] batman-adv: ELP - adding sysfs parameter for elp interval
Quoted 7 lines · Andrew Lunn
Quoted 4 lines · Antonio Quartulli
From: Linus Luessing <[email protected]>
This parameter can be set individually on each interface and allows the configuration of the ndp interval for the link
s/ndp/elp
thanks!
Quoted 24 lines
Quoted 24 lines
quality measurements during runtime. Usually it is desirable to set it to a higher (= slower) value on interfaces which have a more static characteristic (e.g. wired interfaces) or very dense neighbourhoods to reduce overhead.
Developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG.
Signed-off-by Linus Luessing <[email protected]>Signed-off-by Marek Lindner <[email protected]>[[email protected]: respin on top of the latest master]Signed-off-by Antonio Quartulli <[email protected]>--- sysfs-class-net-batman-adv | 8 +++++++- sysfs.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)sysfs-class-net-batman-adv +0
-0@@ -1,4 +1,11 @@
Quoted 4 lines
sysfs-class-net-batman-adv line 3
Quoted 2 lines
sysfs-class-net-batman-adv +2
-0+What: /sys/class/net/<mesh_iface>/batman-adv/elp_interval +Date: Mar 2012Might make sense to update this to 2014?
I kept it as it was when the patch got merged in our repo. But I think it should match the month it gets introduced in the kernel.
Thanks²!
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 07/23] batman-adv: OGMv2 - add basic infrastructure
In reply to Antonio QuartulliQuoted 54 lines
bat_v_ogm.c new file +54
-0+static void batadv_v_ogm_send (struct work_struct *work) +{ +struct batadv_hard_iface *hard_iface; +struct batadv_priv_bat_v *bat_v; +struct batadv_priv *bat_priv; +struct batadv_ogm2_packet *ogm2; +struct sk_buff *skb; +unsigned char *ogm_buff, *pkt_buff; +int ogm_buff_len; +uint16_t tvlv_len =0 ; + + bat_v = container_of(work, struct batadv_priv_bat_v, ogm_wq.work); + bat_priv = container_of(bat_v, struct batadv_priv, bat_v); + +if (atomic_read (&bat_priv->mesh_state) ==BATADV_MESH_DEACTIVATING ) + goto out; + + ogm_buff = bat_priv->bat_v.ogm_buff; + ogm_buff_len = bat_priv->bat_v.ogm_buff_len; +/* tt changes have to be committed before the tvlv data is +* appended as it may alter the tt tvlv container +*/ +batadv_tt_local_commit_changes (bat_priv); + tvlv_len =batadv_tvlv_container_ogm_append (bat_priv, &ogm_buff, + &ogm_buff_len, +BATADV_OGM2_HLEN ); + + bat_priv->bat_v.ogm_buff = ogm_buff; + bat_priv->bat_v.ogm_buff_len = ogm_buff_len; + + skb =netdev_alloc_skb_ip_align (NULL ,ETH_HLEN + ogm_buff_len); +if (!skb) + goto out; + +skb_reserve (skb,ETH_HLEN ); + pkt_buff =skb_put (skb, ogm_buff_len); +memcpy (pkt_buff, ogm_buff, ogm_buff_len); + + ogm2 = (struct batadv_ogm2_packet *)skb->data; + ogm2->seqno =htonl (atomic_read (&bat_priv->bat_v.ogm_seqno)); +atomic_inc (&bat_priv->bat_v.ogm_seqno); + ogm2->tvlv_len =htons (tvlv_len); + +/* broadcast on every interface */ +rcu_read_lock (); +list_for_each_entry_rcu (hard_iface, &batadv_hardif_list, list) { +if (hard_iface->soft_iface != bat_priv->soft_iface) +continue ; + +batadv_dbg (BATADV_DBG_BATMAN , bat_priv, +"Sending own OGM2 packet (originator %pM, seqno %u, metric %u, TTL %d) on interface %s [%pM]\n" , + ogm2->orig,ntohl (ogm2->seqno),ntohl (ogm2->metric), + ogm2->ttl, hard_iface->net_dev->name, + hard_iface->net_dev->dev_addr);
bat_v_ogm.c line 130
Quoted 10 lines
bat_v_ogm.c new file +10
-0+ +batadv_v_ogm_send_to_if (skb, hard_iface); + } +rcu_read_unlock (); + +consume_skb (skb); + +batadv_v_ogm_start_timer (bat_priv); +out: +return ;
If you jump to out because netdev_alloc_skb_ip_align() failed, don't you want to start the timer again? I would assume it is a transient problem not being able to get memory for the skb, and the next time the timer goes off it might work?
bat_v_ogm.c line 203
Quoted 2 lines
bat_v_ogm.c new file +2
-0+ bat_priv->bat_v.ogm_buff_len =BATADV_OGM2_HLEN ; + ogm_buff =kmalloc (bat_priv->bat_v.ogm_buff_len,GFP_ATOMIC );
Maybe use kzalloc to ensure it is zero?
Andrew
Re: [B.A.T.M.A.N.] [RFC 08/23] batman-adv: OGMv2 - implement originators logic
In reply to Antonio Quartullibat_v_ogm.c line 42
Quoted 11 lines
bat_v_ogm.c +11
-0+static struct batadv_orig_node * +batadv_v_ogm_orig_get (struct batadv_priv *bat_priv,const uint8_t *addr) +{ +struct batadv_orig_node *orig_node; +int hash_added; + + orig_node =batadv_orig_hash_find (bat_priv, addr); +if (orig_node) +return orig_node; + + orig_node =batadv_orig_node_new (bat_priv, addr);
Can this fail and return NULL?
bat_v_ogm.c line 49
Quoted 7 lines
bat_v_ogm.c +7
-0+ + hash_added =batadv_hash_add (bat_priv->orig_hash, batadv_compare_orig, + batadv_choose_orig, orig_node, + &orig_node->hash_entry); +if (hash_added !=0 ) { +batadv_orig_node_free_ref (orig_node); +batadv_orig_node_free_ref (orig_node);
Looks odd. If it is correct, it should have a comment why it is correct.
Andrew
Re: [B.A.T.M.A.N.] [RFC 08/23] batman-adv: OGMv2 - implement originators logic
Quoted 5 lines · Andrew Lunn
Quoted 5 lines
bat_v_ogm.c +5
-0+static struct batadv_orig_node * +batadv_v_ogm_orig_get (struct batadv_priv *bat_priv,const uint8_t *addr) +{ +struct batadv_orig_node *orig_node; +int hash_added;
Quoted 8 lines
bat_v_ogm.c line 42
Quoted 6 lines
bat_v_ogm.c +6
-0+ + orig_node =batadv_orig_hash_find (bat_priv, addr); +if (orig_node) +return orig_node; + + orig_node =batadv_orig_node_new (bat_priv, addr);Can this fail and return NULL?
Yes it can. Better to check.
Quoted 11 lines
bat_v_ogm.c line 49
Quoted 8 lines
bat_v_ogm.c +7
-0+ + hash_added =batadv_hash_add (bat_priv->orig_hash, batadv_compare_orig, + batadv_choose_orig, orig_node, + &orig_node->hash_entry); +if (hash_added !=0 ) { +batadv_orig_node_free_ref (orig_node); +batadv_orig_node_free_ref (orig_node);Looks odd. If it is correct, it should have a comment why it is correct.
We have a similar problem in the current (B.A.T.M.A.N. IV) code too. The point is that orig_node->refcounter is initialised to 2, therefore if we want to free the object in this early phase we need to invoke the free_ref() twice.
By the way...I was just thinking that we could invoke kfree() directly here (the orig_node is not referenced in any other context since it has been just allocated).
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 07/23] batman-adv: OGMv2 - add basic infrastructure
In reply to Andrew LunnQuoted 9 lines · Andrew Lunn
bat_v_ogm.c line 130
Quoted 4 lines
bat_v_ogm.c new file +4
-0+ +batadv_v_ogm_start_timer (bat_priv); +out: +return ;If you jump to out because
netdev_alloc_skb_ip_align()failed, don't you want to start the timer again? I would assume it is a transient problem not being able to get memory for the skb, and the next time the timer goes off it might work?
Now that I think about it I agree with you. If netdev_alloc_skb_ip_align() fails either:
- the situation is permanent -> OOM soon
- or the situation is transient -> we should try re-scheduling the task.
Quoted 5 lines
bat_v_ogm.c line 203
Quoted 3 lines
bat_v_ogm.c new file +2
-0+ bat_priv->bat_v.ogm_buff_len =BATADV_OGM2_HLEN ; + ogm_buff =kmalloc (bat_priv->bat_v.ogm_buff_len,GFP_ATOMIC );Maybe use kzalloc to ensure it is zero?
Not really needed because each field is explicitly assigned later. But to be sure we sit on the safe side we can do that: in the end we are not in the fastpath here.
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 07/23] batman-adv: OGMv2 - add basic infrastructure
Quoted 8 lines
Quoted 4 lines
bat_v_ogm.c line 203
Quoted 2 lines
bat_v_ogm.c new file +2
-0+ bat_priv->bat_v.ogm_buff_len =BATADV_OGM2_HLEN ; + ogm_buff =kmalloc (bat_priv->bat_v.ogm_buff_len,GFP_ATOMIC );Maybe use kzalloc to ensure it is zero?
Not really needed because each field is explicitly assigned later. But to be sure we sit on the safe side we can do that: in the end we are not in the fastpath here.
I know some of your structures have explicit align bytes. It would be good to ensure they are zero so that they could be used in the future without having a protocol version bump. So i think it is a good patterns to follow in general when not on the fast path.
Andrew
Re: [B.A.T.M.A.N.] [RFC 07/23] batman-adv: OGMv2 - add basic infrastructure
Quoted 5 lines · Andrew Lunn
Quoted 5 lines
Quoted 4 lines
bat_v_ogm.c line 203
Quoted 2 lines
bat_v_ogm.c new file +2
-0+ bat_priv->bat_v.ogm_buff_len =BATADV_OGM2_HLEN ; + ogm_buff =kmalloc (bat_priv->bat_v.ogm_buff_len,GFP_ATOMIC );Maybe use kzalloc to ensure it is zero?
Quoted 8 lines
Quoted 3 lines
Not really needed because each field is explicitly assigned later. But to be sure we sit on the safe side we can do that: in the end we are not in the fastpath here.
I know some of your structures have explicit align bytes. It would be good to ensure they are zero so that they could be used in the future without having a protocol version bump. So i think it is a good patterns to follow in general when not on the fast path.
True. _I_ had this problem in the past already :-) I'll use kzalloc then!
Thanks!
Quoted 3 lines
Andrew
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 12/23] batman-adv: add base throughput attribute
In reply to Antonio QuartulliQuoted 33 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
when batman-adv is asked to estimate/compute the throughput of an interface, but it fails for whatever reason, then the value in this attribute is used
Signed-off-by Antonio Quartulli <[email protected]>--- bat_v.c | 3 +++ main.h | 7 +++++++ sysfs.c | 7 +++++++ types.h | 1 + 4 files changed, 18 insertions(+)bat_v.c +3
-0@@ -75,6 +75,9 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {int batadv_v_mesh_init (struct batadv_priv *bat_priv) { +atomic_set (&bat_priv->bat_v.base_throughput, +BATADV_DEFAULT_BASE_THROUGHPUT ); +return batadv_v_ogm_init (bat_priv); }main.h +0
-0
main.h line 39
Quoted 7 lines
main.h +4
-0@@ -33,6 +33,13 @@#define BATADV_MAX_METRIC 0xFFFFFFFF#define BATADV_JITTER 20 +/** +* BATADV_DEFAULT_BASE_THROUGHPUT - default value used as throughput for +* hard_ifaces for which it is not possible to measure/estimate the real one. +* Value is expressed in Mbps/10
Mbps/10 is a rather odd unit. How about just Kbps?
Andrew
Re: [B.A.T.M.A.N.] [RFC 11/23] batman-adv: add throughput attribute to hard_ifaces
In reply to Antonio QuartulliQuoted 9 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
This attribute is exported to the user which can manually select its value. It is the throughput value to be used by default when batman-adv is trying to compute the link throughput towards a neighbour using this interface.
If the value is set to 0 then batman-adv will try to detect the throughput by itself.
sysfs documentation is missing, but i guess you know what.
Andrew
Re: [B.A.T.M.A.N.] [RFC 13/23] batman-adv: add last_unicast_tx to struct neigh_node_elp
In reply to Antonio QuartulliQuoted 4 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
This timestamp registers the last time a unicast packet was sent to a given neighbour
I think this changelog needs improving. 95% of the patch is about refactoring a send function into a unicast send and a broadcast send function. The counter makes up the other 5% of the patch.
Andrew
Re: [B.A.T.M.A.N.] [RFC 14/23] batman-adv: ELP - compute the metric based on the estimated throughput
In reply to Antonio QuartulliQuoted 10 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
Implement a stub
get_throughput()function which returns the estimated throughput towards a given neighbour. Its result is then used to compute the metric value.The metric is updated each time a new ELP packet is sent, this way it is possible to timely react to a metric variation which can imply (for example) a neighbour disconnection.
It is very much a style issue, but i would probably split this into two patches. Updating the metric at send time rather than receive should have nothing to do with estimated bandwidth.
Andrew
Quoted 141 lines
Signed-off-by Antonio Quartulli <[email protected]>--- bat_v_elp.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ types.h | 2 ++ 2 files changed, 45 insertions(+), 6 deletions(-)bat_v_elp.c +43
-6@@ -53,6 +53,29 @@ void batadv_elp_neigh_node_free_ref(struct batadv_elp_neigh_node *neigh) }/** +* batadv_v_elp_get_throughput - get the throughput towards a neighbour +* @neigh: the neighbour for which the throughput has to be obtained +* +* Returns the throughput towards the given neighbour. +*/ +static uint32_t +batadv_v_elp_get_throughput (struct batadv_elp_neigh_node *neigh) +{ +struct batadv_hard_iface *hard_iface = neigh->hard_iface; +struct batadv_priv *bat_priv =netdev_priv (hard_iface->soft_iface); +uint32_t throughput; + +/* get the customised user value for the throughput */ + throughput =atomic_read (&hard_iface->bat_v.user_throughput); +/* if the user specified a value, let's return it */ +if (throughput !=0 ) +return throughput; + +/* throughput cannot be computed right now. Return base value */ +return atomic_read (&bat_priv->bat_v.base_throughput); +} + +/** * batadv_v_elp_neigh_new - create a new ELP neighbour node * @hard_iface: the interface the neighbour is connected to * @neigh_addr: the neighbour interface address @@ -75,6 +98,7 @@ batadv_v_elp_neigh_new(struct batadv_hard_iface *hard_iface,memcpy (neigh->addr, neigh_addr,ETH_ALEN ); neigh->last_seen = jiffies;ewma_init (&neigh->metric,1024 ,8 ); + neigh->hard_iface = hard_iface;/* recount initialised to 2 to simplify the caller function */ atomic_set (&neigh->refcount,2 );@@ -147,19 +171,20 @@ static void batadv_v_elp_neigh_purge(struct batadv_hard_iface *hard_iface) }/** -* batadv_v_elp_send_outstanding - ELP periodic broadcast sending +* batadv_v_elp_periodic_work - ELP periodic task per interface * @work: work queue item * -* Sends a broadcast ELP message over the interface that this work item belongs -* to. +* Sends a broadcast ELP message and reads the metric for all the neighbours +* connected to the interface that this work item belongs to. */ -static void batadv_v_elp_send_outstanding (struct work_struct *work) +static void batadv_v_elp_periodic_work (struct work_struct *work) {struct batadv_hard_iface *hard_iface;struct batadv_hard_iface_bat_v *bat_v;struct batadv_priv *bat_priv;struct batadv_elp_packet *elp_packet;uint32_t elp_interval; +struct batadv_elp_neigh_node *neigh;struct sk_buff *skb;uint8_t num_neighs;@@ -181,7 +206,7 @@ static void batadv_v_elp_send_outstanding(struct work_struct *work) skb =skb_copy (hard_iface->bat_v.elp_skb,GFP_ATOMIC );if (!skb) - goto out; + goto update_metric;/* purge outdated entries first */ batadv_v_elp_neigh_purge (hard_iface);@@ -204,6 +229,17 @@ static void batadv_v_elp_send_outstanding(struct work_struct *work)atomic_inc (&hard_iface->bat_v.elp_seqno); +update_metric: +/* Instead of updating the metric each "received" ELP packet, it is +* better to do it on each ELP sending. This way, if a node is dead and +* does not send packets anymore, batman-adv is still able to timely +* react to its death. +*/ +rcu_read_lock (); +hlist_for_each_entry_rcu (neigh, &hard_iface->bat_v.neigh_list, list) +ewma_add (&neigh->metric,batadv_v_elp_get_throughput (neigh)); +rcu_read_unlock (); + restart_timer:batadv_v_elp_start_timer (hard_iface); out:@@ -247,7 +283,7 @@ int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)atomic_set (&hard_iface->bat_v.elp_interval,500 );INIT_DELAYED_WORK (&hard_iface->bat_v.elp_wq, - batadv_v_elp_send_outstanding); + batadv_v_elp_periodic_work);batadv_v_elp_start_timer (hard_iface); res =0 ;@@ -332,6 +368,7 @@ static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv, neigh->last_seen = jiffies; neigh->last_recv_seqno =ntohl (elp_packet->seqno); +ewma_add (&neigh->metric,batadv_v_elp_get_throughput (neigh)); out:if (neigh)types.h +2
-0@@ -345,6 +345,7 @@ struct batadv_gw_node {* @last_unicast_tx: when the last unicast packet has been sent to this neighbor * @refcount: number of contexts the object is used * @rcu: struct used for freeing in an RCU-safe manner +* @hard_iface: the interface where this neighbor is connected to */ struct batadv_elp_neigh_node {struct hlist_node list;@@ -357,6 +358,7 @@ struct batadv_elp_neigh_node {unsigned long last_unicast_tx;atomic_t refcount;struct rcu_head rcu; +struct batadv_hard_iface *hard_iface; };/** Signature · 1 line
1.8.5.3
Re: [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling
In reply to Antonio QuartulliQuoted 8 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
In case of a unused link, the throughput estimation will get stuck to the last sampled value and therefore the reported metric will becomes obsolete.
Send unicast ELP packets to each neighbor to trigger throughput sampling on unused links.
Humm, i can understand the need for this, but i really think the rate control code should be sending the probes, not batman. What do the wifi people say about this? Have they tried submitting patches to them?
bat_v_elp.c static void batadv_v_elp_periodic_work(struct work_struct *work) · line 302
Quoted 9 lines
bat_v_elp.c +5
-0/* Instead of updating the metric each "received" ELP packet, it is * better to do it on each ELP sending. This way, if a node is dead and * does not send packets anymore, batman-adv is still able to timely * react to its death. +* +* The metric is updated by following these steps: +* 1) if the hard_iface if wifi => send a unicast ELP for +* probing/sampling to each neighbor +* 2) update the metric value of each neighbor
Might be worth pointing out here, that because of queuing, there is no guarantee the ELP packets have been send yet and the RC estimated bandwidth could be up to 100ms old.
Quoted 15 lines
bat_v_elp.c +9
-1+* */ rcu_read_lock (); -hlist_for_each_entry_rcu (neigh, &hard_iface->bat_v.neigh_list, list) +hlist_for_each_entry_rcu (neigh, &hard_iface->bat_v.neigh_list, list) { +if (batadv_v_elp_wifi_neigh_probe (hard_iface, neigh) <0 ) +/* if something goes wrong while probing, better to stop +* sending packets immediately and reschedule the task +*/ +break ; +ewma_add (&neigh->metric,batadv_v_elp_get_throughput (neigh)); + }rcu_read_unlock ();
Re: [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling
Quoted 7 lines · Andrew Lunn
Quoted 6 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
In case of a unused link, the throughput estimation will get stuck to the last sampled value and therefore the reported metric will becomes obsolete.
Quoted 7 lines
Quoted 2 lines
Send unicast ELP packets to each neighbor to trigger throughput sampling on unused links.
Humm, i can understand the need for this, but i really think the rate control code should be sending the probes, not batman. What do the wifi people say about this? Have they tried submitting patches to them?
I am CC'ing Felix so that he can give his opinion.
But last time I checked Minstrel I realised that it uses data packets to probe rates (there is not a specific probing packet), meaning that if there is no data packet to send, then no probing is performed.
Sending this ELP packets (when there is no unicast traffic) is a way to trigger this mechanism in Minstrel.
Quoted 14 lines
bat_v_elp.c static void batadv_v_elp_periodic_work(struct work_struct *work) · line 302
Quoted 10 lines
bat_v_elp.c +5
-0/* Instead of updating the metric each "received" ELP packet, it is * better to do it on each ELP sending. This way, if a node is dead and * does not send packets anymore, batman-adv is still able to timely * react to its death. +* +* The metric is updated by following these steps: +* 1) if the hard_iface if wifi => send a unicast ELP for +* probing/sampling to each neighbor +* 2) update the metric value of each neighbor Might be worth pointing out here, that because of queuing, there is no guarantee the ELP packets have been send yet and the RC estimated bandwidth could be up to 100ms old.
OK, I'll make it explicit. Actually this routine is no meant to get a "real time estimation", also because the routing algorithm would not be that fast to react on time.
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 12/23] batman-adv: add base throughput attribute
In reply to Andrew LunnQuoted 37 lines · Andrew Lunn
Quoted 36 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
when batman-adv is asked to estimate/compute the throughput of an interface, but it fails for whatever reason, then the value in this attribute is used
Signed-off-by Antonio Quartulli <[email protected]>--- bat_v.c | 3 +++ main.h | 7 +++++++ sysfs.c | 7 +++++++ types.h | 1 + 4 files changed, 18 insertions(+)bat_v.c +3
-0@@ -75,6 +75,9 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {int batadv_v_mesh_init (struct batadv_priv *bat_priv) { +atomic_set (&bat_priv->bat_v.base_throughput, +BATADV_DEFAULT_BASE_THROUGHPUT ); +return batadv_v_ogm_init (bat_priv); }main.h +0
-0@@ -33,6 +33,13 @@#define BATADV_MAX_METRIC 0xFFFFFFFF#define BATADV_JITTER 20
Quoted 6 lines
main.h line 39
Quoted 4 lines
main.h +4
-0+/** +* BATADV_DEFAULT_BASE_THROUGHPUT - default value used as throughput for +* hard_ifaces for which it is not possible to measure/estimate the real one. +* Value is expressed in Mbps/10 Mbps/10 is a rather odd unit. How about just Kbps?
This is the unit used in cfg/mac80211 because most of the rates are either in the form of XX.0Mbps of XX.YMbps (so just one decimal number needs to be saved).
Moreover I thought that having an higher precision is not very useful because the routing decision cannot be taken on such a fine grained value. Actually the originator table prints the metric in Mbps (XX.YMbps).
Do you think we should really go for the Kbps? this means losing one order of magnitude on the highest value we can store (yeah, it's large enough right now..but in the future who knows!)
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 13/23] batman-adv: add last_unicast_tx to struct neigh_node_elp
In reply to Andrew LunnQuoted 9 lines · Andrew Lunn
Quoted 4 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
This timestamp registers the last time a unicast packet was sent to a given neighbour
I think this changelog needs improving. 95% of the patch is about refactoring a send function into a unicast send and a broadcast send function. The counter makes up the other 5% of the patch.
Yeah I should definitely improve it. Actually the refactoring has been done to allow batman-adv to easily save the last_unicast_tx time. But you are right, I should explain it better.
Thanks!
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 14/23] batman-adv: ELP - compute the metric based on the estimated throughput
In reply to Andrew LunnQuoted 7 lines · Andrew Lunn
Quoted 6 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
Implement a stub
get_throughput()function which returns the estimated throughput towards a given neighbour. Its result is then used to compute the metric value.
Quoted 8 lines
Quoted 4 lines
The metric is updated each time a new ELP packet is sent, this way it is possible to timely react to a metric variation which can imply (for example) a neighbour disconnection.
It is very much a style issue, but i would probably split this into two patches. Updating the metric at send time rather than receive should have nothing to do with estimated bandwidth.
Yes, to make it easier I will first move the reading at sending time and then I'll introduce the throughput estimation.
Thanks!
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling
In reply to Antonio QuartulliQuoted 16 lines · Antonio Quartulli
Quoted 7 lines · Andrew Lunn
Quoted 6 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
In case of a unused link, the throughput estimation will get stuck to the last sampled value and therefore the reported metric will becomes obsolete.
Quoted 7 lines
Quoted 2 lines
Send unicast ELP packets to each neighbor to trigger throughput sampling on unused links.
Humm, i can understand the need for this, but i really think the rate control code should be sending the probes, not batman. What do the wifi people say about this? Have they tried submitting patches to them?
Quoted 4 lines
I am CC'ing Felix so that he can give his opinion.
But last time I checked Minstrel I realised that it uses data packets to probe rates (there is not a specific probing packet), meaning that if there is no data packet to send, then no probing is performed.
Correct. Minstrel never sends dedicated probing packets. Changing minstrel to send active probing packets to serve the needs of batman would be a very bad idea, because pretty much all regular users do not have any need for extra probing.
Quoted 2 lines
Sending this ELP packets (when there is no unicast traffic) is a way to trigger this mechanism in Minstrel.
Right. If I remember correctly, if you send less than 1 packet per 100 ms, then all packets should end up being probing packets. If that doesn't work, we can change minstrel's probing pattern to allow things like batman to get a desirable amount of rate control probing simply by sending unicast packets.
- Felix
Re: [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling
Quoted 26 lines · Felix Fietkau
Quoted 16 lines · Antonio Quartulli
Quoted 7 lines · Andrew Lunn
Quoted 6 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
In case of a unused link, the throughput estimation will get stuck to the last sampled value and therefore the reported metric will becomes obsolete.
Quoted 7 lines
Quoted 2 lines
Send unicast ELP packets to each neighbor to trigger throughput sampling on unused links.
Humm, i can understand the need for this, but i really think the rate control code should be sending the probes, not batman. What do the wifi people say about this? Have they tried submitting patches to them?
Quoted 4 lines
I am CC'ing Felix so that he can give his opinion.
But last time I checked Minstrel I realised that it uses data packets to probe rates (there is not a specific probing packet), meaning that if there is no data packet to send, then no probing is performed.Correct. Minstrel never sends dedicated probing packets. Changing minstrel to send active probing packets to serve the needs of batman would be a very bad idea, because pretty much all regular users do not have any need for extra probing.
Quoted 7 lines
Quoted 2 lines
Sending this ELP packets (when there is no unicast traffic) is a way to trigger this mechanism in Minstrel.
Right. If I remember correctly, if you send less than 1 packet per 100 ms, then all packets should end up being probing packets. If that doesn't work, we can change minstrel's probing pattern to allow things like batman to get a desirable amount of rate control probing simply by sending unicast packets.
This is what I am trying to achieve here: if no unicast packets have been sent for the last 100ms (at least) then send N probing packets in a row (with N = 2 at the moment - it is a define in main.h).
Thanks Felix!
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling
Quoted 35 lines · Antonio Quartulli
Quoted 26 lines · Felix Fietkau
Quoted 16 lines · Antonio Quartulli
Quoted 7 lines · Andrew Lunn
Quoted 6 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
In case of a unused link, the throughput estimation will get stuck to the last sampled value and therefore the reported metric will becomes obsolete.
Quoted 7 lines
Quoted 2 lines
Send unicast ELP packets to each neighbor to trigger throughput sampling on unused links.
Humm, i can understand the need for this, but i really think the rate control code should be sending the probes, not batman. What do the wifi people say about this? Have they tried submitting patches to them?
Quoted 4 lines
I am CC'ing Felix so that he can give his opinion.
But last time I checked Minstrel I realised that it uses data packets to probe rates (there is not a specific probing packet), meaning that if there is no data packet to send, then no probing is performed.Correct. Minstrel never sends dedicated probing packets. Changing minstrel to send active probing packets to serve the needs of batman would be a very bad idea, because pretty much all regular users do not have any need for extra probing.
Quoted 7 lines
Quoted 2 lines
Sending this ELP packets (when there is no unicast traffic) is a way to trigger this mechanism in Minstrel.
Right. If I remember correctly, if you send less than 1 packet per 100 ms, then all packets should end up being probing packets. If that doesn't work, we can change minstrel's probing pattern to allow things like batman to get a desirable amount of rate control probing simply by sending unicast packets.
Quoted 4 lines
This is what I am trying to achieve here: if no unicast packets have been sent for the last 100ms (at least) then send N probing packets in a row (with N = 2 at the moment - it is a define in
main.h).
However, from the experiments performed so far it looked like Minstrel was behaving properly under these batman probing packets.
As soon as we move on with this project I am sure we will get some more feedback from other users (perhaps this is something we can test at the WBM? - this code should be ready and usable by then - cross fingers)
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 14/23] batman-adv: ELP - compute the metric based on the estimated throughput
In reply to Antonio QuartulliQuoted 13 lines · Antonio Quartulli
Quoted 12 lines · Andrew Lunn
Quoted 10 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
Implement a stub
get_throughput()function which returns the estimated throughput towards a given neighbour. Its result is then used to compute the metric value.The metric is updated each time a new ELP packet is sent, this way it is possible to timely react to a metric variation which can imply (for example) a neighbour disconnection.
Quoted 8 lines
Quoted 3 lines
It is very much a style issue, but i would probably split this into two patches. Updating the metric at send time rather than receive should have nothing to do with estimated bandwidth.
Yes, to make it easier I will first move the reading at sending time and then I'll introduce the throughput estimation.
Andrew,
I just rechecked the code and I realised that these "2 changes" are one only because there is no "second change".
Before this patch ELP does not perform any metric estimation.
This patch adds the estimation mechanism and in particular adds it along the ELP message sending path.
Maybe this was not clear? Maybe some previous patch gave you the impression that a sort of metric estimation was already performed in the receiving routine?
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
In reply to Antonio QuartulliQuoted 18 lines · Antonio Quartulli
hard-interface.c +7
-0@@ -297,6 +299,7 @@ void batadv_update_min_mtu(struct net_device *soft_iface)static void batadv_hardif_activate_interface (struct batadv_hard_iface *hard_iface) { +struct net_device *dev = hard_iface->net_dev;struct batadv_priv *bat_priv;struct batadv_hard_iface *primary_if =NULL ;@@ -315,6 +318,22 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)if (!primary_if)batadv_primary_if_select (bat_priv, hard_iface); +/* set the default values */ + hard_iface->bat_v.flags &= ~BATADV_FULL_DUPLEX ; + hard_iface->bat_v.eth_throughput =0 ; +if (dev->phydev) { +if (dev->phydev->duplex ==DUPLEX_FULL ) + hard_iface->bat_v.flags |=BATADV_FULL_DUPLEX ;
hard-interface.c batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) · line 336
Quoted 10 lines
hard-interface.c +10
-0+ +/* set the speed according to the phydev setting. Store the +* value in Kbps (as done for the other throughput variables) +*/ +if (dev->phydev->speed !=SPEED_UNKNOWN ) { + hard_iface->bat_v.eth_throughput = dev->phydev->speed; + hard_iface->bat_v.eth_throughput *=10 ; + } + } +
For the record: I just moved this chunk into a proper bat_algo_ops->bat_iface_activate() API.
This initialisation is obviously B.A.T.M.A.N. V specific and cannot live in the batadv_hardif_activate_interface() function.
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
Quoted 13 lines · Antonio Quartulli
Quoted 12 lines · Antonio Quartulli
hard-interface.c +1
-0@@ -297,6 +299,7 @@ void batadv_update_min_mtu(struct net_device *soft_iface)static void batadv_hardif_activate_interface (struct batadv_hard_iface *hard_iface) { +struct net_device *dev = hard_iface->net_dev;struct batadv_priv *bat_priv;struct batadv_hard_iface *primary_if =NULL ;@@ -315,6 +318,22 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)if (!primary_if)batadv_primary_if_select (bat_priv, hard_iface);
Quoted 10 lines
hard-interface.c batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) · line 330
Quoted 10 lines
hard-interface.c +10
-0+/* set the default values */ + hard_iface->bat_v.flags &= ~BATADV_FULL_DUPLEX ; + hard_iface->bat_v.eth_throughput =0 ; +if (dev->phydev) { +if (dev->phydev->duplex ==DUPLEX_FULL ) + hard_iface->bat_v.flags |=BATADV_FULL_DUPLEX ; + +/* set the speed according to the phydev setting. Store the +* value in Kbps (as done for the other throughput variables) +*/
And of course this is not Kbps but Mbps/10 (like everywhere else)..
Quoted 17 lines
hard-interface.c batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) · line 336
Quoted 6 lines
hard-interface.c +6
-0+if (dev->phydev->speed !=SPEED_UNKNOWN ) { + hard_iface->bat_v.eth_throughput = dev->phydev->speed; + hard_iface->bat_v.eth_throughput *=10 ; + } + } +For the record: I just moved this chunk into a proper
bat_algo_ops->bat_iface_activate()API.This initialisation is obviously B.A.T.M.A.N. V specific and cannot live in the
batadv_hardif_activate_interface()function.Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 12/23] batman-adv: add base throughput attribute
In reply to Antonio QuartulliQuoted 45 lines · Antonio Quartulli
Quoted 37 lines · Andrew Lunn
Quoted 36 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
when batman-adv is asked to estimate/compute the throughput of an interface, but it fails for whatever reason, then the value in this attribute is used
Signed-off-by Antonio Quartulli <[email protected]>--- bat_v.c | 3 +++ main.h | 7 +++++++ sysfs.c | 7 +++++++ types.h | 1 + 4 files changed, 18 insertions(+)bat_v.c +3
-0@@ -75,6 +75,9 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {int batadv_v_mesh_init (struct batadv_priv *bat_priv) { +atomic_set (&bat_priv->bat_v.base_throughput, +BATADV_DEFAULT_BASE_THROUGHPUT ); +return batadv_v_ogm_init (bat_priv); }main.h +0
-0@@ -33,6 +33,13 @@#define BATADV_MAX_METRIC 0xFFFFFFFF#define BATADV_JITTER 20Quoted 6 lines
main.h line 39
Quoted 4 lines
main.h +4
-0+/** +* BATADV_DEFAULT_BASE_THROUGHPUT - default value used as throughput for +* hard_ifaces for which it is not possible to measure/estimate the real one. +* Value is expressed in Mbps/10 Mbps/10 is a rather odd unit. How about just Kbps?
Quoted 6 lines
This is the unit used in cfg/mac80211 because most of the rates are either in the form of XX.0Mbps of XX.YMbps (so just one decimal number needs to be saved).
Moreover I thought that having an higher precision is not very useful because the routing decision cannot be taken on such a fine grained value. Actually the originator table prints the metric in Mbps (XX.YMbps).
It is not precision which i think is important, it is having a unit a user expects. Networking people work in Kbps, or MBps. If it is printed in the originator table as XX.YMBps, then i think this sysfs file also needs to be XX.YMBps. That does however make your parsing more complex, since it is no longer an int. I suppose there is the use case of an ADSL link, with bandwidth of say 2Mbps down, 256Kbps up, and then you do need the decimal point in XX.YMBps.
Andrew
Re: [B.A.T.M.A.N.] [RFC 14/23] batman-adv: ELP - compute the metric based on the estimated throughput
In reply to Antonio QuartulliQuoted 31 lines · Antonio Quartulli
Quoted 13 lines · Antonio Quartulli
Quoted 12 lines · Andrew Lunn
Quoted 10 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
Implement a stub
get_throughput()function which returns the estimated throughput towards a given neighbour. Its result is then used to compute the metric value.The metric is updated each time a new ELP packet is sent, this way it is possible to timely react to a metric variation which can imply (for example) a neighbour disconnection.
Quoted 8 lines
Quoted 3 lines
It is very much a style issue, but i would probably split this into two patches. Updating the metric at send time rather than receive should have nothing to do with estimated bandwidth.
Yes, to make it easier I will first move the reading at sending time and then I'll introduce the throughput estimation.
Andrew,
I just rechecked the code and I realised that these "2 changes" are one only because there is no "second change".
Before this patch ELP does not perform any metric estimation.
Quoted 7 lines
This patch adds the estimation mechanism and in particular adds it along the ELP message sending path.
Maybe this was not clear? Maybe some previous patch gave you the impression that a sort of metric estimation was already performed in the receiving routine?
Ah, ok, it was this comment which confused me:
+ /* Instead of updating the metric each "received" ELP packet, it is
+ * better to do it on each ELP sending. This way, if a node is dead and + * does not send packets anymore, batman-adv is still able to timely + * react to its death.
The "instead of" suggests it was previously done differently. The BATMAN philosophy has been in the past to react on received packets, so i can understand where this came from. But i think this comment could be worded:
/* The metric is updated on each sent packet. This way, if a node is
* dead and no longer sends packets, batman-adv is still able to
* react timely to its death. */
Andrew
Re: [B.A.T.M.A.N.] [RFC 14/23] batman-adv: ELP - compute the metric based on the estimated throughput
Quoted 43 lines · Andrew Lunn
Quoted 31 lines · Antonio Quartulli
Quoted 13 lines · Antonio Quartulli
Quoted 12 lines · Andrew Lunn
Quoted 10 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
Implement a stub
get_throughput()function which returns the estimated throughput towards a given neighbour. Its result is then used to compute the metric value.The metric is updated each time a new ELP packet is sent, this way it is possible to timely react to a metric variation which can imply (for example) a neighbour disconnection.
Quoted 8 lines
Quoted 3 lines
It is very much a style issue, but i would probably split this into two patches. Updating the metric at send time rather than receive should have nothing to do with estimated bandwidth.
Yes, to make it easier I will first move the reading at sending time and then I'll introduce the throughput estimation.
Andrew,
I just rechecked the code and I realised that these "2 changes" are one only because there is no "second change".
Before this patch ELP does not perform any metric estimation.
Quoted 7 lines
This patch adds the estimation mechanism and in particular adds it along the ELP message sending path.
Maybe this was not clear? Maybe some previous patch gave you the impression that a sort of metric estimation was already performed in the receiving routine?
Ah, ok, it was this comment which confused me:
bat_v_elp.c static void batadv_v_elp_send_outstanding(struct work_struct *work) · line 236
Quoted 4 lines
bat_v_elp.c +4
-0+/* Instead of updating the metric each "received" ELP packet, it is +* better to do it on each ELP sending. This way, if a node is dead and +* does not send packets anymore, batman-adv is still able to timely +* react to its death.
Yeah...it is a refusal from a previous approach that has been changed during the development phase, but of course I forgot to reword the comment.
Quoted 8 lines
The "instead of" suggests it was previously done differently. The BATMAN philosophy has been in the past to react on received packets, so i can understand where this came from. But i think this comment could be worded:
/* The metric is updated on each sent packet. This way, if a node is
* dead and no longer sends packets, batman-adv is still able to
* react timely to its death. */
Thanks for the suggestion!
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 12/23] batman-adv: add base throughput attribute
In reply to Andrew LunnQuoted 14 lines · Andrew Lunn
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
+/**
+ *BATADV_DEFAULT_BASE_THROUGHPUT- default value used as throughput for
+ *hard_ifacesfor which it is not possible to measure/estimate the real one.
+ * Value is expressed in Mbps/10Quoted 8 lines
Quoted 1 line
Mbps/10 is a rather odd unit. How about just Kbps?
This is the unit used in cfg/mac80211 because most of the rates are either in the form of XX.0Mbps of XX.YMbps (so just one decimal number needs to be saved).
Moreover I thought that having an higher precision is not very useful because the routing decision cannot be taken on such a fine grained value. Actually the originator table prints the metric in Mbps (XX.YMbps).
Quoted 7 lines
It is not precision which i think is important, it is having a unit a user expects. Networking people work in Kbps, or MBps. If it is printed in the originator table as XX.YMBps, then i think this sysfs file also needs to be XX.YMBps. That does however make your parsing more complex, since it is no longer an int. I suppose there is the use case of an ADSL link, with bandwidth of say 2Mbps down, 256Kbps up, and then you do need the decimal point in XX.YMBps.
I just checked what we do in the "improved GW bandwidth advertisement" introduced not so much time ago:
- we store the bandwidth value in Mbps/10
- we print it in the form XX.YMbps
+ but we allow the user to specify the unit when entering the value in the sysfs interface: "xxxMbps" or "yyyKbps".
This way the user can pick the favourite unit, but of course the value is truncated (in the case of Kbps) to fit the internal representation.
What do you think about this approach?
I also think we have to keep the two consistent with each other (it would allow me to re-use the same parsing function).
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling
In reply to Antonio QuartulliQuoted 9 lines
Quoted 5 lines
Right. If I remember correctly, if you send less than 1 packet per 100 ms, then all packets should end up being probing packets. If that doesn't work, we can change minstrel's probing pattern to allow things like batman to get a desirable amount of rate control probing simply by sending unicast packets.
This is what I am trying to achieve here: if no unicast packets have been sent for the last 100ms (at least) then send N probing packets in a row (with N = 2 at the moment - it is a define in
main.h).
Hi Antonio
One minor thing to consider is that your statement is actually:
if no _batman_ unicast packets have been sent for the last 100ms ...
I've used batman in setups where it has not been the exclusive user of the hard interface. So there could be other traffic which is keeping the RC algorithm up to date. So maybe it would be better to use the hard interface statistic counters rather than last time batman sent a packet?
Andrew
Re: [B.A.T.M.A.N.] [RFC 12/23] batman-adv: add base throughput attribute
In reply to Antonio QuartulliQuoted 8 lines
I just checked what we do in the "improved GW bandwidth advertisement" introduced not so much time ago:
- we store the bandwidth value in Mbps/10
- we print it in the form XX.YMbps
+ but we allow the user to specify the unit when entering the value in the sysfs interface: "xxxMbps" or "yyyKbps".
Quoted 4 lines
This way the user can pick the favourite unit, but of course the value is truncated (in the case of Kbps) to fit the internal representation.
What do you think about this approach?
I think that is good.
Thanks
Andrew
Re: [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling
In reply to Andrew LunnQuoted 14 lines · Andrew Lunn
Quoted 9 lines
Quoted 5 lines
Right. If I remember correctly, if you send less than 1 packet per 100 ms, then all packets should end up being probing packets. If that doesn't work, we can change minstrel's probing pattern to allow things like batman to get a desirable amount of rate control probing simply by sending unicast packets.
This is what I am trying to achieve here: if no unicast packets have been sent for the last 100ms (at least) then send N probing packets in a row (with N = 2 at the moment - it is a define in
main.h).Hi Antonio
One minor thing to consider is that your statement is actually:
Quoted 7 lines
if no _batman_ unicast packets have been sent for the last 100ms ...
I've used batman in setups where it has not been the exclusive user of the hard interface. So there could be other traffic which is keeping the RC algorithm up to date. So maybe it would be better to use the hard interface statistic counters rather than last time batman sent a packet?
We can't use the hard_iface statistics because we need to know where that traffic has been sent to.
The same interface might connected to several neighbours and the rates are selected/probed on a per-peer base.
However, to go in the direction that you are suggesting, I could use the same API I use to read the throughput (cfg80211_get_station()) to also read when the last packet was sent to a given peer.
This information should be good for our purposes, but it means that we probe the neighbours right after having read the throughput.
This should not be a problem because as we said in a previous email we do not require real time throughput updates.
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling
Quoted 2 lines
We can't use the
hard_ifacestatistics because we need to know where that traffic has been sent to.
Oh, yes, my error.
Quoted 5 lines
However, to go in the direction that you are suggesting, I could use the same API I use to read the throughput (
cfg80211_get_station()) to also read when the last packet was sent to a given peer.
This information should be good for our purposes, but it means that we probe the neighbours right after having read the throughput.
My guess is, there are not many use cases where the hard interface is used for other traffic as well as BATMAN. So i don't see it as being a big issue. Maybe put it onto a TODO list once the code has been merged, to swap to using statistics from lower down in the stack.
Andrew
Re: [B.A.T.M.A.N.] [RFC 15/23] batman-adv: ELP - send unicast ELP packets for throughput sampling
Quoted 11 lines · Andrew Lunn
Quoted 2 lines
We can't use the
hard_ifacestatistics because we need to know where that traffic has been sent to.Oh, yes, my error.
Quoted 5 lines
However, to go in the direction that you are suggesting, I could use the same API I use to read the throughput (
cfg80211_get_station()) to also read when the last packet was sent to a given peer.
This information should be good for our purposes, but it means that we probe the neighbours right after having read the throughput.
Quoted 5 lines
My guess is, there are not many use cases where the hard interface is used for other traffic as well as BATMAN. So i don't see it as being a big issue. Maybe put it onto a TODO list once the code has been merged, to swap to using statistics from lower down in the stack.
Yes, note taken ;)
Thanks!
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
In reply to Antonio QuartulliQuoted 82 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
The phydev member of a
net_devicecan be used to get information about an ethernet link like HALF/FULL_DUPLEX and advertised bandwidth (e.g. 100/10Mbps).This information are then stored in the
hard_ifaceobject to be used during the metric computation routine.Signed-off-by Antonio Quartulli <[email protected]>--- bat_v_elp.c | 8 ++++++++ bat_v_ogm.c | 4 ++-- hard-interface.c | 19 +++++++++++++++++++ types.h | 12 ++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-)bat_v_elp.c +8
-0@@ -78,6 +78,14 @@ batadv_v_elp_get_throughput(struct batadv_elp_neigh_node *neigh)if (throughput !=0 )return throughput; +/* In case of Ethernet interface, the throughput has already been +* obtained from the phydev object in the net_device struct (see +* batadv_hardif_activate_interface()). So return this value. +*/ + throughput = hard_iface->bat_v.eth_throughput; +if (throughput !=0 ) +return throughput; +/* if this is a wireless device, then ask its throughput through * cfg80211 API */ bat_v_ogm.c +2
-2@@ -393,8 +393,8 @@ static uint32_t batadv_v_penalty(struct batadv_priv *bat_priv,/* proportion to use the same value used in batman iv (x * 128 / 256) */ hop_penalty = hop_penalty *100 /255 ; -if (batadv_is_wifi_netdev (if_incoming->net_dev) && - metric > link_metric /10 ) +if ((if_incoming->bat_v.flags &BATADV_FULL_DUPLEX ) && + (metric > link_metric /10 ))return metric /2 ;return metric * (100 - hop_penalty) /100 ;hard-interface.c +9
-0@@ -31,6 +31,8 @@#include <linux/if_arp.h> #include <linux/if_ether.h> +#include <linux/netdevice.h> +#include <linux/phy.h> void batadv_hardif_free_rcu (struct rcu_head *rcu) {@@ -297,6 +299,7 @@ void batadv_update_min_mtu(struct net_device *soft_iface)static void batadv_hardif_activate_interface (struct batadv_hard_iface *hard_iface) { +struct net_device *dev = hard_iface->net_dev;struct batadv_priv *bat_priv;struct batadv_hard_iface *primary_if =NULL ;@@ -315,6 +318,22 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)if (!primary_if)batadv_primary_if_select (bat_priv, hard_iface); +/* set the default values */ + hard_iface->bat_v.flags &= ~BATADV_FULL_DUPLEX ; + hard_iface->bat_v.eth_throughput =0 ; +if (dev->phydev) { +if (dev->phydev->duplex ==DUPLEX_FULL ) + hard_iface->bat_v.flags |=BATADV_FULL_DUPLEX ;
hard-interface.c batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) · line 336
Quoted 10 lines
hard-interface.c +10
-0+ +/* set the speed according to the phydev setting. Store the +* value in Kbps (as done for the other throughput variables) +*/ +if (dev->phydev->speed !=SPEED_UNKNOWN ) { + hard_iface->bat_v.eth_throughput = dev->phydev->speed; + hard_iface->bat_v.eth_throughput *=10 ; + } + } +
Hi Antonio
If i'm reading this correctly, you get the bandwidth once when the interface is added to bat0? Are we sure that auto-negotiation has finished? It can take a few seconds to complete after the interface is brought up. It would not be good to have batman use 10Mbps/Half Duplex on my gigabit links...
Is there a notification mechanism which could be used to keep these values up to date? Or is that in a patch i have not yet got to?
Andrew
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
Quoted 96 lines · Andrew Lunn
Quoted 82 lines · Antonio Quartulli
From: Antonio Quartulli <[email protected]>
The phydev member of a
net_devicecan be used to get information about an ethernet link like HALF/FULL_DUPLEX and advertised bandwidth (e.g. 100/10Mbps).This information are then stored in the
hard_ifaceobject to be used during the metric computation routine.Signed-off-by Antonio Quartulli <[email protected]>--- bat_v_elp.c | 8 ++++++++ bat_v_ogm.c | 4 ++-- hard-interface.c | 19 +++++++++++++++++++ types.h | 12 ++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-)bat_v_elp.c +8
-0@@ -78,6 +78,14 @@ batadv_v_elp_get_throughput(struct batadv_elp_neigh_node *neigh)if (throughput !=0 )return throughput; +/* In case of Ethernet interface, the throughput has already been +* obtained from the phydev object in the net_device struct (see +* batadv_hardif_activate_interface()). So return this value. +*/ + throughput = hard_iface->bat_v.eth_throughput; +if (throughput !=0 ) +return throughput; +/* if this is a wireless device, then ask its throughput through * cfg80211 API */ bat_v_ogm.c +2
-2@@ -393,8 +393,8 @@ static uint32_t batadv_v_penalty(struct batadv_priv *bat_priv,/* proportion to use the same value used in batman iv (x * 128 / 256) */ hop_penalty = hop_penalty *100 /255 ; -if (batadv_is_wifi_netdev (if_incoming->net_dev) && - metric > link_metric /10 ) +if ((if_incoming->bat_v.flags &BATADV_FULL_DUPLEX ) && + (metric > link_metric /10 ))return metric /2 ;return metric * (100 - hop_penalty) /100 ;hard-interface.c +9
-0@@ -31,6 +31,8 @@#include <linux/if_arp.h> #include <linux/if_ether.h> +#include <linux/netdevice.h> +#include <linux/phy.h> void batadv_hardif_free_rcu (struct rcu_head *rcu) {@@ -297,6 +299,7 @@ void batadv_update_min_mtu(struct net_device *soft_iface)static void batadv_hardif_activate_interface (struct batadv_hard_iface *hard_iface) { +struct net_device *dev = hard_iface->net_dev;struct batadv_priv *bat_priv;struct batadv_hard_iface *primary_if =NULL ;@@ -315,6 +318,22 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)if (!primary_if)batadv_primary_if_select (bat_priv, hard_iface); +/* set the default values */ + hard_iface->bat_v.flags &= ~BATADV_FULL_DUPLEX ; + hard_iface->bat_v.eth_throughput =0 ; +if (dev->phydev) { +if (dev->phydev->duplex ==DUPLEX_FULL ) + hard_iface->bat_v.flags |=BATADV_FULL_DUPLEX ;hard-interface.c batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) · line 336
Quoted 10 lines
hard-interface.c +10
-0+ +/* set the speed according to the phydev setting. Store the +* value in Kbps (as done for the other throughput variables) +*/ +if (dev->phydev->speed !=SPEED_UNKNOWN ) { + hard_iface->bat_v.eth_throughput = dev->phydev->speed; + hard_iface->bat_v.eth_throughput *=10 ; + } + } +Hi Antonio
Quoted 2 lines
If i'm reading this correctly, you get the bandwidth once when the interface is added to bat0?
it is invoked every time the interface is brought up. So if you disconnect and then reconnect the cable (e.g. to connect the NIC to a faster switch) this function is invoked again and the bandwidth is updated.
Quoted 4 lines
Are we sure that auto-negotiation has
finished? It can take a few seconds to complete after the interface is brought up. It would not be good to have batman use 10Mbps/Half Duplex on my gigabit links...
So it can take up to "few" seconds? I did not expect such a delay!
However this function if invoked when the NETDEV_UP event is issued by the underlying system. I expect the event to be thrown when the interface is ready to be used, not when the auto-negotiatin is still going on. I will double check.
Quoted 3 lines
Is there a notification mechanism which could be used to keep these values up to date? Or is that in a patch i have not yet got to.
No there is no notification mechanism.
I see only two ways of changing this value at runtime:
1) NIC disconnected and re-connected to a different "thing" -> NETDEV_UP is issued, we re-read the values
2) the user manually changes the bandwidth (e.g. using ethtool) -> not handled right now (I would also not consider it a high priority item), but maybe the NETDEV_CHANGE event is fired up in this case?
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
Quoted 10 lines
it is invoked every time the interface is brought up. So if you disconnect and then reconnect the cable (e.g. to connect the NIC to a faster switch) this function is invoked again and the bandwidth is updated.
Quoted 4 lines
Are we sure that auto-negotiation has
finished? It can take a few seconds to complete after the interface is brought up. It would not be good to have batman use 10Mbps/Half Duplex on my gigabit links...So it can take up to "few" seconds? I did not expect such a delay!
It varies a lot between devices. I have a NAS box which i use for kernel hacking. I TFTP boot the kernel, using u-boot configuration variables. I found that for a cold boot it works great, but a warm boot seems to be faster and the TFTP GET command is sent while the phy is still auto-negotiating, and it gets lost. This then triggers a bug in u-boot, it never re-transmits the GET command, and then whole TFTP boot times out eventually.
So i'm just cautious about making assumptions here, especially assumptions which might be mostly true, but in some odd edge case turn out to be false.
Quoted 4 lines
However this function if invoked when the
NETDEV_UPevent is issued by the underlying system. I expect the event to be thrown when the interface is ready to be used, not when the auto-negotiatin is still going on. I will double check.
I had a quick look at the code. It seems like NETDEV_UP is issued directly after the device is opened. There does not seem to be any waiting around for auto-neg.
Andrew
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
Quoted 23 lines · Andrew Lunn
Quoted 10 lines
it is invoked every time the interface is brought up. So if you disconnect and then reconnect the cable (e.g. to connect the NIC to a faster switch) this function is invoked again and the bandwidth is updated.
Quoted 4 lines
Are we sure that auto-negotiation has
finished? It can take a few seconds to complete after the interface is brought up. It would not be good to have batman use 10Mbps/Half Duplex on my gigabit links...So it can take up to "few" seconds? I did not expect such a delay!
It varies a lot between devices. I have a NAS box which i use for kernel hacking. I TFTP boot the kernel, using u-boot configuration variables. I found that for a cold boot it works great, but a warm boot seems to be faster and the TFTP GET command is sent while the phy is still auto-negotiating, and it gets lost. This then triggers a bug in u-boot, it never re-transmits the GET command, and then whole TFTP boot times out eventually.
So i'm just cautious about making assumptions here, especially assumptions which might be mostly true, but in some odd edge case turn out to be false.
Quoted 8 lines
Quoted 4 lines
However this function if invoked when the
NETDEV_UPevent is issued by the underlying system. I expect the event to be thrown when the interface is ready to be used, not when the auto-negotiatin is still going on. I will double check.I had a quick look at the code. It seems like
NETDEV_UPis issued directly after the device is opened. There does not seem to be any waiting around for auto-neg.
Hi Andrew,
This morning I've been trying to dig into the tg3 Ethernet driver to get an idea of what happens before the NETDEV_UP event is fired.
The network stack invokes the ndo_open() callback implemented by the driver and, as far as I can see, this function does not return until having set speed and half/full_duplex state.
Thus it looks like that when NETDEV_UP is fired the speed and the full_duplex attribute have already a meaningful value.
Of course this may vary depending on the driver, so this may not be the case everywhere.
I think that we can keep this approach for now and then perform some tests on a couple of platforms before merging the code. This way we should be "sure" about this particular behaviour.
I think that your NAS might also be a good testing platform, assuming that the owner is willing to insmod batman-adv on that machine :-)
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
Quoted 5 lines
Hi Andrew,
This morning I've been trying to dig into the tg3 Ethernet driver to get an idea of what happens before the
NETDEV_UPevent is fired.
Quoted 8 lines
The network stack invokes the
ndo_open()callback implemented by the driver and, as far as I can see, this function does not return until having set speed and half/full_duplex state.
Thus it looks like that whenNETDEV_UPis fired the speed and thefull_duplexattribute have already a meaningful value.Of course this may vary depending on the driver, so this may not be the case everywhere.
Hi Antonio
I just looked at mv643xx_eth.c, the ethernet driver for my NAS box. Its ndo_open() function calls phy_start(), but does not wait around for the auto-negotiation to complete.
I hacked together a quick test.
#!/bin/bash
ifconfig eth0 down
sleep 2
ifconfig eth0 up
cat /sys/class/net/eth0/duplex
cat /sys/class/net/eth0/speed
sleep 0.5
cat /sys/class/net/eth0/duplex
cat /sys/class/net/eth0/speed
sleep 0.5
cat /sys/class/net/eth0/duplex
cat /sys/class/net/eth0/speed
sleep 0.5
cat /sys/class/net/eth0/duplex
cat /sys/class/net/eth0/speed
sleep 0.5
cat /sys/class/net/eth0/duplex
cat /sys/class/net/eth0/speed
sleep 0.5
cat /sys/class/net/eth0/duplex
cat /sys/class/net/eth0/speed
sleep 0.5
cat /sys/class/net/eth0/duplex
cat /sys/class/net/eth0/speed
Which when run gives:
half
1000
half
1000
half
1000
half
1000
half
1000
half
1000
full
1000
So it is taking 3 seconds after ifconfig returns before it has the right duplex mode.
Quoted 2 lines
I think that your NAS might also be a good testing platform, assuming that the owner is willing to insmod batman-adv on that machine :-)
I've no problems with batman on this NAS box. It is a box dedicated to kernel hacking and experienced many an opps. I currently have 3.13-rc1 on it, which happens to break the ethernet PHY on reboot :-(
Andrew
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
Quoted 11 lines · Andrew Lunn
Quoted 11 lines
Hi Andrew,
This morning I've been trying to dig into the tg3 Ethernet driver to get an idea of what happens before the
NETDEV_UPevent is fired.The network stack invokes the
ndo_open()callback implemented by the driver and, as far as I can see, this function does not return until having set speed and half/full_duplex state.
Thus it looks like that whenNETDEV_UPis fired the speed and thefull_duplexattribute have already a meaningful value.
Quoted 5 lines
Quoted 2 lines
Of course this may vary depending on the driver, so this may not be the case everywhere.
Hi Antonio
Hi Andrew,
Quoted 3 lines
I just looked at
mv643xx_eth.c, the ethernet driver for my NAS box. Itsndo_open()function callsphy_start(), but does not wait around for the auto-negotiation to complete.
oh ok..then it seems we really need to get some kind of notification for this..
Quoted 45 lines
I hacked together a quick test.
#!/bin/bash
ifconfig eth0 down
sleep 2
ifconfig eth0 up
cat/sys/class/net/eth0/duplex
cat/sys/class/net/eth0/speed
sleep 0.5
cat/sys/class/net/eth0/duplex
cat/sys/class/net/eth0/speed
sleep 0.5
cat/sys/class/net/eth0/duplex
cat/sys/class/net/eth0/speed
sleep 0.5
cat/sys/class/net/eth0/duplex
cat/sys/class/net/eth0/speed
sleep 0.5
cat/sys/class/net/eth0/duplex
cat/sys/class/net/eth0/speed
sleep 0.5
cat/sys/class/net/eth0/duplex
cat/sys/class/net/eth0/speed
sleep 0.5
cat/sys/class/net/eth0/duplex
cat/sys/class/net/eth0/speedWhich when run gives:
half
1000
half
1000
half
1000
half
1000
half
1000
half
1000
full
1000
Quoted 2 lines
So it is taking 3 seconds after ifconfig returns before it has the right duplex mode.
Are you 100% sure that the NETDEV_UP event was sent within those 3 seconds and not after?
If you use a serial console you should see the kernel output mixed with your test. (just to be 100% sure..)
Quoted 8 lines
Quoted 3 lines
I think that your NAS might also be a good testing platform, assuming that the owner is willing to insmod batman-adv on that machine :-)
I've no problems with batman on this NAS box. It is a box dedicated to kernel hacking and experienced many an opps. I currently have 3.13-rc1 on it, which happens to break the ethernet PHY on reboot :-(
you shoul dmove to 3.13.3 ;)
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
Quoted 4 lines
Are you 100% sure that the
NETDEV_UPevent was sent within those 3 seconds and not after?
If you use a serial console you should see the kernel output mixed with your test. (just to be 100% sure..)
http://lxr.free-electrons.com/source/net/core/dev.c#L1286
1286 int dev_open(struct net_device *dev)
1287 {
1288 int ret;
1289
1290 if (dev->flags & IFF_UP)
1291 return 0;
1292
1293 ret = __dev_open(dev);
1294 if (ret < 0)
1295 return ret;
1296
1297 rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING, GFP_KERNEL);
1298 call_netdevice_notifiers(NETDEV_UP, dev);
1299
1300 return ret;
1301 }
So the NETDEV_UP is sent as soon as __dev_open() returns, i.e. ndo_open().
What i do see is:
half
1000
half
1000
half
1000
half
1000
half
1000
half
1000mv643xx_eth_port mv643xx_eth_port.0 eth0: link up, 1000 Mb/s, full duplex, flowd full
1000
The link up is from:
http://lxr.free-electrons.com/source/drivers/net/ethernet/marvell/mv643xx_eth.c#L1990
There is no sign of a call_netdevice_notifiers() here, but i think a netlink message will be sent to userspace because of the netif_carrier_on() call.
Andrew
Re: [B.A.T.M.A.N.] [RFC 18/23] batman-adv: ELP - use phydev to determine link characteristics
Quoted 25 lines · Andrew Lunn
Quoted 4 lines
Are you 100% sure that the
NETDEV_UPevent was sent within those 3 seconds and not after?
If you use a serial console you should see the kernel output mixed with your test. (just to be 100% sure..)http://lxr.free-electrons.com/source/net/core/dev.c#L1286
1286 int
dev_open(struct net_device *dev)
1287 {
1288 int ret;
1289
1290 if (dev->flags&IFF_UP)
1291 return 0;
1292
1293 ret =__dev_open(dev);
1294 if (ret < 0)
1295 return ret;
1296
1297rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING, GFP_KERNEL);
1298call_netdevice_notifiers(NETDEV_UP, dev);
1299
1300 return ret;
1301 }
Quoted 2 lines
So the
NETDEV_UPis sent as soon as__dev_open()returns, i.e.ndo_open().
Yeah, I hoped that the negotiation was performed within dev_open() :-(
Quoted 19 lines
What i do see is:
half
1000
half
1000
half
1000
half
1000
half
1000
half
1000mv643xx_eth_portmv643xx_eth_port.0 eth0: link up, 1000 Mb/s, full duplex, flowd full
1000
Quoted 7 lines
The link up is from:
http://lxr.free-electrons.com/source/drivers/net/ethernet/marvell/mv643xx_eth.c#L1990
There is no sign of a
call_netdevice_notifiers()here, but i think a netlink message will be sent to userspace because of thenetif_carrier_on()call.
I tried to follow netif_carrier_on() but I couldn't find any particular function firing any event.
Maybe I should simply make it simple and read the Ethernet card properties inside get_throughput() upon ELP sending (like I do for the wifi throughput)?
I did put it in iface_activate() because I expected this values to be rather static, but now you convinced me that this is not the case :-)
Cheers,
Signature · 1 line
Antonio Quartulli