Skip to contentSkip to conversation

vis packet format

B.A.T.M.A.N. Linus Lüssing 3 participants 5 messages Mar 3, 2010 – Mar 4, 2010

lore
Share & tools
lore
#0 lore raw

Hi,

Marek and I have been chatting a little about the buggy vis raw output yesterday. And there was either the option to sort the mixed list on the receiving vis server or on the sender already. For the second option there was also the idea of changing the vis packet format accordingly to also save some more overhead. Currently, we're sending a mixed list of (src,dest,quality) with the struct vis_info_entry. Instead, the idea for a new format was the following:

vis_packet.entries = number of source interfaces of this originator followed by tuples
{src,num_neighbours,num_neighbours x {dest,quality}}
for each source interface of a node.

Additionally, the first entry shall be the one of the primary interface already.

I've made a little prototype patch, see the attachment for this (it applies on top of Simon's last vis_refcount additions patch). I haven't done the more difficult part yet, the sorting and structuring that has to be done in the generate_vis_packet() instead now.

If you think this kind of format is ok, then I'd like to have some more opinions of how to deal with the structuring in the generate_vis_packet(). My idea so far is, to create num_if lists and malloc and copy the information for every neighbour of an originator during the locked orig_hash iteration and freeing as well as packing those list after realeasing the lock. Or, if the mallocs might take too much time for being used so often during the lock, to allocate num_ifs buffers with the maximum vis_packet size (currently 1000B) for each interface batman is using before entering the spinlock. And I guess, that anyway num_ifs would have to be made an atomic_t, right?

Cheers, Linus

PS: Could someone explain, why the recv_list_add() is being done with a sender_orig instead of vis_orig? Because if using vis_orig, then we could get rid of the sender_orig as well because of having this information in the ethernet header already.

packet.h +0 -1
diff -u batman-adv-git2/packet.h batman-adv-git/packet.h
@@ -92,5 +92,4 @@
 	uint8_t  vis_orig[6];	 /* originator that informs about its
 				  * neighbors */
 	uint8_t  target_orig[6]; /* who should receive this packet */
-	uint8_t  sender_orig[6]; /* who sent or rebroadcasted this packet */
 } __attribute__((packed));
