Skip to content

Commit 29b67c3

Browse files
committed
Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge
Included changes: - update emails for A. Quartulli and M. Lindner in MAINTAINERS - switch to the next on-the-wire protocol version - introduce the T(ype) V(ersion) L(ength) V(alue) framework - adjust the existing components to make them use the new TVLV code - make the TT component use CRC32 instead of CRC16 - totally remove the VIS functionality (has been moved to userspace) - reorder packet types and flags - add static checks on packet format - remove __packed from batadv_ogm_packet
2 parents 5830845 + 18c68d5 commit 29b67c3

29 files changed

+1968
-2133
lines changed

Documentation/ABI/testing/sysfs-class-net-mesh

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,3 @@ Contact: Marek Lindner <[email protected]>
8888
Description:
8989
Defines the routing procotol this mesh instance
9090
uses to find the optimal paths through the mesh.
91-
92-
What: /sys/class/net/<mesh_iface>/mesh/vis_mode
93-
Date: May 2010
94-
Contact: Marek Lindner <[email protected]>
95-
Description:
96-
Each batman node only maintains information about its
97-
own local neighborhood, therefore generating graphs
98-
showing the topology of the entire mesh is not easily
99-
feasible without having a central instance to collect
100-
the local topologies from all nodes. This file allows
101-
to activate the collecting (server) mode.

Documentation/networking/batman-adv.txt

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,15 @@ folder:
6969
# aggregated_ogms gw_bandwidth log_level
7070
# ap_isolation gw_mode orig_interval
7171
# bonding gw_sel_class routing_algo
72-
# bridge_loop_avoidance hop_penalty vis_mode
73-
# fragmentation
72+
# bridge_loop_avoidance hop_penalty fragmentation
7473

7574

7675
There is a special folder for debugging information:
7776

7877
# ls /sys/kernel/debug/batman_adv/bat0/
7978
# bla_backbone_table log transtable_global
8079
# bla_claim_table originators transtable_local
81-
# gateways socket vis_data
80+
# gateways socket
8281

8382
Some of the files contain all sort of status information regard-
8483
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.
127126
# ifconfig eth0 0.0.0.0
128127

129128

130-
VISUALIZATION
131-
-------------
132-
133-
If you want topology visualization, at least one mesh node must
134-
be configured as VIS-server:
135-
136-
# echo "server" > /sys/class/net/bat0/mesh/vis_mode
137-
138-
Each node is either configured as "server" or as "client" (de-
139-
fault: "client"). Clients send their topology data to the server
140-
next to them, and server synchronize with other servers. If there
141-
is no server configured (default) within the mesh, no topology
142-
information will be transmitted. With these "synchronizing
143-
servers", there can be 1 or more vis servers sharing the same (or
144-
at least very similar) data.
145-
146-
When configured as server, you can get a topology snapshot of
147-
your mesh:
148-
149-
# cat /sys/kernel/debug/batman_adv/bat0/vis_data
150-
151-
This raw output is intended to be easily parsable and convertable
152-
with other tools. Have a look at the batctl README if you want a
153-
vis output in dot or json format for instance and how those out-
154-
puts could then be visualised in an image.
155-
156-
The raw format consists of comma separated values per entry where
157-
each entry is giving information about a certain source inter-
158-
face. Each entry can/has to have the following values:
159-
-> "mac" - mac address of an originator's source interface
160-
(each line begins with it)
161-
-> "TQ mac value" - src mac's link quality towards mac address
162-
of a neighbor originator's interface which
163-
is being used for routing
164-
-> "TT mac" - TT announced by source mac
165-
-> "PRIMARY" - this is a primary interface
166-
-> "SEC mac" - secondary mac address of source
167-
(requires preceding PRIMARY)
168-
169-
The TQ value has a range from 4 to 255 with 255 being the best.
170-
The TT entries are showing which hosts are connected to the mesh
171-
via bat0 or being bridged into the mesh network. The PRIMARY/SEC
172-
values are only applied on primary interfaces
173-
174-
175129
LOGGING/DEBUGGING
176130
-----------------
177131

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,9 +1652,9 @@ F: drivers/video/backlight/
16521652
F: include/linux/backlight.h
16531653

