|
@@ -160,59 +160,59 @@ int hna_local_fill_buffer(unsigned char *buff, int buff_len)
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
-int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
|
|
|
- size_t count, loff_t off)
|
|
|
+int hna_local_seq_print_text(struct seq_file *seq, void *offset)
|
|
|
{
|
|
|
+ struct net_device *net_dev = (struct net_device *)seq->private;
|
|
|
struct bat_priv *bat_priv = netdev_priv(net_dev);
|
|
|
struct hna_local_entry *hna_local_entry;
|
|
|
HASHIT(hashit);
|
|
|
- int bytes_written = 0;
|
|
|
+ HASHIT(hashit_count);
|
|
|
unsigned long flags;
|
|
|
- size_t hdr_len;
|
|
|
+ size_t buf_size, pos;
|
|
|
+ char *buff;
|
|
|
|
|
|
if (!bat_priv->primary_if) {
|
|
|
- if (off == 0)
|
|
|
- return sprintf(buff,
|
|
|
- "BATMAN mesh %s disabled - "
|
|
|
- "please specify interfaces to enable it\n",
|
|
|
- net_dev->name);
|
|
|
-
|
|
|
- return 0;
|
|
|
+ return seq_printf(seq, "BATMAN mesh %s disabled - "
|
|
|
+ "please specify interfaces to enable it\n",
|
|
|
+ net_dev->name);
|
|
|
}
|
|
|
|
|
|
- hdr_len = sprintf(buff,
|
|
|
- "Locally retrieved addresses (from %s) "
|
|
|
- "announced via HNA:\n",
|
|
|
- net_dev->name);
|
|
|
-
|
|
|
- if (off < hdr_len)
|
|
|
- bytes_written = hdr_len;
|
|
|
+ seq_printf(seq, "Locally retrieved addresses (from %s) "
|
|
|
+ "announced via HNA:\n",
|
|
|
+ net_dev->name);
|
|
|
|
|
|
spin_lock_irqsave(&hna_local_hash_lock, flags);
|
|
|
|
|
|
- while (hash_iterate(hna_local_hash, &hashit)) {
|
|
|
- hdr_len += 21;
|
|
|
-
|
|
|
- if (count < bytes_written + 22)
|
|
|
- break;
|
|
|
+ buf_size = 1;
|
|
|
+ /* Estimate length for: " * xx:xx:xx:xx:xx:xx\n" */
|
|
|
+ while (hash_iterate(hna_local_hash, &hashit_count))
|
|
|
+ buf_size += 21;
|
|
|
|
|
|
- if (off >= hdr_len)
|
|
|
- continue;
|
|
|
+ buff = kmalloc(buf_size, GFP_ATOMIC);
|
|
|
+ if (!buff) {
|
|
|
+ spin_unlock_irqrestore(&hna_local_hash_lock, flags);
|
|
|
+ return -ENOMEM;
|
|
|
+ }
|
|
|
+ buff[0] = '\0';
|
|
|
+ pos = 0;
|
|
|
|
|
|
+ while (hash_iterate(hna_local_hash, &hashit)) {
|
|
|
hna_local_entry = hashit.bucket->data;
|
|
|
|
|
|
- bytes_written += snprintf(buff + bytes_written, 22,
|
|
|
- " * " MAC_FMT "\n",
|
|
|
- hna_local_entry->addr[0],
|
|
|
- hna_local_entry->addr[1],
|
|
|
- hna_local_entry->addr[2],
|
|
|
- hna_local_entry->addr[3],
|
|
|
- hna_local_entry->addr[4],
|
|
|
- hna_local_entry->addr[5]);
|
|
|
+ pos += snprintf(buff + pos, 22, " * " MAC_FMT "\n",
|
|
|
+ hna_local_entry->addr[0],
|
|
|
+ hna_local_entry->addr[1],
|
|
|
+ hna_local_entry->addr[2],
|
|
|
+ hna_local_entry->addr[3],
|
|
|
+ hna_local_entry->addr[4],
|
|
|
+ hna_local_entry->addr[5]);
|
|
|
}
|
|
|
|
|
|
spin_unlock_irqrestore(&hna_local_hash_lock, flags);
|
|
|
- return bytes_written;
|
|
|
+
|
|
|
+ seq_printf(seq, "%s", buff);
|
|
|
+ kfree(buff);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
static void _hna_local_del(void *data)
|
|
@@ -378,65 +378,66 @@ void hna_global_add_orig(struct orig_node *orig_node,
|
|
|
spin_unlock_irqrestore(&hna_global_hash_lock, flags);
|
|
|
}
|
|
|
|
|
|
-int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
|
|
|
- size_t count, loff_t off)
|
|
|
+int hna_global_seq_print_text(struct seq_file *seq, void *offset)
|
|
|
{
|
|
|
+ struct net_device *net_dev = (struct net_device *)seq->private;
|
|
|
struct bat_priv *bat_priv = netdev_priv(net_dev);
|
|
|
struct hna_global_entry *hna_global_entry;
|
|
|
HASHIT(hashit);
|
|
|
- int bytes_written = 0;
|
|
|
+ HASHIT(hashit_count);
|
|
|
unsigned long flags;
|
|
|
- size_t hdr_len;
|
|
|
+ size_t buf_size, pos;
|
|
|
+ char *buff;
|
|
|
|
|
|
if (!bat_priv->primary_if) {
|
|
|
- if (off == 0)
|
|
|
- return sprintf(buff,
|
|
|
- "BATMAN mesh %s disabled - "
|
|
|
- "please specify interfaces to enable it\n",
|
|
|
- net_dev->name);
|
|
|
-
|
|
|
- return 0;
|
|
|
+ return seq_printf(seq, "BATMAN mesh %s disabled - "
|
|
|
+ "please specify interfaces to enable it\n",
|
|
|
+ net_dev->name);
|
|
|
}
|
|
|
|
|
|
- hdr_len = sprintf(buff,
|
|
|
- "Globally announced HNAs received via the mesh %s "
|
|
|
- "(translation table):\n",
|
|
|
- net_dev->name);
|
|
|
-
|
|
|
- if (off < hdr_len)
|
|
|
- bytes_written = hdr_len;
|
|
|
+ seq_printf(seq, "Globally announced HNAs received via the mesh %s "
|
|
|
+ "(translation table):\n",
|
|
|
+ net_dev->name);
|
|
|
|
|
|
spin_lock_irqsave(&hna_global_hash_lock, flags);
|
|
|
|
|
|
- while (hash_iterate(hna_global_hash, &hashit)) {
|
|
|
- hdr_len += 43;
|
|
|
-
|
|
|
- if (count < bytes_written + 44)
|
|
|
- break;
|
|
|
+ buf_size = 1;
|
|
|
+ /* Estimate length for: " * xx:xx:xx:xx:xx:xx via xx:xx:xx:xx:xx:xx\n"*/
|
|
|
+ while (hash_iterate(hna_global_hash, &hashit_count))
|
|
|
+ buf_size += 43;
|
|
|
|
|
|
- if (off >= hdr_len)
|
|
|
- continue;
|
|
|
+ buff = kmalloc(buf_size, GFP_ATOMIC);
|
|
|
+ if (!buff) {
|
|
|
+ spin_unlock_irqrestore(&hna_global_hash_lock, flags);
|
|
|
+ return -ENOMEM;
|
|
|
+ }
|
|
|
+ buff[0] = '\0';
|
|
|
+ pos = 0;
|
|
|
|
|
|
+ while (hash_iterate(hna_global_hash, &hashit)) {
|
|
|
hna_global_entry = hashit.bucket->data;
|
|
|
|
|
|
- bytes_written += snprintf(buff + bytes_written, 44,
|
|
|
- " * " MAC_FMT " via " MAC_FMT "\n",
|
|
|
- hna_global_entry->addr[0],
|
|
|
- hna_global_entry->addr[1],
|
|
|
- hna_global_entry->addr[2],
|
|
|
- hna_global_entry->addr[3],
|
|
|
- hna_global_entry->addr[4],
|
|
|
- hna_global_entry->addr[5],
|
|
|
- hna_global_entry->orig_node->orig[0],
|
|
|
- hna_global_entry->orig_node->orig[1],
|
|
|
- hna_global_entry->orig_node->orig[2],
|
|
|
- hna_global_entry->orig_node->orig[3],
|
|
|
- hna_global_entry->orig_node->orig[4],
|
|
|
- hna_global_entry->orig_node->orig[5]);
|
|
|
+ pos += snprintf(buff + pos, 44,
|
|
|
+ " * " MAC_FMT " via " MAC_FMT "\n",
|
|
|
+ hna_global_entry->addr[0],
|
|
|
+ hna_global_entry->addr[1],
|
|
|
+ hna_global_entry->addr[2],
|
|
|
+ hna_global_entry->addr[3],
|
|
|
+ hna_global_entry->addr[4],
|
|
|
+ hna_global_entry->addr[5],
|
|
|
+ hna_global_entry->orig_node->orig[0],
|
|
|
+ hna_global_entry->orig_node->orig[1],
|
|
|
+ hna_global_entry->orig_node->orig[2],
|
|
|
+ hna_global_entry->orig_node->orig[3],
|
|
|
+ hna_global_entry->orig_node->orig[4],
|
|
|
+ hna_global_entry->orig_node->orig[5]);
|
|
|
}
|
|
|
|
|
|
spin_unlock_irqrestore(&hna_global_hash_lock, flags);
|
|
|
- return bytes_written;
|
|
|
+
|
|
|
+ seq_printf(seq, "%s", buff);
|
|
|
+ kfree(buff);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
void _hna_global_del_orig(struct hna_global_entry *hna_global_entry,
|