Re: [B.A.T.M.A.N.] [PATCH] batman-adv: encourage batman to take shorter routes by changing the default hop penalty
On Fri, Jan 27, 2012 at 11:54:25PM +0800, Marek Lindner wrote: Hi Andrew, Do you have any performance analysis to show this is really helpful and not harmful? I've seen indoor results where i had to reduce the hop penalty, otherwise BATMAN was taking a short path which worked badly. By reducing the hop penalty, so encouraging it to take more hops, i got usable routes. I see the danger here this could break working networks, so maybe it needs justification? as a matter of fact I do believe it is helpful. In various networks (more than a dozen) I have seen that batman would largely favor multi-hop routes, thus reducing the overall throughput. By setting it to a higher value I regained some of its performance. The networks are still up running - I can show them to you if you are interested. I have seen similar results in my test setups. One simple scenario where I have seen route flapping with hop penalty 10 in multiple setups is: If some nodes are at the same place (e.g. a few netbooks on the same table), they often don't use the direct route but change to a two-hop route to reach their destination - even if the direct link is nearly perfect. There don't even has to be payload traffic involved, the routes just flap because of the little tq oscillations from some packets lost. In these tests, I have also changed the hop penalty to 30 (or even 50, sometimes) and these problems are gone. The TQ metric has limited informative value in terms of available bandwidth/chosen rate. The default wifi broadcast/multicast rate of 1 Mbit/s may lead to prefering low-rate 1 hop links over high-rate 2 hop links. However, this can be often fixed by increasing the mcast rate (mac80211 or madwifi support this). We should consider including rate information in future metrics. Anyway, for now and our current TQ metric I strongly agree in increasing the hop penalty too. Cheers, Simon So, you had to reduce the default value of 10 to something even smaller ? A hop penalty of 10 results in a penatly of 4% per hop. A rough equivalent of 2 lost packets (62/64). Does not sound very much to me. Can you explain your test setup a little more ? Nevertheless, this patch was intended to get a discussion going. The main problem I have been seeing in the last weeks is that OGM broadcasts have a hard time estimating the link quality / throughput on 11n devices. I'll also try to hack a proof of concept for an rssi influence on the routing and see if that has a better effect. signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCH] batctl: add bridge loop avoidance code and remove softif_neigh stuff
Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- debug.c |6 +++--- debug.h |4 ++-- main.c | 50 -- man/batctl.8 |7 +-- sys.c| 12 sys.h|2 ++ 6 files changed, 52 insertions(+), 29 deletions(-) diff --git a/debug.c b/debug.c index 6a553ff..155f499 100644 --- a/debug.c +++ b/debug.c @@ -61,13 +61,13 @@ void trans_global_usage(void) printf( \t -w [interval] watch mode - refresh the global translation table continuously\n); } -void softif_neigh_usage(void) +void bla_claim_table_usage(void) { - printf(Usage: batctl [options] softif_neigh \n); + printf(Usage: batctl [options] claimtable \n); printf(options:\n); printf( \t -h print this help\n); printf( \t -n don't replace mac addresses with bat-host names\n); - printf( \t -w [interval] watch mode - refresh the soft-interface neighbor table continuously\n); + printf( \t -w [interval] watch mode - refresh the bridge loop avoidance claim table continuously\n); } void gateways_usage(void) diff --git a/debug.h b/debug.h index 939f281..50d0e24 100644 --- a/debug.h +++ b/debug.h @@ -24,7 +24,7 @@ #define DEBUG_ORIGINATORS originators #define DEBUG_TRANSTABLE_LOCAL transtable_local #define DEBUG_TRANSTABLE_GLOBAL transtable_global -#define DEBUG_SOFTIF_NEIGH softif_neigh +#define DEBUG_BLA_CLAIM_TABLE bla_claim_table #define DEBUG_GATEWAYS gateways #define DEBUG_VIS_DATA vis_data #define DEBUG_LOG log @@ -32,7 +32,7 @@ void originators_usage(void); void trans_local_usage(void); void trans_global_usage(void); -void softif_neigh_usage(void); +void bla_claim_table_usage(void); void gateways_usage(void); int handle_debug_table(char *mesh_iface, int argc, char **argv, char *file_path, void table_usage(void)); diff --git a/main.c b/main.c index 0dfdb8e..86e2078 100644 --- a/main.c +++ b/main.c @@ -45,27 +45,28 @@ char module_ver_path[] = /sys/module/batman_adv/version; void print_usage(void) { printf(Usage: batctl [options] commands \n); printf(commands:\n); - printf( \tinterface|if[add|del iface(s)]\tdisplay or modify the interface settings\n); - printf( \toriginators|o \tdisplay the originator table\n); - printf( \tinterval|it [orig_interval] \tdisplay or modify the originator interval (in ms)\n); - printf( \tloglevel|ll [level] \tdisplay or modify the log level\n); - printf( \tlog|l \tread the log produced by the kernel module\n); - printf( \tgw_mode|gw [mode]\tdisplay or modify the gateway mode\n); - printf( \tgateways|gwl \tdisplay the gateway server list\n); - printf( \ttranslocal|tl \tdisplay the local translation table\n); - printf( \ttransglobal|tg\tdisplay the global translation table\n); - printf( \tsoftif_neigh|sn \tdisplay the soft-interface neighbor table\n); - printf( \tvis_mode|vm [mode]\tdisplay or modify the status of the VIS server\n); - printf( \tvis_data|vd [dot|JSON]\tdisplay the VIS data in dot or JSON format\n); - printf( \taggregation|ag [0|1] \tdisplay or modify the packet aggregation setting\n); - printf( \tbonding|b [0|1] \tdisplay or modify the bonding mode setting\n); - printf( \tfragmentation|f [0|1] \tdisplay or modify the fragmentation mode setting\n); - printf( \tap_isolation|ap [0|1] \tdisplay or modify the ap isolation mode setting\n); + printf( \tinterface|if [add|del iface(s)]\tdisplay or modify the interface settings\n); + printf( \toriginators|o\tdisplay the originator table\n); + printf( \tinterval|it[orig_interval] \tdisplay or modify the originator interval (in ms)\n); + printf( \tloglevel|ll[level] \tdisplay or modify the log level\n); + printf( \tlog|l\tread the log produced by the kernel module\n); + printf( \tgw_mode|gw [mode]\tdisplay or modify the gateway mode\n); + printf( \tgateways|gwl \tdisplay the gateway server list\n); + printf( \ttranslocal|tl\tdisplay the local translation table\n); + printf( \ttransglobal|tg \tdisplay the global translation table\n); + printf( \tclaimtable|cl\tdisplay the bridge loop avoidance claim table\n); + printf( \tvis_mode|vm[mode]\tdisplay or modify the status of the VIS server\n); + printf( \tvis_data
Re: [B.A.T.M.A.N.] [RFCv2] batman-adv: Add blocking of one hop OGM messages
Hey Martin, On Fri, Feb 10, 2012 at 03:53:11PM +0100, Martin Hundebøll wrote: 13 files changed, 491 insertions(+), 0 deletions(-) please excuse my superficial review, but do we really need to bloat batman-adv by 491 more lines to drop these OGMs? I'm afraid the filter will evolve more and more, and eventually the research/debugging code in batman-adv is bigger than the routing code. ;) (sorry for ranting ;] ) Have you considered using and/or extending the former ebtables patch from Linus[1]? We removed [2] it after some discussions [3], but maybe its worth fixing these problems if its just about dropping some neighbors packets. The patch has some problems, but it was really short and I guess we wouldn't mind accepting the performance overhead by ebtables for research/debugging purposes. Plus, we could make this a compile-feature too. Cheers, Simon [1] http://ftp.uni-kl.de/pub/linux/kernel/people/gregkh/staging/2.6/2.6.35/0120-Staging-batman-adv-Adding-netfilter-bridge-hooks.patch [2] https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2010-September/003305.html [3] http://lkml.indiana.edu/hypermail/linux/kernel/1008.1/02232.html signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH 3/6] batman-adv: register batman ogm receive function during protocol init
On Thu, Mar 01, 2012 at 03:35:18PM +0800, Marek Lindner wrote: -static void bat_iv_ogm_receive(struct hard_iface *if_incoming, -struct sk_buff *skb) +static void _bat_iv_ogm_receive(struct sk_buff *skb, + struct hard_iface *if_incoming) rant Personally, I don't like underscore functions. They are usually created because of a lack of creativity, but are later called from different places, do different jobs and in the end everyone is confused. :) Is it possibble to change the name, e.g. to bat_iv_ogm_handle()? /rant { struct batman_ogm_packet *batman_ogm_packet; struct ethhdr *ethhdr; @@ -1200,6 +1200,39 @@ static void bat_iv_ogm_receive(struct hard_iface *if_incoming, batman_ogm_packet-tt_num_changes)); } +static int bat_iv_ogm_receive(struct sk_buff *skb, + struct hard_iface *hard_iface) +{ + struct ethhdr *ethhdr; + + /* drop packet if it has not necessary minimum size */ + if (unlikely(!pskb_may_pull(skb, BATMAN_OGM_HLEN))) + return NET_RX_DROP; + + ethhdr = (struct ethhdr *)skb_mac_header(skb); + + /* packet with broadcast indication but unicast recipient */ + if (!is_broadcast_ether_addr(ethhdr-h_dest)) + return NET_RX_DROP; + + /* packet with broadcast sender address */ + if (is_broadcast_ether_addr(ethhdr-h_source)) + return NET_RX_DROP; + + /* create a copy of the skb, if needed, to modify it. */ + if (skb_cow(skb, 0) 0) + return NET_RX_DROP; + + /* keep skb linear */ + if (skb_linearize(skb) 0) + return NET_RX_DROP; + + _bat_iv_ogm_receive(skb, hard_iface); + + kfree_skb(skb); + return NET_RX_SUCCESS; +} + We should somewhere add a check whether the hard_iface is actually assigned to a mesh using the BATMAN IV algorithm. When more algorithms are added, we only want the assigned protocol to be handled, others should be ignored. Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH 1/6] batman-adv: introduce is_single_hop_neigh variable to increase readability
Hey Marek, I did a rough review over your patches, and a more detailed one to the HZ/jiffies patch. Looks fine, nice approach to get some more compatibility in. You've also added the handler table from our beer discussion - nice. ;) Apart from some minor comments on patch no. 3, feel free to add Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de to all the patches. Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCHv2 3/6] batman-adv: register batman ogm receive function during protocol init
Hey Marek, this looks much cleaner. Thanks! Simon Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de On Sun, Mar 04, 2012 at 04:56:25PM +0800, Marek Lindner wrote: The B.A.T.M.A.N. IV OGM receive function still was hard-coded although it is a routing protocol specific function. This patch takes advantage of the dynamic packet handler registration to remove the hard-coded function calls. Signed-off-by: Marek Lindner lindner_ma...@yahoo.de --- bat_iv_ogm.c | 31 +++ main.c |5 + routing.c| 22 ++ routing.h|4 +++- types.h |3 --- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index aba0204..784fcef 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -1166,13 +1166,18 @@ out: orig_node_free_ref(orig_node); } -static void bat_iv_ogm_receive(struct hard_iface *if_incoming, -struct sk_buff *skb) +static int bat_iv_ogm_receive(struct sk_buff *skb, + struct hard_iface *if_incoming) { struct batman_ogm_packet *batman_ogm_packet; struct ethhdr *ethhdr; int buff_pos = 0, packet_len; unsigned char *tt_buff, *packet_buff; + bool ret; + + ret = check_management_packet(skb, if_incoming, BATMAN_OGM_HLEN); + if (!ret) + return NET_RX_DROP; packet_len = skb_headlen(skb); ethhdr = (struct ethhdr *)skb_mac_header(skb); @@ -1198,6 +1203,9 @@ static void bat_iv_ogm_receive(struct hard_iface *if_incoming, (packet_buff + buff_pos); } while (bat_iv_ogm_aggr_packet(buff_pos, packet_len, batman_ogm_packet-tt_num_changes)); + + kfree_skb(skb); + return NET_RX_SUCCESS; } static struct bat_algo_ops batman_iv __read_mostly = { @@ -1208,10 +1216,25 @@ static struct bat_algo_ops batman_iv __read_mostly = { .bat_ogm_update_mac = bat_iv_ogm_update_mac, .bat_ogm_schedule = bat_iv_ogm_schedule, .bat_ogm_emit = bat_iv_ogm_emit, - .bat_ogm_receive = bat_iv_ogm_receive, }; int __init bat_iv_init(void) { - return bat_algo_register(batman_iv); + int ret; + + /* batman originator packet */ + ret = recv_handler_register(BAT_IV_OGM, bat_iv_ogm_receive); + if (ret 0) + goto out; + + ret = bat_algo_register(batman_iv); + if (ret 0) + goto handler_unregister; + + goto out; + +handler_unregister: + recv_handler_unregister(BAT_IV_OGM); +out: + return ret; } diff --git a/main.c b/main.c index 0d0cd48..8c3ff21 100644 --- a/main.c +++ b/main.c @@ -263,8 +263,6 @@ static void recv_handler_init(void) for (i = 0; i ARRAY_SIZE(recv_packet_handler); i++) recv_packet_handler[i] = recv_unhandled_packet; - /* batman originator packet */ - recv_packet_handler[BAT_IV_OGM] = recv_bat_ogm_packet; /* batman icmp packet */ recv_packet_handler[BAT_ICMP] = recv_icmp_packet; /* unicast packet */ @@ -331,8 +329,7 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops) !bat_algo_ops-bat_primary_iface_set || !bat_algo_ops-bat_ogm_update_mac || !bat_algo_ops-bat_ogm_schedule || - !bat_algo_ops-bat_ogm_emit || - !bat_algo_ops-bat_ogm_receive) { + !bat_algo_ops-bat_ogm_emit) { pr_info(Routing algo '%s' does not implement required ops\n, bat_algo_ops-name); goto out; diff --git a/routing.c b/routing.c index 0da9f5a..d83502a 100644 --- a/routing.c +++ b/routing.c @@ -248,37 +248,35 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, return 0; } -int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface) +bool check_management_packet(struct sk_buff *skb, + struct hard_iface *hard_iface, + int header_len) { - struct bat_priv *bat_priv = netdev_priv(hard_iface-soft_iface); struct ethhdr *ethhdr; /* drop packet if it has not necessary minimum size */ - if (unlikely(!pskb_may_pull(skb, BATMAN_OGM_HLEN))) - return NET_RX_DROP; + if (unlikely(!pskb_may_pull(skb, header_len))) + return false; ethhdr = (struct ethhdr *)skb_mac_header(skb); /* packet with broadcast indication but unicast recipient */ if (!is_broadcast_ether_addr(ethhdr-h_dest)) - return NET_RX_DROP; + return false; /* packet with broadcast sender address */ if (is_broadcast_ether_addr(ethhdr-h_source)) - return NET_RX_DROP; + return false; /* create a copy of the skb, if needed, to modify it. */ if (skb_cow(skb, 0) 0
Re: [B.A.T.M.A.N.] [Battlemesh] Battlemesh v5 tests
Hey Gabriel, thanks for bringing the discussion to the batman ml and giving some constructive input. I've written this bonding/alternating feature some time ago, and we released it at WBMv3 together with this little documentation to be found in the wiki. Actually, I considered the feature rather simple and therefore I did not write too much about it - because there is not really much to write about, or so I thought. Obviously, there were some things unclear, so thanks for pointing me/us to that. When implementing, it is easy to miss some things that are not that obvious for outsiders, so please feel free to ask or suggest things. We'll rework the bonding/interface alternating part in the next days, and would be happy to include your suggestions. :) Usually, we create the protocol documentation for the purpose of review and documentation for other batman-adv devs - and we don't expect that they all fall on the head at the same time. They are meant to describe the concept and not the actual implementation with all their nasty details. On Wed, Mar 07, 2012 at 11:18:48PM +0100, Gabriel Kerneis wrote: [CC: b.a.t.m.a.n@lists.open-mesh.org, see note 3 in particular] Antonio, On Wed, Mar 07, 2012 at 06:17:52PM +0100, Antonio Quartulli wrote: Technical details about what? Interface-alternating? It is there! Gabriel wrote the link. No. Please re-read my email carefuly. The wiki contains a rough explanation of the general principle (ie. “same interface = bad, different interface = good”). Not the actual algorithm used by batman-adv (quoting from the wiki: “the algorithm tries to avoid forwarding packets on the interface which just received the packet”). Note that the wiki has been updated since then, by Simon with a few more details [1], and by Marek with benchmark results from WBMv3. Maybe algorithm is a big word for a little feature like that. The bonding and interface alternating basically work in two steps: 1) detect that a neighbor is reachable via two different links 2) use the two different links for various manipulations (bonding, interface alternation) 1) The detection part is batman-specific, we use the the PRIMARIES_FIRST_HOP flag to do that. As a reminder (that might be documented somewhere else): * OGMs from the primary interface are broadcasted on ALL interfaces and are spread over the mesh (big TTL) -- these get the PRIMARIES_FIRST_HOP flag, which is cleared when forwarded by other nodes * OGMs from the secondary interfaces are only broadcasted on their respective interface and are only used for local link sensing (TTL = 1) When we receive OGMs with PRIMARIES_FIRST_HOP flags on different interfaces, we know that it came from the same neighbor, just from different interfaces. We have two links to this neighbor. 2) the manipulation step is independent of the routing protocol, as long as the routing protocol routes packets based on their destination and does not care about on which interface it comes in. Because we already made our routing decision (we have chosen a neighbor), it does not matter on which link we send the frame. We use this freedom to either use another interface where the frame came in (interface alternation) or round-robin over the available, detected links (bonding). Note that this would work on any routing protocol and is independent of the BATMAN routing. However, we need the fact that we are on layer 2 and can decide on the packet link usage in batman-adv. This would not work so easily with static layer 3 routing tables, I suppose. Gabriel said he has not enough time to look into it. I'm sorry, but I don't think this is a good reason to blame batman-adv devs :P I finally decided to settle this issue and spent my breakfast reading batman-adv/routing.c [2] instead of my favorite newspaper. Here is what I understood: At all times, batman-adv maintains a list of bonding candidates for each node (bonding_candidate_add, called from bat_iv_ogm.c:699). Some node neigh is a bonding candidate for another node orig if and only if: - neigh and orig have the same primary address, ie. are in fact the same router, that's right - we are talking about one neighbor, and the bonding candidates are the available links to this neighbor. - the links to reach them have the same quality up to some additive constant (BONDING_TQ_THRESHOLD = 50) [3], Yep, it would be useless if we can reach one link perfectly and the other one is dropping all the packets. We want similar TQ quality. - orig does not already have another bonding candidate for the same interface, because it could interfere – but what if the neigh has a better link quality, isn’t it a pity to ignore it? If it had a better quality, it would have been chosen as router already - at least we expect that here. Maybe this is a little rough, but using the same interface/frequency is far
Re: [B.A.T.M.A.N.] [Battlemesh] Diversity in BATMAN
Hey there, On Sun, Mar 11, 2012 at 09:02:54AM -0700, Mitar wrote: Hi! However, in my personal case, there's also the fact that WBM has been evolving in a direction that I don't feel comfortable with (less technical content, more self- promotion, tolerance for bomb-makers, etc.) Self-promotion of good ideas is not necessary bad. And others are there to squash the bad ideas. ;-) I definitly agree. If we promote bad ideas as the batman-adv-team, I'm sure we'll be shouted at very loud, and thats a great thing. But for technical content: I think you could easily volunteer to lead few round tables on the topic of protocol design. For example, this discussion we are now having on the mailing list about different aspects of routing protocols: oh, how I would love to have them in live, with everybody from all protocols together, sitting and explaining their approaches, their arguments and experiences why they are doing something in the way they are doing: is this theoretical argument, or is it simply a practical observation, can we find a theoretical reasoning behind it, can we maybe invalidate some theoretical argument with a practical (repeatable) experiment? Because I think I am not the only one who does not know much about how other protocols are doing things, what were the reasons they have chosen the given approach, ... And it would really help understanding each other, and maybe, maybe, we could in some years even agree on a common routing protocol. ;-) This would also be interesting for non-technical and new people, because they would be able to listen and understand how things work. But because Juliusz is afraid to come, I can volunteer to moderate (and mediate) such tables if others prepare me a list of topics to discuss. Sounds like a great idea! After some discussion with some other batman-adv devs, we would really like to join this. Actually I think its a good thing that we have some different routing protocols. Diversity gives birth to different approaches, which may succeed or fail, and in both events we can learn from each other. Anyway, maybe we should have put a list in the wiki what we want to dicuss? Do you want to put it as a side-event or more like a podium discussion thing? Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] BW degradation on p2p links?
Hey Guido, the problem using one radio is explained further here (from another company, but this applies to any WiFi mesh technology) http://revolutionwifi.blogspot.com/2012/02/mesh-network-performance-impact.html Also, if you use two-radio nodes, make sure that you use one module on 2.4 GHz and one 5 GHz - if you use two modules in the same frequency band with omni antennas, even if you use separate channels (like 1 and 11), they may interfere with each other if the antennas are near to each other. There are quite a few ppl who can confirm this, e.g. check this: https://hackerspace.be/Wbm2009v2/TestInterferenceResults Possible Solutions: * use different bands * use directional or sector antennas * have a reasonable distance between your omni antennas Cheers, Simon On Wed, Mar 28, 2012 at 07:41:05PM -0300, Guido Iribarren wrote: (this time i'll keep the mail short, insane details are attached as text :) ) Well, luckily for batman-adv devs, but unfortunately for me, the problem is in fact related to relaying between wlan interfaces in mr3x20 hardware (at least) I understand this is not anymore batman related, but maybe someone has experience on this, or can point me into the right direction / maillist ? Given you have a good deal of equipments at the BattleMesh, maybe someone has already tried adding a wifi dongle and can confirm seeing this behaviour? (in a line of 2-radio nodes with static routing, packet throughput is halved on each hop) I've repeated the iperf tests in a controlled environment, this time using different subnets on each interface and static routes built with route add. iptables flushed with -F and policy -P FORWARD ACCEPT no batman at all. Packets coming in through wlan1 and out through wlan0 (or viceversa) experience (unexpected) bandwidth degradation. Throughput drops from 30mbps to 15mbps (rough avg) The speed is closely comparable to using only 1 radio (packet comes in through wlan0, goes out through wlan0), so adding the dongle makes no net difference. (besides alternating the channel for transmission, throughput is halved over one hop anyway) 2 consecutive hops, alternating wifi radios, yield 1/3 throughput. (like it happens in a 1-radio mesh) this does not happen if the packet comes in through eth0 and goes out through wlanX (or viceversa) . Throughput is maintained high at 30mbps. = So the hardware (or kernel??) is uncapable of keeping up with the transfer speed *when two radios are involved*. Has anyone bumped into a similar case, or has experience with these equipments? Maybe (again!) i am doing something wrong? If this is confirmed, my only alternative to maintain good throughput along the mesh will be to install 2 x mr3220 on each node, connected back-to-back with ethernet cable. This will definitely work but the cost for each node owner evidently rises ;( Thanks a lot! Guido signature.asc Description: Digital signature
[B.A.T.M.A.N.] B.A.T.M.A.N. GSoC 2012 announcement
Hey there, the student application period for the Google Summer of Code 2012 has opened. A chance for any student to get their hands dirty on their favorite OpenSource project and getting its development process and code base to know better during these 2 months - while getting payed for it! As last year, B.A.T.M.A.N. tasks will be done as part of the freifunk project, which again will serve as an umbrella organization for various projects dealing with wireless mesh networks. If you are interested in mesh networking and B.A.T.M.A.N. and if you also love OpenSource software and would like to become a more firm part of it, then please apply on fore freifunk: http://www.google-melange.com/gsoc/org/show/google/gsoc2012/freifunk and get in touch with us via mailinglist and/or IRC. So far the following ideas have been collected which you may apply for: http://wiki.freifunk.net/Ideas#B.A.T.M.A.N. But feel free to tell us your own suggestions and ideas, too. * *** Student application deadline is the 6th of April!! *** * - GSoC timeline: http://www.google-melange.com/gsoc/events/google/gsoc2012 - Student Check List: http://wiki.freifunk.net/Student_Check_List - Freifunk GSoC Page: http://www.google-melange.com/gsoc/org/show/google/gsoc2012/freifunk Happy routing, The B.A.T.M.A.N. team signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH 0/3] clean up patches
Hey Antonio, thanks a lot for fixing my style bugs!! There is a little bug in one (one line doubled), otherwise: Reviewed-by: Simon Wunderlich s...@hrz.tu-chemnitz.de Cheers, Simon On Sat, Apr 07, 2012 at 11:06:06PM +0200, Antonio Quartulli wrote: ** this patches are for batman-ad/next *** After my first pull request, David S. Miller hardly suggested me to fix some problems that I am going to summarise here. Please respect such suggestions in your next patches: 1) Multi-line comments must end with */ on a new line: /* .. * .. */ 2) if we use #ifdef in our headers to redefine some functions depending on the fact that we are compiling a component or not, we must use static inline functions doing nothing with the correct parameters instead of simple foo(...). In this way we can allow the compiler to check for the types and the number of arguments: Instead of: #define bla_init(...) (1) we must do: static inline bla_init(struct bat_priv *bat_priv) { return 1; } Other than David's complaining I also get a suggestion from Bernd Petrovitsch about the type of stp_addr (it should be static const uint8_t [] instead of uint8_t [] only). I applied such change in patch 2/3. Cheers, signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: fix comments ending style
On Sat, Apr 07, 2012 at 11:06:07PM +0200, Antonio Quartulli wrote: @@ -732,7 +732,7 @@ static int handle_claim(struct bat_priv *bat_priv, } /** - * + * @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information * @hw_src: the Hardware source in the ARP Header * @hw_dst: the Hardware destination in the ARP Header guess this line was duplicated by accident ... Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] Problem with multi-radio, multi-channel in batman-adv
Hey Puyou, On Mon, Apr 16, 2012 at 06:35:04PM +0800, puyou.lu wrote: Hi guys. I’m trying to make a for nodes WMN using four devices with two wireless cards each. I would like to use three different channels to reduce the interference, like this: [Node A] - channel 1 - [Node B] - channel 2 - [Node C] - channel 3 - [Node D] First I configure eight wireless cards to the specific channel in ad-hoc mode using “iw dev wlan0 ibss join …”. Then, I think I should add wlan0 and wlan1 to the same batman-adv interface (that is bat0) in every device. So I need to configure four nodes with the same commands like: echo bat0 /sys/class/net/wlan0/batman_adv/mesh_iface echo bat0 /sys/class/net/wlan1/batman_adv/mesh_iface Last configure an IP address to each bat0. (Node A-10.0.0.1, Node B-10.0.0.2, Node C-10.0.0.3, Node D-10.0.0.4). But it seem Node A can reach Node B and Node C(using ping), but can’t for Node D. Am I following the right procedure? Sorry for my poor English. Any help would be appreciated. The procedure looks right in general. A few questions to debug: * do you use different ESSIDs for the IBSS-networks? ad-hoc devices joining may override the configured channel and select another IBSS-network instead when it has the same ESSID. * have you confirmed that the WiFi connection works without batman-adv? just set up your WiFi, configure different IP addresses and ping for each hop to test. * does the output of batctl originators helps you? Are the other nodes displayed on node 4? Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] Problem with multi-radio, multi-channel in batman-adv
Hi Puyou, On Wed, Apr 18, 2012 at 02:15:19PM +0800, puyou.lu wrote: Hi Simon, I have tried again, and I think the problem is caused by the same ESSID, as you said. I used the same ESSID on every wireless cards of every nodes.When I use different ESSIDs in different channel, the problem seems diappeared. Another question, does the two wireless cards(wlan0 and wlan1) of one node have any differences in receiving and forwarding unicast and broadcast package? Can a gw_client node get IP address from a dhcp server from both wireless cards? Yes, you use the virtual bat0 interface. Whether the data is transported via wlan0 or wlan1 does not matter, you will always receive the data on bat0. There is no difference in the usage, and which interface is used is up to batman-adv to decide. Please make sure that you configure all your services like IP addresses, DHCP, etc on bat0 (or even on bridges above it), not the wlanX interfaces. http://www.open-mesh.org/wiki/batman-adv/Quick-start-guide Cheers, Simon -Original Message- From: b.a.t.m.a.n-boun...@lists.open-mesh.org [mailto:b.a.t.m.a.n-boun...@lists.open-mesh.org] On Behalf Of Simon Wunderlich Sent: Tuesday, April 17, 2012 5:26 PM To: The list for a Better Approach To Mobile Ad-hoc Networking Subject: Re: [B.A.T.M.A.N.] Problem with multi-radio, multi-channel in batman-adv Hey Puyou, On Mon, Apr 16, 2012 at 06:35:04PM +0800, puyou.lu wrote: Hi guys. I’m trying to make a for nodes WMN using four devices with two wireless cards each. I would like to use three different channels to reduce the interference, like this: [Node A] - channel 1 - [Node B] - channel 2 - [Node C] - channel 3 - [Node D] First I configure eight wireless cards to the specific channel in ad-hoc mode using “iw dev wlan0 ibss join …”. Then, I think I should add wlan0 and wlan1 to the same batman-adv interface (that is bat0) in every device. So I need to configure four nodes with the same commands like: echo bat0 /sys/class/net/wlan0/batman_adv/mesh_iface echo bat0 /sys/class/net/wlan1/batman_adv/mesh_iface Last configure an IP address to each bat0. (Node A-10.0.0.1, Node B-10.0.0.2, Node C-10.0.0.3, Node D-10.0.0.4). But it seem Node A can reach Node B and Node C(using ping), but can’ t for Node D. Am I following the right procedure? Sorry for my poor English. Any help would be appreciated. The procedure looks right in general. A few questions to debug: * do you use different ESSIDs for the IBSS-networks? ad-hoc devices joining may override the configured channel and select another IBSS-network instead when it has the same ESSID. * have you confirmed that the WiFi connection works without batman-adv? just set up your WiFi, configure different IP addresses and ping for each hop to test. * does the output of batctl originators helps you? Are the other nodes displayed on node 4? Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: fix visualization output without neighbors on the primary interface
Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de Your patch does the trick, although I think this ugly function could use a rewrite. First counting bytes and then allocating this size to do exactly the same thing again is not really good style. If you would like to volunteer to do this job (or plan to work more on vis), please tell me, otherwise I'll put it in on my TODO list. Thanks Simon On Sat, May 05, 2012 at 05:51:53PM +0200, Matthias Schiffer wrote: The primary entry and the corresponding secondary entries are missing when there are no neighbors on the primary interface. This also causes the TT entries to miss and makes nodes with multiply secondary interface fall apart since there is no way to see they are related without a primary entry. Fix this by always emitting a primary entry. Signed-off-by: Matthias Schiffer mschif...@universe-factory.net --- vis.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/vis.c b/vis.c index cec216f..c515927 100644 --- a/vis.c +++ b/vis.c @@ -207,7 +207,6 @@ int vis_seq_print_text(struct seq_file *seq, void *offset) int vis_server = atomic_read(bat_priv-vis_mode); size_t buff_pos, buf_size; char *buff; - int compare; primary_if = primary_if_get_selected(bat_priv); if (!primary_if) @@ -228,14 +227,18 @@ int vis_seq_print_text(struct seq_file *seq, void *offset) entries = (struct vis_info_entry *) ((char *)packet + sizeof(*packet)); + vis_data_insert_interface(packet-vis_orig, + vis_if_list, true); + for (j = 0; j packet-entries; j++) { if (entries[j].quality == 0) continue; - compare = - compare_eth(entries[j].src, packet-vis_orig); + if (compare_eth(entries[j].src, + packet-vis_orig)) + continue; vis_data_insert_interface(entries[j].src, vis_if_list, - compare); + false); } hlist_for_each_entry(entry, pos, vis_if_list, list) { @@ -276,14 +279,18 @@ int vis_seq_print_text(struct seq_file *seq, void *offset) entries = (struct vis_info_entry *) ((char *)packet + sizeof(*packet)); + vis_data_insert_interface(packet-vis_orig, + vis_if_list, true); + for (j = 0; j packet-entries; j++) { if (entries[j].quality == 0) continue; - compare = - compare_eth(entries[j].src, packet-vis_orig); + if (compare_eth(entries[j].src, + packet-vis_orig)) + continue; vis_data_insert_interface(entries[j].src, vis_if_list, - compare); + false); } hlist_for_each_entry(entry, pos, vis_if_list, list) { -- 1.7.10.1 signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH 06/15] batman-adv: Distributed ARP Table - add snooping functions for ARP messages
Hello David, we are a little bit in a pinch here - the DAT feature sent with this patchset was developed for a long time, and we need your decision to move on as more and more patches depend on it: * should we rewrite DAT to use our own ARP table/backend or * can we use the ARP neighbor table in another way, maybe after your changes? We thought that re-using existing infrastructure would be smarter, but if you disagree, please tell us so - we would like to get this feature finally upstream and need your input to make the neccesary changes. Thanks Simon On Thu, May 17, 2012 at 07:53:54PM +0800, Marek Lindner wrote: David, On Tuesday, May 01, 2012 08:59:04 David Miller wrote: From: Antonio Quartulli or...@autistici.org Date: Tue, 1 May 2012 00:22:30 +0200 However this patch also contains a procedure which queries the neigh table in order to understand whether a given host is known or not. Would it be possible to do that in another way (Without manually touching the table)? Instead, in the next patch (patch 06/15) batman-adv manually increase the neigh timeouts. Do you think we should avoid doing that as well? If we are allowed to do that, how can we perform the same operation in a cleaner way? Last question: why can't other modules use exported functions? Are you going to change them as well? I really don't have time to discuss your neigh issues right now as I'm busy speaking at conferences and dealing with the backlog of other patches. You'll need to find someone else to discuss it with you, sorry. I hope now is a good moment to bring the questions back onto the table. We still are not sure how to proceed because we have no clear picture of what is going to come and how the exported functions are supposed to be used. David, if you don't have the time to discuss the ARP handling with us could you name someone who knows your plans and the code equally well ? So far, nobody has stepped up. let me add another piece of information: The distributed ARP table does not really depend on the kernel's ARP table. We can easily write our own backend to be totally independent of the kernel's ARP table. Initially, we thought it might be considered a smart move if the code made use of existing kernel infrastructure instead of writing our own storage / user space API / etc, hence duplicating what is already there. But if you feel this is the better way forward we certainly will make the necessary changes. Regards, Marek signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH 06/15] batman-adv: Distributed ARP Table - add snooping functions for ARP messages
Hey David, thanks for your answer, On Thu, May 24, 2012 at 01:54:57AM -0400, David Miller wrote: From: Sven Eckelmann s...@narfation.org Date: Thu, 24 May 2012 07:34:12 +0200 _You_ were the person that declined the pull request because _you_ wanted to rewrite the ARP handling. So _you_ are the person that has the insight in _your_ plans. Either _you_ tell us what is _your_ problem with it or _you_ will have to point us to a person that knows _you_. If I say that you must not use ARP nor neighbour layer internals, it doesn't mean that I have to come up with the alternative implementation for you. well, thats pretty much answers it. If we must not use ARP or neighbour internals, even after your rewrite (?), we have to come up with an alternative in any case (write our own backened). We don't expect you to come up with an alternative implementation, but as you are the one accepting the patches (or not) we need to know why you decline something and what the problem is so we ca n work around or improve. Thanks Simon signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCH] batman-adv: Add the backbone gateway list to debugfs
This is especially useful if there are no claims yet, but we still want to know which gateways are using bridge loop avoidance in the network. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 68 +++ bridge_loop_avoidance.h |8 ++ debugfs.c | 12 + 3 files changed, 88 insertions(+) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 38aab1e..f3c6dc0 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1592,3 +1592,71 @@ out: batadv_hardif_free_ref(primary_if); return ret; } + +int batadv_bla_gw_table_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_hashtable *hash = bat_priv-backbone_hash; + struct batadv_backbone_gw *backbone_gw; + struct batadv_hard_iface *primary_if; + struct hlist_node *node; + struct hlist_head *head; + int last_seen_secs; + int last_seen_msecs; + uint32_t i; + bool is_own; + int ret = 0; + uint8_t *primary_addr; + + primary_if = batadv_primary_if_get_selected(bat_priv); + if (!primary_if) { + ret = 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) { + ret = seq_printf(seq, +BATMAN mesh %s disabled - primary interface not active\n, +net_dev-name); + goto out; + } + + primary_addr = primary_if-net_dev-dev_addr; + seq_printf(seq, + Backbones announced for the mesh %s (orig %pM, group id %04x)\n, + net_dev-name, primary_addr, + ntohs(bat_priv-claim_dest.group)); + seq_printf(seq,%-17s%-5s %-9s (%-4s)\n, + Originator, VID, last seen, CRC); + for (i = 0; i hash-size; i++) { + head = hash-table[i]; + + rcu_read_lock(); + hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { + last_seen_msecs = jiffies_to_msecs(jiffies - + backbone_gw-lasttime); + last_seen_secs = last_seen_msecs / 1000; + last_seen_msecs = last_seen_msecs % 1000; + + + is_own = batadv_compare_eth(backbone_gw-orig, + primary_addr); + if (is_own) + continue; + + seq_printf(seq, + * %pM on % 5d % 4i.%03is (%04x)\n, + backbone_gw-orig, backbone_gw-vid, + last_seen_secs, last_seen_msecs, + backbone_gw-crc); + } + rcu_read_unlock(); + } +out: + if (primary_if) + batadv_hardif_free_ref(primary_if); + return ret; +} diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 08d13cb..58015ce 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -26,6 +26,8 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); int batadv_bla_is_backbone_gw(struct sk_buff *skb, struct batadv_orig_node *orig_node, int hdr_size); int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); +int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, +void *offset); int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig); int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, struct batadv_bcast_packet *bcast_packet, @@ -64,6 +66,12 @@ static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, return 0; } +static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, + void *offset) +{ + return 0; +} + static inline int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig) { diff --git a/debugfs.c b/debugfs.c index e45cf0e..ee8b322 100644 --- a/debugfs.c +++ b/debugfs.c @@ -263,6 +263,15 @@ static int batadv_bla_claim_table_open(struct inode *inode, struct file *file) return single_open(file, batadv_bla_claim_table_seq_print_text, net_dev); } + +static int batadv_bla_backbone_table_open(struct
[B.A.T.M.A.N.] [PATCHv2] batman-adv: Add the backbone gateway list to debugfs
This is especially useful if there are no claims yet, but we still want to know which gateways are using bridge loop avoidance in the network. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- [EDIT: forgot to rename the function ...] --- bridge_loop_avoidance.c | 68 +++ bridge_loop_avoidance.h |8 ++ debugfs.c | 12 + 3 files changed, 88 insertions(+) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 38aab1e..75587af 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1592,3 +1592,71 @@ out: batadv_hardif_free_ref(primary_if); return ret; } + +int batadv_bla_backbone_table_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_hashtable *hash = bat_priv-backbone_hash; + struct batadv_backbone_gw *backbone_gw; + struct batadv_hard_iface *primary_if; + struct hlist_node *node; + struct hlist_head *head; + int last_seen_secs; + int last_seen_msecs; + uint32_t i; + bool is_own; + int ret = 0; + uint8_t *primary_addr; + + primary_if = batadv_primary_if_get_selected(bat_priv); + if (!primary_if) { + ret = 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) { + ret = seq_printf(seq, +BATMAN mesh %s disabled - primary interface not active\n, +net_dev-name); + goto out; + } + + primary_addr = primary_if-net_dev-dev_addr; + seq_printf(seq, + Backbones announced for the mesh %s (orig %pM, group id %04x)\n, + net_dev-name, primary_addr, + ntohs(bat_priv-claim_dest.group)); + seq_printf(seq,%-17s%-5s %-9s (%-4s)\n, + Originator, VID, last seen, CRC); + for (i = 0; i hash-size; i++) { + head = hash-table[i]; + + rcu_read_lock(); + hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { + last_seen_msecs = jiffies_to_msecs(jiffies - + backbone_gw-lasttime); + last_seen_secs = last_seen_msecs / 1000; + last_seen_msecs = last_seen_msecs % 1000; + + + is_own = batadv_compare_eth(backbone_gw-orig, + primary_addr); + if (is_own) + continue; + + seq_printf(seq, + * %pM on % 5d % 4i.%03is (%04x)\n, + backbone_gw-orig, backbone_gw-vid, + last_seen_secs, last_seen_msecs, + backbone_gw-crc); + } + rcu_read_unlock(); + } +out: + if (primary_if) + batadv_hardif_free_ref(primary_if); + return ret; +} diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 08d13cb..58015ce 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -26,6 +26,8 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); int batadv_bla_is_backbone_gw(struct sk_buff *skb, struct batadv_orig_node *orig_node, int hdr_size); int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); +int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, +void *offset); int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig); int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, struct batadv_bcast_packet *bcast_packet, @@ -64,6 +66,12 @@ static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, return 0; } +static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, + void *offset) +{ + return 0; +} + static inline int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig) { diff --git a/debugfs.c b/debugfs.c index e45cf0e..ee8b322 100644 --- a/debugfs.c +++ b/debugfs.c @@ -263,6 +263,15 @@ static int batadv_bla_claim_table_open(struct inode *inode, struct file *file) return single_open(file, batadv_bla_claim_table_seq_print_text, net_dev
Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: Add the backbone gateway list to debugfs
Hey Sven, On Thu, Jun 14, 2012 at 10:43:55PM +0200, Sven Eckelmann wrote: You forgot the README and most likely the batctl part. I planned to send the batctl patch later, but README is definitly missing. Thanks! Simon signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCH] batctl: add support for the bla backbone table in debugfs
Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- debug.c | 10 ++ debug.h |2 ++ main.c |6 ++ 3 files changed, 18 insertions(+) diff --git a/debug.c b/debug.c index 928f81d..5dca633 100644 --- a/debug.c +++ b/debug.c @@ -70,6 +70,16 @@ void bla_claim_table_usage(void) printf( \t -w [interval] watch mode - refresh the bridge loop avoidance claim table continuously\n); } +void bla_backbone_table_usage(void) +{ + printf(Usage: batctl [options] backbone table\n); + printf(options:\n); + printf( \t -h print this help\n); + printf( \t -n don't replace mac addresses with bat-host names\n); + printf( \t -w [interval] watch mode - refresh the bridge loop avoidance backbone table continuously\n); +} + + void gateways_usage(void) { printf(Usage: batctl [options] gateways \n); diff --git a/debug.h b/debug.h index 50d0e24..2c6d24c 100644 --- a/debug.h +++ b/debug.h @@ -25,6 +25,7 @@ #define DEBUG_TRANSTABLE_LOCAL transtable_local #define DEBUG_TRANSTABLE_GLOBAL transtable_global #define DEBUG_BLA_CLAIM_TABLE bla_claim_table +#define DEBUG_BLA_BACKBONE_TABLE bla_backbone_table #define DEBUG_GATEWAYS gateways #define DEBUG_VIS_DATA vis_data #define DEBUG_LOG log @@ -33,6 +34,7 @@ void originators_usage(void); void trans_local_usage(void); void trans_global_usage(void); void bla_claim_table_usage(void); +void bla_backbone_table_usage(void); void gateways_usage(void); int handle_debug_table(char *mesh_iface, int argc, char **argv, char *file_path, void table_usage(void)); diff --git a/main.c b/main.c index 72b1ea4..929b762 100644 --- a/main.c +++ b/main.c @@ -56,6 +56,7 @@ void print_usage(void) { printf( \ttranslocal|tl\tdisplay the local translation table\n); printf( \ttransglobal|tg \tdisplay the global translation table\n); printf( \tclaimtable|cl\tdisplay the bridge loop avoidance claim table\n); + printf( \tbackbonetable|bbl\tdisplay the bridge loop avoidance backbone table\n); printf( \tvis_mode|vm[mode]\tdisplay or modify the status of the VIS server\n); printf( \tvis_data|vd[dot|JSON]\tdisplay the VIS data in dot or JSON format\n); printf( \taggregation|ag [0|1] \tdisplay or modify the packet aggregation setting\n); @@ -158,6 +159,11 @@ int main(int argc, char **argv) ret = handle_debug_table(mesh_iface, argc - 1, argv + 1, DEBUG_BLA_CLAIM_TABLE, bla_claim_table_usage); + } else if ((strcmp(argv[1], backbonetable) == 0) || (strcmp(argv[1], bbl) == 0)) { + + ret = handle_debug_table(mesh_iface, argc - 1, argv + 1, +DEBUG_BLA_BACKBONE_TABLE, +bla_backbone_table_usage); } else if ((strcmp(argv[1], loglevel) == 0) || (strcmp(argv[1], ll) == 0)) { -- 1.7.10
[B.A.T.M.A.N.] [PATCHv3] batman-adv: Add the backbone gateway list to debugfs
This is especially useful if there are no claims yet, but we still want to know which gateways are using bridge loop avoidance in the network. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- [EDITv2: forgot to rename the function ...] [EDITv3: add README entry] --- README |7 ++--- bridge_loop_avoidance.c | 68 +++ bridge_loop_avoidance.h |8 ++ debugfs.c | 12 + 4 files changed, 92 insertions(+), 3 deletions(-) diff --git a/README b/README index 8f3ae4a..a173d2a 100644 --- a/README +++ b/README @@ -75,9 +75,10 @@ folder: There is a special folder for debugging information: -# ls /sys/kernel/debug/batman_adv/bat0/ -# bla_claim_tablelogsocket transtable_local -# gateways originatorstranstable_global vis_data +# ls /sys/kernel/debug/batman_adv/bat0/ +# bla_backbone_table log transtable_global +# bla_claim_table originators transtable_local +# gatewayssocket vis_data Some of the files contain all sort of status information regard- ing the mesh network. For example, you can view the table of diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 38aab1e..75587af 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1592,3 +1592,71 @@ out: batadv_hardif_free_ref(primary_if); return ret; } + +int batadv_bla_backbone_table_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_hashtable *hash = bat_priv-backbone_hash; + struct batadv_backbone_gw *backbone_gw; + struct batadv_hard_iface *primary_if; + struct hlist_node *node; + struct hlist_head *head; + int last_seen_secs; + int last_seen_msecs; + uint32_t i; + bool is_own; + int ret = 0; + uint8_t *primary_addr; + + primary_if = batadv_primary_if_get_selected(bat_priv); + if (!primary_if) { + ret = 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) { + ret = seq_printf(seq, +BATMAN mesh %s disabled - primary interface not active\n, +net_dev-name); + goto out; + } + + primary_addr = primary_if-net_dev-dev_addr; + seq_printf(seq, + Backbones announced for the mesh %s (orig %pM, group id %04x)\n, + net_dev-name, primary_addr, + ntohs(bat_priv-claim_dest.group)); + seq_printf(seq,%-17s%-5s %-9s (%-4s)\n, + Originator, VID, last seen, CRC); + for (i = 0; i hash-size; i++) { + head = hash-table[i]; + + rcu_read_lock(); + hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { + last_seen_msecs = jiffies_to_msecs(jiffies - + backbone_gw-lasttime); + last_seen_secs = last_seen_msecs / 1000; + last_seen_msecs = last_seen_msecs % 1000; + + + is_own = batadv_compare_eth(backbone_gw-orig, + primary_addr); + if (is_own) + continue; + + seq_printf(seq, + * %pM on % 5d % 4i.%03is (%04x)\n, + backbone_gw-orig, backbone_gw-vid, + last_seen_secs, last_seen_msecs, + backbone_gw-crc); + } + rcu_read_unlock(); + } +out: + if (primary_if) + batadv_hardif_free_ref(primary_if); + return ret; +} diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 08d13cb..58015ce 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -26,6 +26,8 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); int batadv_bla_is_backbone_gw(struct sk_buff *skb, struct batadv_orig_node *orig_node, int hdr_size); int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); +int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, +void *offset); int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig); int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, struct
Re: [B.A.T.M.A.N.] link alternation when radios are not on batman-adv router?
On Thu, Jun 14, 2012 at 04:51:01PM -0300, gto...@inti.gob.ar wrote: Hi, we are interested too in interface alternating, so we made some tests to understand how it works. As you can see on the attached sketch.png, we connected two pair of routers using their ethernet interfaces, E6 with E7, and E8 with E9. All of them have eth0, and an ad hoc interface, wlan0-1, managed by batman. E6 and E8 are in channel 11, whereas E7 and E9 are in channel 1. Besides we used two other routers, E12 and E13, both in channel 11, with their tx power set to just 0 dbm, to avoid a direct sight between them. Then we sent traffic from E12 to E13. We expected that packets travelled from E12 to E6, and that E6 forwarded them to his eth0 to use the interface alternating feature, making traffic flow to E7, then E9, E8 and finally E13. But instead, we observed that the actual path was E12--E6--E8--E13. The resulting routes for each router are attached in a text file, and also the graph from the batctl vd dot command. After this result, we read again the thread mentioned by Guido, specially in this part: https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2012-March/006344.html And if we understand correctly, the alternation feature works after the batman path has been selected. So in our case, E12 looks at his table to know where to send a packet to E13, and finds E6. Then E6 receives the packet and looks in his own table, finding that the best path to reach E13 is E8. At this point, the alternating should work, but there's only one interface directly connected to E8, so the packet goes there, and so on. We think that if E6 and E7 were not two different routers running batman-adv but they were two radios of the same batman-adv router, and the same for E8 and E9, the alternating would work, because the unique router would choose the best path, and then would find two possible interfaces to the same next-hop, changing the interface. This is entirely correct - batman-adv has only one link to choose from (E6 - E8) to reach its best nexthop E8, so there is no way to alternate the interfaces. We'd like to know if this interpretation is correct, and in that case, if it were possible to use interface alternating in a case like this, with two routers connected to work together. Thanks! Mhm, with the current implementation - no, unfortunately not. We would need some kind of multipath routing to select between routes, this is much more complex. An alternative might be to use the routers E7/E9 as secondary routers without batman, but only forwarding traffic between Ethernet and WiFi. Then the primary routers (E6 - E8) would think they have an alternative route via Ethernet (because they don't see the intermediate hops E7/E9). This comes with some caveats however, e.g. 4-addr mode in Ad-Hoc, you need some very simple ethernet forwarder, and most probably other things I forgot. Cheers, Simon signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCHv5] batman-adv: Add the backbone gateway list to debugfs
This is especially useful if there are no claims yet, but we still want to know which gateways are using bridge loop avoidance in the network. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- [EDITv2: forgot to rename the function ...] [EDITv3: add README entry] [EDITv4: fix style] [EDITv5: some more style fixes] --- README |7 ++--- bridge_loop_avoidance.c | 65 +++ bridge_loop_avoidance.h |8 ++ debugfs.c | 12 + 4 files changed, 89 insertions(+), 3 deletions(-) diff --git a/README b/README index 8f3ae4a..a173d2a 100644 --- a/README +++ b/README @@ -75,9 +75,10 @@ folder: There is a special folder for debugging information: -# ls /sys/kernel/debug/batman_adv/bat0/ -# bla_claim_tablelogsocket transtable_local -# gateways originatorstranstable_global vis_data +# ls /sys/kernel/debug/batman_adv/bat0/ +# bla_backbone_table log transtable_global +# bla_claim_table originators transtable_local +# gatewayssocket vis_data Some of the files contain all sort of status information regard- ing the mesh network. For example, you can view the table of diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 38aab1e..03fe5ea 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1592,3 +1592,68 @@ out: batadv_hardif_free_ref(primary_if); return ret; } + +int batadv_bla_backbone_table_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_hashtable *hash = bat_priv-backbone_hash; + struct batadv_backbone_gw *backbone_gw; + struct batadv_hard_iface *primary_if; + struct hlist_node *node; + struct hlist_head *head; + int secs, msecs; + uint32_t i; + bool is_own; + int ret = 0; + uint8_t *primary_addr; + + primary_if = batadv_primary_if_get_selected(bat_priv); + if (!primary_if) { + ret = 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) { + ret = seq_printf(seq, +BATMAN mesh %s disabled - primary interface not active\n, +net_dev-name); + goto out; + } + + primary_addr = primary_if-net_dev-dev_addr; + seq_printf(seq, + Backbones announced for the mesh %s (orig %pM, group id %04x)\n, + net_dev-name, primary_addr, + ntohs(bat_priv-claim_dest.group)); + seq_printf(seq,%-17s%-5s %-9s (%-4s)\n, + Originator, VID, last seen, CRC); + for (i = 0; i hash-size; i++) { + head = hash-table[i]; + + rcu_read_lock(); + hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { + msecs = jiffies_to_msecs(jiffies - +backbone_gw-lasttime); + secs = msecs / 1000; + msecs = msecs % 1000; + + is_own = batadv_compare_eth(backbone_gw-orig, + primary_addr); + if (is_own) + continue; + + seq_printf(seq, + * %pM on % 5d % 4i.%03is (%04x)\n, + backbone_gw-orig, backbone_gw-vid, + secs, msecs, backbone_gw-crc); + } + rcu_read_unlock(); + } +out: + if (primary_if) + batadv_hardif_free_ref(primary_if); + return ret; +} diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 08d13cb..35d39e3 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -26,6 +26,8 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); int batadv_bla_is_backbone_gw(struct sk_buff *skb, struct batadv_orig_node *orig_node, int hdr_size); int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); +int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, +void *offset); int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig); int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, struct batadv_bcast_packet *bcast_packet, @@ -64,6 +66,12 @@ static inline int
[B.A.T.M.A.N.] [PATCH 1/2] batman-adv: correct comments in bridge loop avoidance
Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c |5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 38aab1e..a61bb74 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -280,7 +280,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, NULL, /* Ethernet SRC/HW SRC: originator mac */ primary_if-net_dev-dev_addr, -/* HW DST: FF:43:05:XX:00:00 +/* HW DST: FF:43:05:XX:YY:YY * with XX = claim type * and YY:YY = group id */ @@ -322,7 +322,8 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, break; case BATADV_CLAIM_TYPE_REQUEST: /* request frame -* set HW SRC to the special mac containg the crc +* set HW SRC and header destination to the receiving backbone +* gws mac */ memcpy(hw_src, mac, ETH_ALEN); memcpy(ethhdr-h_dest, mac, ETH_ALEN); -- 1.7.10
[B.A.T.M.A.N.] [PATCH 2/2] batman-adv: rename bridge loop avoidance claim types
for consistency reasons within the code and with the documentation, we should always call it claim and unclaim. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 18 +- packet.h|4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index a61bb74..6882715 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -294,7 +294,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, /* now we pretend that the client would have sent this ... */ switch (claimtype) { - case BATADV_CLAIM_TYPE_ADD: + case BATADV_CLAIM_TYPE_CLAIM: /* normal claim frame * set Ethernet SRC to the clients mac */ @@ -302,7 +302,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, batadv_dbg(BATADV_DBG_BLA, bat_priv, bla_send_claim(): CLAIM %pM on vid %d\n, mac, vid); break; - case BATADV_CLAIM_TYPE_DEL: + case BATADV_CLAIM_TYPE_UNCLAIM: /* unclaim frame * set HW SRC to the clients mac */ @@ -465,7 +465,7 @@ static void batadv_bla_answer_request(struct batadv_priv *bat_priv, continue; batadv_bla_send_claim(bat_priv, claim-addr, claim-vid, - BATADV_CLAIM_TYPE_ADD); + BATADV_CLAIM_TYPE_CLAIM); } rcu_read_unlock(); } @@ -700,7 +700,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv, if (primary_if batadv_compare_eth(backbone_addr, primary_if-net_dev-dev_addr)) batadv_bla_send_claim(bat_priv, claim_addr, vid, - BATADV_CLAIM_TYPE_DEL); + BATADV_CLAIM_TYPE_UNCLAIM); backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid); @@ -736,7 +736,7 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv, batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw); if (batadv_compare_eth(backbone_addr, primary_if-net_dev-dev_addr)) batadv_bla_send_claim(bat_priv, claim_addr, vid, - BATADV_CLAIM_TYPE_ADD); + BATADV_CLAIM_TYPE_CLAIM); /* TODO: we could call something like tt_local_del() here. */ @@ -779,12 +779,12 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv, * otherwise assume it is in the hw_src */ switch (bla_dst-type) { - case BATADV_CLAIM_TYPE_ADD: + case BATADV_CLAIM_TYPE_CLAIM: backbone_addr = hw_src; break; case BATADV_CLAIM_TYPE_REQUEST: case BATADV_CLAIM_TYPE_ANNOUNCE: - case BATADV_CLAIM_TYPE_DEL: + case BATADV_CLAIM_TYPE_UNCLAIM: backbone_addr = ethhdr-h_source; break; default: @@ -900,12 +900,12 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, /* check for the different types of claim frames ... */ switch (bla_dst-type) { - case BATADV_CLAIM_TYPE_ADD: + case BATADV_CLAIM_TYPE_CLAIM: if (batadv_handle_claim(bat_priv, primary_if, hw_src, ethhdr-h_source, vid)) return 1; break; - case BATADV_CLAIM_TYPE_DEL: + case BATADV_CLAIM_TYPE_UNCLAIM: if (batadv_handle_unclaim(bat_priv, primary_if, ethhdr-h_source, hw_src, vid)) return 1; diff --git a/packet.h b/packet.h index c0ed5b4..67374dd 100644 --- a/packet.h +++ b/packet.h @@ -92,8 +92,8 @@ enum batadv_tt_client_flags { /* claim frame types for the bridge loop avoidance */ enum batadv_bla_claimframe { - BATADV_CLAIM_TYPE_ADD = 0x00, - BATADV_CLAIM_TYPE_DEL = 0x01, + BATADV_CLAIM_TYPE_CLAIM = 0x00, + BATADV_CLAIM_TYPE_UNCLAIM = 0x01, BATADV_CLAIM_TYPE_ANNOUNCE = 0x02, BATADV_CLAIM_TYPE_REQUEST = 0x03, }; -- 1.7.10
[B.A.T.M.A.N.] [PATCH] batman-adv: check batadv_orig_hash_add_if() return code
If this call fails, some of the orig_nodes spaces may have been resized for the increased number of interface, and some may not. If we would just continue with the larger number of interfaces, this would lead to access to not allocated memory later. We better check the return code, and don't add the interface if no memory is available. OTOH, keeping some of the orig_nodes with too much memory allocated should hurt no one (except for a few too many bytes allocated). Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- hard-interface.c |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hard-interface.c b/hard-interface.c index 282bf6e..2d7f4f2 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -313,7 +313,12 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, hard_iface-if_num = bat_priv-num_ifaces; bat_priv-num_ifaces++; hard_iface-if_status = BATADV_IF_INACTIVE; - batadv_orig_hash_add_if(hard_iface, bat_priv-num_ifaces); + ret = batadv_orig_hash_add_if(hard_iface, bat_priv-num_ifaces); + if (ret 0) { + bat_priv-bat_algo_ops-bat_iface_disable(hard_iface); + bat_priv-num_ifaces--; + goto err_dev; + } hard_iface-batman_adv_ptype.type = ethertype; hard_iface-batman_adv_ptype.func = batadv_batman_skb_recv; -- 1.7.10
Re: [B.A.T.M.A.N.] [B.A.T.M.A.N] OGM problem and documentation
Hello Arthur, On Tue, Jul 03, 2012 at 10:57:28AM +0200, Arthur Lambert wrote: Hi, I am testing Batman Advance (Batman release 2012 1.0) and I am trying to measure signaling on some topology of VMs. I have 81 nodes (Debian, 3.0.9) with KVM virtualization. My topology is something like this : http://imgur.com/Xh1gM I have a topology with an adjacency matrix of maximum 4 as you can see on my screenshot. I record on each VM signaling received and sent. On some VM, my node send OGM at each orig_interval but does not receive any OGM at all. Is it normal ? Well, no. :) Have you checked that the problem is really with batman and not with a layer below (I don't know how you interconnect your VMs, wirefilter/bridges/etc)? You can check using tcpdump on the interface batman is using and see if you have any incoming packets of other nodes. If not, there is most probably something wrong with the interconnect. Moreover, I have found a wonderful documention here : http://gitorious.org/batman-adv-doc. Unfortunatly, it is not maintened since two years. I have also found some papers which describe your protocol, but most of the time, the paper are too old or not correct in the protocol description. At this moment, my first source of information is the code. Can you advise me a good paper or documentation on the architecture and features of Batman Advance set apart your twiki. Well yeah, this documentation is pretty old. I'd suggest to read http://downloads.open-mesh.org/batman/papers/batman-adv_network_coding.pdf which has a nice and (quite) up-to-date introduction to batman-adv included. Furthermore, we try to keep the Wiki as much up to date as possible, if there is something missing feel free to ask. Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [B.A.T.M.A.N] OGM problem and documentation
Hey Arthur, On Wed, Jul 04, 2012 at 12:00:09PM +0200, Arthur Lambert wrote: Hello, thanks for your answer, This is what I thought.. Its probably a mistake in my script to measure signaling. I will check that. I have already read the document that you give to me. This document discribes most of the features of Batman and some interesting stuffs. But I am looking for information about global architecture, how the protocol handles threads. An example of usefull draw : http://imgur.com/3ecCY. Its not always easy to study or understand a complex project like Batman when you does not know how a ad-hoc protocol works. I am trying for example to follow the execution of the module with tools like LTTNG to see how works the implementation of workqueue or using GCOV to follow the data path. That's pretty interesting! I don't know if we have something like an architecture illustration (but haven't see any recently). If you get anything interesting out of that (illustration, performance insights, etc), please tell us. And I interconnect my vm with special way. Its a king of bridge but the tool that I use simulate network topology so it more complicated than that. Ah ok. Is it a self-written tool or something public? We usually use vde/wirefilter to build up different topologies, see: http://www.open-mesh.org/wiki/open-mesh/Emulation Would be interesting if there are other possibilities :) I will come back problably later to ask questions, but at this moment, I have to many questions, I need first to continue reading the code and twiki, running my tests, ... again and again. Good luck! Cheers Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] BLAII + gw_mode, DHCP sometimes gets dropped
On Wed, Jul 04, 2012 at 09:43:13AM -0300, Guido Iribarren wrote: On Wed, Jul 4, 2012 at 6:12 AM, Simon Wunderlich simon.wunderl...@s2003.tu-chemnitz.de wrote: Hello Guido, On Tue, Jul 03, 2012 at 05:07:17PM -0300, Guido Iribarren wrote: Hello there again, I have observed a problem since updating to 2012.2 and enabled BLAII I'm compiling logs to understand what's happening, but as always, reading logs only gets me more lost :( So here i am again begging for help There are some debug levels for BLA as well, and you can now get the claimlist with batctl (which is basically the list of clients a gateway feels responsible for) - this may help for debugging. But first, we should clarify some more details for your setup. Yes, I've seen the cl command, but didn't completely understand how to interpret it. For example, right now I see the clients claimed in the cl of mesh nodes, and even the same client claimed in different nodes. ( when I say mesh nodes, and in the rest of the email, i'm referring to http://www.open-mesh.org/wiki/batman-adv/Bridge-loop-avoidance-II#Definitions ) i.e. sample mesh-nodes: root@charly:~# batctl cl Claims announced for the mesh bat0 (origcharly, group id 6412) Client VID Originator[o] (CRC ) * 00:25:d3:f5:93:76 on-1 bycharly [x] (77f9) * f8d1113b6e66_eth0 on-1 bycharly [x] (77f9) root@hquilla:~# batctl cl Claims announced for the mesh bat0 (orig hquilla, group id 82cb) Client VID Originator[o] (CRC ) * 00:25:d3:f5:93:76 on-1 by hquilla [x] (c72e) * 00:24:81:4b:ea:6d on-1 by hquilla [x] (c72e) maybe that's fine because they have different group ids? (??) Yup. They are not interconnected via Ethernet, so they are in different backbones and have a different group id. If there are other gatways on the backbone with claims, you should see them in the claim list as well. is there any documentation on the cl output? Yup, you can find it here: http://www.open-mesh.org/wiki/batman-adv/Understand-your-batman-adv-network as far i could interpret, CRC identifies a particular version of a table, yup. [o] = [x] means this is claimed by myself yup. group id identifies different backbones (like in this case:) http://www.open-mesh.org/wiki/batman-adv/Bridge-loop-avoidance-Testcases#Two-LANs-connected-by-one-mesh yup. and VID, is always set to -1 :P oh, mybe it's vlan id (?) since i'm not using VLANs it means you have no VLAN here. the setup is the same I described in yesterday's attachment, but what's not pictured is an ethernet cable between colmena-casa and f8d11504758. f8d11504758 is the only router that connects to the internet (through WAN cable), and it's also the only one that has dnsmasq running and gw_mode=server. All the other nodes have gw_mode=client All of the nodes have bridge_loop_avoidance=1 (even though there are no other utp connections, so it could in fact be enabled only on colmena-casa and f8d11504758) with this setup, dhcp requests from the mesh sometimes get lost, either they don't reach f8d11504758 or the reply doesn't get out Questions: * which node runs the DHCP server? colmena-casa, f8d11504758 or something else? Only the node f8d11504758 runs a DHCP server (dnsmasq) on its interface br-lan no other dhcp server is running on the network OK. * at which point is DHCP getting lost? is the DISCOVER/REQUEST from the client getting lost, or the reply from the server? Well, I just managed to get a clarifying tcpdump! hquilla sent a select (REQUEST) that reached the wlan0-2 (mesh) interface of f8d11504758 and it was silently dropped (didn't appear on a batctl td of bat0) this repeated several times, until a lucky REQUEST managed to pass through, was sniffed at bat0, and got a reply from dnsmasq I couldn't see any difference between the unlucky and lucky REQUESTs or DISCOVERs, but running a batctl cl -w1 did the trick: when the client is currently claimed by f8d11504758 as in * hquilla_eth0 on-1 by f8d11504758 [x] (d38b) both the REQUESTs and DISCOVERs reach dnsmasq fine but if the client is currently claimed by colmena-casa as in * hquilla_eth0 on-1 by colmena-casa [ ] (3d7f) these discover/requests get dropped by batman when they arrive through wlan0-2 Ah, this helps. If the client is claimed by colmena-case, the request should go from hquilla to colmena-casa via mesh, and from colmena-casa to f8d11504758 via LAN. I guess the problem is the interaction between BLA and the gateway feature. The DHCP request is sent via unicast to f8d11504758, but the destination address is still broadcast. The bla implementation in f8d11504758 will then think that colmena-casa also has received the broadcast (but it didn't), and therefore drop it. I'll
[B.A.T.M.A.N.] [PATCH] batman-adv: check incoming packet type for bla
If the gateway functionality is used, some broadcast packets (DHCP requests) may be transmitted as unicast packets. As the bridge loop avoidance code now only considers the payload Ethernet destination, it may drop the DHCP request for clients which are claimed by other backbone gateways, because it falsely infers from the broadcast address that the right backbone gateway should havehandled the broadcast. Fix this by checking and delegating the batman-adv packet type used for transmission. Reported-by: Guido Iribarren guidoiribar...@buenosaireslibre.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c |6 -- bridge_loop_avoidance.h |5 +++-- soft-interface.c|6 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 6452e2f..8478083 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1368,6 +1368,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv) /* @bat_priv: the bat priv with all the soft interface information * @skb: the frame to be checked * @vid: the VLAN ID of the frame + * @is_bcast: the packet came in a broadcast packet type * * bla_rx avoidance checks if: * * we have to race for a claim @@ -1377,7 +1378,8 @@ void batadv_bla_free(struct batadv_priv *bat_priv) * returns 1, otherwise it returns 0 and the caller shall further * process the skb. */ -int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) +int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid, + bool is_bcast) { struct ethhdr *ethhdr; struct batadv_claim search_claim, *claim = NULL; @@ -1422,7 +1424,7 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) } /* if it is a broadcast ... */ - if (is_multicast_ether_addr(ethhdr-h_dest)) { + if (is_multicast_ether_addr(ethhdr-h_dest) is_bcast) { /* ... drop it. the responsible gateway is in charge. */ goto handled; } else { diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 35d39e3..789cb73 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -21,7 +21,8 @@ #define _NET_BATMAN_ADV_BLA_H_ #ifdef CONFIG_BATMAN_ADV_BLA -int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); +int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid, + bool is_bcast); int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); int batadv_bla_is_backbone_gw(struct sk_buff *skb, struct batadv_orig_node *orig_node, int hdr_size); @@ -42,7 +43,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv); #else /* ifdef CONFIG_BATMAN_ADV_BLA */ static inline int batadv_bla_rx(struct batadv_priv *bat_priv, - struct sk_buff *skb, short vid) + struct sk_buff *skb, short vid, bool is_bcast) { return 0; } diff --git a/soft-interface.c b/soft-interface.c index 96736ea..be39f89 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -274,9 +274,13 @@ void batadv_interface_rx(struct net_device *soft_iface, struct batadv_priv *bat_priv = netdev_priv(soft_iface); struct ethhdr *ethhdr; struct vlan_ethhdr *vhdr; + struct batadv_header *batadv_header = (struct batadv_header *)skb-data; short vid __maybe_unused = -1; + bool is_bcast; __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); + is_bcast = !!(batadv_header-packet_type == BATADV_BCAST); + /* check if enough space is available for pulling, and pull */ if (!pskb_may_pull(skb, hdr_size)) goto dropped; @@ -323,7 +327,7 @@ void batadv_interface_rx(struct net_device *soft_iface, /* Let the bridge loop avoidance check the packet. If will * not handle it, we can safely push it up. */ - if (batadv_bla_rx(bat_priv, skb, vid)) + if (batadv_bla_rx(bat_priv, skb, vid, is_bcast)) goto out; netif_rx(skb); -- 1.7.10
Re: [B.A.T.M.A.N.] BLAII + gw_mode, DHCP sometimes gets dropped
Hey Guido, thanks again for the good debugging, that really helped to understand the problem :) I've sent a patch, is it possible for you to apply it and retry? it should be enough to update the two gateway nodes. Cheers Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] BLAII + gw_mode, DHCP sometimes gets dropped
Sorry, my fault. Will send a patch based on maint in a minute. On Wed, Jul 04, 2012 at 03:12:59PM -0300, Guido Iribarren wrote: On Wed, Jul 4, 2012 at 11:05 AM, Simon Wunderlich simon.wunderl...@s2003.tu-chemnitz.de wrote: Hey Guido, thanks again for the good debugging, that really helped to understand the problem :) Thanks free software! :D I've sent a patch, is it possible for you to apply it and retry? it should be enough to update the two gateway nodes. Definitely! here's the output, tho: Applying ./patches/-batman-adv-check-incoming-packet-type-for-bla.patch using plaintext: patching file bridge_loop_avoidance.c Hunk #1 succeeded at 1351 with fuzz 1 (offset -17 lines). Hunk #2 FAILED at 1378. Hunk #3 FAILED at 1423. 2 out of 3 hunks FAILED -- saving rejects to file bridge_loop_avoidance.c.rej patching file bridge_loop_avoidance.h Hunk #1 FAILED at 21. Hunk #2 FAILED at 42. 2 out of 2 hunks FAILED -- saving rejects to file bridge_loop_avoidance.h.rej patching file soft-interface.c Hunk #1 FAILED at 274. Hunk #2 FAILED at 323. 2 out of 2 hunks FAILED -- saving rejects to file soft-interface.c.rej Patch failed! Please fix ./patches/-batman-adv-check-incoming-packet-type-for-bla.patch! i'm trying to apply against openwrt@torvic:~/trunk/feeds/packages/net/batman-adv$ svn info Path: . URL: svn://svn.openwrt.org/openwrt/packages/net/batman-adv Repository Root: svn://svn.openwrt.org/openwrt Repository UUID: 3c298f89-4303-0410-b956-a3cf2f4a3e73 Revision: 32587 Node Kind: directory Schedule: normal Last Changed Author: marek Last Changed Rev: 32579 Last Changed Date: 2012-07-02 13:20:20 -0300 (Mon, 02 Jul 2012) Visually inspecting the rejects, seems my source code still doesn't have the batadv_ prefix in functions names. i.e.: int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) I've seen many patches flying around dealing with the batadv_ prefix for dave, but didn't pay much attention to them: which of those should i grab? Or, Simon, could you kindly send another patch that i can apply cleanly to r32587 of svn://svn.openwrt.org/openwrt/packages/net/batman-adv in any case, i see the changes are simple, so i *could* try a manual apply of the patch... but last time i tried (with other patch), it got overwritten by openwrt build system. Thanks a lot for the support! Gui Cheers Simon -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAk/0TYwACgkQrzg/fFk7axbznwCg5oyyF4UaWJBV8GXztFSGG8sa vnAAoJYcgNuCcdA5fZKrIvaUE888FzSI =zd3Q -END PGP SIGNATURE- signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCH-maint] batman-adv: check incoming packet type for bla
If the gateway functionality is used, some broadcast packets (DHCP requests) may be transmitted as unicast packets. As the bridge loop avoidance code now only considers the payload Ethernet destination, it may drop the DHCP request for clients which are claimed by other backbone gateways, because it falsely infers from the broadcast address that the right backbone gateway should havehandled the broadcast. Fix this by checking and delegating the batman-adv packet type used for transmission. Reported-by: Guido Iribarren guidoiribar...@buenosaireslibre.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- PATCHv2 adds a comment why we are doing this, and adds the is_bcast check to the other is_multicast_ether_addr() check in this function. PATCH-maint is the backport for maint --- bridge_loop_avoidance.c | 15 +++ bridge_loop_avoidance.h |5 +++-- soft-interface.c|6 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 8bf9751..2b82a0f 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1351,6 +1351,7 @@ void bla_free(struct bat_priv *bat_priv) * @bat_priv: the bat priv with all the soft interface information * @skb: the frame to be checked * @vid: the VLAN ID of the frame + * @is_bcast: the packet came in a broadcast packet type. * * bla_rx avoidance checks if: * * we have to race for a claim @@ -1361,7 +1362,8 @@ void bla_free(struct bat_priv *bat_priv) * process the skb. * */ -int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) +int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid, + bool is_bcast) { struct ethhdr *ethhdr; struct claim search_claim, *claim = NULL; @@ -1380,7 +1382,7 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) if (unlikely(atomic_read(bat_priv-bla_num_requests))) /* don't allow broadcasts while requests are in flight */ - if (is_multicast_ether_addr(ethhdr-h_dest)) + if (is_multicast_ether_addr(ethhdr-h_dest) is_bcast) goto handled; memcpy(search_claim.addr, ethhdr-h_source, ETH_ALEN); @@ -1406,8 +1408,13 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) } /* if it is a broadcast ... */ - if (is_multicast_ether_addr(ethhdr-h_dest)) { - /* ... drop it. the responsible gateway is in charge. */ + if (is_multicast_ether_addr(ethhdr-h_dest) is_bcast) { + /* ... drop it. the responsible gateway is in charge. +* +* We need to check is_bcast because with the gateway +* feature, broadcasts (like DHCP requests) may be sent +* using a unicast packet type. +*/ goto handled; } else { /* seems the client considers us as its best gateway. diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index e39f93a..dc5227b 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -23,7 +23,8 @@ #define _NET_BATMAN_ADV_BLA_H_ #ifdef CONFIG_BATMAN_ADV_BLA -int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); +int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid, + bool is_bcast); int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); int bla_is_backbone_gw(struct sk_buff *skb, struct orig_node *orig_node, int hdr_size); @@ -41,7 +42,7 @@ void bla_free(struct bat_priv *bat_priv); #else /* ifdef CONFIG_BATMAN_ADV_BLA */ static inline int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, -short vid) +short vid, bool is_bcast) { return 0; } diff --git a/soft-interface.c b/soft-interface.c index 6e2530b..92a4070 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -256,7 +256,11 @@ void interface_rx(struct net_device *soft_iface, struct bat_priv *bat_priv = netdev_priv(soft_iface); struct ethhdr *ethhdr; struct vlan_ethhdr *vhdr; + struct batman_header *batadv_header = (struct batman_header *)skb-data; short vid __maybe_unused = -1; + bool is_bcast; + + is_bcast = !!(batadv_header-packet_type == BAT_BCAST); /* check if enough space is available for pulling, and pull */ if (!pskb_may_pull(skb, hdr_size)) @@ -302,7 +306,7 @@ void interface_rx(struct net_device *soft_iface, /* Let the bridge loop avoidance check the packet. If will * not handle it, we can safely push it up. */ - if (bla_rx(bat_priv, skb, vid)) + if (bla_rx(bat_priv, skb, vid, is_bcast)) goto out; netif_rx(skb); -- 1.7.10
[B.A.T.M.A.N.] [PATCH-maint-v2] batman-adv: check incoming packet type for bla
If the gateway functionality is used, some broadcast packets (DHCP requests) may be transmitted as unicast packets. As the bridge loop avoidance code now only considers the payload Ethernet destination, it may drop the DHCP request for clients which are claimed by other backbone gateways, because it falsely infers from the broadcast address that the right backbone gateway should havehandled the broadcast. Fix this by checking and delegating the batman-adv packet type used for transmission. Reported-by: Guido Iribarren guidoiribar...@buenosaireslibre.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- PATCHv2 adds a comment why we are doing this, and adds the is_bcast check to the other is_multicast_ether_addr() check in this function. PATCH-maint is the backport for maint PATCH-maint-v2 is even checkpatch clean, and remove obsolete !! --- bridge_loop_avoidance.c | 15 +++ bridge_loop_avoidance.h |5 +++-- soft-interface.c|6 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 8bf9751..c5863f4 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1351,6 +1351,7 @@ void bla_free(struct bat_priv *bat_priv) * @bat_priv: the bat priv with all the soft interface information * @skb: the frame to be checked * @vid: the VLAN ID of the frame + * @is_bcast: the packet came in a broadcast packet type. * * bla_rx avoidance checks if: * * we have to race for a claim @@ -1361,7 +1362,8 @@ void bla_free(struct bat_priv *bat_priv) * process the skb. * */ -int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) +int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid, + bool is_bcast) { struct ethhdr *ethhdr; struct claim search_claim, *claim = NULL; @@ -1380,7 +1382,7 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) if (unlikely(atomic_read(bat_priv-bla_num_requests))) /* don't allow broadcasts while requests are in flight */ - if (is_multicast_ether_addr(ethhdr-h_dest)) + if (is_multicast_ether_addr(ethhdr-h_dest) is_bcast) goto handled; memcpy(search_claim.addr, ethhdr-h_source, ETH_ALEN); @@ -1406,8 +1408,13 @@ int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) } /* if it is a broadcast ... */ - if (is_multicast_ether_addr(ethhdr-h_dest)) { - /* ... drop it. the responsible gateway is in charge. */ + if (is_multicast_ether_addr(ethhdr-h_dest) is_bcast) { + /* ... drop it. the responsible gateway is in charge. +* +* We need to check is_bcast because with the gateway +* feature, broadcasts (like DHCP requests) may be sent +* using a unicast packet type. +*/ goto handled; } else { /* seems the client considers us as its best gateway. diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index e39f93a..dc5227b 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -23,7 +23,8 @@ #define _NET_BATMAN_ADV_BLA_H_ #ifdef CONFIG_BATMAN_ADV_BLA -int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); +int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid, + bool is_bcast); int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); int bla_is_backbone_gw(struct sk_buff *skb, struct orig_node *orig_node, int hdr_size); @@ -41,7 +42,7 @@ void bla_free(struct bat_priv *bat_priv); #else /* ifdef CONFIG_BATMAN_ADV_BLA */ static inline int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, -short vid) +short vid, bool is_bcast) { return 0; } diff --git a/soft-interface.c b/soft-interface.c index 6e2530b..a0ec0e4 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -256,7 +256,11 @@ void interface_rx(struct net_device *soft_iface, struct bat_priv *bat_priv = netdev_priv(soft_iface); struct ethhdr *ethhdr; struct vlan_ethhdr *vhdr; + struct batman_header *batadv_header = (struct batman_header *)skb-data; short vid __maybe_unused = -1; + bool is_bcast; + + is_bcast = (batadv_header-packet_type == BAT_BCAST); /* check if enough space is available for pulling, and pull */ if (!pskb_may_pull(skb, hdr_size)) @@ -302,7 +306,7 @@ void interface_rx(struct net_device *soft_iface, /* Let the bridge loop avoidance check the packet. If will * not handle it, we can safely push it up. */ - if (bla_rx(bat_priv, skb, vid)) + if (bla_rx(bat_priv, skb, vid, is_bcast)) goto out; netif_rx(skb); -- 1.7.10
[B.A.T.M.A.N.] [PATCH-v2] batman-adv: check incoming packet type for bla
If the gateway functionality is used, some broadcast packets (DHCP requests) may be transmitted as unicast packets. As the bridge loop avoidance code now only considers the payload Ethernet destination, it may drop the DHCP request for clients which are claimed by other backbone gateways, because it falsely infers from the broadcast address that the right backbone gateway should havehandled the broadcast. Fix this by checking and delegating the batman-adv packet type used for transmission. Reported-by: Guido Iribarren guidoiribar...@buenosaireslibre.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- PATCHv2 adds a comment why we are doing this, and adds the is_bcast check to the other is_multicast_ether_addr() check in this function, and remove obsolete !!. --- bridge_loop_avoidance.c | 15 +++ bridge_loop_avoidance.h |5 +++-- soft-interface.c|6 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 6452e2f..1af7af5 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1368,6 +1368,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv) /* @bat_priv: the bat priv with all the soft interface information * @skb: the frame to be checked * @vid: the VLAN ID of the frame + * @is_bcast: the packet came in a broadcast packet type. * * bla_rx avoidance checks if: * * we have to race for a claim @@ -1377,7 +1378,8 @@ void batadv_bla_free(struct batadv_priv *bat_priv) * returns 1, otherwise it returns 0 and the caller shall further * process the skb. */ -int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) +int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid, + bool is_bcast) { struct ethhdr *ethhdr; struct batadv_claim search_claim, *claim = NULL; @@ -1396,7 +1398,7 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) if (unlikely(atomic_read(bat_priv-bla_num_requests))) /* don't allow broadcasts while requests are in flight */ - if (is_multicast_ether_addr(ethhdr-h_dest)) + if (is_multicast_ether_addr(ethhdr-h_dest) is_bcast) goto handled; memcpy(search_claim.addr, ethhdr-h_source, ETH_ALEN); @@ -1422,8 +1424,13 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) } /* if it is a broadcast ... */ - if (is_multicast_ether_addr(ethhdr-h_dest)) { - /* ... drop it. the responsible gateway is in charge. */ + if (is_multicast_ether_addr(ethhdr-h_dest) is_bcast) { + /* ... drop it. the responsible gateway is in charge. +* +* We need to check is_bcast because with the gateway +* feature, broadcasts (like DHCP requests) may be sent +* using a unicast packet type. +*/ goto handled; } else { /* seems the client considers us as its best gateway. diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 35d39e3..789cb73 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -21,7 +21,8 @@ #define _NET_BATMAN_ADV_BLA_H_ #ifdef CONFIG_BATMAN_ADV_BLA -int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); +int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid, + bool is_bcast); int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); int batadv_bla_is_backbone_gw(struct sk_buff *skb, struct batadv_orig_node *orig_node, int hdr_size); @@ -42,7 +43,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv); #else /* ifdef CONFIG_BATMAN_ADV_BLA */ static inline int batadv_bla_rx(struct batadv_priv *bat_priv, - struct sk_buff *skb, short vid) + struct sk_buff *skb, short vid, bool is_bcast) { return 0; } diff --git a/soft-interface.c b/soft-interface.c index 96736ea..ae7d23e 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -274,9 +274,13 @@ void batadv_interface_rx(struct net_device *soft_iface, struct batadv_priv *bat_priv = netdev_priv(soft_iface); struct ethhdr *ethhdr; struct vlan_ethhdr *vhdr; + struct batadv_header *batadv_header = (struct batadv_header *)skb-data; short vid __maybe_unused = -1; + bool is_bcast; __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); + is_bcast = (batadv_header-packet_type == BATADV_BCAST); + /* check if enough space is available for pulling, and pull */ if (!pskb_may_pull(skb, hdr_size)) goto dropped; @@ -323,7 +327,7 @@ void batadv_interface_rx(struct net_device *soft_iface, /* Let the bridge loop
Re: [B.A.T.M.A.N.] BLAII + gw_mode, DHCP sometimes gets dropped
Hello Guido, thank you very much for testing, it's nice to hear that it works! :) Cheers, Simon On Thu, Jul 05, 2012 at 04:51:57PM -0300, Guido Iribarren wrote: Your patch works flawlessly Simon, I sysupgraded f8d11504758 with the patched batman, and DHCP requests are back to normal when using gw_mode=client I patched colmena-casa first, but it didn't make a difference; which was expected, since colmena-casa is just a backbone gateway, and it doesn't have the actual DHCP server running, as such, it's only job was to forward unicast requests to f8d11504758, which was already doing fine. The problem was that f8d11504758 was dropping the packets, and with your patch it doesn't anymore. Thanks a lot! On Wed, Jul 4, 2012 at 3:46 PM, Guido Iribarren guidoiribar...@buenosaireslibre.org wrote: On Wed, Jul 4, 2012 at 3:30 PM, Simon Wunderlich simon.wunderl...@s2003.tu-chemnitz.de wrote: Sorry, my fault. Will send a patch based on maint in a minute. Applying ./patches/-batman-adv-check-incoming-packet-type-for-bla.patch using plaintext: patching file bridge_loop_avoidance.c patching file bridge_loop_avoidance.h patching file soft-interface.c Now i'm having fun, heh Thanks! Gui signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] 2012.2 OGMs over ethernet issue?
Hey Guido, On Sat, Jul 07, 2012 at 12:37:24AM -0300, Guido Iribarren wrote: Hello again nice folks, I updated today another segment of the network with just 4 nodes, to batman-adv 2012.2 (the one i compiled yesterday with simon patches for blaII, marek stability fixes, and debug log enabled , yikes!) and i couldn't get batman to work over wired ethernet?? (?) P -(50mts wlan)- D -(ubnt transparent bridge) 2km -- C \eth---/ Node P and D connected by ethernet on eth0 but close enough that could also see each other through adhoc wlan, with bla enabled, correctly preferred ethernet connection to communicate between them (iperf yielded 92mbps), so far so good. As seen on the dump, you only use eth0 in batman? Is the Ad-Hoc connection still active (on wlan0 or wlan-1)? now, node D and C, too far away from each other to communicate over wlan, but connected by a lng eth cable (mediated by a wds transparent bridge) wouldn't find each other batman originator. C originator table was empty, and D only showed P. I thought the transparent bridge was misbehaving, so I tried in a simpler setup using P and D, with the wifi off: but after disabling wlan0 (batctl if del wlan0-2) and adding eth0 (batctl if add eth0) on both nodes, batman could not see each other anymore :( i thought i was doing something wrong, so i tried in different ways, but could not get it to work. batctl td eth0 shows both outgoing OGMs from local , and incoming OGMs from remote, but batctl l only reported outgoing OGMs. http://pastebin.com/7DDUaXu1 Mhm, that's weird indeed. Is eth0 really not included in any other bridge? It looks like the incoming packets don't reach BATMAN for some reason. Also have you checked that the WDS bridge works via IP? You could first set up some IP addresses and ping each other, confirm traffic with tcpdump, and then activate batman-adv to see if the OGMs go through. So far, it doesn't seem like anything from your C node comes through at all. Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] RFC: Migration to a new git server backend
Hey, On Sun, Jul 22, 2012 at 01:43:25AM +0200, Sven Eckelmann wrote: Hi, maybe some of you have seen that I talked in the channel to Antonio whether we should migrate to a different solution to serve our git repositories. This is (in my opinion) a good idea because gitosis [1] (the software that we are currently using) isn't maintained anymore and will be dropped [2] in the next version of Debian. My preferred replacement is gitolite [3]. I already talked with Simon and discussed what side effect this could have. Maybe side effects is not the correct word to describe it... lets call it options. Gitolite allows to define access rights for refs. For people that are not familiar with the storage in git: You can for example say that people can only commit to branches with a specific prefix. Just to give an example. We want that only the release team can create tags - refs/tags/ is only marked for the release team as read-write. Now we have more interesting features like ordex is only allowed to write in branches starting with ordex/ - refs/heads/ordex/ is marked as rw for ordex. Now the question is: Do we want to use this feature or not. We had following ideas: 1. 1 repository per project use only one repo for each project (batman-adv, batctl, batmand, ...) and use branch namespaces for individual users: * master, next, maint for the main stuff * ordex/ (for example ordex/dat), hundeboll/, ... for users * tags only for release team 2. 2 repositories per project use one official repo for each project (batman-adv, batctl, batmand, ...) and one for other people * master, next, maint in both repos (synced from the main one) * ordex/ (for example ordex/dat), hundeboll/, ... for users in the second repo * tags in both repositories allowed (but in the second repo only with user prefix) 3. 1+x repositories per project Keep everything like now * master, next, maint for the main stuff * each user has his own copy of the main repo in his user folder * tags can freely commit in his own repo Special repositories with big differences like linux-merge are kept in a special repository. I'd prefer to go with option one, or maybe two. To me, it looks like having tags is the main practical difference? (I don't use any, but maybe others do ...). Changing the repos is more a cosmetic change IMHO and may decrease administration work. I have no practical concerns whatsoever, but git.open-mesh.org will look more beautiful :) Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] 2012.2 OGMs over ethernet issue?
Hey Gui, On Mon, Jul 23, 2012 at 04:20:39AM -0300, Gui Iribarren wrote: On Sun, Jul 8, 2012 at 7:09 AM, Simon Wunderlich simon.wunderl...@s2003.tu-chemnitz.de wrote: [..] When it doesn't work is when the ad-hoc connection is severed. which makes the thing look like http://www.open-mesh.org/attachments/download/128 that is, there are two gateways that can only talk to each other through ethernet (although it's not batctl if added) don't get each other OGMs after careful re-reading of BLAII docs in the wiki, and extensive chats with NicoEchaniz, i understood this is the planned behaviour (no OGMs on lan) Yes, that is expected behaviour. We don't want OGMs on the LAN, there were issues with some more intelligent switches which regarded OGMs as threat to the network. :) OGMs are only sent on interfaces added with batctl if add, and nowhere else. now, node D and C, too far away from each other to communicate over wlan, but connected by a lng eth cable (mediated by a wds transparent bridge) wouldn't find each other batman originator. C originator table was empty, and D only showed P. I thought the transparent bridge was misbehaving, so I tried in a simpler setup using P and D, with the wifi off: but after disabling wlan0 (batctl if del wlan0-2) and adding eth0 (batctl if add eth0) on both nodes, batman could not see each other anymore :( i thought i was doing something wrong, so i tried in different ways, but could not get it to work. batctl td eth0 shows both outgoing OGMs from local , and incoming OGMs from remote, but batctl l only reported outgoing OGMs. http://pastebin.com/7DDUaXu1 Mhm, that's weird indeed. Is eth0 really not included in any other bridge? It looks like the incoming packets don't reach BATMAN for some reason. Definitely not included in any bridge. Funny thing is, the only workaround i found for the bug is to *include* the interface in a bridge, and add that bridge to bat0 as in: brctl delif br-lan eth0 batctl if add eth0 # doesn't work brctl delif br-lan eth0 brctl addbr blah brctl addif blah eth0 batctl if add blah # works fine, OGMs pass through perfectly OK, so you say that it doesn't work when you simply add eth0 batctl, but it works with the bridge? What is the minimal setup which is not working, two routers and one cable? I'm sorry but you lost me somewhere, would be nice to get the smallest reproducable setup. :) Cheers and thanks, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] 2012.2 OGMs over ethernet issue?
Hello Guido, On Sat, Jul 28, 2012 at 03:34:29PM -0300, Gui Iribarren wrote: On Wed, Jul 25, 2012 at 5:34 PM, Simon Wunderlich OK, so you say that it doesn't work when you simply add eth0 batctl, but it works with the bridge? Exactly. With a caveat: turns out adding plain eth0 (no vlans involved) works fine as expected, the problem arises when using vlans. What is the minimal setup which is not working, two routers and one cable? I just reproduced it minimally: two routers, one cable, no adhoc, no bla2, no gw_mode, identical setup in both routers. enabling bla2 makes no difference. http://pastebin.com/y1JwMaDM A=f8:d1:11:54:50:f9 B=f8:d1:11:3b:78:df A batctl td shows incoming OGMs from neighbour B, but batctl ll doesn't react. viceversa for B. ping6 works fine over eth0.2 between A and B adding a simple option type 'bridge' on both routers solves the OGM issue, like so: config interface 'eth0_2' option type 'bridge' option ifname 'eth0.2' option proto 'none' option mtu '1528' with this, eth0.2 is included in br-eth0_2, and bat0 manages br-eth0_2... OGMs do come through correctly, and batctl o shows neighbour on both sides. all in all, workaround is not complicated (in fact a one-liner) but i find it curious that without the bridge thingy, batctl td catches the OGMs, yet batman doesn't recognize them. I haven't tinkered with vlans before, so i might be misunderstanding how they should work. Thanks for working that out. I've just tried out VLANs on Ethernet with BATMAN myself, and it worked well here - so I can't reproduce it by simply using VLANs. Another cause of the fault may be the VLAN stuff in OpenWRT, as this is not a real VLAN but just a way to address the ports on your box. I have not much experience with that, but I've heard funny things about it. ;) Have you tried changing the VLAN config? E.g. changing ports '0t 2t' for eth0.2 to '0t 2' (to remove tagging)? Do you have the same problem on other types of devices? (Maybe the internal switch is acting weird) Maybe some else has more experience on Switch/VLAN-config than me and can have a look at that config. :) http://pastebin.com/y1JwMaDM As I said, Ethernet/VLANs work fine for me, and I know other people running batman over Ethernet-VLANs as well ... Cheers Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] propagate gw_mode over two mesh linked by ethernet with bla2
Hello Guido, On Sun, Aug 05, 2012 at 03:26:43AM -0300, Gui Iribarren wrote: Here i am again, the involuntary stress-tester of gw_mode + bla2 and mailing-list readers' headache ;) Given the setup described here http://www.open-mesh.org/attachments/download/128 let's say one node in mesh1 sets gw_mode=server any node in mesh1 will list it in batctl gwl but nodes in mesh2 won't get it, since backbone gateways (BGs) of mesh2 only get claims from BGs of mesh1, which do not include gw_mode status with bla1 setup, OGMs did flood the ethernet backbone, carrying gw_mode information, and both mesh1 and mesh2 would get to know gateways I miss that functionality! :( so, as Simon himself suggests [0] in the wiki' shortest-ever FAQ ;), having full control of the ethernet backbone, I batctl-if-added an ethernet vlan on BGs of both sides of the ethernet cable. OGMs flood the ethernet backbone again as expected; running batctl o in mesh1 nodes show nodes from mesh2, and viceversa; i smiled! unfortunately, trying to get a DHCP lease while connected to a mesh node was again malfunctioning :( a couple of quick batctl td, and i thnk that looked like dhcp request packets were being dropped at the backbone gateway, kinda like the check incoming type for bla bug, but i didn't try to narrow it down instead reverted configs back to gw_mode=off and things started working again Mhm, we could track this further down if you want. So you have eth0 in your bridge and batman using a VLAN (e.g. eth0.1234) at the same time? i won't dig much into that since it's quite possible i entangled up my configs yet again, so i'll focus on the original question: are there any plans (or is it even feasible) to propagate gw_mode status through the ethernet backbone (assuming not sending OGMs)? maybe including/appending it in claim frames? No, at least I didn't plan to do so, and I wouldn't favor to build a second attachment system on claims as we did on OGMs - this will only bring more complexity. Instead, we should focus/support/fix the situation as you described above - let batman use Ethernet directly. what i understand so far is that with current blaII, meshes connected solely by ethernet backbone (which can't overhear each other OGMs through wifi) only know which macs are on the other side of the eth backbone so as to keep the single broadcast domain united, but are fragmented in terms of VIS data, gw, TT, and orig table. Yes, there are two separate meshes, and the only stuff which is supposed to be shared is the users payload traffic. sorry if i'm asking obvious questions, the blaII wiki explains notably clear the model, but is missing gw_mode interactions, and it wasn't evident to me how would that work - in fact, coming from bla1, i wrongly assumed it would be similar. if it's relevant, i can try to add validated snippets from this thread to the wiki[0] Each node at the edge to the wired network may announce itself as a gateway, provided that a DHCP server is available in the LAN (or any network behind it, e.g. a mesh). From a concept view, a gateway (or maybe even multiple gateways) in mesh2 will not automatically announced in mesh1 - this must be configured manually, or let batman use Ethernet if this is explicitly required. Feel free to update the Wiki, although I'd suggest to add an FAQ to the user page and not on the technical documentation. :) If you want, I'd be happy to work things out regarding multiple meshes+bridge+vlan+ethernet+batman+blaII with you. ;) Cheers, Simon [1] http://www.open-mesh.org/projects/batman-adv/wiki/Bridge-loop-avoidance signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [RFC 0/3] GSOC 2012: bandwidth meter project
Hello Edo, as discussed already, some general remarks: * please squash these patches to one - as far as I can see, the 2 others are mostly fixes to the first one * Don't turn on debugging in the Makefile - we don't want that by default * please also include the batctl patch, it is important for testing Thanks Simon On Thu, Aug 09, 2012 at 02:15:23PM +0200, Edo Monticelli wrote: Hi, I have almost completed my Google Summer of Code project and I'd like to have a feedback from the batman community. The project is a kernel-space bandwidth meter, a lightweight tool to measure network performance between batman nodes. You can find a general project description in the project wiki page: http://www.open-mesh.org/projects/batman-adv/wiki/GSOC2012_BW Any advice is welcome, Edo Monticelli Edo Monticelli (3): batman-adv: bandwidth meter implementation batman-adv: sender retransmission counter batman-adv: seqnumber is wrap around safe Makefile |2 +- Makefile.kbuild |1 + bw_meter.c | 531 ++ bw_meter.h |7 + icmp_socket.c| 18 ++ main.c |2 + packet.h | 22 ++- routing.c| 15 ++- soft-interface.c |5 + types.h | 38 10 files changed, 634 insertions(+), 7 deletions(-) create mode 100644 bw_meter.c create mode 100644 bw_meter.h -- 1.7.8.6 signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] propagate gw_mode over two mesh linked by ethernet with bla2
Hey Guido, On Fri, Aug 10, 2012 at 04:27:13PM -0300, Gui Iribarren wrote: Case closed: i had gone lost in a myriad of different openwrt revisions, compiled binaries, and patches, so I unknowingly updated that part of the network to a more recent openwrt version, but that didn't have the check incoming type for bla patch. So it was a simple regression on my part. I just reflashed those routers to a firmware confirmed to include the patch, and everything is working again. (bla2+gw_mode+vlan) Thanks a lot Marek for pushing that patch to openwrt batman-adv stable package, it helped a lot in getting things straight :) OK, thanks for letting us know! Feel free to update the Wiki, although I'd suggest to add an FAQ to the user page and not on the technical documentation. :) Done, added two entries to the FAQ rewording this thread :) Looks good, thanks for your contribution. :) Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] Batman-adv and routed subnets
Hey Luca, On Fri, Aug 03, 2012 at 11:40:43AM +0200, Luca Pretto wrote: Thanks for your answer Sven. So, I've obviously misunderstood the part mixing non-B.A.T.M.A.N. systems with batman-adv [] I admit: the fact that batman-adv operates al L2 really confuses me a lot! I'm a DIY nerd with no background training, so it's quite difficult to me.. But I won't give up! ;D Sven explained it already ... just think of batman-adv as a big, distributed switch with some nice extras. ;) So, do you think that I should try to setup OSPF on every node, to keep the thing as-much-auto-scaling-as-possible? from your description, you want to have some smaller subnets, and use batman-adv for the backbone to interconnect them. That's a fine approach, and you can use any routing technology on top (quagga with OSPF/BGP, olsr, babel, ...) to announce the networks. Whatever seems most suitable for you. :) But in that case I suspect I won't be able to use the Gateway support functions. Is it correct? [%] The gateway support is just for sending DHCP packets to the best gateway, and this gateway is selected by batman-adv. But this won't work for you, because the users will get the DHCP leases from their local DHCP server responsible for the network. So this feature won't help you as long as you are subnetting. The idea of the gateway feature is that you have multiple DHCP servers which are serving as router for their respective internet connection, e.g.: * router A serves subnet 10.9.1.0/24 * router B serves subnet 10.9.2.0/24 * router C serves subnet 10.9.3.0/24 * some more routers don't act as a DHCP server as they don't have an Internet uplink Then, you'd just bridge all APs so that users DHCP requests will end up in the mesh at one of the DHCP servers - and the gateway feature will make sure that it's the DHCP server with the best connection quality. ;) OTOH, subnetting has it's plus side as well if you want to seperate the APs somehow or limit the broadcast scope. Also on very large networks I'd recommend to use subnets or smaller mesh islands. Cheers, Simon Have a nice day, Luca [] http://www.open-mesh.org/projects/batman-adv/wiki/Quick-start-guide [%] http://www.open-mesh.org/projects/batman-adv/wiki/Gateways Il giorno 03/ago/2012, alle ore 11:22, Sven Eckelmann ha scritto: First thing: batman-adv doesn't route (as in l3 routing). batman-adv creates a distributed switch on l2 (so, batman-adv does path finding). Therefore, batman-adv doesn't care about the l3 stuff. And the stuff you've mentioned above is l3 stuff. So out of scope for batman- adv. Either you create static routes, use proxy arp or use another software that distributes the l3 routes. Kind regards, Sven signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [RFC] batman-adv: Set special lockdep classes to avoid lockdep warning
Hey Sven, it works in my QEMU machines (and I could reproduce the bug report from 162). Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de (provided you add some sane commit message. ;] ) Cheers, Simon On Sun, Aug 19, 2012 at 09:29:53AM +0200, Sven Eckelmann wrote: [text will be added after I am awake... maybe] [Should be fix the problem found in bug 162... formerly known as 161. code stolen from macvlan... this is just a reimplementation of a solution proposed by Simon Wunderlich] Reported-by: Linus Lüssing linus.luess...@web.de Signed-off-by: Sven Eckelmann s...@narfation.org --- soft-interface.c | 29 + 1 file changed, 29 insertions(+) diff --git a/soft-interface.c b/soft-interface.c index 1aee7db..588c6f6 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -344,7 +344,36 @@ out: return; } +/* + * batman-adv network devices have devices nesting below it and are a special + * super class of normal network devices; split their locks off into a + * separate class since they always nest. + */ +static struct lock_class_key batadv_netdev_xmit_lock_key; +static struct lock_class_key batadv_netdev_addr_lock_key; + +static void batadv_set_lockdep_class_one(struct net_device *dev, + struct netdev_queue *txq, + void *_unused) +{ + lockdep_set_class(txq-_xmit_lock, batadv_netdev_xmit_lock_key); +} + +static void batadv_set_lockdep_class(struct net_device *dev) +{ + lockdep_set_class(dev-addr_list_lock, batadv_netdev_addr_lock_key); + netdev_for_each_tx_queue(dev, batadv_set_lockdep_class_one, NULL); +} + +static int batadv_softif_init(struct net_device *dev) +{ + batadv_set_lockdep_class(dev); + + return 0; +} + static const struct net_device_ops batadv_netdev_ops = { + .ndo_init = batadv_softif_init, .ndo_open = batadv_interface_open, .ndo_stop = batadv_interface_release, .ndo_get_stats = batadv_interface_stats, -- 1.7.10.4 signature.asc Description: Digital signature
[B.A.T.M.A.N.] [RFC] batman-adv: don't allow ECTP traffic on batman-adv
We have seen this to break networks when used with bridge loop avoidance. As we can't see any benefit from sending these ancient frames via our mesh, we just drop them. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- soft-interface.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/soft-interface.c b/soft-interface.c index 1aee7db..f04a605 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -143,8 +143,10 @@ static int batadv_interface_tx(struct sk_buff *skb, struct batadv_bcast_packet *bcast_packet; struct vlan_ethhdr *vhdr; __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); - static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00, - 0x00}; + static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, + 0x00, 0x00}; + static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, + 0x00, 0x00}; unsigned int header_len = 0; int data_len = skb-len, ret; short vid __maybe_unused = -1; @@ -177,10 +179,16 @@ static int batadv_interface_tx(struct sk_buff *skb, /* don't accept stp packets. STP does not help in meshes. * better use the bridge loop avoidance ... +* +* The same goes for ECTP sent at least by some Cisco Switches, +* it might confuse the mesh when used with bridge loop avoidance. */ if (batadv_compare_eth(ethhdr-h_dest, stp_addr)) goto dropped; + if (batadv_compare_eth(ethhdr-h_dest, ectp_addr)) + goto dropped; + if (is_multicast_ether_addr(ethhdr-h_dest)) { do_bcast = true; -- 1.7.10
[B.A.T.M.A.N.] [PATCH] batman-adv: don't rely on positions in struct for hashing
The hash functions in the bridge loop avoidance code expects the VLAN vid to be right after the mac address, but this is not guaranteed. Fix this by explicitly hashing over the right fields of the struct. Reported-by: Marek Lindner lindner_ma...@yahoo.de Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 32 ++-- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 0921509..7e62c79 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -37,18 +37,26 @@ static void batadv_bla_periodic_work(struct work_struct *work); static void batadv_bla_send_announce(struct batadv_priv *bat_priv, struct batadv_backbone_gw *backbone_gw); +static inline void hash_bytes(uint32_t *hash, void *data, uint32_t size) +{ + const unsigned char *key = data; + int i; + + for (i = 0; i size; i++) { + *hash += key[i]; + *hash += (*hash 10); + *hash ^= (*hash 6); + } +} + /* return the index of the claim */ static inline uint32_t batadv_choose_claim(const void *data, uint32_t size) { - const unsigned char *key = data; + struct batadv_claim *claim = (struct batadv_claim *)data; uint32_t hash = 0; - size_t i; - for (i = 0; i ETH_ALEN + sizeof(short); i++) { - hash += key[i]; - hash += (hash 10); - hash ^= (hash 6); - } + hash_bytes(hash, claim-addr, sizeof(claim-addr)); + hash_bytes(hash, claim-vid, sizeof(claim-vid)); hash += (hash 3); hash ^= (hash 11); @@ -61,15 +69,11 @@ static inline uint32_t batadv_choose_claim(const void *data, uint32_t size) static inline uint32_t batadv_choose_backbone_gw(const void *data, uint32_t size) { - const unsigned char *key = data; + struct batadv_claim *claim = (struct batadv_claim *)data; uint32_t hash = 0; - size_t i; - for (i = 0; i ETH_ALEN + sizeof(short); i++) { - hash += key[i]; - hash += (hash 10); - hash ^= (hash 6); - } + hash_bytes(hash, claim-addr, sizeof(claim-addr)); + hash_bytes(hash, claim-vid, sizeof(claim-vid)); hash += (hash 3); hash ^= (hash 11); -- 1.7.10
Re: [B.A.T.M.A.N.] [PATCH] batman-adv: bandwidth meter implementation
On Thu, Aug 23, 2012 at 03:41:58PM +0200, Edo Monticelli wrote: The bandwith meter module is a simple, kernel-space replacement for bandwith measurements tool like iperf and netper. It is intended to approximate TCP behaviour. It is invoked through batctl: the protocol is connection oriented, with cumulative acknowledgment and sliding window. Sender keeps a timeout, which is checked by a worker function regoularly invoked through the workqueue mechanism. If the timeout is expired at the time worker is executed, the whole window is re-transmitted. Sequence number in packet header is 16 bit and is wrap around safe. BATADV_BW_FIRST_SEQ is the sequence number of the first packet. It is set to 65530 to generate a wrap-around. *Both sides must agree on this value*. I guess we can skip the paragraph, no? No need to bother people with these technical details in a summary. :) The receiver maintains a bitmap of BATADV_BW_WINDOW_SIZE to account for received packets not in order, so to avoid that they are unecessarly resent. Every time a packet is received, if it is either in order or not, an ack with the seqno equal to the last in order packet is sent back. The test *can* be interrupted by batctl. A receiver side timeout avoids unlimited waitings for sender packets: after one second of inactivity, the receiver abort the ongoing test. The sender aborts the test after having resent BATADV_BW_MAX_RETRY the same window. When the test is over, the results are returned to batctl through a call to the function batadv_socket_receive_packet(), before freeing struct batadv_bw_vars. This function only accepts struct batadv_icmp_packet_rr, so that structure is used and a cast is done to struct batadv_bw_result. The function basically sends a particular icmp packet through the local socket. In case any error occured during the test, this is also reported to batctl. Signed-off-by: Edo Monticelli mon...@autistici.org --- Makefile.kbuild |1 + bw_meter.c | 622 +++ bw_meter.h |7 + icmp_socket.c | 18 ++ main.c |2 + packet.h| 38 +++- routing.c | 15 ++- types.h | 25 +++ 8 files changed, 722 insertions(+), 6 deletions(-) create mode 100644 bw_meter.c create mode 100644 bw_meter.h diff --git a/Makefile.kbuild b/Makefile.kbuild index 8676d2b..8c08ff9 100644 --- a/Makefile.kbuild +++ b/Makefile.kbuild @@ -23,6 +23,7 @@ batman-adv-y += bat_iv_ogm.o batman-adv-y += bitarray.o batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o batman-adv-y += debugfs.o +batman-adv-y += bw_meter.o batman-adv-y += gateway_client.o batman-adv-y += gateway_common.o batman-adv-y += hard-interface.o diff --git a/bw_meter.c b/bw_meter.c new file mode 100644 index 000..2bc0374 --- /dev/null +++ b/bw_meter.c @@ -0,0 +1,622 @@ +#include main.h +#include send.h +#include hash.h +#include originator.h +#include hard-interface.h +#include bw_meter.h +#include icmp_socket.h +#include types.h +#include bw_meter.h + Didn't we agree to add some comments to these defines? these are quite a lot and not (always) self-explanatory. +#define BATADV_BW_PACKET_LEN 1400 +#define BATADV_BW_WINDOW_SIZE 30 +#define BATADV_BW_CLEAN_RECEIVER_TIMEOUT 2000 +#define BATADV_BW_TIMEOUT 60 +#define BATADV_BW_WORKER_TIMEOUT 30 +#define BATADV_BW_RECV_TIMEOUT 1000 +#define BATADV_BW_TOTAL_TO_SEND 1 +#define BATADV_BW_MAX_RETRY 3 +#define BATADV_BW_FIRST_SEQ 65530 + +#define batadv_bw_batctl_error_notify(status, uid) \ + batadv_bw_batctl_notify(status, uid, 0) + +static int batadv_bw_queue_sender_worker(struct batadv_bw_vars *bw_vars); +static int batadv_bw_queue_receiver_worker(struct batadv_bw_vars *bw_vars); + +static void batadv_bw_vars_free(struct batadv_bw_vars *bw_vars) +{ + spin_lock_bh(bw_vars-bat_priv-bw_list_lock); + list_del(bw_vars-list); + spin_unlock_bh(bw_vars-bat_priv-bw_list_lock); + kfree(bw_vars); +} + +static int batadv_bw_icmp_send(struct batadv_priv *bat_priv, +struct sk_buff *skb) +{ + struct batadv_hard_iface *primary_if = NULL; + struct batadv_orig_node *orig_node = NULL; + struct batadv_neigh_node *neigh_node = NULL; + struct batadv_icmp_packet *icmp_packet; + int ret = -1; + + icmp_packet = (struct batadv_icmp_packet *)skb-data; + primary_if = batadv_primary_if_get_selected(bat_priv); + if (!primary_if) { + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, +Meter:batadv_bw_icmp_send: no primary if\n); + goto out; + } + if (atomic_read(bat_priv-mesh_state) != BATADV_MESH_ACTIVE) { + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, +Meter:batadv_bw_icmp_send: mesh inactive\n); + goto dst_unreach; + } + +
[B.A.T.M.A.N.] [PATCH 1/2] batman-adv: send announcement when backbone gw is registered
To avoid loops in the startup phase until the first announcement is sent, send an announcement immediately as soon as a backbone gw is added. This may happen due to various reasons, e.g. a packet passes the rx or tx path. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 0921509..c522bdf 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -362,7 +362,7 @@ out: */ static struct batadv_backbone_gw * batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, - short vid) + short vid, bool own_backbone) { struct batadv_backbone_gw *entry; struct batadv_orig_node *orig_node; @@ -409,6 +409,10 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, became a backbone gateway); batadv_orig_node_free_ref(orig_node); } + + if (own_backbone) + batadv_bla_send_announce(bat_priv, entry); + return entry; } @@ -424,7 +428,7 @@ batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv, backbone_gw = batadv_bla_get_backbone_gw(bat_priv, primary_if-net_dev-dev_addr, -vid); +vid, true); if (unlikely(!backbone_gw)) return; @@ -632,7 +636,8 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv, if (memcmp(an_addr, batadv_announce_mac, 4) != 0) return 0; - backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid); + backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid, +false); if (unlikely(!backbone_gw)) return 1; @@ -730,7 +735,8 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv, /* register the gateway if not yet available, and add the claim. */ - backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid); + backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid, +false); if (unlikely(!backbone_gw)) return 1; -- 1.7.10
[B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: allow bla traffic only after first worker period
When adding a backbone gateway for the first time, it might not yet be known in the backbone, and therefore we should not forward broadcasts yet. This behaviour is the same as when sending a request to another backbone gw because of a CRC mismatch. The backbone gw will operate normal after the next periodic bla work. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index c522bdf..db046d8 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -410,9 +410,14 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, batadv_orig_node_free_ref(orig_node); } - if (own_backbone) + if (own_backbone) { batadv_bla_send_announce(bat_priv, entry); + /* this will be decreased in the worker thread */ + atomic_inc(entry-request_sent); + atomic_inc(bat_priv-bla.num_requests); + } + return entry; } @@ -1146,6 +1151,19 @@ static void batadv_bla_periodic_work(struct work_struct *work) backbone_gw-lasttime = jiffies; batadv_bla_send_announce(bat_priv, backbone_gw); + + /* request_sent is only set after creation to avoid +* problems when we are not yet known as backbone gw +* in the backbone. +* +* We can reset this now and allow traffic again. +*/ + + if (atomic_read(backbone_gw-request_sent) == 0) + continue; + + atomic_dec(backbone_gw-bat_priv-bla.num_requests); + atomic_set(backbone_gw-request_sent, 0); } rcu_read_unlock(); } -- 1.7.10
[B.A.T.M.A.N.] [PATCH] batman-adv: dirty hack to recompute mac_len in the rx path
It is possible that the mac_len is not properly exported because of strange device configuration (this behaviour has been observed when using batman-adv on top of a vlan interface). Therefore it is needed to explicitly recompute it at the very beginning of the rx path. This is done by appending the recompute function to the skb_share_mac() function, hence the dirty hack in the subject. We expect this problem to be fixed in linux 3.8 and above. Reported-by: Antonio Quartulli or...@autistici.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- this is a rewrite of Antonios patch batman-adv: recompute mac_len at the beginning of the rx path. It is intended to fix the issue for out-of-kernel releases, without hurting the in-kernel code too much. Obviously, this patch won't go upstream into the kernel. This version includes Svens more sane version, and also has implements skb_reset_mac_len() for kernels prior to 3.0. --- compat.h | 24 1 file changed, 24 insertions(+) diff --git a/compat.h b/compat.h index 14969e0..47223f5 100644 --- a/compat.h +++ b/compat.h @@ -137,6 +137,11 @@ void batadv_free_rcu_neigh_node(struct rcu_head *rcu); void batadv_free_rcu_tt_local_entry(struct rcu_head *rcu); void batadv_free_rcu_backbone_gw(struct rcu_head *rcu); +static inline void skb_reset_mac_len(struct sk_buff *skb) +{ + skb-mac_len = skb-network_header - skb-mac_header; +} + #endif /* KERNEL_VERSION(3, 0, 0) */ @@ -159,4 +164,23 @@ static inline void eth_hw_addr_random(struct net_device *dev) #endif /* KERNEL_VERSION(3, 5, 0) */ +#if LINUX_VERSION_CODE KERNEL_VERSION(3, 8, 0) + +/* hack for not correctly set mac_len. This may happen for some special + * configurations like batman-adv on VLANs. + * + * This is pretty dirty, but we only use skb_share_check() in main.c right + * before mac_len is checked, and the recomputation shouldn't hurt too much. + */ +#define skb_share_check(skb, b) \ + ({ \ + struct sk_buff *_t_skb; \ + _t_skb = skb_share_check(skb, b); \ + if (_t_skb) \ + skb_reset_mac_len(_t_skb); \ + _t_skb; \ + }) + +#endif /* KERNEL_VERSION(3, 8, 0) */ + #endif /* _NET_BATMAN_ADV_COMPAT_H_ */ -- 1.7.10
[B.A.T.M.A.N.] [PATCH 2/2] batman-adv: fix bla compare function
The address and the VLAN VID may not be packed in the respective structs. Fix this by comparing the elements individually. Reported-by: Marek Lindner lindner_ma...@yahoo.de Reported-by: Sven Eckelmann s...@narfation.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 758d921..8313322 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -77,8 +77,10 @@ static int batadv_compare_backbone_gw(const struct hlist_node *node, { const void *data1 = container_of(node, struct batadv_backbone_gw, hash_entry); + const struct batadv_backbone_gw *gw1 = data1, *gw2 = data2; - return (memcmp(data1, data2, ETH_ALEN + sizeof(short)) == 0 ? 1 : 0); + return (((memcmp(gw1-orig, gw2-orig, ETH_ALEN) == 0) +(gw1-vid == gw2-vid)) ? 1 : 0); } /* compares address and vid of two claims */ @@ -87,8 +89,10 @@ static int batadv_compare_claim(const struct hlist_node *node, { const void *data1 = container_of(node, struct batadv_claim, hash_entry); + const struct batadv_claim *cl1 = data1, *cl2 = data2; - return (memcmp(data1, data2, ETH_ALEN + sizeof(short)) == 0 ? 1 : 0); + return (((memcmp(cl1-addr, cl2-addr, ETH_ALEN) == 0) +(cl1-vid == cl2-vid)) ? 1 : 0); } /* free a backbone gw */ -- 1.7.10
[B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: fix bla compare function
The address and the VLAN VID may not be packed in the respective structs. Fix this by comparing the elements individually. Reported-by: Marek Lindner lindner_ma...@yahoo.de Reported-by: Sven Eckelmann s...@narfation.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 18 -- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 758d921..a617f2c 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -77,8 +77,15 @@ static int batadv_compare_backbone_gw(const struct hlist_node *node, { const void *data1 = container_of(node, struct batadv_backbone_gw, hash_entry); + const struct batadv_backbone_gw *gw1 = data1, *gw2 = data2; - return (memcmp(data1, data2, ETH_ALEN + sizeof(short)) == 0 ? 1 : 0); + if (memcmp(gw1-orig, gw2-orig, ETH_ALEN)) + return 0; + + if (gw1-vid != gw2-vid) + return 0; + + return 1; } /* compares address and vid of two claims */ @@ -87,8 +94,15 @@ static int batadv_compare_claim(const struct hlist_node *node, { const void *data1 = container_of(node, struct batadv_claim, hash_entry); + const struct batadv_claim *cl1 = data1, *cl2 = data2; - return (memcmp(data1, data2, ETH_ALEN + sizeof(short)) == 0 ? 1 : 0); + if (memcmp(cl1-addr, cl2-addr, ETH_ALEN)) + return 0; + + if (cl1-vid != cl2-vid) + return 0; + + return 1; } /* free a backbone gw */ -- 1.7.10
Re: [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: Fix potential broadcast BLA-duplicate-check race condition
Looks good, although I don't think this will happen very often - it is only called when receiving packets, and AFAIK there can only be multiple threads when using multiple interfaces. Anyway, doing the spinlock shouldn't hurt and might save us some pain when this function is used more often, or with multiple interfaces, or cases I don't see now. :) Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de On Wed, Oct 17, 2012 at 02:53:05PM +0200, Linus Lüssing wrote: Threads in the bottom half of batadv_bla_check_bcast_duplist() might otherwise for instance overwrite variables which other threads might be using/reading at the same time in the top half, potentially leading to messing up the bcast_duplist, possibly resulting in false bridge loop avoidance duplicate check decisions. Signed-off-by: Linus Lüssing linus.luess...@web.de --- Note: I didn't observe such issues yet, probably because of the usually quite low broadcast data throughput - and on high broadcast throughput, then packet loss is usually caused by the limited capacity for broadcast packets on 802.11 media anyway. bridge_loop_avoidance.c | 16 +++- main.c |1 + types.h |2 ++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index b828875..c6c1c59 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1263,7 +1263,7 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, struct batadv_bcast_packet *bcast_packet, int bcast_packet_len) { - int i, length, curr; + int i, length, curr, ret = 0; uint8_t *content; uint16_t crc; struct batadv_bcast_duplist_entry *entry; @@ -1275,6 +1275,8 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, /* calculate the crc ... */ crc = crc16(0, content, length); + spin_lock_bh(bat_priv-bla.bcast_duplist_lock); + for (i = 0; i BATADV_DUPLIST_SIZE; i++) { curr = (bat_priv-bla.bcast_duplist_curr + i); curr %= BATADV_DUPLIST_SIZE; @@ -1296,9 +1298,11 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, /* this entry seems to match: same crc, not too old, * and from another gw. therefore return 1 to forbid it. */ - return 1; + ret = 1; + goto out; } - /* not found, add a new entry (overwrite the oldest entry) */ + /* not found, add a new entry (overwrite the oldest entry) + * and allow it, its the first occurence. */ curr = (bat_priv-bla.bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1); curr %= BATADV_DUPLIST_SIZE; entry = bat_priv-bla.bcast_duplist[curr]; @@ -1307,8 +1311,10 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, memcpy(entry-orig, bcast_packet-orig, ETH_ALEN); bat_priv-bla.bcast_duplist_curr = curr; - /* allow it, its the first occurence. */ - return 0; +out: + spin_unlock_bh(bat_priv-bla.bcast_duplist_lock); + + return ret; } diff --git a/main.c b/main.c index 70797de..f54efe9 100644 --- a/main.c +++ b/main.c @@ -102,6 +102,7 @@ int batadv_mesh_init(struct net_device *soft_iface) spin_lock_init(bat_priv-gw.list_lock); spin_lock_init(bat_priv-vis.hash_lock); spin_lock_init(bat_priv-vis.list_lock); + spin_lock_init(bat_priv-bla.bcast_duplist_lock); INIT_HLIST_HEAD(bat_priv-forw_bat_list); INIT_HLIST_HEAD(bat_priv-forw_bcast_list); diff --git a/types.h b/types.h index 8a5d84c..7b3d0d7 100644 --- a/types.h +++ b/types.h @@ -228,6 +228,8 @@ struct batadv_priv_bla { struct batadv_hashtable *backbone_hash; struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; int bcast_duplist_curr; + /* protects bcast_duplist and bcast_duplist_curr */ + spinlock_t bcast_duplist_lock; struct batadv_bla_claim_dst claim_dest; struct delayed_work work; }; -- 1.7.10.4 signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCHv2 1/2] batman-adv: Fix broadcast packet CRC calculation
Good catch! When can I buy you the beer? :D Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de On Wed, Oct 17, 2012 at 02:53:04PM +0200, Linus Lüssing wrote: So far the crc16 checksum for a batman-adv broadcast data packet, received on a batman-adv hard interface, was calculated over zero bytes of its content leading to many incoming broadcast data packets wrongly being dropped. This patch fixes this issue by calculating the crc16 over the actual, complete broadcast payload. The issue is a regression introduced by batman-adv: add broadcast duplicate check. Signed-off-by: Linus Lüssing linus.luess...@web.de --- It led to about 60-80% broadcast packet loss to a direct neighbor with a ping6 with a 1s interval in our scenario, but about no packet loss with an interval smaller than 0.2s. Also see: https://projects.universe-factory.net/issues/65 (German) v2: ~ fixed typo (regrission vs. regression) ~ commit name instead of commit hash in the commit message bridge_loop_avoidance.c |8 routing.c |8 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index a617f2c..b828875 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1247,8 +1247,8 @@ int batadv_bla_init(struct batadv_priv *bat_priv) /** * batadv_bla_check_bcast_duplist * @bat_priv: the bat priv with all the soft interface information - * @bcast_packet: originator mac address - * @hdr_size: maximum length of the frame + * @bcast_packet: encapsulated broadcast frame plus batman header + * @bcast_packet_len: length of encapsulated broadcast frame plus batman header * * check if it is on our broadcast list. Another gateway might * have sent the same packet because it is connected to the same backbone, @@ -1261,14 +1261,14 @@ int batadv_bla_init(struct batadv_priv *bat_priv) */ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, struct batadv_bcast_packet *bcast_packet, -int hdr_size) +int bcast_packet_len) { int i, length, curr; uint8_t *content; uint16_t crc; struct batadv_bcast_duplist_entry *entry; - length = hdr_size - sizeof(*bcast_packet); + length = bcast_packet_len - sizeof(*bcast_packet); content = (uint8_t *)bcast_packet; content += sizeof(*bcast_packet); diff --git a/routing.c b/routing.c index 6b2104d..5da62df 100644 --- a/routing.c +++ b/routing.c @@ -1181,8 +1181,14 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, spin_unlock_bh(orig_node-bcast_seqno_lock); + /* keep skb linear for crc calculation */ + if (skb_linearize(skb) 0) + goto out; + + bcast_packet = (struct batadv_bcast_packet *)skb-data; + /* check whether this has been sent by another originator before */ - if (batadv_bla_check_bcast_duplist(bat_priv, bcast_packet, hdr_size)) + if (batadv_bla_check_bcast_duplist(bat_priv, bcast_packet, skb-len)) goto out; /* rebroadcast packet */ -- 1.7.10.4 signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCH] batman-adv: Fix broadcast duplist for fragmentation
If the skb is fragmented, the checksum must be computed on the individual fragments, just using skb-data may fail on fragmented data. Instead of doing linearizing the packet, use the new batadv_crc32 to do that more efficiently- it should not hurt replacing the old crc16 by the new crc32. Reported-by: Sven Eckelmann s...@narfation.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- bridge_loop_avoidance.c | 18 +++--- bridge_loop_avoidance.h |3 +-- routing.c | 10 +++--- types.h |2 +- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index c6c1c59..b766441 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1247,8 +1247,7 @@ int batadv_bla_init(struct batadv_priv *bat_priv) /** * batadv_bla_check_bcast_duplist * @bat_priv: the bat priv with all the soft interface information - * @bcast_packet: encapsulated broadcast frame plus batman header - * @bcast_packet_len: length of encapsulated broadcast frame plus batman header + * @skb: contains the bcast_packet to be checked * * check if it is on our broadcast list. Another gateway might * have sent the same packet because it is connected to the same backbone, @@ -1260,20 +1259,17 @@ int batadv_bla_init(struct batadv_priv *bat_priv) * the same host however as this might be intended. */ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, - struct batadv_bcast_packet *bcast_packet, - int bcast_packet_len) + struct sk_buff *skb) { - int i, length, curr, ret = 0; - uint8_t *content; - uint16_t crc; + int i, curr, ret = 0; + uint32_t crc; + struct batadv_bcast_packet *bcast_packet; struct batadv_bcast_duplist_entry *entry; - length = bcast_packet_len - sizeof(*bcast_packet); - content = (uint8_t *)bcast_packet; - content += sizeof(*bcast_packet); + bcast_packet = (struct batadv_bcast_packet *)skb-data; /* calculate the crc ... */ - crc = crc16(0, content, length); + crc = batadv_skb_crc32(skb, (u8 *)(bcast_packet + 1)); spin_lock_bh(bat_priv-bla.bcast_duplist_lock); diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 789cb73..f1bc9cd 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -31,8 +31,7 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset); int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig); int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, - struct batadv_bcast_packet *bcast_packet, - int hdr_size); + struct sk_buff *skb); void batadv_bla_update_orig_address(struct batadv_priv *bat_priv, struct batadv_hard_iface *primary_if, struct batadv_hard_iface *oldif); diff --git a/routing.c b/routing.c index 5da62df..5da7724 100644 --- a/routing.c +++ b/routing.c @@ -1181,16 +1181,12 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, spin_unlock_bh(orig_node-bcast_seqno_lock); - /* keep skb linear for crc calculation */ - if (skb_linearize(skb) 0) - goto out; - - bcast_packet = (struct batadv_bcast_packet *)skb-data; - /* check whether this has been sent by another originator before */ - if (batadv_bla_check_bcast_duplist(bat_priv, bcast_packet, skb-len)) + if (batadv_bla_check_bcast_duplist(bat_priv, skb)) goto out; + bcast_packet = (struct batadv_bcast_packet *)skb-data; + /* rebroadcast packet */ batadv_add_bcast_packet_to_list(bat_priv, skb, 1); diff --git a/types.h b/types.h index 7b3d0d7..354b699 100644 --- a/types.h +++ b/types.h @@ -156,7 +156,7 @@ struct batadv_neigh_node { #ifdef CONFIG_BATMAN_ADV_BLA struct batadv_bcast_duplist_entry { uint8_t orig[ETH_ALEN]; - uint16_t crc; + uint32_t crc; unsigned long entrytime; }; #endif -- 1.7.10
Re: [B.A.T.M.A.N.] [PATCH 2/4] alfred: Fix parsing of short program parameter -v and -V
Applied in revision 3c2de69. Thanks, Simon On Wed, Oct 17, 2012 at 09:55:56PM +0200, Sven Eckelmann wrote: Signed-off-by: Sven Eckelmann s...@narfation.org --- main.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 0315fe3..96e401a 100644 --- a/main.c +++ b/main.c @@ -78,7 +78,7 @@ struct globals *alfred_init(int argc, char *argv[]) globals-best_server = NULL; globals-clientmode_version = 0; - while ((opt = getopt_long(argc, argv, ms:r:hi:, long_options, + while ((opt = getopt_long(argc, argv, ms:r:hi:vV:, long_options, opt_ind)) != -1) { switch (opt) { case 'r': -- 1.7.10.4 signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCHv4] batman-adv: Fix broadcast duplist for fragmentation
If the skb is fragmented, the checksum must be computed on the individual fragments, just using skb-data may fail on fragmented data. Instead of doing linearizing the packet, use the new batadv_crc32 to do that more efficiently- it should not hurt replacing the old crc16 by the new crc32. Reported-by: Sven Eckelmann s...@narfation.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- PATCHv2: change uint32_t to __be32 PATCHv3: this time also changed in types.h PATCHv4: also compile if bla is disabled --- bridge_loop_avoidance.c | 18 +++--- bridge_loop_avoidance.h |6 ++ routing.c | 10 +++--- types.h |2 +- 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index a05b1b4..b6da6ae 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1249,8 +1249,7 @@ int batadv_bla_init(struct batadv_priv *bat_priv) /** * batadv_bla_check_bcast_duplist * @bat_priv: the bat priv with all the soft interface information - * @bcast_packet: encapsulated broadcast frame plus batman header - * @bcast_packet_len: length of encapsulated broadcast frame plus batman header + * @skb: contains the bcast_packet to be checked * * check if it is on our broadcast list. Another gateway might * have sent the same packet because it is connected to the same backbone, @@ -1262,20 +1261,17 @@ int batadv_bla_init(struct batadv_priv *bat_priv) * the same host however as this might be intended. */ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, - struct batadv_bcast_packet *bcast_packet, - int bcast_packet_len) + struct sk_buff *skb) { - int i, length, curr, ret = 0; - uint8_t *content; - uint16_t crc; + int i, curr, ret = 0; + __be32 crc; + struct batadv_bcast_packet *bcast_packet; struct batadv_bcast_duplist_entry *entry; - length = bcast_packet_len - sizeof(*bcast_packet); - content = (uint8_t *)bcast_packet; - content += sizeof(*bcast_packet); + bcast_packet = (struct batadv_bcast_packet *)skb-data; /* calculate the crc ... */ - crc = crc16(0, content, length); + crc = batadv_skb_crc32(skb, (u8 *)(bcast_packet + 1)); spin_lock_bh(bat_priv-bla.bcast_duplist_lock); diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 789cb73..196d9a0 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -31,8 +31,7 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset); int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig); int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, - struct batadv_bcast_packet *bcast_packet, - int hdr_size); + struct sk_buff *skb); void batadv_bla_update_orig_address(struct batadv_priv *bat_priv, struct batadv_hard_iface *primary_if, struct batadv_hard_iface *oldif); @@ -81,8 +80,7 @@ static inline int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, static inline int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, - struct batadv_bcast_packet *bcast_packet, - int hdr_size) + struct sk_buff *skb) { return 0; } diff --git a/routing.c b/routing.c index 5da62df..5da7724 100644 --- a/routing.c +++ b/routing.c @@ -1181,16 +1181,12 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, spin_unlock_bh(orig_node-bcast_seqno_lock); - /* keep skb linear for crc calculation */ - if (skb_linearize(skb) 0) - goto out; - - bcast_packet = (struct batadv_bcast_packet *)skb-data; - /* check whether this has been sent by another originator before */ - if (batadv_bla_check_bcast_duplist(bat_priv, bcast_packet, skb-len)) + if (batadv_bla_check_bcast_duplist(bat_priv, skb)) goto out; + bcast_packet = (struct batadv_bcast_packet *)skb-data; + /* rebroadcast packet */ batadv_add_bcast_packet_to_list(bat_priv, skb, 1); diff --git a/types.h b/types.h index 7b3d0d7..ae9ac9a 100644 --- a/types.h +++ b/types.h @@ -156,7 +156,7 @@ struct batadv_neigh_node { #ifdef CONFIG_BATMAN_ADV_BLA struct batadv_bcast_duplist_entry { uint8_t orig[ETH_ALEN]; - uint16_t crc; + __be32 crc; unsigned long entrytime; }; #endif -- 1.7.10
Re: [B.A.T.M.A.N.] [PATCH] batman-adv: don't compile the BLA switch if not requested
On Mon, Nov 26, 2012 at 01:27:29AM +0100, Antonio Quartulli wrote: When the Bridge Loop Avoidance component is not compiled-in, its boolean switch should be not compiled as well. This patch surrounds the switch with a proper ifdef. This behaviour was introduced by 9fd6b0615b5499b270d39a92b8790e206cf75833 (batman-adv: add bridge loop avoidance compile option) Signed-off-by: Antonio Quartulli or...@autistici.org Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- soft-interface.c | 2 ++ types.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/soft-interface.c b/soft-interface.c index 8000639..aa34267 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -480,7 +480,9 @@ struct net_device *batadv_softif_create(const char *name) atomic_set(bat_priv-aggregated_ogms, 1); atomic_set(bat_priv-bonding, 0); +#ifdef CONFIG_BATMAN_ADV_BLA atomic_set(bat_priv-bridge_loop_avoidance, 0); +#endif #ifdef CONFIG_BATMAN_ADV_DAT atomic_set(bat_priv-distributed_arp_table, 1); #endif diff --git a/types.h b/types.h index ae9ac9a..030ce41 100644 --- a/types.h +++ b/types.h @@ -273,7 +273,9 @@ struct batadv_priv { atomic_t bonding; /* boolean */ atomic_t fragmentation; /* boolean */ atomic_t ap_isolation; /* boolean */ +#ifdef CONFIG_BATMAN_ADV_BLA atomic_t bridge_loop_avoidance; /* boolean */ +#endif #ifdef CONFIG_BATMAN_ADV_DAT atomic_t distributed_arp_table; /* boolean */ #endif -- 1.8.0 signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] net, batman: lockdep circular dependency warning
Hey Sven, thanks for showing these approaches! Comments inline ... On Tue, Dec 04, 2012 at 03:51:55PM +0100, Sven Eckelmann wrote: Hi, thanks for your report. It seems nobody else wanted to give an answer... so I try to give a small overview. On Monday 12 November 2012 15:37:47 Sasha Levin wrote: Hi all, While fuzzing with trinity inside a KVM tools (lkvm) guest running latest -next kernel, I've stumbled on the following: [ 1002.969392] == [ 1002.971639] [ INFO: possible circular locking dependency detected ] [ 1002.975805] 3.7.0-rc5-next-20121112-sasha-00018-g2f4ce0e #127 Tainted: G W [ 1002.983691] --- [ 1002.983691] trinity-child18/8149 is trying to acquire lock: [ 1002.983691] (s_active#313){.+}, at: [812f9941] sysfs_addrm_finish+0x31/0x60 [ 1002.983691] [ 1002.983691] but task is already holding lock: [ 1002.983691] (rtnl_mutex){+.+.+.}, at: [834fcc62] rtnl_lock+0x12/0x20 [ 1002.983691] [ 1002.983691] which lock already depends on the new lock. It is known that batman-adv has a problem with the attaching/detaching of interfaces over this sysfs. The cause of this problem is related to the fact that batman-adv not only creates its own net_devices, but also unregisters net_devices. This unregister will add a new element in the net_todo_list. This will cause a rtnl_lock when it calls netdev_wait_allrefs (there are some condition, but we just ignore them for now). So the whole exercise of using rtnl_trylock was useless. This extra rtnl_lock can cause a deadlock as you found out because it is activated through a sysfs file and therefore the s_active mutex is locked (we have the dependency s_active - rtnl_mutex, but other users have rtnl_mutex - s_active). So, what to do? There are different possibilities. We have to keep in mind that there is a patchset (not yet accepted by the batman-adv maintainers) which allows to use `ip link` or compatible tools to create/destroy batman-adv devices and attach/detach other devices. 1. Remove the sysfs interface to attach/detach net_devices (which destroys/creates batman-adv devices) This is not really backward compatible and therefore not really acceptable. Marek Lindner and Simon Wunderlich are also against forcing users to require special tools to add/configure batman-adv devices (even batctl, ip and so on). Yeah, at least I think we should keep what we have for now and fix it before moving to the next interface. It has its merits I would like to keep, having text output is one of them. :) 2. Ignore the possible deadlock (sry, fill in your own comment...) That probably won't help. :) 3. Add workarounds in the core net code Simon Wunderlich already tried it... I personally think it is not the right way because it more likely to introduce more bugs by hiding a batman-adv bug. And these bugs are a lot harder to find... trust me For example the usage of __rtnl_unlock will let this bug to appear in other places which use rtnl_trylock. This is caused by the fact that the todo item isn't processed by __rtnl_unlock (this is the whole idea by calling it) and therefore the todo work stays in net_todo_list. Another user of rtnl_trylock will now call rtnl_unlock and don't expect an entry in net_todo_list because he never unregistered a device. So he now has the problem of batman-adv (what an unsocial läderlappen). And moving everybody using rtnl_trylock to __rtnl_unlock has still the problem that batman-adv don't immediatelly work on its todo and so maybe causes other side effects because... the notifications weren't sent and therefore the refcount of the unregistered device didn't went to zero. (I'll leave other side effects as homework for the reader) You are right, it can probably not solved as easily as I thought before. Also, it seems the bridge code is not concerned as I thought at first. Although I still don't like the rtnl_unlock() concept in general, but I can't provide an alternative here so I should't moan about that. :) 4. Don't automatically remove batman-adv devices The current approach is to automatically unregister batman-adv devices when they don't have attached slave-devices (hardif called by batman-adv). Removing this will slightly change the behaviour, but the interface can still be removed using `ip link del dev bat0` or a similar tool. That would be possible, but we must at least make sure that the initialization is done for all internal tables (tt, bla, ...), counters, seqnos, etc when the first device is added. Otherwise old users might assume that the device is resetted correctly when removing all hard interfaces of one soft interface and add it again under the same soft interface name. 5. Add
Re: [B.A.T.M.A.N.] [RFC] batman-adv: postpone OGM preparation to sending time
On Tue, Dec 11, 2012 at 10:57:24PM +0100, Antonio Quartulli wrote: OGMs are currently prepared 1 originator interval in advance then the time they are used to be sent. This means that once in the air they carry old information (e.g. TT announcements). To fix this, postpone the OGM creation to the same time of sending, in this way the OGM is first created and then immediately sent. This patch also removes an insane -2 that was introduced with 4d30670880c84071dba4b220f595e64d6c01d1ba (batman-adv: accept delayed rebroadcasts to avoid bogus routing under heavy load) in the OGM seqno validation code that was put there to fix a possible heavy loaded scenario. First that operation shown to be completely not valid and consequently it was creating problem to the new behaviour introduced by this patch Actually the -2 was not introduced there but was present (in some form) for a much longer time ... something before 2009, didn't trace it to the very end. :) The reason for this was: * seqno is increased right after scheduling a new (own OGM) * the scheduled OGM was waiting one more cycle before beeing finally sent Seems we forgot to document this properly, but removing this one is a good idea. :) Your patch thankfully seems to correctly eliminate both reasons for correcting the incoming seqno. I haven't reviewed the rest (don't know if this will stir trouble for the aggregation), but wanted to comment on this history bit. :) Please remove/correct the reference if you merge or send it again. Thanks! Simon signature.asc Description: Digital signature
[B.A.T.M.A.N.] [RFC] batman-adv: postpone sysfs removal when unregistering
When processing the unregister notify for a hard interface, removing the sysfs files may lead to a circular deadlock (rtnl mutex - s_active). To overcome this problem, postpone the sysfs removal in a worker. Reported-by: Sasha Levin sasha.le...@oracle.com Reported-by: Sven Eckelmann s...@narfation.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- Postponing the sysfs removal for the hardif unregister is easier than other alternatives involving deferring. This should bring us to the same level to the bridge code, which also messes with sysfs in the notifier processing function, and uses rtnl_trylock when called from within sysfs. As far as I could understand the net/core code, only the unregister case is the critical one, so the original bug should hopefully be fixed. Anyway, I might overlook something so I'm sending this as RFC. --- hard-interface.c | 18 -- types.h |1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hard-interface.c b/hard-interface.c index f1d37cd..075cb27 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -506,6 +506,19 @@ out: return NULL; } +static void batadv_hardif_remove_interface_finish(struct work_struct *work) +{ + struct delayed_work *delayed_work; + struct batadv_hard_iface *hard_iface; + + delayed_work = container_of(work, struct delayed_work, work); + hard_iface = container_of(delayed_work, struct batadv_hard_iface, + cleanup_work); + + batadv_sysfs_del_hardif(hard_iface-hardif_obj); + batadv_hardif_free_ref(hard_iface); +} + static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) { ASSERT_RTNL(); @@ -518,8 +531,9 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) return; hard_iface-if_status = BATADV_IF_TO_BE_REMOVED; - batadv_sysfs_del_hardif(hard_iface-hardif_obj); - batadv_hardif_free_ref(hard_iface); + INIT_DELAYED_WORK(hard_iface-cleanup_work, + batadv_hardif_remove_interface_finish); + queue_work(batadv_event_workqueue, hard_iface-cleanup_work); } void batadv_hardif_remove_interfaces(void) diff --git a/types.h b/types.h index 030ce41..6e9746a 100644 --- a/types.h +++ b/types.h @@ -63,6 +63,7 @@ struct batadv_hard_iface { struct net_device *soft_iface; struct rcu_head rcu; struct batadv_hard_iface_bat_iv bat_iv; + struct delayed_work cleanup_work; }; /** -- 1.7.10.4
Re: [B.A.T.M.A.N.] [RFC] batman-adv: postpone sysfs removal when unregistering
This patch needs rework for two reasons: * we still need to defer the softif as well, otherwise we keep the deadlock for the softif * work struct and delayed_work are mixed up here I'll post a revised version soon. Cheers, Simon On Wed, Dec 12, 2012 at 12:05:05AM +0100, Simon Wunderlich wrote: When processing the unregister notify for a hard interface, removing the sysfs files may lead to a circular deadlock (rtnl mutex - s_active). To overcome this problem, postpone the sysfs removal in a worker. Reported-by: Sasha Levin sasha.le...@oracle.com Reported-by: Sven Eckelmann s...@narfation.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- Postponing the sysfs removal for the hardif unregister is easier than other alternatives involving deferring. This should bring us to the same level to the bridge code, which also messes with sysfs in the notifier processing function, and uses rtnl_trylock when called from within sysfs. As far as I could understand the net/core code, only the unregister case is the critical one, so the original bug should hopefully be fixed. Anyway, I might overlook something so I'm sending this as RFC. --- hard-interface.c | 18 -- types.h |1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hard-interface.c b/hard-interface.c index f1d37cd..075cb27 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -506,6 +506,19 @@ out: return NULL; } +static void batadv_hardif_remove_interface_finish(struct work_struct *work) +{ + struct delayed_work *delayed_work; + struct batadv_hard_iface *hard_iface; + + delayed_work = container_of(work, struct delayed_work, work); + hard_iface = container_of(delayed_work, struct batadv_hard_iface, + cleanup_work); + + batadv_sysfs_del_hardif(hard_iface-hardif_obj); + batadv_hardif_free_ref(hard_iface); +} + static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) { ASSERT_RTNL(); @@ -518,8 +531,9 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) return; hard_iface-if_status = BATADV_IF_TO_BE_REMOVED; - batadv_sysfs_del_hardif(hard_iface-hardif_obj); - batadv_hardif_free_ref(hard_iface); + INIT_DELAYED_WORK(hard_iface-cleanup_work, + batadv_hardif_remove_interface_finish); + queue_work(batadv_event_workqueue, hard_iface-cleanup_work); } void batadv_hardif_remove_interfaces(void) diff --git a/types.h b/types.h index 030ce41..6e9746a 100644 --- a/types.h +++ b/types.h @@ -63,6 +63,7 @@ struct batadv_hard_iface { struct net_device *soft_iface; struct rcu_head rcu; struct batadv_hard_iface_bat_iv bat_iv; + struct delayed_work cleanup_work; }; /** -- 1.7.10.4 signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCH] batman-adv: postpone sysfs removal when unregistering
When processing the unregister notify for a hard interface, removing the sysfs files may lead to a circular deadlock (rtnl mutex - s_active). To overcome this problem, postpone the sysfs removal in a worker. Reported-by: Sasha Levin sasha.le...@oracle.com Reported-by: Sven Eckelmann s...@narfation.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- Changes from RFCv1: * use work_struct properly, instead of delayed_work * postpone for softifs as well as for hardifs Postponing the sysfs removal for the hardif unregister is easier than other alternatives involving deferring. This should bring us to the same level to the bridge code, which also messes with sysfs in the notifier processing function, and uses rtnl_trylock when called from within sysfs. As far as I could understand the net/core code, only the unregister case is the critical one, so the original bug should hopefully be fixed. --- hard-interface.c | 16 ++-- soft-interface.c | 26 +++--- types.h |3 +++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/hard-interface.c b/hard-interface.c index f1d37cd..eb3a12d 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -506,6 +506,17 @@ out: return NULL; } +static void batadv_hardif_remove_interface_finish(struct work_struct *work) +{ + struct batadv_hard_iface *hard_iface; + + hard_iface = container_of(work, struct batadv_hard_iface, + cleanup_work); + + batadv_sysfs_del_hardif(hard_iface-hardif_obj); + batadv_hardif_free_ref(hard_iface); +} + static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) { ASSERT_RTNL(); @@ -518,8 +529,9 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) return; hard_iface-if_status = BATADV_IF_TO_BE_REMOVED; - batadv_sysfs_del_hardif(hard_iface-hardif_obj); - batadv_hardif_free_ref(hard_iface); + INIT_WORK(hard_iface-cleanup_work, + batadv_hardif_remove_interface_finish); + queue_work(batadv_event_workqueue, hard_iface-cleanup_work); } void batadv_hardif_remove_interfaces(void) diff --git a/soft-interface.c b/soft-interface.c index a8eb963..b8a307b 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -464,6 +464,7 @@ struct net_device *batadv_softif_create(const char *name) goto out; bat_priv = netdev_priv(soft_iface); + bat_priv-soft_iface = soft_iface; /* batadv_interface_stats() needs to be available as soon as * register_netdevice() has been called @@ -550,12 +551,31 @@ out: return NULL; } +static void batadv_softif_destroy_finish(struct work_struct *work) +{ + struct batadv_priv *bat_priv; + struct net_device *soft_iface; + + bat_priv = container_of(work, struct batadv_priv, + cleanup_work); + soft_iface = bat_priv-soft_iface; + + batadv_debugfs_del_meshif(soft_iface); + batadv_sysfs_del_meshif(soft_iface); + + rtnl_lock(); + unregister_netdevice(soft_iface); + rtnl_unlock(); +} + void batadv_softif_destroy(struct net_device *soft_iface) { - batadv_debugfs_del_meshif(soft_iface); - batadv_sysfs_del_meshif(soft_iface); + struct batadv_priv *bat_priv = netdev_priv(soft_iface); + batadv_mesh_free(soft_iface); - unregister_netdevice(soft_iface); + + INIT_WORK(bat_priv-cleanup_work, batadv_softif_destroy_finish); + queue_work(batadv_event_workqueue, bat_priv-cleanup_work); } int batadv_softif_is_valid(const struct net_device *net_dev) diff --git a/types.h b/types.h index d8061ac..a9800ee 100644 --- a/types.h +++ b/types.h @@ -63,6 +63,7 @@ struct batadv_hard_iface { struct net_device *soft_iface; struct rcu_head rcu; struct batadv_hard_iface_bat_iv bat_iv; + struct work_struct cleanup_work; }; /** @@ -266,6 +267,7 @@ struct batadv_priv_dat { struct batadv_priv { atomic_t mesh_state; + struct net_device *soft_iface; struct net_device_stats stats; uint64_t __percpu *bat_counters; /* Per cpu counters */ atomic_t aggregated_ogms; /* boolean */ @@ -302,6 +304,7 @@ struct batadv_priv { spinlock_t forw_bat_list_lock; /* protects forw_bat_list */ spinlock_t forw_bcast_list_lock; /* protects forw_bcast_list */ struct delayed_work orig_work; + struct work_struct cleanup_work; struct batadv_hard_iface __rcu *primary_if; /* rcu protected pointer */ struct batadv_algo_ops *bat_algo_ops; #ifdef CONFIG_BATMAN_ADV_BLA -- 1.7.10.4
[B.A.T.M.A.N.] [PATCH] batman-adv: fix NET_ADDR_RANDOM usage for pre-3.9 kernel
Kernel before 3.9 have the NET_ADDR_RANDOM flag which needs to be set. This patch adds the necessary compat change for older kernel. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- compat.h | 13 + 1 file changed, 13 insertions(+) diff --git a/compat.h b/compat.h index 3d03a2f..e21b310 100644 --- a/compat.h +++ b/compat.h @@ -198,6 +198,19 @@ static inline void eth_hw_addr_random(struct net_device *dev) #define prandom_u32() random32() +#define batadv_interface_set_mac_addr(x, y) \ +__batadv_interface_set_mac_addr(struct net_device *dev, void *p);\ +static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) \ +{\ + int ret;\ +\ + ret = __batadv_interface_set_mac_addr(dev, p);\ + if (!ret) \ + dev-addr_assign_type = ~NET_ADDR_RANDOM;\ + return ret;\ +}\ +static int __batadv_interface_set_mac_addr(x, y) + #endif /* KERNEL_VERSION(3, 9, 0) */ #endif /* _NET_BATMAN_ADV_COMPAT_H_ */ -- 1.7.10.4
Re: [B.A.T.M.A.N.] [PATCH] batman-adv: postpone sysfs removal when unregistering
Hey Antonio, On Thu, Jan 10, 2013 at 04:34:47AM +0200, Antonio Quartulli wrote: Hello Simon, thanks a lot for taking care of this and sorry for my very late reply.. no problem, thanks for your review! Il 31.12.2012 01:40 Simon Wunderlich ha scritto: diff --git a/hard-interface.c b/hard-interface.c index f1d37cd..eb3a12d 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -506,6 +506,17 @@ out: return NULL; } +static void batadv_hardif_remove_interface_finish(struct work_struct *work) +{ +struct batadv_hard_iface *hard_iface; + +hard_iface = container_of(work, struct batadv_hard_iface, + cleanup_work); + +batadv_sysfs_del_hardif(hard_iface-hardif_obj); +batadv_hardif_free_ref(hard_iface); +} + static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) { ASSERT_RTNL(); @@ -518,8 +529,9 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) return; hard_iface-if_status = BATADV_IF_TO_BE_REMOVED; -batadv_sysfs_del_hardif(hard_iface-hardif_obj); -batadv_hardif_free_ref(hard_iface); +INIT_WORK(hard_iface-cleanup_work, + batadv_hardif_remove_interface_finish); +queue_work(batadv_event_workqueue, hard_iface-cleanup_work); } why do we need to postpone the invocation of batadv_hardif_remove_interface_finish() ? Is it also creating a possible deadlock? As far as I understood only rtnl_lock() would create the problem, but it is not invoked in batadv_hardif_remove_interface_finish(). It seems I am missing something? batadv_hardif_remove_interface() is called by batadv_hard_if_event(), which is protected rtnl_lock(). You can find an ASSERT_RTNL() there too. As batadv_hardif_remove_interface() then removes sysfs, this could be problematic. Other than this, remember that the INIT_WORK macro does not need to be invoked each and every time you want to enqueue the work. It should be invoked once only (A patch fixing this issue for all the delayed works we have in the code has been recently applied). However it is not a real issue, but we want to keep the code consistent :) Well, the work item is actually only initialized once, before taking the interface down. Then the struct is destroyed, so it can't be called again. But you are right, for consistency I will move the INIT_WORK macros to positions where the structs are initialized. int batadv_softif_is_valid(const struct net_device *net_dev) diff --git a/types.h b/types.h index d8061ac..a9800ee 100644 --- a/types.h +++ b/types.h @@ -63,6 +63,7 @@ struct batadv_hard_iface { struct net_device *soft_iface; struct rcu_head rcu; struct batadv_hard_iface_bat_iv bat_iv; +struct work_struct cleanup_work; }; kernel doc :) The Mareks kernel doc patch wasn't applied at this time, so I didn't bother documenting my single new variable, but will do that in the next revision. :) Thanks, Simon signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCHv2] batman-adv: postpone sysfs removal when unregistering
When processing the unregister notify for a hard interface, removing the sysfs files may lead to a circular deadlock (rtnl mutex - s_active). To overcome this problem, postpone the sysfs removal in a worker. Reported-by: Sasha Levin sasha.le...@oracle.com Reported-by: Sven Eckelmann s...@narfation.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- Changes from PATCHv1: * INIT_WORK() in respective struct initialization functions * kerneldoc Changes from RFCv1: * use work_struct properly, instead of delayed_work * postpone for softifs as well as for hardifs Postponing the sysfs removal for the hardif unregister is easier than other alternatives involving deferring. This should bring us to the same level to the bridge code, which also messes with sysfs in the notifier processing function, and uses rtnl_trylock when called from within sysfs. As far as I could understand the net/core code, only the unregister case is the critical one, so the original bug should hopefully be fixed. --- hard-interface.c | 17 +++-- soft-interface.c | 25 ++--- types.h |6 ++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/hard-interface.c b/hard-interface.c index 78cf350..8b84321 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -457,6 +457,17 @@ out: batadv_hardif_free_ref(primary_if); } +static void batadv_hardif_remove_interface_finish(struct work_struct *work) +{ + struct batadv_hard_iface *hard_iface; + + hard_iface = container_of(work, struct batadv_hard_iface, + cleanup_work); + + batadv_sysfs_del_hardif(hard_iface-hardif_obj); + batadv_hardif_free_ref(hard_iface); +} + static struct batadv_hard_iface * batadv_hardif_add_interface(struct net_device *net_dev) { @@ -484,6 +495,9 @@ batadv_hardif_add_interface(struct net_device *net_dev) hard_iface-soft_iface = NULL; hard_iface-if_status = BATADV_IF_NOT_IN_USE; INIT_LIST_HEAD(hard_iface-list); + INIT_WORK(hard_iface-cleanup_work, + batadv_hardif_remove_interface_finish); + /* extra reference for return */ atomic_set(hard_iface-refcount, 2); @@ -518,8 +532,7 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) return; hard_iface-if_status = BATADV_IF_TO_BE_REMOVED; - batadv_sysfs_del_hardif(hard_iface-hardif_obj); - batadv_hardif_free_ref(hard_iface); + queue_work(batadv_event_workqueue, hard_iface-cleanup_work); } void batadv_hardif_remove_interfaces(void) diff --git a/soft-interface.c b/soft-interface.c index e67e013..b8e46bb 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -449,6 +449,23 @@ static void batadv_interface_setup(struct net_device *dev) memset(priv, 0, sizeof(*priv)); } +static void batadv_softif_destroy_finish(struct work_struct *work) +{ + struct batadv_priv *bat_priv; + struct net_device *soft_iface; + + bat_priv = container_of(work, struct batadv_priv, + cleanup_work); + soft_iface = bat_priv-soft_iface; + + batadv_debugfs_del_meshif(soft_iface); + batadv_sysfs_del_meshif(soft_iface); + + rtnl_lock(); + unregister_netdevice(soft_iface); + rtnl_unlock(); +} + struct net_device *batadv_softif_create(const char *name) { struct net_device *soft_iface; @@ -463,6 +480,8 @@ struct net_device *batadv_softif_create(const char *name) goto out; bat_priv = netdev_priv(soft_iface); + bat_priv-soft_iface = soft_iface; + INIT_WORK(bat_priv-cleanup_work, batadv_softif_destroy_finish); /* batadv_interface_stats() needs to be available as soon as * register_netdevice() has been called @@ -551,10 +570,10 @@ out: void batadv_softif_destroy(struct net_device *soft_iface) { - batadv_debugfs_del_meshif(soft_iface); - batadv_sysfs_del_meshif(soft_iface); + struct batadv_priv *bat_priv = netdev_priv(soft_iface); + batadv_mesh_free(soft_iface); - unregister_netdevice(soft_iface); + queue_work(batadv_event_workqueue, bat_priv-cleanup_work); } int batadv_softif_is_valid(const struct net_device *net_dev) diff --git a/types.h b/types.h index 89ac1fb..4cd87a0 100644 --- a/types.h +++ b/types.h @@ -68,6 +68,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 + * @cleanup_work: work queue callback item for hard interface deinit */ struct batadv_hard_iface { struct list_head list; @@ -81,6 +82,7 @@ struct batadv_hard_iface { struct net_device *soft_iface; struct rcu_head rcu; struct batadv_hard_iface_bat_iv bat_iv; + struct work_struct cleanup_work
[B.A.T.M.A.N.] [PATCHv3] batman-adv: postpone sysfs removal when unregistering
When processing the unregister notify for a hard interface, removing the sysfs files may lead to a circular deadlock (rtnl mutex - s_active). To overcome this problem, postpone the sysfs removal in a worker. Reported-by: Sasha Levin sasha.le...@oracle.com Reported-by: Sven Eckelmann s...@narfation.org Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- Changes from PATCHv2: * kerneldoc for functions Changes from PATCHv1: * INIT_WORK() in respective struct initialization functions * kerneldoc Changes from RFCv1: * use work_struct properly, instead of delayed_work * postpone for softifs as well as for hardifs Postponing the sysfs removal for the hardif unregister is easier than other alternatives involving deferring. This should bring us to the same level to the bridge code, which also messes with sysfs in the notifier processing function, and uses rtnl_trylock when called from within sysfs. As far as I could understand the net/core code, only the unregister case is the critical one, so the original bug should hopefully be fixed. --- hard-interface.c | 24 ++-- soft-interface.c | 32 +--- types.h |6 ++ 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/hard-interface.c b/hard-interface.c index 78cf350..368219e 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -457,6 +457,24 @@ out: batadv_hardif_free_ref(primary_if); } +/** + * batadv_hardif_remove_interface_finish - cleans up the remains of a hardif + * @work: work queue item + * + * Free the parts of the hard interface which can not be removed under + * rtnl lock (to prevent deadlock situations). + */ +static void batadv_hardif_remove_interface_finish(struct work_struct *work) +{ + struct batadv_hard_iface *hard_iface; + + hard_iface = container_of(work, struct batadv_hard_iface, + cleanup_work); + + batadv_sysfs_del_hardif(hard_iface-hardif_obj); + batadv_hardif_free_ref(hard_iface); +} + static struct batadv_hard_iface * batadv_hardif_add_interface(struct net_device *net_dev) { @@ -484,6 +502,9 @@ batadv_hardif_add_interface(struct net_device *net_dev) hard_iface-soft_iface = NULL; hard_iface-if_status = BATADV_IF_NOT_IN_USE; INIT_LIST_HEAD(hard_iface-list); + INIT_WORK(hard_iface-cleanup_work, + batadv_hardif_remove_interface_finish); + /* extra reference for return */ atomic_set(hard_iface-refcount, 2); @@ -518,8 +539,7 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) return; hard_iface-if_status = BATADV_IF_TO_BE_REMOVED; - batadv_sysfs_del_hardif(hard_iface-hardif_obj); - batadv_hardif_free_ref(hard_iface); + queue_work(batadv_event_workqueue, hard_iface-cleanup_work); } void batadv_hardif_remove_interfaces(void) diff --git a/soft-interface.c b/soft-interface.c index e67e013..2711e87 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -449,6 +449,30 @@ static void batadv_interface_setup(struct net_device *dev) memset(priv, 0, sizeof(*priv)); } +/** + * batadv_softif_destroy_finish - cleans up the remains of a softif + * @work: work queue item + * + * Free the parts of the soft interface which can not be removed under + * rtnl lock (to prevent deadlock situations). + */ +static void batadv_softif_destroy_finish(struct work_struct *work) +{ + struct batadv_priv *bat_priv; + struct net_device *soft_iface; + + bat_priv = container_of(work, struct batadv_priv, + cleanup_work); + soft_iface = bat_priv-soft_iface; + + batadv_debugfs_del_meshif(soft_iface); + batadv_sysfs_del_meshif(soft_iface); + + rtnl_lock(); + unregister_netdevice(soft_iface); + rtnl_unlock(); +} + struct net_device *batadv_softif_create(const char *name) { struct net_device *soft_iface; @@ -463,6 +487,8 @@ struct net_device *batadv_softif_create(const char *name) goto out; bat_priv = netdev_priv(soft_iface); + bat_priv-soft_iface = soft_iface; + INIT_WORK(bat_priv-cleanup_work, batadv_softif_destroy_finish); /* batadv_interface_stats() needs to be available as soon as * register_netdevice() has been called @@ -551,10 +577,10 @@ out: void batadv_softif_destroy(struct net_device *soft_iface) { - batadv_debugfs_del_meshif(soft_iface); - batadv_sysfs_del_meshif(soft_iface); + struct batadv_priv *bat_priv = netdev_priv(soft_iface); + batadv_mesh_free(soft_iface); - unregister_netdevice(soft_iface); + queue_work(batadv_event_workqueue, bat_priv-cleanup_work); } int batadv_softif_is_valid(const struct net_device *net_dev) diff --git a/types.h b/types.h index 89ac1fb..4cd87a0 100644 --- a/types.h +++ b/types.h @@ -68,6 +68,7 @@ struct
[B.A.T.M.A.N.] The B.A.T.M.A.N. project endorses the Battle of the Mesh v6
The Wireless Battle of the Mesh[1] is an event that aims to bring together people from across the globe to test the performance of different routing protocols for ad-hoc networks, like Babel, B.A.T.M.A.N., BMX, OLSR, and 802.11s. Of course, new protocols (working on OpenWRT[2]) are always welcome! This year the even will take place from Monday 15th till Sunday 21st of April at the University of Aalborg, Denmark. The B.A.T.M.A.N. project endorses and supports the Battle of the Mesh v6 because of the efforts made by its community to advance the field of wireless mesh networking and foster the development of grassroots community networks. As last year, many members of the B.A.T.M.A.N. team will gather at the event to attend the B.A.T.M.A.N. developer meeting and present, discuss and experiment with new ideas. Above all, we are all looking forward to connect with interesting people at this event! The B.A.T.M.A.N. project will support the event by: * help to promote the event * numerous members of the B.A.T.M.A.N. community have already confirmed their attendance * co-fund travel costs for attendees from South America * give talks about advancement of our community in certain aspects * help setting up testbed for protocol testing Of course, we are available for discussions, ideas, and live tests! Many other communities endorse and support the Wireless Battle of The Mesh v6, an up to date list of the endorsers[3] of the Battlemesh v6 can be found at the main Battlemesh website[4]. Happy routing, The B.A.T.M.A.N. team [1] http://battlemesh.org/ [2] http://openwrt.org/ [3] http://battlemesh.org/Endorsements2013 [4] http://battlemesh.org/BattleMeshV6 signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH] batman-adv: add compat support for the new netlink ops
Hey Antonio, I've tested this (just test, no code review) in my 2.6.32 qemu (Debian squeeze, iproute from wheezy). It generally loads and batctl if add/del seems to work, but there is something weird going on with bridge interaction. After calling the following 3 commands: brctl addbr br0 batctl if add eth0 ip link set dev eth0 master br0 I would expect that eth0 moved from bat0 to br0 (or some error is reported). But what I see is: root@debian:~# batctl if eth0: active br0: not in use root@debian:~# brctl show bridge name bridge id STP enabled interfaces br0 8000. no Even more weird, after doing batctl if del eth0 or batctl if del br0, I don't get any output, but both devices remain in bat0 (according to batctl if). But I do get some output that it's trying to remove eth0: [ 102.788930] batman_adv: bat0: Interface deactivated: eth0 [ 102.788935] batman_adv: bat0: Removing interface: eth0 Note that I don't have this behaviour on my host machine (3.2.0, Debian unstable kernel). So I can't ack this now, although I don't know if the problem is in this patch, in the current batman-adv/netlink implementation or somewhere in 2.6.32 kernel release. Cheers, Simon On Sun, Feb 17, 2013 at 03:43:04PM +0100, Antonio Quartulli wrote: This patches enable the new rtnl ops to compile on kernels starting from 2.6.32 Signed-off-by: Antonio Quartulli or...@autistici.org --- Could not be uglier. *Compile tested only* because linux-2.6.32 does not compile on my laptop compat.h | 40 1 file changed, 40 insertions(+) diff --git a/compat.h b/compat.h index 885e551..de22e2b 100644 --- a/compat.h +++ b/compat.h @@ -71,6 +71,9 @@ static inline void batadv_this_cpu_add(uint64_t *count_ptr, size_t count) put_cpu(); } +#define batadv_softif_destroy_netlink(dev, head) batadv_softif_destroy_netlink(dev) +#define unregister_netdevice_queue(dev, head) unregister_netdevice(dev) + #endif /* KERNEL_VERSION(2, 6, 33) */ @@ -132,6 +135,43 @@ static inline int batadv_param_set_copystring(const char *val, #define kstrtoul strict_strtoul #define kstrtol strict_strtol +#define batadv_softif_slave_add(x, y) \ +batadv_softif_slave_add(struct net_device *dev, struct ifreq *rq, int cmd)\ +{\ + return 0;\ +}\ +static int __batadv_softif_slave_add(x, y) + +#define batadv_softif_slave_del(x, y) \ +__batadv_softif_slave_del(struct net_device *dev, struct net_device *slave_dev);\ +static int batadv_softif_slave_del(struct net_device *dev, struct ifreq *rq, int cmd)\ +{\ + struct batadv_priv *bat_priv = netdev_priv(dev);\ + struct net_device *slave_dev;\ + int ret;\ + if (!capable(CAP_NET_ADMIN))\ + return -EPERM;\ + slave_dev = dev_get_by_index(init_net, rq-ifr_ifindex);\ + if (!dev)\ + return -EINVAL;\ + switch(cmd) {\ + case SIOCBRADDIF:\ + ret = __batadv_softif_slave_add(bat_priv-soft_iface, slave_dev);\ + case SIOCBRDELIF:\ + ret = __batadv_softif_slave_del(bat_priv-soft_iface, slave_dev);\ + default:\ + pr_debug(batman-adv does not support ioctl 0x%x\n, cmd);\ + return -EOPNOTSUPP;\ + }\ +\ + dev_put(slave_dev);\ + return ret;\ +}\ +static int __batadv_softif_slave_del(x, y) + +#define ndo_add_slave ndo_do_ioctl +#define ndo_del_slave ndo_do_ioctl + #endif /* KERNEL_VERSION(2, 6, 39) */ -- 1.8.1.2 signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH] alfred: in recv_alfred_packet() add break at the end of the case block
On Tue, Feb 19, 2013 at 03:36:46PM +0100, Antonio Quartulli wrote: In recv_alfred_packet() a break statement is missing at the end of a case block and the function is returning -1 instead of 0 even if the packet type was known. Add a break to let the function behave correctly. However this bug is harmless at the moment because the return value of the function is not checked anywhere. Signed-off: Antonio Quartulli anto...@open-mesh.com --- recv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/recv.c b/recv.c index 0170695..ffabba5 100644 --- a/recv.c +++ b/recv.c @@ -416,6 +416,7 @@ int recv_alfred_packet(struct globals *globals) case ALFRED_STATUS_TXEND: process_alfred_status_txend(globals, source.sin6_addr, (struct alfred_status_v0 *)packet); + break; Applied (git rev 274133d) Thanks, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH] batman-adv: add compat support for the new netlink ops
On Tue, Feb 19, 2013 at 09:08:44AM +0800, Marek Lindner wrote: Hi Simon, I've tested this (just test, no code review) in my 2.6.32 qemu (Debian squeeze, iproute from wheezy). It generally loads and batctl if add/del seems to work, but there is something weird going on with bridge interaction. After calling the following 3 commands: brctl addbr br0 batctl if add eth0 ip link set dev eth0 master br0 I would expect that eth0 moved from bat0 to br0 (or some error is reported). I feel some confusion here. It could very well be that 2.6.32 did not yet support this kind of interface transfer. You could repeat your test without any of the later patches (just go back to the last stable release) to see what happens. It is very likely that our patches have nothing to do with that. you are right - I've checked 2013.0.0, same behaviour - and now that you mention it, this is all completely independent from batman-adv/netlink. Sorry for reporting stuff like that ... :) Also it seems that batctl (2010.0.0, from debian stable) reports all devices, even if they are not added to batman-adv. It reports them as not in use. This confused me, haven't seen that on other systems (unused devices are just skipped ...). After upding to the wheezy version of batctl (2012.1.0), this effect was gone. Anyway, I've tested a little more and still I see some issues: These are the tests we should do in order to confirm the compat patch in question: * batctl if add $iface some OGMS here batctl if del $iface This works fine, I see OGMs, and the interface is removed cleanly. * ip link add dev bat0 type batadv This works fine. ip link set dev $iface master bat0 This doesn't work. eth0 is not added to batman. To further test, I've added it via batctl. some OGMS here yes (bat0 created with ip, eth0 added using batctl) ip link set dev $iface nomaster has no effect ip link del dev bat0 works. Even more interesting are combinations of those: * batctl if add $iface some OGMS here ip link set dev $iface nomaster ip link del dev bat0 * ip link add dev bat0 type batadv ip link set dev $iface master bat0 some OGMS here batctl if del $iface Some of these combinations are tested above, but I'd suggest we should fix the general case first. :) Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCH] batman-adv: add compat support for the new netlink ops
On Wed, Feb 20, 2013 at 02:26:25PM +0100, Antonio Quartulli wrote: Hi Simon, ip link set dev $iface master bat0 This doesn't work. eth0 is not added to batman. To further test, I've added it via batctl. I'm not sure..but I think this does not work because the set master command does not use ioctl, but rtnl only. Since in this kernel we don't have rtnl for these operations (this is why we have this hacky patch) I did not expect this command to work. OK Even more interesting are combinations of those: * batctl if add $iface some OGMS here ip link set dev $iface nomaster ip link del dev bat0 * ip link add dev bat0 type batadv ip link set dev $iface master bat0 some OGMS here batctl if del $iface Some of these combinations are tested above, but I'd suggest we should fix the general case first. :) what would you like to fix? :) We have just implemented a feature and now we don't have any userspace tool which can exploit it! :-D Well, if we don't expect this command to work then it's fine. Personally I don't care as long as batctl works. :) If there are any other things to test, please let me know. Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: add compat support for the new netlink ops
Hey guys, As requested, just did a quick test again: * batctl if add $iface some OGMS here batctl if del $iface -- still works fine * batctl link add dev bat0 type batadv -- creates the bat0 interface * ip link set dev eth0 master bat0 -- no output, no effect * ip link del dev bat0 -- deletes the bat0 interface Used: Debian stable (squeeze) with original kernel (linux-iamge-2.6.32-5-686, version 2.6.32-46) batctl (2012.1.0-1) and iproute (20120521-3) from wheezy So no difference noticed here. :) I've checked back with iproute package from squeeze (20120521-3): * ip link add dev bat0 type batadv still works * ip link set dev eth0 master bat0 throws an error and does nothing: Error: either dev is duplicate, or master is a garbage. so to summarize: it compiles again, batctl works, and ip at least allows to add the bat0 interface but adding interfaces into a softiface using ip doesn't. Hope that helps! Cheers, Simon Tested-by: Simon Wunderlich s...@hrz.tu-chemnitz.de On Wed, Feb 20, 2013 at 03:57:31PM +0100, Antonio Quartulli wrote: This patches enable the new rtnl ops to compile on kernels starting from 2.6.32 Signed-off-by: Antonio Quartulli or...@autistici.org --- v2: - do not handle ioctl. just return EOPNOTSUPP compat.h | 21 + 1 file changed, 21 insertions(+) diff --git a/compat.h b/compat.h index 425b3d9..23ced4a 100644 --- a/compat.h +++ b/compat.h @@ -71,6 +71,9 @@ static inline void batadv_this_cpu_add(uint64_t *count_ptr, size_t count) put_cpu(); } +#define batadv_softif_destroy_netlink(dev, head) batadv_softif_destroy_netlink(dev) +#define unregister_netdevice_queue(dev, head) unregister_netdevice(dev) + #endif /* KERNEL_VERSION(2, 6, 33) */ @@ -132,6 +135,24 @@ static inline int batadv_param_set_copystring(const char *val, #define kstrtoul strict_strtoul #define kstrtol strict_strtol +#define batadv_softif_slave_add(x, y) \ +batadv_softif_slave_add(struct net_device *dev, struct ifreq *rq, int cmd)\ +{\ + return -EOPNOTSUPP;\ +}\ +static int __attribute__((unused)) __batadv_softif_slave_add(x, y) + +#define batadv_softif_slave_del(x, y) \ +__batadv_softif_slave_del(struct net_device *dev, struct net_device *slave_dev);\ +static int batadv_softif_slave_del(struct net_device *dev, struct ifreq *rq, int cmd)\ +{\ + return -EOPNOTSUPP;\ +}\ +static int __attribute__((unused)) __batadv_softif_slave_del(x, y) + +#define ndo_add_slave ndo_do_ioctl +#define ndo_del_slave ndo_do_ioctl + #endif /* KERNEL_VERSION(2, 6, 39) */ -- 1.8.1.2 signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCH] batman-adv: change compat code to remove sparse warning
The latest compat patch fixing rtnl ops compile errors from 2.6.32 (batman-adv: add compat support for the new netlink ops) fixes the compilation, but leaves some sparse errors: batman-adv/soft-interface.c:573:10: warning: Initializer entry defined twice batman-adv/soft-interface.c:574:10: also defined here This patch uses another approach by moving the initializers in a dummy struct instead. This also removes the sparse errors. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- compat.h | 30 +- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/compat.h b/compat.h index 64244ac..69c3dc2 100644 --- a/compat.h +++ b/compat.h @@ -135,23 +135,19 @@ static inline int batadv_param_set_copystring(const char *val, #define kstrtoul strict_strtoul #define kstrtol strict_strtol -#define batadv_softif_slave_add(x, y) \ -batadv_softif_slave_add(struct net_device *dev, struct ifreq *rq, int cmd)\ -{\ - return -EOPNOTSUPP;\ -}\ -static int __attribute__((unused)) __batadv_softif_slave_add(x, y) - -#define batadv_softif_slave_del(x, y) \ -__batadv_softif_slave_del(struct net_device *dev, struct net_device *slave_dev);\ -static int batadv_softif_slave_del(struct net_device *dev, struct ifreq *rq, int cmd)\ -{\ - return -EOPNOTSUPP;\ -}\ -static int __attribute__((unused)) __batadv_softif_slave_del(x, y) - -#define ndo_add_slave ndo_do_ioctl -#define ndo_del_slave ndo_do_ioctl +/* Hack for removing ndo_add/del_slave at the end of net_device_ops. + * This is somewhat ugly because it requires that ndo_validate_addr + * is at the end of this struct in soft-interface.c. + */ +#define ndo_validate_addr \ + ndo_validate_addr = eth_validate_addr, \ +}; \ +static const struct { \ + void *ndo_validate_addr; \ + void *ndo_add_slave; \ + void *ndo_del_slave; \ +} __attribute__((unused)) __useless_ops1 = { \ + .ndo_validate_addr #endif /* KERNEL_VERSION(2, 6, 39) */ -- 1.7.10.4
Re: [B.A.T.M.A.N.] [PATCHv4] batman-adv: remove interfacing enslaving loop private check
Hi, I've tested this for compatibility on 2.6.32 (Debian stable) in my virtual machine. Marek suggested to use: batctl if add eth0 vconfig add bat0 5 batctl if add bat0.5 and the last command fails with: Error - can't write to file '/sys/class/net/bat0.5/batman_adv/mesh_iface': Operation not permitted which looks good and expected to me. Without the patch, the directory /sys/class/net/bat0.5/batman_adv does not even exist - probably because the check was removed in this patch. Another thing I have tried, which behaves bad with and without this patch: batctl if add eth0 brctl addbr br0 brctl addif br0 bat0 batctl if add br0 (wait a few seconds) rmmod batman-adv First, enslaving br0 into bat0 does not fail, but it makes no sense to enslave bat0 through br0 into bat0 again - we should probably prevent this too. Removing the module crashes the kernel, not always, but pretty reliably (I have the feeling it happens more often after applying this patch, but not sure). Unfortunately I couldn't get any useful backtraces so far, if it fails it usually instantly reboots or hangs without output (this is in kvm with -curses). I've succeeded to get some trace part, it's probably not useful but i've attached it to the bottom anyway [1]. Any thoughts on that? :) Cheers, Simon [1] [ 130.688334] [c1270aaf] ? do_page_fault+0x0/0x307 [ 130.688334] [c101bb73] ? bad_area_nosemaphore+0xa/0xc [ 130.688334] [c126f303] ? error_code+0x73/0x78 [ 130.688334] [c8c60f89] ? br_nf_pre_routing+0x28/0x4a8 [bridge] [ 130.688334] [c11d007b] ? sock_rmalloc+0x1e/0x68 [ 130.688334] [c11d9bee] ? netif_receive_skb+0x2dd/0x3d6 [ 130.688334] [c8c60f89] ? br_nf_pre_routing+0x28/0x4a8 [bridge] [ 130.688334] [c11d9bee] ? netif_receive_skb+0x2dd/0x3d6 [ 130.688334] [c8c5d5b2] ? br_handle_frame_finish+0xd2/0xff [bridge] [ 130.688334] [c8c5d760] ? br_handle_frame+0x181/0x195 [bridge] [ 130.688334] [c11d9bee] ? netif_receive_skb+0x2dd/0x3d6 [ 130.688334] [c8c5d5b2] ? br_handle_frame_finish+0xd2/0xff [bridge] [ 130.688334] [c8c5d760] ? br_handle_frame+0x181/0x195 [bridge] [ 130.688334] [c11d9bee] ? netif_receive_skb+0x2dd/0x3d6 [ 130.688334] [c8c5d5b2] ? br_handle_frame_finish+0xd2/0xff [bridge] [ 130.688334] [c8c5d760] ? br_handle_frame+0x181/0x195 [bridge] [ 130.688334] [c11d9bee] ? netif_receive_skb+0x2dd/0x3d6 [ 130.688334] [c8c5d5b2] ? br_handle_frame_finish+0xd2/0xff [bridge] [ 130.688334] [c8c5d760] ? br_handle_frame+0x181/0x195 [bridge] [ 130.688334] [c11d9bee] ? netif_receive_skb+0x2dd/0x3d6 [ 130.688334] [c8c5d5b2] ? br_handle_frame_finish+0xd2/0xff [bridge] [ 130.688334] [c8c5d760] ? br_handle_frame+0x181/0x195 [bridge] [ 130.688334] [c11d9bee] ? netif_receive_skb+0x2dd/0x3d6 [ 130.688334] [c8c5d5b2] ? br_handle_frame_finish+0xd2/0xff [bridge] On Fri, Mar 01, 2013 at 10:44:47PM +0100, Antonio Quartulli wrote: Now that the new dev_upper API is used, the private check for enslaving loops is not needed anymore as this is performed by the new API itself. Reported-by: Marek Lindner lindner_ma...@yahoo.de Signed-off-by: Antonio Quartulli or...@autistici.org --- v2, v3, v4: - no change to this patch v4: - added compat code compat.c | 53 + compat.h | 5 - hard-interface.c | 43 --- 3 files changed, 57 insertions(+), 44 deletions(-) diff --git a/compat.c b/compat.c index 764878f..da63ea6 100644 --- a/compat.c +++ b/compat.c @@ -24,6 +24,7 @@ #include linux/in.h #include linux/version.h #include main.h +#include soft-interface.h #if LINUX_VERSION_CODE KERNEL_VERSION(3, 0, 0) @@ -85,3 +86,55 @@ void batadv_free_rcu_nc_path(struct rcu_head *rcu) #endif #endif /* KERNEL_VERSION(3, 0, 0) */ + +#if LINUX_VERSION_CODE KERNEL_VERSION(3, 9, 0) + +/** + * batadv_is_on_batman_iface - check if a device is a batman iface descendant + * @net_dev: the device to check + * + * If the user creates any virtual device on top of a batman-adv interface, it + * is important to prevent this new interface to be used to create a new mesh + * network (this behaviour would lead to a batman-over-batman configuration). + * This function recursively checks all the fathers of the device passed as + * argument looking for a batman-adv soft interface. + * + * Returns true if the device is descendant of a batman-adv mesh interface (or + * if it is a batman-adv interface itself), false otherwise + */ +static bool batadv_is_on_batman_iface(const struct net_device *net_dev) +{ + struct
Re: [B.A.T.M.A.N.] [PATCH] batman-adv: change VID semantic in the BLA code
Hey Antonio, On Wed, Apr 03, 2013 at 11:23:59AM +0200, Antonio Quartulli wrote: On Wed, Apr 03, 2013 at 11:17:14AM +0200, Antonio Quartulli wrote: From: Antonio Quartulli anto...@open-mesh.com In order to make batman-adv fully vlan aware later, the semantic used for variables storing the VLAN ID values has to be changed in order to be adapted to the new one which will be used batman-adv wide. That is for the TT change later I guess? Was confused first, because batman-adv is already pretty VLAN aware ... maybe add this as a comment? In particular, the VID has to be an _unsigned_ short int and its 4 MSB will be used as a flag bitfield, while the remaining 12 bits are used to store the real VID value Cc: Simon Wunderlich s...@hrz.tu-chemnitz.de Signed-off-by: Antonio Quartulli anto...@open-mesh.com [cut..] diff --git a/packet.h b/packet.h index a51ccfc..d5464f6 100644 --- a/packet.h +++ b/packet.h @@ -105,6 +105,14 @@ enum batadv_tt_client_flags { BATADV_TT_CLIENT_PENDING = BIT(10), }; +/** + * batadv_vlan_flags - flags for the four MSB of any vlan ID field + * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not + */ +enum batadv_vlan_flags { + BATADV_VLAN_HAS_TAG = BIT(15), +}; + Please put this into main.h or somewhere else as long as it is not sent over the wire. /* claim frame types for the bridge loop avoidance */ enum batadv_bla_claimframe { BATADV_CLAIM_TYPE_CLAIM = 0x00, diff --git a/soft-interface.c b/soft-interface.c index 403b8c4..34597a2 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -154,7 +154,7 @@ static int batadv_interface_tx(struct sk_buff *skb, 0x00, 0x00}; unsigned int header_len = 0; int data_len = skb-len, ret; - short vid __maybe_unused = -1; + unsigned short vid __maybe_unused = BATADV_NO_FLAGS; bool do_bcast = false; uint32_t seqno; unsigned long brd_delay = 1; @@ -303,7 +303,7 @@ void batadv_interface_rx(struct net_device *soft_iface, struct ethhdr *ethhdr; struct vlan_ethhdr *vhdr; struct batadv_header *batadv_header = (struct batadv_header *)skb-data; - short vid __maybe_unused = -1; + unsigned short vid __maybe_unused = BATADV_NO_FLAGS; __be16 ethertype = __constant_htons(ETH_P_BATMAN); bool is_bcast; I just realised that this change is going to break compatibility because we change the menaing of the value that BLA sends over the wire. We must postpone this change to the next (BIG) compat bump. Actually no, it just uses the VID internally, so this is not a problem. See: http://www.open-mesh.org/projects/batman-adv/wiki/Bridge-loop-avoidance-Protocol If there is a VID, it will send the frame in the respective VLAN. The patch looks fine in generally, I have no objections. Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: change VID semantic in the BLA code
Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de Just a small thing which can be adjusted when merging: On Mon, Apr 08, 2013 at 11:17:16AM +0200, Antonio Quartulli wrote: @@ -909,8 +910,9 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, ethhdr); if (ret == 1) batadv_dbg(BATADV_DBG_BLA, bat_priv, -bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n, -ethhdr-h_source, vid, hw_src, hw_dst); +bla_process_claim(): received a claim frame from another group. From: %pM on vid %u ...(hw_src %pM, hw_dst %pM)\n, +ethhdr-h_source, vid, hw_src, +hw_dst); This could be put on one line. Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: print the VID properly
On Thu, Apr 18, 2013 at 03:43:47PM +0200, Antonio Quartulli wrote: From: Antonio Quartulli anto...@open-mesh.com Since the MSB bits of any vid variable are now used for storing flags, print the vid properly by taking the flags away and printing -1 in case of VID representing no real VLAN. Signed-off-by: Antonio Quartulli anto...@open-mesh.com --- bridge_loop_avoidance.c | 57 ++--- main.h | 2 ++ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 16f9239..24a62ac 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -307,7 +307,8 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, */ memcpy(ethhdr-h_source, mac, ETH_ALEN); batadv_dbg(BATADV_DBG_BLA, bat_priv, -bla_send_claim(): CLAIM %pM on vid %hu\n, mac, vid); +bla_send_claim(): CLAIM %pM on vid %hd\n, mac, +BATADV_PRINT_VID(vid)); You've changed all these strings from %d into %hu and now back to %hd? Why not just leave everything at %d and reduce the bloat of these patches? It should not hurt anyone - yes, printing -1 is not pretty but this is developer debug info anyway. And keeping %d instead of %hd should not be a problem as far as I understand. Apart from that, using the BATADV_PRINT_VID macro is a good idea IMHO. Cheers, Simon signature.asc Description: Digital signature
Re: [B.A.T.M.A.N.] [PATCHv3 1/2] batman-adv: change VID semantic in the BLA code
On Fri, Apr 19, 2013 at 06:07:00PM +0200, Antonio Quartulli wrote: From: Antonio Quartulli anto...@open-mesh.com In order to make batman-adv fully vlan aware later, the semantic used for variables storing the VLAN ID values has to be changed in order to be adapted to the new one which will be used batman-adv wide. In particular, the VID has to be an _unsigned_ short int and its 4 MSB will be used as a flag bitfield, while the remaining 12 bits are used to store the real VID value Cc: Simon Wunderlich s...@hrz.tu-chemnitz.de Signed-off-by: Antonio Quartulli anto...@open-mesh.com Acked-by: Simon Wunderlich s...@hrz.tu-chemnitz.de signature.asc Description: Digital signature
[B.A.T.M.A.N.] [PATCH 3/3] batman-adv: remove packed from batadv_ogm_packet
As we decreased the struct size from 26 to 24 byte, we can remove __packed as the compile will not add any more padding. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- packet.h |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packet.h b/packet.h index c90856d..be390ea 100644 --- a/packet.h +++ b/packet.h @@ -178,7 +178,10 @@ struct batadv_ogm_packet { uint8_t reserved; uint8_t tq; __be16 tvlv_len; -} __packed; + /* __packed is not needed as the struct is divisible by 4. +* Add it again if this is ever changed again. +*/ +}; #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet) -- 1.7.10.4
[B.A.T.M.A.N.] [PATCH 2/3] batman-adv: reorder packet types
Reordering the packet type numbers allows us to handle unicast packets in a general way - even if we don't know the specific packet type, we can still forward it. There was already code handling this for a couple of unicast packets, and this is the more generalized version to do that. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- main.c| 28 +++- packet.h | 34 +- routing.c | 19 +++ routing.h |2 ++ 4 files changed, 69 insertions(+), 14 deletions(-) diff --git a/main.c b/main.c index a003067..5c0a8db 100644 --- a/main.c +++ b/main.c @@ -328,18 +328,31 @@ static void batadv_recv_handler_init(void) for (i = 0; i ARRAY_SIZE(batadv_rx_handler); i++) batadv_rx_handler[i] = batadv_recv_unhandled_packet; - /* batman icmp packet */ - batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; + for (i = BATADV_UNICAST_MIN; i = BATADV_UNICAST_MAX; i++) + batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet; + + /* compile time checks for struct member offsets */ + BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10); + BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4); + BUILD_BUG_ON(offsetof(struct batadv_unicast_frag_packet, dest) != 4); + BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4); + BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4); + BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4); + + /* broadcast packet */ + batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; + + /* unicast packets ... */ /* unicast with 4 addresses packet */ batadv_rx_handler[BATADV_UNICAST_4ADDR] = batadv_recv_unicast_packet; /* unicast packet */ batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet; /* fragmented unicast packet */ batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; - /* broadcast packet */ - batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; /* unicast tvlv packet */ batadv_rx_handler[BATADV_UNICAST_TVLV] = batadv_recv_unicast_tvlv; + /* batman icmp packet */ + batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; } int @@ -347,7 +360,12 @@ batadv_recv_handler_register(uint8_t packet_type, int (*recv_handler)(struct sk_buff *, struct batadv_hard_iface *)) { - if (batadv_rx_handler[packet_type] != batadv_recv_unhandled_packet) + int (*curr)(struct sk_buff *, + struct batadv_hard_iface *); + curr = batadv_rx_handler[packet_type]; + + if ((curr != batadv_recv_unhandled_packet) + (curr != batadv_recv_unhandled_unicast_packet)) return -EBUSY; batadv_rx_handler[packet_type] = recv_handler; diff --git a/packet.h b/packet.h index 8ec9cf7..c90856d 100644 --- a/packet.h +++ b/packet.h @@ -22,18 +22,34 @@ /** * enum batadv_packettype - types for batman-adv encapsulated packets + * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV + * @BATADV_BCAST: broadcast packets carrying broadcast payload + * @BATADV_CODED: network coded packets + * + * @BATADV_UNICAST: unicast packets carrying unicast payload traffic + * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original + * payload packet + * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of + * the sender + * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers + * */ + enum batadv_packettype { - BATADV_IV_OGM = 0x01, - BATADV_ICMP = 0x02, - BATADV_UNICAST = 0x03, - BATADV_BCAST= 0x04, - BATADV_VIS = 0x05, - BATADV_UNICAST_FRAG = 0x06, - BATADV_UNICAST_4ADDR= 0x09, - BATADV_CODED= 0x0a, - BATADV_UNICAST_TVLV = 0x0b, + /* 0x00 - 0x3f: local packets or special rules for handling */ + BATADV_IV_OGM = 0x00, + BATADV_BCAST= 0x01, + BATADV_CODED= 0x02, + /* 0x40 - 0x7f: unicast */ +#define BATADV_UNICAST_MIN 0x40 + BATADV_UNICAST = 0x40, + BATADV_UNICAST_FRAG = 0x41, + BATADV_UNICAST_4ADDR= 0x42, + BATADV_ICMP = 0x43, + BATADV_UNICAST_TVLV = 0x44, +#define BATADV_UNICAST_MAX 0x7f + /* 0x80 - 0xff: reserved */ }; /** diff --git a/routing.c b/routing.c index d48f9f9..b63a002 100644 --- a/routing.c +++ b/routing.c @@ -892,6 +892,25 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, return 1; } +int batadv_recv_unhandled_unicast_packet(struct sk_buff
[B.A.T.M.A.N.] [PATCH 0/3] compat bump work
These are some patches for inclusion for the next compat bump: * remove vis server - this functionality will be provided by alfred and associated programs in the future and does not really belong to kernel space * reorder packet types - this allows to route future unicast packets even if not yet implemented * remove __packed from ogm packets to allow better access in compiled code This is based on ordex/compat_bump. Simon Wunderlich (3): batman-adv: remove vis functionality batman-adv: reorder packet types batman-adv: remove packed from batadv_ogm_packet Makefile.kbuild |1 - bat_iv_ogm.c |7 - debugfs.c|9 - hard-interface.c |9 - main.c | 39 ++- packet.h | 56 ++-- routing.c| 70 ++-- routing.h|2 + send.c |1 - soft-interface.c |1 - sysfs.c | 72 - types.h | 82 - vis.c| 935 -- vis.h| 36 --- 14 files changed, 73 insertions(+), 1247 deletions(-) delete mode 100644 vis.c delete mode 100644 vis.h -- 1.7.10.4
[B.A.T.M.A.N.] [PATCH 1/3] batman-adv: remove vis functionality
This is replaced by a userspace program, we don't need this functionality to bloat the kernel. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- Makefile.kbuild |1 - bat_iv_ogm.c |7 - debugfs.c|9 - hard-interface.c |9 - main.c | 11 - packet.h | 17 - routing.c| 51 --- send.c |1 - soft-interface.c |1 - sysfs.c | 72 - types.h | 82 - vis.c| 935 -- vis.h| 36 --- 13 files changed, 1232 deletions(-) delete mode 100644 vis.c delete mode 100644 vis.h diff --git a/Makefile.kbuild b/Makefile.kbuild index 489bb36..8ddbfe6 100644 --- a/Makefile.kbuild +++ b/Makefile.kbuild @@ -38,4 +38,3 @@ batman-adv-y += soft-interface.o batman-adv-y += sysfs.o batman-adv-y += translation-table.o batman-adv-y += unicast.o -batman-adv-y += vis.o diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 2acebad..d6f31ec 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -671,11 +671,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) struct batadv_ogm_packet *batadv_ogm_packet; struct batadv_hard_iface *primary_if; int *ogm_buff_len = hard_iface-bat_iv.ogm_buff_len; - int vis_server; uint32_t seqno; uint16_t tvlv_len = 0; - vis_server = atomic_read(bat_priv-vis_mode); primary_if = batadv_primary_if_get_selected(bat_priv); if (hard_iface == primary_if) { @@ -696,11 +694,6 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) batadv_ogm_packet-seqno = htonl(seqno); atomic_inc(hard_iface-bat_iv.ogm_seqno); - if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC) - batadv_ogm_packet-flags |= BATADV_VIS_SERVER; - else - batadv_ogm_packet-flags = ~BATADV_VIS_SERVER; - batadv_iv_ogm_slide_own_bcast_window(hard_iface); batadv_iv_ogm_queue_add(bat_priv, hard_iface-bat_iv.ogm_buff, hard_iface-bat_iv.ogm_buff_len, hard_iface, 1, diff --git a/debugfs.c b/debugfs.c index f186a55..049a7a2 100644 --- a/debugfs.c +++ b/debugfs.c @@ -28,7 +28,6 @@ #include gateway_common.h #include gateway_client.h #include soft-interface.h -#include vis.h #include icmp_socket.h #include bridge_loop_avoidance.h #include distributed-arp-table.h @@ -300,12 +299,6 @@ static int batadv_transtable_local_open(struct inode *inode, struct file *file) return single_open(file, batadv_tt_local_seq_print_text, net_dev); } -static int batadv_vis_data_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode-i_private; - return single_open(file, batadv_vis_seq_print_text, net_dev); -} - struct batadv_debuginfo { struct attribute attr; const struct file_operations fops; @@ -356,7 +349,6 @@ static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open); #endif static BATADV_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open); -static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); #ifdef CONFIG_BATMAN_ADV_NC static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open); #endif @@ -373,7 +365,6 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { batadv_debuginfo_dat_cache, #endif batadv_debuginfo_transtable_local, - batadv_debuginfo_vis_data, #ifdef CONFIG_BATMAN_ADV_NC batadv_debuginfo_nc_nodes, #endif diff --git a/hard-interface.c b/hard-interface.c index dc4ac29..9746600 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -194,22 +194,13 @@ out: static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv, struct batadv_hard_iface *oldif) { - struct batadv_vis_packet *vis_packet; struct batadv_hard_iface *primary_if; - struct sk_buff *skb; primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out; batadv_dat_init_own_addr(bat_priv, primary_if); - - skb = bat_priv-vis.my_info-skb_packet; - vis_packet = (struct batadv_vis_packet *)skb-data; - memcpy(vis_packet-vis_orig, primary_if-net_dev-dev_addr, ETH_ALEN); - memcpy(vis_packet-sender_orig, - primary_if-net_dev-dev_addr, ETH_ALEN); - batadv_bla_update_orig_address(bat_priv, primary_if, oldif); out: if (primary_if) diff --git a/main.c b/main.c index 2bf3f4e..a003067 100644 --- a/main.c +++ b/main.c @@ -34,7 +34,6 @@ #include distributed-arp-table.h #include unicast.h #include gateway_common.h -#include vis.h #include hash.h #include bat_algo.h #include network-coding.h @@ -107,8 +106,6 @@ int batadv_mesh_init(struct net_device *soft_iface) spin_lock_init(bat_priv-tt.roam_list_lock); spin_lock_init
[B.A.T.M.A.N.] [PATCHv2 0/6] compat bump work
Changes to v1: * move the build check macros in a separate flag * reorder batadv_iv_flags and remove VIS stuff * add check for adding record route info for icmp request/replies This is based on ordex/compat_bump. Simon Wunderlich (6): batman-adv: remove vis functionality batman-adv: add build check macros for packet member offset batman-adv: reorder packet types batman-adv: remove packed from batadv_ogm_packet batman-adv: reorder batadv_iv_flags batman-adv: only add recordroute information to icmp request/reply Makefile.kbuild |1 - bat_iv_ogm.c |7 - debugfs.c|9 - hard-interface.c |9 - main.c | 39 ++- packet.h | 66 ++-- routing.c| 74 ++--- routing.h|2 + send.c |1 - soft-interface.c |1 - sysfs.c | 72 - types.h | 82 - vis.c| 935 -- vis.h| 36 --- 14 files changed, 81 insertions(+), 1253 deletions(-) delete mode 100644 vis.c delete mode 100644 vis.h -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv2 2/6] batman-adv: add build check macros for packet member offset
Since we removed the __packed from most of the packets, we should make sure that the offset generated by the compile are correct for sent/received data. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- main.c |8 1 file changed, 8 insertions(+) diff --git a/main.c b/main.c index a003067..5c76d6f 100644 --- a/main.c +++ b/main.c @@ -328,6 +328,14 @@ static void batadv_recv_handler_init(void) for (i = 0; i ARRAY_SIZE(batadv_rx_handler); i++) batadv_rx_handler[i] = batadv_recv_unhandled_packet; + /* compile time checks for struct member offsets */ + BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10); + BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4); + BUILD_BUG_ON(offsetof(struct batadv_unicast_frag_packet, dest) != 4); + BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4); + BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4); + BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4); + /* batman icmp packet */ batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; /* unicast with 4 addresses packet */ -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv2 6/6] batman-adv: only add recordroute information to icmp request/reply
Adding host information for record route is only required for ICMP requests and replys, and should not be added to just any (future?) packet type. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- routing.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/routing.c b/routing.c index b63a002..eca5ae4 100644 --- a/routing.c +++ b/routing.c @@ -379,7 +379,9 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, icmp_packet = (struct batadv_icmp_packet_rr *)skb-data; /* add record route information if not full */ - if ((hdr_size == sizeof(struct batadv_icmp_packet_rr)) + if ((icmp_packet-msg_type == BATADV_ECHO_REPLY || +icmp_packet-msg_type == BATADV_ECHO_REQUEST) + (hdr_size == sizeof(struct batadv_icmp_packet_rr)) (icmp_packet-rr_cur BATADV_RR_LEN)) { memcpy((icmp_packet-rr[icmp_packet-rr_cur]), ethhdr-h_dest, ETH_ALEN); -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv2 3/6] batman-adv: reorder packet types
Reordering the packet type numbers allows us to handle unicast packets in a general way - even if we don't know the specific packet type, we can still forward it. There was already code handling this for a couple of unicast packets, and this is the more generalized version to do that. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- main.c| 20 +++- packet.h | 34 +- routing.c | 19 +++ routing.h |2 ++ 4 files changed, 61 insertions(+), 14 deletions(-) diff --git a/main.c b/main.c index 5c76d6f..5c0a8db 100644 --- a/main.c +++ b/main.c @@ -328,6 +328,9 @@ static void batadv_recv_handler_init(void) for (i = 0; i ARRAY_SIZE(batadv_rx_handler); i++) batadv_rx_handler[i] = batadv_recv_unhandled_packet; + for (i = BATADV_UNICAST_MIN; i = BATADV_UNICAST_MAX; i++) + batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet; + /* compile time checks for struct member offsets */ BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10); BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4); @@ -336,18 +339,20 @@ static void batadv_recv_handler_init(void) BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4); BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4); - /* batman icmp packet */ - batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; + /* broadcast packet */ + batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; + + /* unicast packets ... */ /* unicast with 4 addresses packet */ batadv_rx_handler[BATADV_UNICAST_4ADDR] = batadv_recv_unicast_packet; /* unicast packet */ batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet; /* fragmented unicast packet */ batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; - /* broadcast packet */ - batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; /* unicast tvlv packet */ batadv_rx_handler[BATADV_UNICAST_TVLV] = batadv_recv_unicast_tvlv; + /* batman icmp packet */ + batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; } int @@ -355,7 +360,12 @@ batadv_recv_handler_register(uint8_t packet_type, int (*recv_handler)(struct sk_buff *, struct batadv_hard_iface *)) { - if (batadv_rx_handler[packet_type] != batadv_recv_unhandled_packet) + int (*curr)(struct sk_buff *, + struct batadv_hard_iface *); + curr = batadv_rx_handler[packet_type]; + + if ((curr != batadv_recv_unhandled_packet) + (curr != batadv_recv_unhandled_unicast_packet)) return -EBUSY; batadv_rx_handler[packet_type] = recv_handler; diff --git a/packet.h b/packet.h index 8ec9cf7..c90856d 100644 --- a/packet.h +++ b/packet.h @@ -22,18 +22,34 @@ /** * enum batadv_packettype - types for batman-adv encapsulated packets + * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV + * @BATADV_BCAST: broadcast packets carrying broadcast payload + * @BATADV_CODED: network coded packets + * + * @BATADV_UNICAST: unicast packets carrying unicast payload traffic + * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original + * payload packet + * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of + * the sender + * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers + * */ + enum batadv_packettype { - BATADV_IV_OGM = 0x01, - BATADV_ICMP = 0x02, - BATADV_UNICAST = 0x03, - BATADV_BCAST= 0x04, - BATADV_VIS = 0x05, - BATADV_UNICAST_FRAG = 0x06, - BATADV_UNICAST_4ADDR= 0x09, - BATADV_CODED= 0x0a, - BATADV_UNICAST_TVLV = 0x0b, + /* 0x00 - 0x3f: local packets or special rules for handling */ + BATADV_IV_OGM = 0x00, + BATADV_BCAST= 0x01, + BATADV_CODED= 0x02, + /* 0x40 - 0x7f: unicast */ +#define BATADV_UNICAST_MIN 0x40 + BATADV_UNICAST = 0x40, + BATADV_UNICAST_FRAG = 0x41, + BATADV_UNICAST_4ADDR= 0x42, + BATADV_ICMP = 0x43, + BATADV_UNICAST_TVLV = 0x44, +#define BATADV_UNICAST_MAX 0x7f + /* 0x80 - 0xff: reserved */ }; /** diff --git a/routing.c b/routing.c index d48f9f9..b63a002 100644 --- a/routing.c +++ b/routing.c @@ -892,6 +892,25 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, return 1; } +int batadv_recv_unhandled_unicast_packet(struct sk_buff *skb, +struct batadv_hard_iface *recv_if) +{ + struct
[B.A.T.M.A.N.] [PATCHv2 4/6] batman-adv: remove packed from batadv_ogm_packet
As we decreased the struct size from 26 to 24 byte, we can remove __packed as the compile will not add any more padding. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- packet.h |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packet.h b/packet.h index c90856d..88d3aa6 100644 --- a/packet.h +++ b/packet.h @@ -178,7 +178,10 @@ struct batadv_ogm_packet { uint8_t reserved; uint8_t tq; __be16 tvlv_len; -} __packed; + /* __packed is not needed as the struct size is divisible by 4, +* and the largest data type in this struct has a size of 4. +*/ +}; #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet) -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv2 5/6] batman-adv: reorder batadv_iv_flags
The vis flag is not needed anymore, and since we do a compat bump we can start with the first bit again Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- packet.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packet.h b/packet.h index 88d3aa6..cda3236 100644 --- a/packet.h +++ b/packet.h @@ -70,10 +70,9 @@ enum batadv_subtype { #define BATADV_COMPAT_VERSION 14 enum batadv_iv_flags { - BATADV_NOT_BEST_NEXT_HOP = BIT(3), - BATADV_PRIMARIES_FIRST_HOP = BIT(4), - BATADV_VIS_SERVER = BIT(5), - BATADV_DIRECTLINK = BIT(6), + BATADV_NOT_BEST_NEXT_HOP = BIT(0), + BATADV_PRIMARIES_FIRST_HOP = BIT(1), + BATADV_DIRECTLINK = BIT(2), }; /* ICMP message types */ @@ -167,11 +166,12 @@ struct batadv_header { /** * struct batadv_ogm_packet - ogm (routing protocol) packet * @header: common batman packet header + * @flags: contains routing relevant flags - see enum batadv_iv_flags * @tvlv_len: length of tvlv data following the ogm header */ struct batadv_ogm_packet { struct batadv_header header; - uint8_t flags;/* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ + uint8_t flags; __be32 seqno; uint8_t orig[ETH_ALEN]; uint8_t prev_sender[ETH_ALEN]; -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv2 1/6] batman-adv: remove vis functionality
This is replaced by a userspace program, we don't need this functionality to bloat the kernel. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- Makefile.kbuild |1 - bat_iv_ogm.c |7 - debugfs.c|9 - hard-interface.c |9 - main.c | 11 - packet.h | 17 - routing.c| 51 --- send.c |1 - soft-interface.c |1 - sysfs.c | 72 - types.h | 82 - vis.c| 935 -- vis.h| 36 --- 13 files changed, 1232 deletions(-) delete mode 100644 vis.c delete mode 100644 vis.h diff --git a/Makefile.kbuild b/Makefile.kbuild index 489bb36..8ddbfe6 100644 --- a/Makefile.kbuild +++ b/Makefile.kbuild @@ -38,4 +38,3 @@ batman-adv-y += soft-interface.o batman-adv-y += sysfs.o batman-adv-y += translation-table.o batman-adv-y += unicast.o -batman-adv-y += vis.o diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 2acebad..d6f31ec 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -671,11 +671,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) struct batadv_ogm_packet *batadv_ogm_packet; struct batadv_hard_iface *primary_if; int *ogm_buff_len = hard_iface-bat_iv.ogm_buff_len; - int vis_server; uint32_t seqno; uint16_t tvlv_len = 0; - vis_server = atomic_read(bat_priv-vis_mode); primary_if = batadv_primary_if_get_selected(bat_priv); if (hard_iface == primary_if) { @@ -696,11 +694,6 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) batadv_ogm_packet-seqno = htonl(seqno); atomic_inc(hard_iface-bat_iv.ogm_seqno); - if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC) - batadv_ogm_packet-flags |= BATADV_VIS_SERVER; - else - batadv_ogm_packet-flags = ~BATADV_VIS_SERVER; - batadv_iv_ogm_slide_own_bcast_window(hard_iface); batadv_iv_ogm_queue_add(bat_priv, hard_iface-bat_iv.ogm_buff, hard_iface-bat_iv.ogm_buff_len, hard_iface, 1, diff --git a/debugfs.c b/debugfs.c index f186a55..049a7a2 100644 --- a/debugfs.c +++ b/debugfs.c @@ -28,7 +28,6 @@ #include gateway_common.h #include gateway_client.h #include soft-interface.h -#include vis.h #include icmp_socket.h #include bridge_loop_avoidance.h #include distributed-arp-table.h @@ -300,12 +299,6 @@ static int batadv_transtable_local_open(struct inode *inode, struct file *file) return single_open(file, batadv_tt_local_seq_print_text, net_dev); } -static int batadv_vis_data_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode-i_private; - return single_open(file, batadv_vis_seq_print_text, net_dev); -} - struct batadv_debuginfo { struct attribute attr; const struct file_operations fops; @@ -356,7 +349,6 @@ static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open); #endif static BATADV_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open); -static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); #ifdef CONFIG_BATMAN_ADV_NC static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open); #endif @@ -373,7 +365,6 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { batadv_debuginfo_dat_cache, #endif batadv_debuginfo_transtable_local, - batadv_debuginfo_vis_data, #ifdef CONFIG_BATMAN_ADV_NC batadv_debuginfo_nc_nodes, #endif diff --git a/hard-interface.c b/hard-interface.c index dc4ac29..9746600 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -194,22 +194,13 @@ out: static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv, struct batadv_hard_iface *oldif) { - struct batadv_vis_packet *vis_packet; struct batadv_hard_iface *primary_if; - struct sk_buff *skb; primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out; batadv_dat_init_own_addr(bat_priv, primary_if); - - skb = bat_priv-vis.my_info-skb_packet; - vis_packet = (struct batadv_vis_packet *)skb-data; - memcpy(vis_packet-vis_orig, primary_if-net_dev-dev_addr, ETH_ALEN); - memcpy(vis_packet-sender_orig, - primary_if-net_dev-dev_addr, ETH_ALEN); - batadv_bla_update_orig_address(bat_priv, primary_if, oldif); out: if (primary_if) diff --git a/main.c b/main.c index 2bf3f4e..a003067 100644 --- a/main.c +++ b/main.c @@ -34,7 +34,6 @@ #include distributed-arp-table.h #include unicast.h #include gateway_common.h -#include vis.h #include hash.h #include bat_algo.h #include network-coding.h @@ -107,8 +106,6 @@ int batadv_mesh_init(struct net_device *soft_iface) spin_lock_init(bat_priv-tt.roam_list_lock); spin_lock_init
[B.A.T.M.A.N.] [PATCHv3 4/6] batman-adv: remove packed from batadv_ogm_packet
As we decreased the struct size from 26 to 24 byte, we can remove __packed as the compiler will not add any more padding. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- packet.h |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packet.h b/packet.h index c90856d..88d3aa6 100644 --- a/packet.h +++ b/packet.h @@ -178,7 +178,10 @@ struct batadv_ogm_packet { uint8_t reserved; uint8_t tq; __be16 tvlv_len; -} __packed; + /* __packed is not needed as the struct size is divisible by 4, +* and the largest data type in this struct has a size of 4. +*/ +}; #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet) -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv3 2/6] batman-adv: add build check macros for packet member offset
Since we removed the __packed from most of the packets, we should make sure that the offset generated by the compiler are correct for sent/received data. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- main.c |8 1 file changed, 8 insertions(+) diff --git a/main.c b/main.c index a003067..5c76d6f 100644 --- a/main.c +++ b/main.c @@ -328,6 +328,14 @@ static void batadv_recv_handler_init(void) for (i = 0; i ARRAY_SIZE(batadv_rx_handler); i++) batadv_rx_handler[i] = batadv_recv_unhandled_packet; + /* compile time checks for struct member offsets */ + BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10); + BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4); + BUILD_BUG_ON(offsetof(struct batadv_unicast_frag_packet, dest) != 4); + BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4); + BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4); + BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4); + /* batman icmp packet */ batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; /* unicast with 4 addresses packet */ -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv3 5/6] batman-adv: reorder batadv_iv_flags
The vis flag is not needed anymore, and since we do a compat bump we can start with the first bit again Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- packet.h | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packet.h b/packet.h index 88d3aa6..8cc9068 100644 --- a/packet.h +++ b/packet.h @@ -69,11 +69,19 @@ enum batadv_subtype { /* this file is included by batctl which needs these defines */ #define BATADV_COMPAT_VERSION 14 +/** + * enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets + * @BATADV_NOT_BEST_NEXT_HOP: flag is set when ogm packet is forwarded and was + * previously received from someone else than the best neighbor. + * @BATADV_PRIMARIES_FIRST_HOP: flag is set when the primary interface address + * is used, and the packet travels its first hop. + * @BATADV_DIRECTLINK: flag is for the first hop or if rebroadcasted from a + * one hop neighbor on the interface where it was originally received. + */ enum batadv_iv_flags { - BATADV_NOT_BEST_NEXT_HOP = BIT(3), - BATADV_PRIMARIES_FIRST_HOP = BIT(4), - BATADV_VIS_SERVER = BIT(5), - BATADV_DIRECTLINK = BIT(6), + BATADV_NOT_BEST_NEXT_HOP = BIT(0), + BATADV_PRIMARIES_FIRST_HOP = BIT(1), + BATADV_DIRECTLINK = BIT(2), }; /* ICMP message types */ @@ -167,11 +175,12 @@ struct batadv_header { /** * struct batadv_ogm_packet - ogm (routing protocol) packet * @header: common batman packet header + * @flags: contains routing relevant flags - see enum batadv_iv_flags * @tvlv_len: length of tvlv data following the ogm header */ struct batadv_ogm_packet { struct batadv_header header; - uint8_t flags;/* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ + uint8_t flags; __be32 seqno; uint8_t orig[ETH_ALEN]; uint8_t prev_sender[ETH_ALEN]; -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv3 3/6] batman-adv: reorder packet types
Reordering the packet type numbers allows us to handle unicast packets in a general way - even if we don't know the specific packet type, we can still forward it. There was already code handling this for a couple of unicast packets, and this is the more generalized version to do that. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- main.c| 20 +++- packet.h | 34 +- routing.c | 28 routing.h |2 ++ 4 files changed, 70 insertions(+), 14 deletions(-) diff --git a/main.c b/main.c index 5c76d6f..5c0a8db 100644 --- a/main.c +++ b/main.c @@ -328,6 +328,9 @@ static void batadv_recv_handler_init(void) for (i = 0; i ARRAY_SIZE(batadv_rx_handler); i++) batadv_rx_handler[i] = batadv_recv_unhandled_packet; + for (i = BATADV_UNICAST_MIN; i = BATADV_UNICAST_MAX; i++) + batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet; + /* compile time checks for struct member offsets */ BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10); BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4); @@ -336,18 +339,20 @@ static void batadv_recv_handler_init(void) BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4); BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4); - /* batman icmp packet */ - batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; + /* broadcast packet */ + batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; + + /* unicast packets ... */ /* unicast with 4 addresses packet */ batadv_rx_handler[BATADV_UNICAST_4ADDR] = batadv_recv_unicast_packet; /* unicast packet */ batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet; /* fragmented unicast packet */ batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; - /* broadcast packet */ - batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; /* unicast tvlv packet */ batadv_rx_handler[BATADV_UNICAST_TVLV] = batadv_recv_unicast_tvlv; + /* batman icmp packet */ + batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; } int @@ -355,7 +360,12 @@ batadv_recv_handler_register(uint8_t packet_type, int (*recv_handler)(struct sk_buff *, struct batadv_hard_iface *)) { - if (batadv_rx_handler[packet_type] != batadv_recv_unhandled_packet) + int (*curr)(struct sk_buff *, + struct batadv_hard_iface *); + curr = batadv_rx_handler[packet_type]; + + if ((curr != batadv_recv_unhandled_packet) + (curr != batadv_recv_unhandled_unicast_packet)) return -EBUSY; batadv_rx_handler[packet_type] = recv_handler; diff --git a/packet.h b/packet.h index 8ec9cf7..c90856d 100644 --- a/packet.h +++ b/packet.h @@ -22,18 +22,34 @@ /** * enum batadv_packettype - types for batman-adv encapsulated packets + * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV + * @BATADV_BCAST: broadcast packets carrying broadcast payload + * @BATADV_CODED: network coded packets + * + * @BATADV_UNICAST: unicast packets carrying unicast payload traffic + * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original + * payload packet + * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of + * the sender + * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers + * */ + enum batadv_packettype { - BATADV_IV_OGM = 0x01, - BATADV_ICMP = 0x02, - BATADV_UNICAST = 0x03, - BATADV_BCAST= 0x04, - BATADV_VIS = 0x05, - BATADV_UNICAST_FRAG = 0x06, - BATADV_UNICAST_4ADDR= 0x09, - BATADV_CODED= 0x0a, - BATADV_UNICAST_TVLV = 0x0b, + /* 0x00 - 0x3f: local packets or special rules for handling */ + BATADV_IV_OGM = 0x00, + BATADV_BCAST= 0x01, + BATADV_CODED= 0x02, + /* 0x40 - 0x7f: unicast */ +#define BATADV_UNICAST_MIN 0x40 + BATADV_UNICAST = 0x40, + BATADV_UNICAST_FRAG = 0x41, + BATADV_UNICAST_4ADDR= 0x42, + BATADV_ICMP = 0x43, + BATADV_UNICAST_TVLV = 0x44, +#define BATADV_UNICAST_MAX 0x7f + /* 0x80 - 0xff: reserved */ }; /** diff --git a/routing.c b/routing.c index d48f9f9..cb219e1 100644 --- a/routing.c +++ b/routing.c @@ -892,6 +892,34 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, return 1; } +/** + * batadv_recv_unhandled_unicast_packet - receive and process packets which + * are in the unicast number space but not yet known
[B.A.T.M.A.N.] [PATCHv3 6/6] batman-adv: only add recordroute information to icmp request/reply
Adding host information for record route is only required for ICMP requests and replys, and should not be added to just any (future?) packet type. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- routing.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/routing.c b/routing.c index cb219e1..b2efdbc 100644 --- a/routing.c +++ b/routing.c @@ -379,7 +379,9 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, icmp_packet = (struct batadv_icmp_packet_rr *)skb-data; /* add record route information if not full */ - if ((hdr_size == sizeof(struct batadv_icmp_packet_rr)) + if ((icmp_packet-msg_type == BATADV_ECHO_REPLY || +icmp_packet-msg_type == BATADV_ECHO_REQUEST) + (hdr_size == sizeof(struct batadv_icmp_packet_rr)) (icmp_packet-rr_cur BATADV_RR_LEN)) { memcpy((icmp_packet-rr[icmp_packet-rr_cur]), ethhdr-h_dest, ETH_ALEN); -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv3 0/6] compat bum work
Changes to v2: * add some kernel doc * fix typos in commit messages Simon Wunderlich (6): batman-adv: remove vis functionality batman-adv: add build check macros for packet member offset batman-adv: reorder packet types batman-adv: remove packed from batadv_ogm_packet batman-adv: reorder batadv_iv_flags batman-adv: only add recordroute information to icmp request/reply Makefile.kbuild |1 - bat_iv_ogm.c |7 - debugfs.c|9 - hard-interface.c |9 - main.c | 39 ++- packet.h | 75 +++-- routing.c| 83 ++--- routing.h|2 + send.c |1 - soft-interface.c |1 - sysfs.c | 72 - types.h | 82 - vis.c| 935 -- vis.h| 36 --- 14 files changed, 99 insertions(+), 1253 deletions(-) delete mode 100644 vis.c delete mode 100644 vis.h -- 1.7.10.4
[B.A.T.M.A.N.] [PATCHv3 1/6] batman-adv: remove vis functionality
This is replaced by a userspace program, we don't need this functionality to bloat the kernel. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- Makefile.kbuild |1 - bat_iv_ogm.c |7 - debugfs.c|9 - hard-interface.c |9 - main.c | 11 - packet.h | 17 - routing.c| 51 --- send.c |1 - soft-interface.c |1 - sysfs.c | 72 - types.h | 82 - vis.c| 935 -- vis.h| 36 --- 13 files changed, 1232 deletions(-) delete mode 100644 vis.c delete mode 100644 vis.h diff --git a/Makefile.kbuild b/Makefile.kbuild index 489bb36..8ddbfe6 100644 --- a/Makefile.kbuild +++ b/Makefile.kbuild @@ -38,4 +38,3 @@ batman-adv-y += soft-interface.o batman-adv-y += sysfs.o batman-adv-y += translation-table.o batman-adv-y += unicast.o -batman-adv-y += vis.o diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 2acebad..d6f31ec 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -671,11 +671,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) struct batadv_ogm_packet *batadv_ogm_packet; struct batadv_hard_iface *primary_if; int *ogm_buff_len = hard_iface-bat_iv.ogm_buff_len; - int vis_server; uint32_t seqno; uint16_t tvlv_len = 0; - vis_server = atomic_read(bat_priv-vis_mode); primary_if = batadv_primary_if_get_selected(bat_priv); if (hard_iface == primary_if) { @@ -696,11 +694,6 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) batadv_ogm_packet-seqno = htonl(seqno); atomic_inc(hard_iface-bat_iv.ogm_seqno); - if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC) - batadv_ogm_packet-flags |= BATADV_VIS_SERVER; - else - batadv_ogm_packet-flags = ~BATADV_VIS_SERVER; - batadv_iv_ogm_slide_own_bcast_window(hard_iface); batadv_iv_ogm_queue_add(bat_priv, hard_iface-bat_iv.ogm_buff, hard_iface-bat_iv.ogm_buff_len, hard_iface, 1, diff --git a/debugfs.c b/debugfs.c index f186a55..049a7a2 100644 --- a/debugfs.c +++ b/debugfs.c @@ -28,7 +28,6 @@ #include gateway_common.h #include gateway_client.h #include soft-interface.h -#include vis.h #include icmp_socket.h #include bridge_loop_avoidance.h #include distributed-arp-table.h @@ -300,12 +299,6 @@ static int batadv_transtable_local_open(struct inode *inode, struct file *file) return single_open(file, batadv_tt_local_seq_print_text, net_dev); } -static int batadv_vis_data_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode-i_private; - return single_open(file, batadv_vis_seq_print_text, net_dev); -} - struct batadv_debuginfo { struct attribute attr; const struct file_operations fops; @@ -356,7 +349,6 @@ static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open); #endif static BATADV_DEBUGINFO(transtable_local, S_IRUGO, batadv_transtable_local_open); -static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); #ifdef CONFIG_BATMAN_ADV_NC static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open); #endif @@ -373,7 +365,6 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { batadv_debuginfo_dat_cache, #endif batadv_debuginfo_transtable_local, - batadv_debuginfo_vis_data, #ifdef CONFIG_BATMAN_ADV_NC batadv_debuginfo_nc_nodes, #endif diff --git a/hard-interface.c b/hard-interface.c index dc4ac29..9746600 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -194,22 +194,13 @@ out: static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv, struct batadv_hard_iface *oldif) { - struct batadv_vis_packet *vis_packet; struct batadv_hard_iface *primary_if; - struct sk_buff *skb; primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) goto out; batadv_dat_init_own_addr(bat_priv, primary_if); - - skb = bat_priv-vis.my_info-skb_packet; - vis_packet = (struct batadv_vis_packet *)skb-data; - memcpy(vis_packet-vis_orig, primary_if-net_dev-dev_addr, ETH_ALEN); - memcpy(vis_packet-sender_orig, - primary_if-net_dev-dev_addr, ETH_ALEN); - batadv_bla_update_orig_address(bat_priv, primary_if, oldif); out: if (primary_if) diff --git a/main.c b/main.c index 2bf3f4e..a003067 100644 --- a/main.c +++ b/main.c @@ -34,7 +34,6 @@ #include distributed-arp-table.h #include unicast.h #include gateway_common.h -#include vis.h #include hash.h #include bat_algo.h #include network-coding.h @@ -107,8 +106,6 @@ int batadv_mesh_init(struct net_device *soft_iface) spin_lock_init(bat_priv-tt.roam_list_lock); spin_lock_init
[B.A.T.M.A.N.] [PATCHv4 4/6] batman-adv: remove packed from batadv_ogm_packet
As we decreased the struct size from 26 to 24 byte, we can remove __packed as the compiler will not add any more padding. Signed-off-by: Simon Wunderlich s...@hrz.tu-chemnitz.de --- packet.h |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packet.h b/packet.h index 6d3b943..6982d16 100644 --- a/packet.h +++ b/packet.h @@ -178,7 +178,10 @@ struct batadv_ogm_packet { uint8_t reserved; uint8_t tq; __be16 tvlv_len; -} __packed; + /* __packed is not needed as the struct size is divisible by 4, +* and the largest data type in this struct has a size of 4. +*/ +}; #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet) -- 1.7.10.4