16541654
BATMAN ADVANCED
1655-
M: Marek Lindner <[email protected]>
1655+
M: Marek Lindner <[email protected]>
16561656
M: Simon Wunderlich <[email protected]>
1657-
M: Antonio Quartulli <[email protected]>
1657+
M: Antonio Quartulli <[email protected]>
16581658
16591659
W: http://www.open-mesh.org/
16601660
S: Maintained

net/batman-adv/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@ batman-adv-y += soft-interface.o
3838
batman-adv-y += sysfs.o
3939
batman-adv-y += translation-table.o
4040
batman-adv-y += unicast.o
41-
batman-adv-y += vis.o

net/batman-adv/bat_iv_ogm.c

Lines changed: 35 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
135135
batadv_ogm_packet->header.version = BATADV_COMPAT_VERSION;
136136
batadv_ogm_packet->header.ttl = 2;
137137
batadv_ogm_packet->flags = BATADV_NO_FLAGS;
138+
batadv_ogm_packet->reserved = 0;
138139
batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
139-
batadv_ogm_packet->tt_num_changes = 0;
140-
batadv_ogm_packet->ttvn = 0;
141140

142141
res = 0;
143142

@@ -207,12 +206,12 @@ static uint8_t batadv_hop_penalty(uint8_t tq,
207206

208207
/* is there another aggregated packet here? */
209208
static int batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len,
210-
int tt_num_changes)
209+
__be16 tvlv_len)
211210
{
212211
int next_buff_pos = 0;
213212

214213
next_buff_pos += buff_pos + BATADV_OGM_HLEN;
215-
next_buff_pos += batadv_tt_len(tt_num_changes);
214+
next_buff_pos += ntohs(tvlv_len);
216215

217216
return (next_buff_pos <= packet_len) &&
218217
(next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES);
@@ -240,7 +239,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
240239

241240
/* adjust all flags and log packets */
242241
while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
243-
batadv_ogm_packet->tt_num_changes)) {
242+
batadv_ogm_packet->tvlv_len)) {
244243
/* we might have aggregated direct link packets with an
245244
* ordinary base packet
246245
*/
@@ -256,18 +255,18 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
256255
fwd_str = "Sending own";
257256

258257
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
259-
"%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
258+
"%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s) on interface %s [%pM]\n",
260259
fwd_str, (packet_num > 0 ? "aggregated " : ""),
261260
batadv_ogm_packet->orig,
262261
ntohl(batadv_ogm_packet->seqno),
263262
batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl,
264263
(batadv_ogm_packet->flags & BATADV_DIRECTLINK ?
265264
"on" : "off"),
266-
batadv_ogm_packet->ttvn, hard_iface->net_dev->name,
265+
hard_iface->net_dev->name,
267266
hard_iface->net_dev->dev_addr);
268267

269268
buff_pos += BATADV_OGM_HLEN;
270-
buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);
269+
buff_pos += ntohs(batadv_ogm_packet->tvlv_len);
271270
packet_num++;
272271
packet_pos = forw_packet->skb->data + buff_pos;
273272
batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
@@ -601,7 +600,7 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
601600
struct batadv_hard_iface *if_incoming)
602601
{
603602
struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
604-
uint8_t tt_num_changes;
603+
uint16_t tvlv_len;
605604

606605
if (batadv_ogm_packet->header.ttl <= 1) {
607606
batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "ttl exceeded\n");
@@ -621,7 +620,7 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
621620
return;
622621
}
623622

624-
tt_num_changes = batadv_ogm_packet->tt_num_changes;
623+
tvlv_len = ntohs(batadv_ogm_packet->tvlv_len);
625624

626625
batadv_ogm_packet->header.ttl--;
627626
memcpy(batadv_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);
@@ -642,7 +641,7 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
642641
batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK;
643642

644643
batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batadv_ogm_packet,
645-
BATADV_OGM_HLEN + batadv_tt_len(tt_num_changes),
644+
BATADV_OGM_HLEN + tvlv_len,
646645
if_incoming, 0, batadv_iv_ogm_fwd_send_time());
647646
}
648647

@@ -688,43 +687,29 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
688687
struct batadv_ogm_packet *batadv_ogm_packet;
689688
struct batadv_hard_iface *primary_if;
690689
int *ogm_buff_len = &hard_iface->bat_iv.ogm_buff_len;
691-
int vis_server, tt_num_changes = 0;
692690
uint32_t seqno;
693-
uint8_t bandwidth;
691+
uint16_t tvlv_len = 0;
694692

