|
@@ -20,6 +20,7 @@
|
|
|
|
|
|
#include <linux/atomic.h>
|
|
|
#include <linux/byteorder/generic.h>
|
|
|
+#include <linux/errno.h>
|
|
|
#include <linux/etherdevice.h>
|
|
|
#include <linux/fs.h>
|
|
|
#include <linux/if_ether.h>
|
|
@@ -31,6 +32,7 @@
|
|
|
#include <linux/kref.h>
|
|
|
#include <linux/list.h>
|
|
|
#include <linux/netdevice.h>
|
|
|
+#include <linux/netlink.h>
|
|
|
#include <linux/rculist.h>
|
|
|
#include <linux/rcupdate.h>
|
|
|
#include <linux/seq_file.h>
|
|
@@ -39,13 +41,17 @@
|
|
|
#include <linux/spinlock.h>
|
|
|
#include <linux/stddef.h>
|
|
|
#include <linux/udp.h>
|
|
|
+#include <net/sock.h>
|
|
|
+#include <uapi/linux/batman_adv.h>
|
|
|
|
|
|
#include "gateway_common.h"
|
|
|
#include "hard-interface.h"
|
|
|
#include "log.h"
|
|
|
+#include "netlink.h"
|
|
|
#include "originator.h"
|
|
|
#include "packet.h"
|
|
|
#include "routing.h"
|
|
|
+#include "soft-interface.h"
|
|
|
#include "sysfs.h"
|
|
|
#include "translation-table.h"
|
|
|
|
|
@@ -500,6 +506,59 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * batadv_gw_dump - Dump gateways into a message
|
|
|
+ * @msg: Netlink message to dump into
|
|
|
+ * @cb: Control block containing additional options
|
|
|
+ *
|
|
|
+ * Return: Error code, or length of message
|
|
|
+ */
|
|
|
+int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb)
|
|
|
+{
|
|
|
+ struct batadv_hard_iface *primary_if = NULL;
|
|
|
+ struct net *net = sock_net(cb->skb->sk);
|
|
|
+ struct net_device *soft_iface;
|
|
|
+ struct batadv_priv *bat_priv;
|
|
|
+ int ifindex;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ ifindex = batadv_netlink_get_ifindex(cb->nlh,
|
|
|
+ BATADV_ATTR_MESH_IFINDEX);
|
|
|
+ if (!ifindex)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ soft_iface = dev_get_by_index(net, ifindex);
|
|
|
+ if (!soft_iface || !batadv_softif_is_valid(soft_iface)) {
|
|
|
+ ret = -ENODEV;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ bat_priv = netdev_priv(soft_iface);
|
|
|
+
|
|
|
+ primary_if = batadv_primary_if_get_selected(bat_priv);
|
|
|
+ if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) {
|
|
|
+ ret = -ENOENT;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!bat_priv->algo_ops->gw.dump) {
|
|
|
+ ret = -EOPNOTSUPP;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ bat_priv->algo_ops->gw.dump(msg, cb, bat_priv);
|
|
|
+
|
|
|
+ ret = msg->len;
|
|
|
+
|
|
|
+out:
|
|
|
+ if (primary_if)
|
|
|
+ batadv_hardif_put(primary_if);
|
|
|
+ if (soft_iface)
|
|
|
+ dev_put(soft_iface);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* batadv_gw_dhcp_recipient_get - check if a packet is a DHCP message
|
|
|
* @skb: the packet to check
|