[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
[B.A.T.M.A.N.] [PATCHv4 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 2a14722..6b2cfb5 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.] [PATCHv4 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 --- routing.h|2 - send.c |1 - soft-interface.c |1 - sysfs.c | 72 - types.h | 82 - vis.c| 936 -- vis.h| 36 --- 14 files changed, 1235 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 5e41f7b..5432573 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -669,11 +669,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) { @@ -694,11 +692,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 f257a5b..2a14722 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);
[B.A.T.M.A.N.] [PATCHv4 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 6b2cfb5..8a8fd00 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 0ce4867..6d3b943 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 e3040a2..3f5802c 100644 --- a/routing.c +++ b/routing.c @@ -895,6 +895,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 to the
[B.A.T.M.A.N.] [PATCHv4 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 3f5802c..7c372f1 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.] [PATCHv4 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 6982d16..222d106 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 15 +/** + * 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.] [PATCHv5 1/6] batman-adv: remove vis functionality
From: Simon Wunderlich s...@hrz.tu-chemnitz.de 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 --- Changes from v4: * remove orig_node-flags (only needed for vis flags) * remove vis from README * remove vis from sysfs description file * remove vis defines in main.h --- Makefile.kbuild |1 - README | 50 +-- bat_iv_ogm.c |8 - debugfs.c|9 - hard-interface.c |9 - main.c | 11 - main.h |2 - packet.h | 17 - routing.c| 51 --- routing.h|2 - send.c |1 - soft-interface.c |1 - sysfs-class-net-mesh | 11 - sysfs.c | 72 types.h | 84 - vis.c| 936 -- vis.h| 36 -- 17 files changed, 2 insertions(+), 1299 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/README b/README index c1d8204..897d1f4 100644 --- a/README +++ b/README @@ -69,8 +69,7 @@ folder: # aggregated_ogmsgw_bandwidth log_level # ap_isolation gw_modeorig_interval # bondinggw_sel_class routing_algo -# bridge_loop_avoidance hop_penaltyvis_mode -# fragmentation +# bridge_loop_avoidance hop_penaltyfragmentation There is a special folder for debugging information: @@ -78,7 +77,7 @@ There is a special folder for debugging information: # ls /sys/kernel/debug/batman_adv/bat0/ # bla_backbone_table log transtable_global # bla_claim_table originators transtable_local -# gatewayssocket vis_data +# gatewayssocket Some of the files contain all sort of status information regard- ing the mesh network. For example, you can view the table of @@ -127,51 +126,6 @@ ously assigned to interfaces now used by batman advanced, e.g. # ifconfig eth0 0.0.0.0 -VISUALIZATION -- - -If you want topology visualization, at least one mesh node must -be configured as VIS-server: - -# echo server /sys/class/net/bat0/mesh/vis_mode - -Each node is either configured as server or as client (de- -fault: client). Clients send their topology data to the server -next to them, and server synchronize with other servers. If there -is no server configured (default) within the mesh, no topology -information will be transmitted. With these synchronizing -servers, there can be 1 or more vis servers sharing the same (or -at least very similar) data. - -When configured as server, you can get a topology snapshot of -your mesh: - -# cat /sys/kernel/debug/batman_adv/bat0/vis_data - -This raw output is intended to be easily parsable and convertable -with other tools. Have a look at the batctl README if you want a -vis output in dot or json format for instance and how those out- -puts could then be visualised in an image. - -The raw format consists of comma separated values per entry where -each entry is giving information about a certain source inter- -face. Each entry can/has to have the following values: -- mac - mac address of an originator's source interface - (each line begins with it) -- TQ mac value - src mac's link quality towards mac address - of a neighbor originator's interface which - is being used for routing -- TT mac - TT announced by source mac -- PRIMARY - this is a primary interface -- SEC mac - secondary mac address of source - (requires preceding PRIMARY) - -The TQ value has a range from 4 to 255 with 255 being the best. -The TT entries are showing which hosts are connected to the mesh -via bat0 or being bridged into the mesh network. The PRIMARY/SEC -values are only applied on primary interfaces - - LOGGING/DEBUGGING - diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 5e41f7b..8d87f87 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -669,11 +669,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) { @@ -694,11 +692,6 @@ static void
Re: [B.A.T.M.A.N.] [PATCHv5 1/6] batman-adv: remove vis functionality
On Thursday, April 25, 2013 17:57:42 1366879046-24507-2-git-send-email- s...@hrz.tu-chemnitz.de wrote: diff --git a/packet.h b/packet.h index aee6b96..0ce4867 100644 --- a/packet.h +++ b/packet.h @@ -69,12 +69,6 @@ enum batadv_icmp_packettype { BATADV_PARAMETER_PROBLEM = 12, }; -/* vis defines */ -enum batadv_vis_packettype { - BATADV_VIS_TYPE_SERVER_SYNC = 0, - BATADV_VIS_TYPE_CLIENT_UPDATE = 1, -}; - /* fragmentation defines */ enum batadv_unicast_frag_flags { BATADV_UNI_FRAG_HEAD = BIT(0), @@ -257,17 +251,6 @@ struct batadv_bcast_packet { #pragma pack() -struct batadv_vis_packet { - struct batadv_header header; - uint8_t vis_type; /* which type of vis-participant sent this? */ - __be32 seqno; /* sequence number */ - uint8_t entries;/* number of entries behind this struct */ - uint8_t reserved; - uint8_t vis_orig[ETH_ALEN];/* originator reporting its neighbors */ - uint8_t target_orig[ETH_ALEN]; /* who should receive this packet */ - uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */ -}; - /** * struct batadv_coded_packet - network coded packet * @header: common batman packet header and ttl of first included packet The corresponding batadv_iv flag (BATADV_VIS_SERVER) should be removed as well. The same is true for the packet type (BATADV_VIS). What about the batctl patch ? Cheers, Marek