695-
vis_server = atomic_read(&bat_priv->vis_mode);
696693
primary_if = batadv_primary_if_get_selected(bat_priv);
697694

698-
if (hard_iface == primary_if)
699-
tt_num_changes = batadv_tt_append_diff(bat_priv, ogm_buff,
700-
ogm_buff_len,
701-
BATADV_OGM_HLEN);
695+
if (hard_iface == primary_if) {
696+
/* tt changes have to be committed before the tvlv data is
697+
* appended as it may alter the tt tvlv container
698+
*/
699+
batadv_tt_local_commit_changes(bat_priv);
700+
tvlv_len = batadv_tvlv_container_ogm_append(bat_priv, ogm_buff,
701+
ogm_buff_len,
702+
BATADV_OGM_HLEN);
703+
}
702704

703705
batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
706+
batadv_ogm_packet->tvlv_len = htons(tvlv_len);
704707

705708
/* change sequence number to network order */
706709
seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
707710
batadv_ogm_packet->seqno = htonl(seqno);
708711
atomic_inc(&hard_iface->bat_iv.ogm_seqno);
709712

710-
batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
711-
batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
712-
if (tt_num_changes >= 0)
713-
batadv_ogm_packet->tt_num_changes = tt_num_changes;
714-
715-
if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC)
716-
batadv_ogm_packet->flags |= BATADV_VIS_SERVER;
717-
else
718-
batadv_ogm_packet->flags &= ~BATADV_VIS_SERVER;
719-
720-
if (hard_iface == primary_if &&
721-
atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER) {
722-
bandwidth = (uint8_t)atomic_read(&bat_priv->gw_bandwidth);
723-
batadv_ogm_packet->gw_flags = bandwidth;
724-
} else {
725-
batadv_ogm_packet->gw_flags = BATADV_NO_FLAGS;
726-
}
727-
728713
batadv_iv_ogm_slide_own_bcast_window(hard_iface);
729714
batadv_iv_ogm_queue_add(bat_priv, hard_iface->bat_iv.ogm_buff,
730715
hard_iface->bat_iv.ogm_buff_len, hard_iface, 1,
@@ -798,7 +783,6 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
798783

799784
rcu_read_unlock();
800785

801-
orig_node->flags = batadv_ogm_packet->flags;
802786
neigh_node->last_seen = jiffies;
803787

804788
spin_lock_bh(&neigh_node->lq_update_lock);
@@ -820,11 +804,11 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
820804
*/
821805
router = batadv_orig_node_get_router(orig_node);
822806
if (router == neigh_node)
823-
goto update_tt;
807+
goto out;
824808

825809
/* if this neighbor does not offer a better TQ we won't consider it */
826810
if (router && (router->tq_avg > neigh_node->tq_avg))
827-
goto update_tt;
811+
goto out;
828812

829813
/* if the TQ is the same and the link not more symmetric we
830814
* won't consider it either
@@ -843,35 +827,10 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
843827
spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
844828

845829
if (sum_orig >= sum_neigh)
846-
goto update_tt;
830+
goto out;
847831
}
848832

849833
batadv_update_route(bat_priv, orig_node, neigh_node);
850-
851-
update_tt:
852-
/* I have to check for transtable changes only if the OGM has been
853-
* sent through a primary interface
854-
*/
855-
if (((batadv_ogm_packet->orig != ethhdr->h_source) &&
856-
(batadv_ogm_packet->header.ttl > 2)) ||
857-
(batadv_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP))
858-
batadv_tt_update_orig(bat_priv, orig_node, tt_buff,
859-
batadv_ogm_packet->tt_num_changes,
860-
batadv_ogm_packet->ttvn,
861-
ntohs(batadv_ogm_packet->tt_crc));
862-
863-
if (orig_node->gw_flags != batadv_ogm_packet->gw_flags)
864-
batadv_gw_node_update(bat_priv, orig_node,
865-
batadv_ogm_packet->gw_flags);
866-
867-
orig_node->gw_flags = batadv_ogm_packet->gw_flags;
868-
869-
/* restart gateway selection if fast or late switching was enabled */
870-
if ((orig_node->gw_flags) &&
871-
(atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_CLIENT) &&
872-
(atomic_read(&bat_priv->gw_sel_class) > 2))
873-
batadv_gw_check_election(bat_priv, orig_node);
874-
875834
goto out;
876835

877836
unlock:
@@ -1122,13 +1081,11 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
11221081
is_single_hop_neigh = true;
11231082

11241083
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1125-
"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %#.4x, changes %u, tq %d, TTL %d, V %d, IDF %d)\n",
1084+
"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, tq %d, TTL %d, V %d, IDF %d)\n",
11261085
ethhdr->h_source, if_incoming->net_dev->name,
11271086
if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig,
11281087
batadv_ogm_packet->prev_sender,
1129-
ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->ttvn,
1130-
ntohs(batadv_ogm_packet->tt_crc),
1131-
batadv_ogm_packet->tt_num_changes, batadv_ogm_packet->tq,
1088+
ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->tq,
11321089
batadv_ogm_packet->header.ttl,
11331090
batadv_ogm_packet->header.version, has_directlink_flag);
11341091

