Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29b67c39 authored by David S. Miller's avatar David S. Miller
Browse files

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
parents 58308451 18c68d59
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -88,14 +88,3 @@ Contact: Marek Lindner <lindner_marek@yahoo.de>
Description:
                Defines the routing procotol this mesh instance
                uses to find the optimal paths through the mesh.

What:           /sys/class/net/<mesh_iface>/mesh/vis_mode
Date:           May 2010
Contact:        Marek Lindner <lindner_marek@yahoo.de>
Description:
                Each batman node only maintains information about its
                own local neighborhood, therefore generating graphs
                showing the topology of the entire mesh is not easily
                feasible without having a central instance to collect
                the local topologies from all nodes. This file allows
                to activate the collecting (server) mode.
+2 −48
Original line number Diff line number Diff line
@@ -69,8 +69,7 @@ folder:
# aggregated_ogms        gw_bandwidth           log_level
# ap_isolation           gw_mode                orig_interval
# bonding                gw_sel_class           routing_algo
# bridge_loop_avoidance  hop_penalty            vis_mode
# fragmentation
# bridge_loop_avoidance  hop_penalty            fragmentation


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
# gateways            socket              vis_data
# gateways            socket

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
-----------------

+2 −2
Original line number Diff line number Diff line
@@ -1652,9 +1652,9 @@ F: drivers/video/backlight/
F:	include/linux/backlight.h

BATMAN ADVANCED
M:	Marek Lindner <lindner_marek@yahoo.de>
M:	Marek Lindner <mareklindner@neomailbox.ch>
M:	Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
M:	Antonio Quartulli <ordex@autistici.org>
M:	Antonio Quartulli <antonio@meshcoding.com>
L:	b.a.t.m.a.n@lists.open-mesh.org
W:	http://www.open-mesh.org/
S:	Maintained
+0 −1
Original line number Diff line number Diff line
@@ -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
+35 −76
Original line number Diff line number Diff line
@@ -135,9 +135,8 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
	batadv_ogm_packet->header.version = BATADV_COMPAT_VERSION;
	batadv_ogm_packet->header.ttl = 2;
	batadv_ogm_packet->flags = BATADV_NO_FLAGS;
	batadv_ogm_packet->reserved = 0;
	batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
	batadv_ogm_packet->tt_num_changes = 0;
	batadv_ogm_packet->ttvn = 0;

	res = 0;

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

/* is there another aggregated packet here? */
static int batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len,
				     int tt_num_changes)
				     __be16 tvlv_len)
{
	int next_buff_pos = 0;

	next_buff_pos += buff_pos + BATADV_OGM_HLEN;
	next_buff_pos += batadv_tt_len(tt_num_changes);
	next_buff_pos += ntohs(tvlv_len);

	return (next_buff_pos <= packet_len) &&
	       (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,

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

		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
			   "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
			   "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s) on interface %s [%pM]\n",
			   fwd_str, (packet_num > 0 ? "aggregated " : ""),
			   batadv_ogm_packet->orig,
			   ntohl(batadv_ogm_packet->seqno),
			   batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl,
			   (batadv_ogm_packet->flags & BATADV_DIRECTLINK ?
			    "on" : "off"),
			   batadv_ogm_packet->ttvn, hard_iface->net_dev->name,
			   hard_iface->net_dev->name,
			   hard_iface->net_dev->dev_addr);

		buff_pos += BATADV_OGM_HLEN;
		buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);
		buff_pos += ntohs(batadv_ogm_packet->tvlv_len);
		packet_num++;
		packet_pos = forw_packet->skb->data + buff_pos;
		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,
				  struct batadv_hard_iface *if_incoming)
{
	struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
	uint8_t tt_num_changes;
	uint16_t tvlv_len;

	if (batadv_ogm_packet->header.ttl <= 1) {
		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,
			return;
	}

	tt_num_changes = batadv_ogm_packet->tt_num_changes;
	tvlv_len = ntohs(batadv_ogm_packet->tvlv_len);

	batadv_ogm_packet->header.ttl--;
	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,
		batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK;

	batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batadv_ogm_packet,
				BATADV_OGM_HLEN + batadv_tt_len(tt_num_changes),
				BATADV_OGM_HLEN + tvlv_len,
				if_incoming, 0, batadv_iv_ogm_fwd_send_time());
}

