--- /dev/null
+From: Sven Eckelmann <sven@narfation.org>
+Date: Mon, 10 May 2021 15:05:42 +0200
+Subject: batman-adv: Always send iface index+name in genlmsg
+
+The batman-adv netlink messages often contain the interface index and
+interface name in the same message. This makes it easy for the receiver to
+operate on the incoming data when it either needs to print something or
+needs to operate on the interface index.
+
+But one of the attributes was missing for:
+
+* neighbor table dumps
+* originator table dumps
+* gateway list dumps
+* query of hardif information
+* query of vid information
+
+The userspace therefore had to implement special workarounds using
+SIOCGIFNAME or SIOCGIFINDEX depending on what was actually provided.
+Providing both information simplifies the userspace code massively without
+adding a lot of extra overhead in the kernel portion.
+
+Signed-off-by: Sven Eckelmann <sven@narfation.org>
+Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/77c7d62618259f22f36427eaa62668e6e1c43090
+
+diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
+index 789f257be24f36ace3e63628a3381a6d46dcccd9..680def809838097a9949de1dc9861923911f3d04 100644
+--- a/net/batman-adv/bat_iv_ogm.c
++++ b/net/batman-adv/bat_iv_ogm.c
+@@ -1849,6 +1849,8 @@ batadv_iv_ogm_orig_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
+ orig_node->orig) ||
+ nla_put(msg, BATADV_ATTR_NEIGH_ADDRESS, ETH_ALEN,
+ neigh_node->addr) ||
++ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
++ neigh_node->if_incoming->net_dev->name) ||
+ nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
+ neigh_node->if_incoming->net_dev->ifindex) ||
+ nla_put_u8(msg, BATADV_ATTR_TQ, tq_avg) ||
+@@ -2078,6 +2080,8 @@ batadv_iv_ogm_neigh_dump_neigh(struct sk_buff *msg, u32 portid, u32 seq,
+
+ if (nla_put(msg, BATADV_ATTR_NEIGH_ADDRESS, ETH_ALEN,
+ hardif_neigh->addr) ||
++ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
++ hardif_neigh->if_incoming->net_dev->name) ||
+ nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
+ hardif_neigh->if_incoming->net_dev->ifindex) ||
+ nla_put_u32(msg, BATADV_ATTR_LAST_SEEN_MSECS,
+@@ -2459,6 +2463,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid,
+ router->addr) ||
+ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
+ router->if_incoming->net_dev->name) ||
++ nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
++ router->if_incoming->net_dev->ifindex) ||
+ nla_put_u32(msg, BATADV_ATTR_BANDWIDTH_DOWN,
+ gw_node->bandwidth_down) ||
+ nla_put_u32(msg, BATADV_ATTR_BANDWIDTH_UP,
+diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
+index eeb3f6d00d8541b377c9703837ef76b05e8d061e..fd7f30f5f3033fd1a9e21518a71e66b557212374 100644
+--- a/net/batman-adv/bat_v.c
++++ b/net/batman-adv/bat_v.c
+@@ -145,6 +145,8 @@ batadv_v_neigh_dump_neigh(struct sk_buff *msg, u32 portid, u32 seq,
+
+ if (nla_put(msg, BATADV_ATTR_NEIGH_ADDRESS, ETH_ALEN,
+ hardif_neigh->addr) ||
++ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
++ hardif_neigh->if_incoming->net_dev->name) ||
+ nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
+ hardif_neigh->if_incoming->net_dev->ifindex) ||
+ nla_put_u32(msg, BATADV_ATTR_LAST_SEEN_MSECS,
+@@ -297,6 +299,8 @@ batadv_v_orig_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
+ if (nla_put(msg, BATADV_ATTR_ORIG_ADDRESS, ETH_ALEN, orig_node->orig) ||
+ nla_put(msg, BATADV_ATTR_NEIGH_ADDRESS, ETH_ALEN,
+ neigh_node->addr) ||
++ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
++ neigh_node->if_incoming->net_dev->name) ||
+ nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
+ neigh_node->if_incoming->net_dev->ifindex) ||
+ nla_put_u32(msg, BATADV_ATTR_THROUGHPUT, throughput) ||
+@@ -738,6 +742,12 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid,
+ goto out;
+ }
+
++ if (nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
++ router->if_incoming->net_dev->ifindex)) {
++ genlmsg_cancel(msg, hdr);
++ goto out;
++ }
++
+ if (nla_put_u32(msg, BATADV_ATTR_BANDWIDTH_DOWN,
+ gw_node->bandwidth_down)) {
+ genlmsg_cancel(msg, hdr);
+diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
+index b6a703ddd8e97e6a02e8d73c5728802f090ab419..27f78f0c4aea025b964301e20f972031ab8ad478 100644
+--- a/net/batman-adv/netlink.c
++++ b/net/batman-adv/netlink.c
+@@ -813,6 +813,10 @@ static int batadv_netlink_hardif_fill(struct sk_buff *msg,
+ bat_priv->soft_iface->ifindex))
+ goto nla_put_failure;
+
++ if (nla_put_string(msg, BATADV_ATTR_MESH_IFNAME,
++ bat_priv->soft_iface->name))
++ goto nla_put_failure;
++
+ if (nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
+ net_dev->ifindex) ||
+ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
+@@ -1044,6 +1048,10 @@ static int batadv_netlink_vlan_fill(struct sk_buff *msg,
+ bat_priv->soft_iface->ifindex))
+ goto nla_put_failure;
+
++ if (nla_put_string(msg, BATADV_ATTR_MESH_IFNAME,
++ bat_priv->soft_iface->name))
++ goto nla_put_failure;
++
+ if (nla_put_u32(msg, BATADV_ATTR_VLANID, vlan->vid & VLAN_VID_MASK))
+ goto nla_put_failure;
+