@@ -1254,6 +1211,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
12541211
goto out;
12551212
}
12561213

1214+
batadv_tvlv_ogm_receive(bat_priv, batadv_ogm_packet, orig_node);
1215+
12571216
/* if sender is a direct neighbor the sender mac equals
12581217
* originator mac
12591218
*/
@@ -1350,9 +1309,9 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
13501309
struct batadv_ogm_packet *batadv_ogm_packet;
13511310
struct ethhdr *ethhdr;
13521311
int buff_pos = 0, packet_len;
1353-
unsigned char *tt_buff, *packet_buff;
1354-
bool ret;
1312+
unsigned char *tvlv_buff, *packet_buff;
13551313
uint8_t *packet_pos;
1314+
bool ret;
13561315

13571316
ret = batadv_check_management_packet(skb, if_incoming, BATADV_OGM_HLEN);
13581317
if (!ret)
@@ -1375,14 +1334,14 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
13751334

13761335
/* unpack the aggregated packets and process them one by one */
13771336
while (batadv_iv_ogm_aggr_packet(buff_pos, packet_len,
1378-
batadv_ogm_packet->tt_num_changes)) {
1379-
tt_buff = packet_buff + buff_pos + BATADV_OGM_HLEN;
1337+
batadv_ogm_packet->tvlv_len)) {
1338+
tvlv_buff = packet_buff + buff_pos + BATADV_OGM_HLEN;
13801339

1381-
batadv_iv_ogm_process(ethhdr, batadv_ogm_packet, tt_buff,
1382-
if_incoming);
1340+
batadv_iv_ogm_process(ethhdr, batadv_ogm_packet,
1341+
tvlv_buff, if_incoming);
13831342

13841343
buff_pos += BATADV_OGM_HLEN;
1385-
buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);
1344+
buff_pos += ntohs(batadv_ogm_packet->tvlv_len);
13861345

13871346
packet_pos = packet_buff + buff_pos;
13881347
batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;

net/batman-adv/debugfs.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "gateway_common.h"
2929
#include "gateway_client.h"
3030
#include "soft-interface.h"
31-
#include "vis.h"
3231
#include "icmp_socket.h"
3332
#include "bridge_loop_avoidance.h"
3433
#include "distributed-arp-table.h"
@@ -300,12 +299,6 @@ static int batadv_transtable_local_open(struct inode *inode, struct file *file)
300299
return single_open(file, batadv_tt_local_seq_print_text, net_dev);
301300
}
302301

303-
static int batadv_vis_data_open(struct inode *inode, struct file *file)
304-
{
305-
struct net_device *net_dev = (struct net_device *)inode->i_private;
306-
return single_open(file, batadv_vis_seq_print_text, net_dev);
307-
}
308-
309302
struct batadv_debuginfo {
310303
struct attribute attr;
311304
const struct file_operations fops;
@@ -356,7 +349,6 @@ static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open);
356349
#endif
357350
static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
358351
batadv_transtable_local_open);
359-
static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open);
360352
#ifdef CONFIG_BATMAN_ADV_NC
361353
static BATADV_DEBUGINFO(nc_nodes, S_IRUGO, batadv_nc_nodes_open);
362354
#endif
@@ -373,7 +365,6 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
373365
&batadv_debuginfo_dat_cache,
374366
#endif
375367
&batadv_debuginfo_transtable_local,
376-
&batadv_debuginfo_vis_data,
377368
#ifdef CONFIG_BATMAN_ADV_NC
378369
&batadv_debuginfo_nc_nodes,
379370
#endif

0 commit comments

Comments
 (0)