proc.c +1 -17
diff -u batman-adv-git2/proc.c batman-adv-git/proc.c
@@ -368,10 +368,6 @@
 {
 	HASHIT(hashit);
 	struct vis_info *info;
-	struct vis_info_entry *entries;
-	HLIST_HEAD(vis_if_list);
-	int i;
-	char tmp_addr_str[ETH_STR_LEN];
 	unsigned long flags;
 	int vis_server = atomic_read(&vis_mode);
 
@@ -386,19 +382,7 @@
 	spin_lock_irqsave(&vis_hash_lock, flags);
 	while (hash_iterate(vis_hash, &hashit)) {
 		info = hashit.bucket->data;
-		entries = (struct vis_info_entry *)
-			((char *)info + sizeof(struct vis_info));
-		addr_to_string(tmp_addr_str, info->packet.vis_orig);
-		seq_printf(seq, "%s,", tmp_addr_str);
-
-		for (i = 0; i < info->packet.entries; i++) {
-			proc_vis_read_entry(seq, &entries[i], &vis_if_list,
-					    info->packet.vis_orig);
-		}
-
-		/* add primary/secondary records */
-		proc_vis_read_prim_sec(seq, &vis_if_list);
-		seq_printf(seq, "\n");
+		proc_vis_read_entry(seq, info);
 	}
 	spin_unlock_irqrestore(&vis_hash_lock, flags);
 
routing.c +1 -1
diff -u batman-adv-git2/routing.c batman-adv-git/routing.c
@@ -954,7 +954,7 @@
 	if (is_my_mac(vis_packet->vis_orig))
 		return NET_RX_DROP;
 
-	if (is_my_mac(vis_packet->sender_orig))
+	if (is_my_mac(ethhdr->h_source))
 		return NET_RX_DROP;
 
 	switch (vis_packet->vis_type) {
vis.c +52 -54

145 lines not on this page · raw message

vis.h +10 -8
diff -u batman-adv-git2/vis.h batman-adv-git/vis.h
@@ -35,9 +35,13 @@
 	/* vis_info may follow here*/
 } __attribute__((packed));
 
-struct vis_info_entry {
+struct vis_if_entry {
 	uint8_t  src[ETH_ALEN];
-	uint8_t  dest[ETH_ALEN];
+	uint8_t  num_neigh;
+} __attribute__((packed));
+
+struct vis_neigh_entry {
+	uint8_t  dest[ETH_ALEN]; /* neighbor's interface mac */
 	uint8_t  quality;	/* quality = 0 means HNA */
 } __attribute__((packed));
 
@@ -49,12 +53,10 @@
 extern struct hashtable_t *vis_hash;
 extern spinlock_t vis_hash_lock;
 
-void proc_vis_read_entry(struct seq_file *seq,
-				struct vis_info_entry *entry,
-				struct hlist_head *if_list,
-				uint8_t *vis_orig);
-void proc_vis_read_prim_sec(struct seq_file *seq,
-			    struct hlist_head *if_list);
+void proc_vis_read_prim_sec(struct seq_file *seq, struct vis_info *info);
+void proc_vis_read_neigh(struct seq_file *seq, struct vis_if_entry *if_entry);
+void proc_vis_read_entry(struct seq_file *seq, struct vis_info *info);
+
 void receive_server_sync_packet(struct vis_packet *vis_packet,
 				int vis_info_len);
 void receive_client_update_packet(struct vis_packet *vis_packet,
#1 lore raw

And maybe the last explanation about the "buggy vis output" wasn't clear enough. With the current vis raw output we're loosing the information with _which_ interface we are seeing another nodes's interface (currently we are always starting a vis raw output line with the primary interface mac instead of the according interface's mac).

Cheers, Linus

#2 lore raw
In reply to Linus Lüssing
Quoted 7 lines · Linus L??ssing

Hi,

Marek and I have been chatting a little about the buggy vis raw output yesterday. And there was either the option to sort the mixed list on the receiving vis server or on the sender already. For the second option there was also the idea of changing the vis packet format accordingly to also save some more overhead.

A comment about the mainline development process. Changes which are clearly bug fixes we should be able to get merged into the -rc kernels at any time. Changes which look like development work have to wait until the next merge window.

This vis problem about it showing the wrong interface will be in -rc1. It would be nice to get it fixed. We are more likely to get such a fix accepted if it is small and looks like a bug fix. I expect it will get rejected if it is big and looks like development work.

So can we develop two fixes? Something small and simple for -rc1 and an optimizing fix which will go into linux-next and then into mainline during the next merge window?

Andrew

#3 lore raw

Hi Andrew,

Ah, okay, that makes sense. I was wondering about how the compatibility version would have to bedone anyway in such a case :D. So it should probably also be a general thing to better not change the compat-version during one merge window, right?

I'll try to make too patches now then, that's fine.

Cheers, Linus

Quoted 25 lines · Andrew Lunn
Quoted 7 lines · Linus L??ssing

Hi,

Marek and I have been chatting a little about the buggy vis raw output yesterday. And there was either the option to sort the mixed list on the receiving vis server or on the sender already. For the second option there was also the idea of changing the vis packet format accordingly to also save some more overhead.

A comment about the mainline development process. Changes which are clearly bug fixes we should be able to get merged into the -rc kernels at any time. Changes which look like development work have to wait until the next merge window.

This vis problem about it showing the wrong interface will be in -rc1. It would be nice to get it fixed. We are more likely to get such a fix accepted if it is small and looks like a bug fix. I expect it will get rejected if it is big and looks like development work.

So can we develop two fixes? Something small and simple for -rc1 and an optimizing fix which will go into linux-next and then into mainline during the next merge window?

Andrew

#4 lore raw

Hi,

Quoted 4 lines

Ah, okay, that makes sense. I was wondering about how the compatibility version would have to bedone anyway in such a case :D. So it should probably also be a general thing to better not change the compat-version during one merge window, right?

if you change the vis packet format we will need to increase the compat version, hence it will go into the development branch (gearing towards 0.3 at the moment). If your patch maintains compatibility it can be merged into the maint branch.

Regards,
Marek