Skip to contentSkip to conversation

Odd use of %14pM in net/batman-adv/distributed-arp-table.c

PATCH In review Joe Perches 3 participants 6 messages Jun 13, 2017 – Jun 14, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

An output mac address is 17 bytes

         1

12345678901234567
00:11:22:33:44:55

but in net/batman-adv/distributed-arp-table.c

int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset) {
[...]

			seq_printf(seq, " * %15pI4 %14pM %4i %6i:%02i\n",
				   &dat_entry->ip, dat_entry->mac_addr,
				   batadv_print_vid(dat_entry->vid),
				   last_seen_mins, last_seen_secs);

%14pM is odd as this should not emit the last byte of the mac address. So given the example above, it would output 00:11:22:33:44

Is that what's really desired?

If so, I'd suggest using something more obvious like %5phC

maintainer
#1 lore raw
Quoted 1 line · On Dienstag, 13. Juni 2017 14:51:41 CEST Joe Perches wrote:

An output mac address is 17 bytes

[...]

Quoted 1 line

but in net/batman-adv/distributed-arp-table.c

[...]

Quoted 3 lines

%14pM is odd as this should not emit the last byte of the mac address. So given the example above, it would output 00:11:22:33:44

[...]

I completely agree too the "wrong length" part. It is currently not omitting the last byte:

Distributed ARP Table (bat0):
IPv4 MAC VID last-seen
* 10.204.28.206 e8:50:8b:8b:71:8d -1 4:05
* 10.204.77.54 6c:2f:2c:43:70:eb -1 1:56
* 10.25.21.138 ec:1f:72:c3:15:51 -1 4:21
* 10.204.27.220 08:70:45:8c:ac:db -1 2:32
* 192.168.42.22 64:66:b3:bb:8e:ef -1 0:18
* 10.204.64.1 02:ba:7a:df:04:00 -1 0:00
* 192.168.42.27 e8:de:27:f9:0f:48 -1 0:32

But it definitely also not "correct". I see something similar in the IV OGM code:

net/batman-adv/bat_iv_ogm.c: "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, iface_penalty: %3i, total tq: %3i, if_incoming = %s, if_outgoing = %s\n",

Do you want to provide a patch to convert it to simple %pM's?

Kind regards,
Sven

#2 lore raw
Quoted 7 lines · Sven Eckelmann
Quoted 1 line · On Dienstag, 13. Juni 2017 14:51:41 CEST Joe Perches wrote:

An output mac address is 17 bytes

[...]

Quoted 1 line

but in net/batman-adv/distributed-arp-table.c

[...]

Quoted 8 lines
Quoted 3 lines

%14pM is odd as this should not emit the last byte of the mac address. So given the example above, it would output 00:11:22:33:44

[...]

I completely agree too the "wrong length" part. It is currently not omitting the last byte:

Right, I only looked at vsprintf.c and mistook precision for field_width.

Do you want to provide a patch to convert it to simple %pM's?

OK.

#3 lore raw

PATCH 1/1 batman-adv: Remove unnecessary length qualifier in %14pM

In reply to Sven Eckelmann

It's misleading and unnecessary.

---
 net/batman-adv/distributed-arp-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/distributed-arp-table.c +1 -1
index 6930d6b50f99..b6cfa78e9381 100644
@@ -834,7 +834,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
 			last_seen_msecs = last_seen_msecs % 60000;
 			last_seen_secs = last_seen_msecs / 1000;
 
-			seq_printf(seq, " * %15pI4 %14pM %4i %6i:%02i\n",
+			seq_printf(seq, " * %15pI4 %pM %4i %6i:%02i\n",
 				   &dat_entry->ip, dat_entry->mac_addr,
 				   batadv_print_vid(dat_entry->vid),
 				   last_seen_mins, last_seen_secs);
Signature · 1 line
2.10.0.rc2.1.g053435c
maintainer
#5 lore raw

Re: [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM

In reply to Joe Perches
Quoted 6 lines · On Mittwoch, 14. Juni 2017 02:33:52 CEST Joe Perches wrote:

It's misleading and unnecessary.

---
 net/batman-adv/distributed-arp-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

The patch was applied and is currently queued up as 454ea1866ef45c6f1b747bd27a8203318be72b5d in batadv/net-next.

Thanks,
Sven