@@ -688,43 +687,29 @@ 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, tt_num_changes = 0;
	uint32_t seqno;
	uint8_t bandwidth;
	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)
		tt_num_changes = batadv_tt_append_diff(bat_priv, ogm_buff,
	if (hard_iface == primary_if) {
		/* tt changes have to be committed before the tvlv data is
		 * appended as it may alter the tt tvlv container
		 */
		batadv_tt_local_commit_changes(bat_priv);
		tvlv_len = batadv_tvlv_container_ogm_append(bat_priv, ogm_buff,
							    ogm_buff_len,
							    BATADV_OGM_HLEN);
	}

	batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
	batadv_ogm_packet->tvlv_len = htons(tvlv_len);

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

	batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
	batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
	if (tt_num_changes >= 0)
		batadv_ogm_packet->tt_num_changes = tt_num_changes;

	if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC)
		batadv_ogm_packet->flags |= BATADV_VIS_SERVER;
	else
		batadv_ogm_packet->flags &= ~BATADV_VIS_SERVER;

	if (hard_iface == primary_if &&
	    atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER) {
		bandwidth = (uint8_t)atomic_read(&bat_priv->gw_bandwidth);
		batadv_ogm_packet->gw_flags = bandwidth;
	} else {
		batadv_ogm_packet->gw_flags = BATADV_NO_FLAGS;
	}

	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,
@@ -798,7 +783,6 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,

	rcu_read_unlock();

	orig_node->flags = batadv_ogm_packet->flags;
	neigh_node->last_seen = jiffies;

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

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

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

		if (sum_orig >= sum_neigh)
			goto update_tt;
			goto out;
	}

	batadv_update_route(bat_priv, orig_node, neigh_node);

update_tt:
	/* I have to check for transtable changes only if the OGM has been
	 * sent through a primary interface
	 */
	if (((batadv_ogm_packet->orig != ethhdr->h_source) &&
	     (batadv_ogm_packet->header.ttl > 2)) ||
	    (batadv_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP))
		batadv_tt_update_orig(bat_priv, orig_node, tt_buff,
				      batadv_ogm_packet->tt_num_changes,
				      batadv_ogm_packet->ttvn,
				      ntohs(batadv_ogm_packet->tt_crc));

	if (orig_node->gw_flags != batadv_ogm_packet->gw_flags)
		batadv_gw_node_update(bat_priv, orig_node,
				      batadv_ogm_packet->gw_flags);

	orig_node->gw_flags = batadv_ogm_packet->gw_flags;

	/* restart gateway selection if fast or late switching was enabled */
	if ((orig_node->gw_flags) &&
	    (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_CLIENT) &&
	    (atomic_read(&bat_priv->gw_sel_class) > 2))
		batadv_gw_check_election(bat_priv, orig_node);

	goto out;

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

	batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
		   "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",
		   "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",
		   ethhdr->h_source, if_incoming->net_dev->name,
		   if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig,
		   batadv_ogm_packet->prev_sender,
		   ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->ttvn,
		   ntohs(batadv_ogm_packet->tt_crc),
		   batadv_ogm_packet->tt_num_changes, batadv_ogm_packet->tq,
		   ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->tq,
		   batadv_ogm_packet->header.ttl,
		   batadv_ogm_packet->header.version, has_directlink_flag);

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

	batadv_tvlv_ogm_receive(bat_priv, batadv_ogm_packet, orig_node);

	/* if sender is a direct neighbor the sender mac equals
	 * originator mac
	 */
@@ -1350,9 +1309,9 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
	struct batadv_ogm_packet *batadv_ogm_packet;
	struct ethhdr *ethhdr;
	int buff_pos = 0, packet_len;
	unsigned char *tt_buff, *packet_buff;
	bool ret;
	unsigned char *tvlv_buff, *packet_buff;
	uint8_t *packet_pos;
	bool ret;

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

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

		batadv_iv_ogm_process(ethhdr, batadv_ogm_packet, tt_buff,
				      if_incoming);
		batadv_iv_ogm_process(ethhdr, batadv_ogm_packet,
				      tvlv_buff, if_incoming);

		buff_pos += BATADV_OGM_HLEN;
		buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);
		buff_pos += ntohs(batadv_ogm_packet->tvlv_len);

		packet_pos = packet_buff + buff_pos;
		batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
Loading