Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'batadv-next-pullrequest-20250117' of git://git.open-mesh.org/linux-merge

Simon Wunderlich says:

====================
This cleanup patchset includes the following patches:

- bump version strings, by Simon Wunderlich

- Reorder includes for distributed-arp-table.c, by Sven Eckelmann

- Fix translation table change handling, by Remi Pommarel (2 patches)

- Map VID 0 to untagged TT VLAN, by Sven Eckelmann

- Update MAINTAINERS/mailmap e-mail addresses, by the respective authors
(4 patches)

- netlink: reduce duplicate code by returning interfaces,
by Linus Lüssing

* tag 'batadv-next-pullrequest-20250117' of git://git.open-mesh.org/linux-merge:
batman-adv: netlink: reduce duplicate code by returning interfaces
MAINTAINERS: mailmap: add entries for Antonio Quartulli
mailmap: add entries for Sven Eckelmann
mailmap: add entries for Simon Wunderlich
MAINTAINERS: update email address of Marek Linder
batman-adv: Map VID 0 to untagged TT VLAN
batman-adv: Don't keep redundant TT change events
batman-adv: Remove atomic usage for tt.local_changes
batman-adv: Reorder includes for distributed-arp-table.c
batman-adv: Start new development cycle
====================

Link: https://patch.msgid.link/20250117123910.219278-1-sw@simonwunderlich.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+251 -252
+19
.mailmap
··· 83 83 Antoine Tenart <atenart@kernel.org> <antoine.tenart@bootlin.com> 84 84 Antoine Tenart <atenart@kernel.org> <antoine.tenart@free-electrons.com> 85 85 Antonio Ospite <ao2@ao2.it> <ao2@amarulasolutions.com> 86 + Antonio Quartulli <antonio@mandelbit.com> <antonio@meshcoding.com> 87 + Antonio Quartulli <antonio@mandelbit.com> <antonio@open-mesh.com> 88 + Antonio Quartulli <antonio@mandelbit.com> <antonio.quartulli@open-mesh.com> 89 + Antonio Quartulli <antonio@mandelbit.com> <ordex@autistici.org> 90 + Antonio Quartulli <antonio@mandelbit.com> <ordex@ritirata.org> 91 + Antonio Quartulli <antonio@mandelbit.com> <antonio@openvpn.net> 92 + Antonio Quartulli <antonio@mandelbit.com> <a@unstable.cc> 86 93 Anup Patel <anup@brainfault.org> <anup.patel@wdc.com> 87 94 Archit Taneja <archit@ti.com> 88 95 Ard Biesheuvel <ardb@kernel.org> <ard.biesheuvel@linaro.org> ··· 436 429 Marc Zyngier <maz@kernel.org> <marc.zyngier@arm.com> 437 430 Marek Behún <kabel@kernel.org> <marek.behun@nic.cz> 438 431 Marek Behún <kabel@kernel.org> Marek Behun <marek.behun@nic.cz> 432 + Marek Lindner <marek.lindner@mailbox.org> <lindner_marek@yahoo.de> 433 + Marek Lindner <marek.lindner@mailbox.org> <mareklindner@neomailbox.ch> 439 434 Mark Brown <broonie@sirena.org.uk> 440 435 Mark Starovoytov <mstarovo@pm.me> <mstarovoitov@marvell.com> 441 436 Markus Schneider-Pargmann <msp@baylibre.com> <mpa@pengutronix.de> ··· 653 644 Simon Horman <horms@kernel.org> <simon.horman@corigine.com> 654 645 Simon Horman <horms@kernel.org> <simon.horman@netronome.com> 655 646 Simon Kelley <simon@thekelleys.org.uk> 647 + Simon Wunderlich <sw@simonwunderlich.de> <simon.wunderlich@open-mesh.com> 648 + Simon Wunderlich <sw@simonwunderlich.de> <simon.wunderlich@s2003.tu-chemnitz.de> 649 + Simon Wunderlich <sw@simonwunderlich.de> <simon.wunderlich@saxnet.de> 650 + Simon Wunderlich <sw@simonwunderlich.de> <simon@open-mesh.com> 651 + Simon Wunderlich <sw@simonwunderlich.de> <siwu@hrz.tu-chemnitz.de> 656 652 Sricharan Ramabadhran <quic_srichara@quicinc.com> <sricharan@codeaurora.org> 657 653 Srinivas Ramana <quic_sramana@quicinc.com> <sramana@codeaurora.org> 658 654 Sriram R <quic_srirrama@quicinc.com> <srirrama@codeaurora.org> ··· 678 664 Sudeep Holla <sudeep.holla@arm.com> Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com> 679 665 Sumit Semwal <sumit.semwal@ti.com> 680 666 Surabhi Vishnoi <quic_svishnoi@quicinc.com> <svishnoi@codeaurora.org> 667 + Sven Eckelmann <sven@narfation.org> <seckelmann@datto.com> 668 + Sven Eckelmann <sven@narfation.org> <sven.eckelmann@gmx.de> 669 + Sven Eckelmann <sven@narfation.org> <sven.eckelmann@open-mesh.com> 670 + Sven Eckelmann <sven@narfation.org> <sven.eckelmann@openmesh.com> 671 + Sven Eckelmann <sven@narfation.org> <sven@open-mesh.com> 681 672 Takashi YOSHII <takashi.yoshii.zj@renesas.com> 682 673 Tamizh Chelvam Raja <quic_tamizhr@quicinc.com> <tamizhr@codeaurora.org> 683 674 Taniya Das <quic_tdas@quicinc.com> <tdas@codeaurora.org>
+1 -1
Documentation/networking/batman-adv.rst
··· 164 164 165 165 You can also contact the Authors: 166 166 167 - * Marek Lindner <mareklindner@neomailbox.ch> 167 + * Marek Lindner <marek.lindner@mailbox.org> 168 168 * Simon Wunderlich <sw@simonwunderlich.de>
+2 -2
MAINTAINERS
··· 3874 3874 F: drivers/platform/x86/barco-p50-gpio.c 3875 3875 3876 3876 BATMAN ADVANCED 3877 - M: Marek Lindner <mareklindner@neomailbox.ch> 3877 + M: Marek Lindner <marek.lindner@mailbox.org> 3878 3878 M: Simon Wunderlich <sw@simonwunderlich.de> 3879 - M: Antonio Quartulli <a@unstable.cc> 3879 + M: Antonio Quartulli <antonio@mandelbit.com> 3880 3880 M: Sven Eckelmann <sven@narfation.org> 3881 3881 L: b.a.t.m.a.n@lists.open-mesh.org (moderated for non-subscribers) 3882 3882 S: Maintained
+7 -26
net/batman-adv/bridge_loop_avoidance.c
··· 12 12 #include <linux/compiler.h> 13 13 #include <linux/container_of.h> 14 14 #include <linux/crc16.h> 15 + #include <linux/err.h> 15 16 #include <linux/errno.h> 16 17 #include <linux/etherdevice.h> 17 18 #include <linux/gfp.h> ··· 39 38 #include <net/arp.h> 40 39 #include <net/genetlink.h> 41 40 #include <net/netlink.h> 42 - #include <net/sock.h> 43 41 #include <uapi/linux/batadv_packet.h> 44 42 #include <uapi/linux/batman_adv.h> 45 43 ··· 47 47 #include "log.h" 48 48 #include "netlink.h" 49 49 #include "originator.h" 50 - #include "soft-interface.h" 51 50 #include "translation-table.h" 52 51 53 52 static const u8 batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05}; ··· 2232 2233 { 2233 2234 struct batadv_hard_iface *primary_if = NULL; 2234 2235 int portid = NETLINK_CB(cb->skb).portid; 2235 - struct net *net = sock_net(cb->skb->sk); 2236 2236 struct net_device *soft_iface; 2237 2237 struct batadv_hashtable *hash; 2238 2238 struct batadv_priv *bat_priv; 2239 2239 int bucket = cb->args[0]; 2240 2240 int idx = cb->args[1]; 2241 - int ifindex; 2242 2241 int ret = 0; 2243 2242 2244 - ifindex = batadv_netlink_get_ifindex(cb->nlh, 2245 - BATADV_ATTR_MESH_IFINDEX); 2246 - if (!ifindex) 2247 - return -EINVAL; 2248 - 2249 - soft_iface = dev_get_by_index(net, ifindex); 2250 - if (!soft_iface || !batadv_softif_is_valid(soft_iface)) { 2251 - ret = -ENODEV; 2252 - goto out; 2253 - } 2243 + soft_iface = batadv_netlink_get_softif(cb); 2244 + if (IS_ERR(soft_iface)) 2245 + return PTR_ERR(soft_iface); 2254 2246 2255 2247 bat_priv = netdev_priv(soft_iface); 2256 2248 hash = bat_priv->bla.claim_hash; ··· 2393 2403 { 2394 2404 struct batadv_hard_iface *primary_if = NULL; 2395 2405 int portid = NETLINK_CB(cb->skb).portid; 2396 - struct net *net = sock_net(cb->skb->sk); 2397 2406 struct net_device *soft_iface; 2398 2407 struct batadv_hashtable *hash; 2399 2408 struct batadv_priv *bat_priv; 2400 2409 int bucket = cb->args[0]; 2401 2410 int idx = cb->args[1]; 2402 - int ifindex; 2403 2411 int ret = 0; 2404 2412 2405 - ifindex = batadv_netlink_get_ifindex(cb->nlh, 2406 - BATADV_ATTR_MESH_IFINDEX); 2407 - if (!ifindex) 2408 - return -EINVAL; 2409 - 2410 - soft_iface = dev_get_by_index(net, ifindex); 2411 - if (!soft_iface || !batadv_softif_is_valid(soft_iface)) { 2412 - ret = -ENODEV; 2413 - goto out; 2414 - } 2413 + soft_iface = batadv_netlink_get_softif(cb); 2414 + if (IS_ERR(soft_iface)) 2415 + return PTR_ERR(soft_iface); 2415 2416 2416 2417 bat_priv = netdev_priv(soft_iface); 2417 2418 hash = bat_priv->bla.backbone_hash;
+5 -15
net/batman-adv/distributed-arp-table.c
··· 7 7 #include "distributed-arp-table.h" 8 8 #include "main.h" 9 9 10 - #include <linux/unaligned.h> 11 10 #include <linux/atomic.h> 12 11 #include <linux/bitops.h> 13 12 #include <linux/byteorder/generic.h> 14 13 #include <linux/container_of.h> 14 + #include <linux/err.h> 15 15 #include <linux/errno.h> 16 16 #include <linux/etherdevice.h> 17 17 #include <linux/gfp.h> ··· 32 32 #include <linux/stddef.h> 33 33 #include <linux/string.h> 34 34 #include <linux/udp.h> 35 + #include <linux/unaligned.h> 35 36 #include <linux/workqueue.h> 36 37 #include <net/arp.h> 37 38 #include <net/genetlink.h> 38 39 #include <net/netlink.h> 39 - #include <net/sock.h> 40 40 #include <uapi/linux/batman_adv.h> 41 41 42 42 #include "bridge_loop_avoidance.h" ··· 46 46 #include "netlink.h" 47 47 #include "originator.h" 48 48 #include "send.h" 49 - #include "soft-interface.h" 50 49 #include "translation-table.h" 51 50 #include "tvlv.h" 52 51 ··· 936 937 { 937 938 struct batadv_hard_iface *primary_if = NULL; 938 939 int portid = NETLINK_CB(cb->skb).portid; 939 - struct net *net = sock_net(cb->skb->sk); 940 940 struct net_device *soft_iface; 941 941 struct batadv_hashtable *hash; 942 942 struct batadv_priv *bat_priv; 943 943 int bucket = cb->args[0]; 944 944 int idx = cb->args[1]; 945 - int ifindex; 946 945 int ret = 0; 947 946 948 - ifindex = batadv_netlink_get_ifindex(cb->nlh, 949 - BATADV_ATTR_MESH_IFINDEX); 950 - if (!ifindex) 951 - return -EINVAL; 952 - 953 - soft_iface = dev_get_by_index(net, ifindex); 954 - if (!soft_iface || !batadv_softif_is_valid(soft_iface)) { 955 - ret = -ENODEV; 956 - goto out; 957 - } 947 + soft_iface = batadv_netlink_get_softif(cb); 948 + if (IS_ERR(soft_iface)) 949 + return PTR_ERR(soft_iface); 958 950 959 951 bat_priv = netdev_priv(soft_iface); 960 952 hash = bat_priv->dat.hash;
+4 -14
net/batman-adv/gateway_client.c
··· 10 10 #include <linux/atomic.h> 11 11 #include <linux/byteorder/generic.h> 12 12 #include <linux/container_of.h> 13 + #include <linux/err.h> 13 14 #include <linux/errno.h> 14 15 #include <linux/etherdevice.h> 15 16 #include <linux/gfp.h> ··· 32 31 #include <linux/sprintf.h> 33 32 #include <linux/stddef.h> 34 33 #include <linux/udp.h> 35 - #include <net/sock.h> 36 34 #include <uapi/linux/batadv_packet.h> 37 35 #include <uapi/linux/batman_adv.h> 38 36 ··· 40 40 #include "netlink.h" 41 41 #include "originator.h" 42 42 #include "routing.h" 43 - #include "soft-interface.h" 44 43 #include "translation-table.h" 45 44 46 45 /* These are the offsets of the "hw type" and "hw address length" in the dhcp ··· 501 502 int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb) 502 503 { 503 504 struct batadv_hard_iface *primary_if = NULL; 504 - struct net *net = sock_net(cb->skb->sk); 505 505 struct net_device *soft_iface; 506 506 struct batadv_priv *bat_priv; 507 - int ifindex; 508 507 int ret; 509 508 510 - ifindex = batadv_netlink_get_ifindex(cb->nlh, 511 - BATADV_ATTR_MESH_IFINDEX); 512 - if (!ifindex) 513 - return -EINVAL; 514 - 515 - soft_iface = dev_get_by_index(net, ifindex); 516 - if (!soft_iface || !batadv_softif_is_valid(soft_iface)) { 517 - ret = -ENODEV; 518 - goto out; 519 - } 509 + soft_iface = batadv_netlink_get_softif(cb); 510 + if (IS_ERR(soft_iface)) 511 + return PTR_ERR(soft_iface); 520 512 521 513 bat_priv = netdev_priv(soft_iface); 522 514
+7
net/batman-adv/main.c
··· 637 637 638 638 vhdr = (struct vlan_ethhdr *)(skb->data + header_len); 639 639 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK; 640 + 641 + /* VID 0 is only used to indicate "priority tag" frames which only 642 + * contain priority information and no VID. 643 + */ 644 + if (vid == 0) 645 + return BATADV_NO_FLAGS; 646 + 640 647 vid |= BATADV_VLAN_HAS_TAG; 641 648 642 649 return vid;
+2 -2
net/batman-adv/main.h
··· 7 7 #ifndef _NET_BATMAN_ADV_MAIN_H_ 8 8 #define _NET_BATMAN_ADV_MAIN_H_ 9 9 10 - #define BATADV_DRIVER_AUTHOR "Marek Lindner <mareklindner@neomailbox.ch>, " \ 10 + #define BATADV_DRIVER_AUTHOR "Marek Lindner <marek.lindner@mailbox.org>, " \ 11 11 "Simon Wunderlich <sw@simonwunderlich.de>" 12 12 #define BATADV_DRIVER_DESC "B.A.T.M.A.N. advanced" 13 13 #define BATADV_DRIVER_DEVICE "batman-adv" 14 14 15 15 #ifndef BATADV_SOURCE_VERSION 16 - #define BATADV_SOURCE_VERSION "2024.3" 16 + #define BATADV_SOURCE_VERSION "2025.0" 17 17 #endif 18 18 19 19 /* B.A.T.M.A.N. parameters */
+4 -13
net/batman-adv/multicast.c
··· 12 12 #include <linux/bug.h> 13 13 #include <linux/byteorder/generic.h> 14 14 #include <linux/container_of.h> 15 + #include <linux/err.h> 15 16 #include <linux/errno.h> 16 17 #include <linux/etherdevice.h> 17 18 #include <linux/gfp.h> ··· 47 46 #include <net/ip.h> 48 47 #include <net/ipv6.h> 49 48 #include <net/netlink.h> 50 - #include <net/sock.h> 51 49 #include <uapi/linux/batadv_packet.h> 52 50 #include <uapi/linux/batman_adv.h> 53 51 ··· 56 56 #include "log.h" 57 57 #include "netlink.h" 58 58 #include "send.h" 59 - #include "soft-interface.h" 60 59 #include "translation-table.h" 61 60 #include "tvlv.h" 62 61 ··· 2103 2104 struct batadv_hard_iface **primary_if) 2104 2105 { 2105 2106 struct batadv_hard_iface *hard_iface = NULL; 2106 - struct net *net = sock_net(cb->skb->sk); 2107 2107 struct net_device *soft_iface; 2108 2108 struct batadv_priv *bat_priv; 2109 - int ifindex; 2110 2109 int ret = 0; 2111 2110 2112 - ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); 2113 - if (!ifindex) 2114 - return -EINVAL; 2115 - 2116 - soft_iface = dev_get_by_index(net, ifindex); 2117 - if (!soft_iface || !batadv_softif_is_valid(soft_iface)) { 2118 - ret = -ENODEV; 2119 - goto out; 2120 - } 2111 + soft_iface = batadv_netlink_get_softif(cb); 2112 + if (IS_ERR(soft_iface)) 2113 + return PTR_ERR(soft_iface); 2121 2114 2122 2115 bat_priv = netdev_priv(soft_iface); 2123 2116
+103 -43
net/batman-adv/netlink.c
··· 158 158 * 159 159 * Return: interface index, or 0. 160 160 */ 161 - int 162 - batadv_netlink_get_ifindex(const struct nlmsghdr *nlh, int attrtype) 161 + static int batadv_netlink_get_ifindex(const struct nlmsghdr *nlh, int attrtype) 163 162 { 164 163 struct nlattr *attr = nlmsg_find_attr(nlh, GENL_HDRLEN, attrtype); 165 164 ··· 880 881 } 881 882 882 883 /** 883 - * batadv_netlink_get_hardif() - Get hardif attributes 884 + * batadv_netlink_cmd_get_hardif() - Get hardif attributes 884 885 * @skb: Netlink message with request data 885 886 * @info: receiver information 886 887 * 887 888 * Return: 0 on success or negative error number in case of failure 888 889 */ 889 - static int batadv_netlink_get_hardif(struct sk_buff *skb, 890 - struct genl_info *info) 890 + static int batadv_netlink_cmd_get_hardif(struct sk_buff *skb, 891 + struct genl_info *info) 891 892 { 892 893 struct batadv_hard_iface *hard_iface = info->user_ptr[1]; 893 894 struct batadv_priv *bat_priv = info->user_ptr[0]; ··· 963 964 static int 964 965 batadv_netlink_dump_hardif(struct sk_buff *msg, struct netlink_callback *cb) 965 966 { 966 - struct net *net = sock_net(cb->skb->sk); 967 967 struct net_device *soft_iface; 968 968 struct batadv_hard_iface *hard_iface; 969 969 struct batadv_priv *bat_priv; 970 - int ifindex; 971 970 int portid = NETLINK_CB(cb->skb).portid; 972 971 int skip = cb->args[0]; 973 972 int i = 0; 974 973 975 - ifindex = batadv_netlink_get_ifindex(cb->nlh, 976 - BATADV_ATTR_MESH_IFINDEX); 977 - if (!ifindex) 978 - return -EINVAL; 979 - 980 - soft_iface = dev_get_by_index(net, ifindex); 981 - if (!soft_iface) 982 - return -ENODEV; 983 - 984 - if (!batadv_softif_is_valid(soft_iface)) { 985 - dev_put(soft_iface); 986 - return -ENODEV; 987 - } 974 + soft_iface = batadv_netlink_get_softif(cb); 975 + if (IS_ERR(soft_iface)) 976 + return PTR_ERR(soft_iface); 988 977 989 978 bat_priv = netdev_priv(soft_iface); 990 979 ··· 1137 1150 } 1138 1151 1139 1152 /** 1140 - * batadv_get_softif_from_info() - Retrieve soft interface from genl attributes 1153 + * batadv_netlink_get_softif_from_ifindex() - Get soft-iface from ifindex 1141 1154 * @net: the applicable net namespace 1142 - * @info: receiver information 1155 + * @ifindex: index of the soft interface 1143 1156 * 1144 1157 * Return: Pointer to soft interface (with increased refcnt) on success, error 1145 1158 * pointer on error 1146 1159 */ 1147 1160 static struct net_device * 1148 - batadv_get_softif_from_info(struct net *net, struct genl_info *info) 1161 + batadv_netlink_get_softif_from_ifindex(struct net *net, int ifindex) 1149 1162 { 1150 1163 struct net_device *soft_iface; 1151 - int ifindex; 1152 - 1153 - if (!info->attrs[BATADV_ATTR_MESH_IFINDEX]) 1154 - return ERR_PTR(-EINVAL); 1155 - 1156 - ifindex = nla_get_u32(info->attrs[BATADV_ATTR_MESH_IFINDEX]); 1157 1164 1158 1165 soft_iface = dev_get_by_index(net, ifindex); 1159 1166 if (!soft_iface) ··· 1165 1184 } 1166 1185 1167 1186 /** 1168 - * batadv_get_hardif_from_info() - Retrieve hardif from genl attributes 1169 - * @bat_priv: the bat priv with all the soft interface information 1187 + * batadv_netlink_get_softif_from_info() - Get soft-iface from genl attributes 1170 1188 * @net: the applicable net namespace 1171 1189 * @info: receiver information 1190 + * 1191 + * Return: Pointer to soft interface (with increased refcnt) on success, error 1192 + * pointer on error 1193 + */ 1194 + static struct net_device * 1195 + batadv_netlink_get_softif_from_info(struct net *net, struct genl_info *info) 1196 + { 1197 + int ifindex; 1198 + 1199 + if (!info->attrs[BATADV_ATTR_MESH_IFINDEX]) 1200 + return ERR_PTR(-EINVAL); 1201 + 1202 + ifindex = nla_get_u32(info->attrs[BATADV_ATTR_MESH_IFINDEX]); 1203 + 1204 + return batadv_netlink_get_softif_from_ifindex(net, ifindex); 1205 + } 1206 + 1207 + /** 1208 + * batadv_netlink_get_softif() - Retrieve soft interface from netlink callback 1209 + * @cb: callback structure containing arguments 1210 + * 1211 + * Return: Pointer to soft interface (with increased refcnt) on success, error 1212 + * pointer on error 1213 + */ 1214 + struct net_device *batadv_netlink_get_softif(struct netlink_callback *cb) 1215 + { 1216 + int ifindex = batadv_netlink_get_ifindex(cb->nlh, 1217 + BATADV_ATTR_MESH_IFINDEX); 1218 + if (!ifindex) 1219 + return ERR_PTR(-ENONET); 1220 + 1221 + return batadv_netlink_get_softif_from_ifindex(sock_net(cb->skb->sk), 1222 + ifindex); 1223 + } 1224 + 1225 + /** 1226 + * batadv_netlink_get_hardif_from_ifindex() - Get hard-iface from ifindex 1227 + * @bat_priv: the bat priv with all the soft interface information 1228 + * @net: the applicable net namespace 1229 + * @ifindex: index of the hard interface 1172 1230 * 1173 1231 * Return: Pointer to hard interface (with increased refcnt) on success, error 1174 1232 * pointer on error 1175 1233 */ 1176 1234 static struct batadv_hard_iface * 1177 - batadv_get_hardif_from_info(struct batadv_priv *bat_priv, struct net *net, 1178 - struct genl_info *info) 1235 + batadv_netlink_get_hardif_from_ifindex(struct batadv_priv *bat_priv, 1236 + struct net *net, int ifindex) 1179 1237 { 1180 1238 struct batadv_hard_iface *hard_iface; 1181 1239 struct net_device *hard_dev; 1182 - unsigned int hardif_index; 1183 1240 1184 - if (!info->attrs[BATADV_ATTR_HARD_IFINDEX]) 1185 - return ERR_PTR(-EINVAL); 1186 - 1187 - hardif_index = nla_get_u32(info->attrs[BATADV_ATTR_HARD_IFINDEX]); 1188 - 1189 - hard_dev = dev_get_by_index(net, hardif_index); 1241 + hard_dev = dev_get_by_index(net, ifindex); 1190 1242 if (!hard_dev) 1191 1243 return ERR_PTR(-ENODEV); 1192 1244 ··· 1241 1227 dev_put(hard_dev); 1242 1228 1243 1229 return ERR_PTR(-EINVAL); 1230 + } 1231 + 1232 + /** 1233 + * batadv_netlink_get_hardif_from_info() - Get hard-iface from genl attributes 1234 + * @bat_priv: the bat priv with all the soft interface information 1235 + * @net: the applicable net namespace 1236 + * @info: receiver information 1237 + * 1238 + * Return: Pointer to hard interface (with increased refcnt) on success, error 1239 + * pointer on error 1240 + */ 1241 + static struct batadv_hard_iface * 1242 + batadv_netlink_get_hardif_from_info(struct batadv_priv *bat_priv, 1243 + struct net *net, struct genl_info *info) 1244 + { 1245 + int ifindex; 1246 + 1247 + if (!info->attrs[BATADV_ATTR_HARD_IFINDEX]) 1248 + return ERR_PTR(-EINVAL); 1249 + 1250 + ifindex = nla_get_u32(info->attrs[BATADV_ATTR_HARD_IFINDEX]); 1251 + 1252 + return batadv_netlink_get_hardif_from_ifindex(bat_priv, net, ifindex); 1253 + } 1254 + 1255 + /** 1256 + * batadv_netlink_get_hardif() - Retrieve hard interface from netlink callback 1257 + * @bat_priv: the bat priv with all the soft interface information 1258 + * @cb: callback structure containing arguments 1259 + * 1260 + * Return: Pointer to hard interface (with increased refcnt) on success, error 1261 + * pointer on error 1262 + */ 1263 + struct batadv_hard_iface * 1264 + batadv_netlink_get_hardif(struct batadv_priv *bat_priv, 1265 + struct netlink_callback *cb) 1266 + { 1267 + int ifindex = batadv_netlink_get_ifindex(cb->nlh, 1268 + BATADV_ATTR_HARD_IFINDEX); 1269 + if (!ifindex) 1270 + return ERR_PTR(-ENONET); 1271 + 1272 + return batadv_netlink_get_hardif_from_ifindex(bat_priv, 1273 + sock_net(cb->skb->sk), 1274 + ifindex); 1244 1275 } 1245 1276 1246 1277 /** ··· 1347 1288 return -EINVAL; 1348 1289 1349 1290 if (ops->internal_flags & BATADV_FLAG_NEED_MESH) { 1350 - soft_iface = batadv_get_softif_from_info(net, info); 1291 + soft_iface = batadv_netlink_get_softif_from_info(net, info); 1351 1292 if (IS_ERR(soft_iface)) 1352 1293 return PTR_ERR(soft_iface); 1353 1294 ··· 1356 1297 } 1357 1298 1358 1299 if (ops->internal_flags & BATADV_FLAG_NEED_HARDIF) { 1359 - hard_iface = batadv_get_hardif_from_info(bat_priv, net, info); 1300 + hard_iface = batadv_netlink_get_hardif_from_info(bat_priv, net, 1301 + info); 1360 1302 if (IS_ERR(hard_iface)) { 1361 1303 ret = PTR_ERR(hard_iface); 1362 1304 goto err_put_softif; ··· 1450 1390 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, 1451 1391 /* can be retrieved by unprivileged users */ 1452 1392 .dumpit = batadv_netlink_dump_hardif, 1453 - .doit = batadv_netlink_get_hardif, 1393 + .doit = batadv_netlink_cmd_get_hardif, 1454 1394 .internal_flags = BATADV_FLAG_NEED_MESH | 1455 1395 BATADV_FLAG_NEED_HARDIF, 1456 1396 },
+4 -1
net/batman-adv/netlink.h
··· 15 15 16 16 void batadv_netlink_register(void); 17 17 void batadv_netlink_unregister(void); 18 - int batadv_netlink_get_ifindex(const struct nlmsghdr *nlh, int attrtype); 18 + struct net_device *batadv_netlink_get_softif(struct netlink_callback *cb); 19 + struct batadv_hard_iface * 20 + batadv_netlink_get_hardif(struct batadv_priv *bat_priv, 21 + struct netlink_callback *cb); 19 22 20 23 int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst, 21 24 u8 result, u32 test_time, u64 total_bytes,
+41 -75
net/batman-adv/originator.c
··· 9 9 10 10 #include <linux/atomic.h> 11 11 #include <linux/container_of.h> 12 + #include <linux/err.h> 12 13 #include <linux/errno.h> 13 14 #include <linux/etherdevice.h> 14 15 #include <linux/gfp.h> ··· 27 26 #include <linux/spinlock.h> 28 27 #include <linux/stddef.h> 29 28 #include <linux/workqueue.h> 30 - #include <net/sock.h> 31 29 #include <uapi/linux/batadv_packet.h> 32 - #include <uapi/linux/batman_adv.h> 33 30 34 31 #include "bat_algo.h" 35 32 #include "distributed-arp-table.h" ··· 40 41 #include "netlink.h" 41 42 #include "network-coding.h" 42 43 #include "routing.h" 43 - #include "soft-interface.h" 44 44 #include "translation-table.h" 45 45 46 46 /* hash class keys */ ··· 753 755 */ 754 756 int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb) 755 757 { 756 - struct net *net = sock_net(cb->skb->sk); 758 + struct batadv_hard_iface *primary_if, *hard_iface; 757 759 struct net_device *soft_iface; 758 - struct net_device *hard_iface = NULL; 759 - struct batadv_hard_iface *hardif = BATADV_IF_DEFAULT; 760 760 struct batadv_priv *bat_priv; 761 - struct batadv_hard_iface *primary_if = NULL; 762 761 int ret; 763 - int ifindex, hard_ifindex; 764 762 765 - ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); 766 - if (!ifindex) 767 - return -EINVAL; 768 - 769 - soft_iface = dev_get_by_index(net, ifindex); 770 - if (!soft_iface || !batadv_softif_is_valid(soft_iface)) { 771 - ret = -ENODEV; 772 - goto out; 773 - } 763 + soft_iface = batadv_netlink_get_softif(cb); 764 + if (IS_ERR(soft_iface)) 765 + return PTR_ERR(soft_iface); 774 766 775 767 bat_priv = netdev_priv(soft_iface); 776 768 777 769 primary_if = batadv_primary_if_get_selected(bat_priv); 778 770 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) { 779 771 ret = -ENOENT; 780 - goto out; 772 + goto out_put_soft_iface; 781 773 } 782 774 783 - hard_ifindex = batadv_netlink_get_ifindex(cb->nlh, 784 - BATADV_ATTR_HARD_IFINDEX); 785 - if (hard_ifindex) { 786 - hard_iface = dev_get_by_index(net, hard_ifindex); 787 - if (hard_iface) 788 - hardif = batadv_hardif_get_by_netdev(hard_iface); 789 - 790 - if (!hardif) { 791 - ret = -ENODEV; 792 - goto out; 793 - } 794 - 795 - if (hardif->soft_iface != soft_iface) { 796 - ret = -ENOENT; 797 - goto out; 798 - } 775 + hard_iface = batadv_netlink_get_hardif(bat_priv, cb); 776 + if (IS_ERR(hard_iface) && PTR_ERR(hard_iface) != -ENONET) { 777 + ret = PTR_ERR(hard_iface); 778 + goto out_put_primary_if; 779 + } else if (IS_ERR(hard_iface)) { 780 + /* => PTR_ERR(hard_iface) == -ENONET 781 + * => no hard-iface given, ok 782 + */ 783 + hard_iface = BATADV_IF_DEFAULT; 799 784 } 800 785 801 786 if (!bat_priv->algo_ops->neigh.dump) { 802 787 ret = -EOPNOTSUPP; 803 - goto out; 788 + goto out_put_hard_iface; 804 789 } 805 790 806 - bat_priv->algo_ops->neigh.dump(msg, cb, bat_priv, hardif); 791 + bat_priv->algo_ops->neigh.dump(msg, cb, bat_priv, hard_iface); 807 792 808 793 ret = msg->len; 809 794 810 - out: 811 - batadv_hardif_put(hardif); 812 - dev_put(hard_iface); 795 + out_put_hard_iface: 796 + batadv_hardif_put(hard_iface); 797 + out_put_primary_if: 813 798 batadv_hardif_put(primary_if); 799 + out_put_soft_iface: 814 800 dev_put(soft_iface); 815 801 816 802 return ret; ··· 1324 1342 */ 1325 1343 int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb) 1326 1344 { 1327 - struct net *net = sock_net(cb->skb->sk); 1345 + struct batadv_hard_iface *primary_if, *hard_iface; 1328 1346 struct net_device *soft_iface; 1329 - struct net_device *hard_iface = NULL; 1330 - struct batadv_hard_iface *hardif = BATADV_IF_DEFAULT; 1331 1347 struct batadv_priv *bat_priv; 1332 - struct batadv_hard_iface *primary_if = NULL; 1333 1348 int ret; 1334 - int ifindex, hard_ifindex; 1335 1349 1336 - ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); 1337 - if (!ifindex) 1338 - return -EINVAL; 1339 - 1340 - soft_iface = dev_get_by_index(net, ifindex); 1341 - if (!soft_iface || !batadv_softif_is_valid(soft_iface)) { 1342 - ret = -ENODEV; 1343 - goto out; 1344 - } 1350 + soft_iface = batadv_netlink_get_softif(cb); 1351 + if (IS_ERR(soft_iface)) 1352 + return PTR_ERR(soft_iface); 1345 1353 1346 1354 bat_priv = netdev_priv(soft_iface); 1347 1355 1348 1356 primary_if = batadv_primary_if_get_selected(bat_priv); 1349 1357 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) { 1350 1358 ret = -ENOENT; 1351 - goto out; 1359 + goto out_put_soft_iface; 1352 1360 } 1353 1361 1354 - hard_ifindex = batadv_netlink_get_ifindex(cb->nlh, 1355 - BATADV_ATTR_HARD_IFINDEX); 1356 - if (hard_ifindex) { 1357 - hard_iface = dev_get_by_index(net, hard_ifindex); 1358 - if (hard_iface) 1359 - hardif = batadv_hardif_get_by_netdev(hard_iface); 1360 - 1361 - if (!hardif) { 1362 - ret = -ENODEV; 1363 - goto out; 1364 - } 1365 - 1366 - if (hardif->soft_iface != soft_iface) { 1367 - ret = -ENOENT; 1368 - goto out; 1369 - } 1362 + hard_iface = batadv_netlink_get_hardif(bat_priv, cb); 1363 + if (IS_ERR(hard_iface) && PTR_ERR(hard_iface) != -ENONET) { 1364 + ret = PTR_ERR(hard_iface); 1365 + goto out_put_primary_if; 1366 + } else if (IS_ERR(hard_iface)) { 1367 + /* => PTR_ERR(hard_iface) == -ENONET 1368 + * => no hard-iface given, ok 1369 + */ 1370 + hard_iface = BATADV_IF_DEFAULT; 1370 1371 } 1371 1372 1372 1373 if (!bat_priv->algo_ops->orig.dump) { 1373 1374 ret = -EOPNOTSUPP; 1374 - goto out; 1375 + goto out_put_hard_iface; 1375 1376 } 1376 1377 1377 - bat_priv->algo_ops->orig.dump(msg, cb, bat_priv, hardif); 1378 + bat_priv->algo_ops->orig.dump(msg, cb, bat_priv, hard_iface); 1378 1379 1379 1380 ret = msg->len; 1380 1381 1381 - out: 1382 - batadv_hardif_put(hardif); 1383 - dev_put(hard_iface); 1382 + out_put_hard_iface: 1383 + batadv_hardif_put(hard_iface); 1384 + out_put_primary_if: 1384 1385 batadv_hardif_put(primary_if); 1386 + out_put_soft_iface: 1385 1387 dev_put(soft_iface); 1386 1388 1387 1389 return ret;
+15 -1
net/batman-adv/soft-interface.c
··· 637 637 if (proto != htons(ETH_P_8021Q)) 638 638 return -EINVAL; 639 639 640 + /* VID 0 is only used to indicate "priority tag" frames which only 641 + * contain priority information and no VID. No management structures 642 + * should be created for this VID and it should be handled like an 643 + * untagged frame. 644 + */ 645 + if (vid == 0) 646 + return 0; 647 + 640 648 vid |= BATADV_VLAN_HAS_TAG; 641 649 642 650 /* if a new vlan is getting created and it already exists, it means that ··· 691 683 */ 692 684 if (proto != htons(ETH_P_8021Q)) 693 685 return -EINVAL; 686 + 687 + /* "priority tag" frames are handled like "untagged" frames 688 + * and no softif_vlan needs to be destroyed 689 + */ 690 + if (vid == 0) 691 + return 0; 694 692 695 693 vlan = batadv_softif_vlan_get(bat_priv, vid | BATADV_VLAN_HAS_TAG); 696 694 if (!vlan) ··· 797 783 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); 798 784 atomic_set(&bat_priv->bcast_seqno, 1); 799 785 atomic_set(&bat_priv->tt.vn, 0); 800 - atomic_set(&bat_priv->tt.local_changes, 0); 801 786 atomic_set(&bat_priv->tt.ogm_append_cnt, 0); 802 787 #ifdef CONFIG_BATMAN_ADV_BLA 803 788 atomic_set(&bat_priv->bla.num_requests, 0); 804 789 #endif 805 790 atomic_set(&bat_priv->tp_num, 0); 806 791 792 + WRITE_ONCE(bat_priv->tt.local_changes, 0); 807 793 bat_priv->tt.last_changeset = NULL; 808 794 bat_priv->tt.last_changeset_len = 0; 809 795 bat_priv->isolation_mark = 0;
+35 -57
net/batman-adv/translation-table.c
··· 15 15 #include <linux/compiler.h> 16 16 #include <linux/container_of.h> 17 17 #include <linux/crc32c.h> 18 + #include <linux/err.h> 18 19 #include <linux/errno.h> 19 20 #include <linux/etherdevice.h> 20 21 #include <linux/gfp.h> ··· 40 39 #include <linux/workqueue.h> 41 40 #include <net/genetlink.h> 42 41 #include <net/netlink.h> 43 - #include <net/sock.h> 44 42 #include <uapi/linux/batadv_packet.h> 45 43 #include <uapi/linux/batman_adv.h> 46 44 ··· 423 423 struct batadv_tt_change_node *tt_change_node, *entry, *safe; 424 424 struct batadv_tt_common_entry *common = &tt_local_entry->common; 425 425 u8 flags = common->flags | event_flags; 426 - bool event_removed = false; 427 426 bool del_op_requested, del_op_entry; 427 + size_t changes; 428 428 429 429 tt_change_node = kmem_cache_alloc(batadv_tt_change_cache, GFP_ATOMIC); 430 430 if (!tt_change_node) ··· 438 438 439 439 del_op_requested = flags & BATADV_TT_CLIENT_DEL; 440 440 441 - /* check for ADD+DEL or DEL+ADD events */ 441 + /* check for ADD+DEL, DEL+ADD, ADD+ADD or DEL+DEL events */ 442 442 spin_lock_bh(&bat_priv->tt.changes_list_lock); 443 + changes = READ_ONCE(bat_priv->tt.local_changes); 443 444 list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list, 444 445 list) { 445 446 if (!batadv_compare_eth(entry->change.addr, common->addr)) 446 447 continue; 447 448 448 - /* DEL+ADD in the same orig interval have no effect and can be 449 - * removed to avoid silly behaviour on the receiver side. The 450 - * other way around (ADD+DEL) can happen in case of roaming of 451 - * a client still in the NEW state. Roaming of NEW clients is 452 - * now possible due to automatically recognition of "temporary" 453 - * clients 454 - */ 455 449 del_op_entry = entry->change.flags & BATADV_TT_CLIENT_DEL; 456 - if (!del_op_requested && del_op_entry) 457 - goto del; 458 - if (del_op_requested && !del_op_entry) 459 - goto del; 460 - 461 - /* this is a second add in the same originator interval. It 462 - * means that flags have been changed: update them! 463 - */ 464 - if (!del_op_requested && !del_op_entry) 450 + if (del_op_requested != del_op_entry) { 451 + /* DEL+ADD in the same orig interval have no effect and 452 + * can be removed to avoid silly behaviour on the 453 + * receiver side. The other way around (ADD+DEL) can 454 + * happen in case of roaming of a client still in the 455 + * NEW state. Roaming of NEW clients is now possible due 456 + * to automatically recognition of "temporary" clients 457 + */ 458 + list_del(&entry->list); 459 + kmem_cache_free(batadv_tt_change_cache, entry); 460 + changes--; 461 + } else { 462 + /* this is a second add or del in the same originator 463 + * interval. It could mean that flags have been changed 464 + * (e.g. double add): update them 465 + */ 465 466 entry->change.flags = flags; 467 + } 466 468 467 - continue; 468 - del: 469 - list_del(&entry->list); 470 - kmem_cache_free(batadv_tt_change_cache, entry); 471 469 kmem_cache_free(batadv_tt_change_cache, tt_change_node); 472 - event_removed = true; 473 - goto unlock; 470 + goto update_changes; 474 471 } 475 472 476 473 /* track the change in the OGMinterval list */ 477 474 list_add_tail(&tt_change_node->list, &bat_priv->tt.changes_list); 475 + changes++; 478 476 479 - unlock: 477 + update_changes: 478 + WRITE_ONCE(bat_priv->tt.local_changes, changes); 480 479 spin_unlock_bh(&bat_priv->tt.changes_list_lock); 481 - 482 - if (event_removed) 483 - atomic_dec(&bat_priv->tt.local_changes); 484 - else 485 - atomic_inc(&bat_priv->tt.local_changes); 486 480 } 487 481 488 482 /** ··· 946 952 size_t tt_extra_len = 0; 947 953 u16 tvlv_len; 948 954 949 - tt_diff_entries_num = atomic_read(&bat_priv->tt.local_changes); 955 + tt_diff_entries_num = READ_ONCE(bat_priv->tt.local_changes); 950 956 tt_diff_len = batadv_tt_len(tt_diff_entries_num); 951 957 952 958 /* if we have too many changes for one packet don't send any ··· 973 979 goto container_register; 974 980 975 981 spin_lock_bh(&bat_priv->tt.changes_list_lock); 976 - atomic_set(&bat_priv->tt.local_changes, 0); 982 + WRITE_ONCE(bat_priv->tt.local_changes, 0); 977 983 978 984 list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list, 979 985 list) { ··· 1130 1136 */ 1131 1137 int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb) 1132 1138 { 1133 - struct net *net = sock_net(cb->skb->sk); 1134 1139 struct net_device *soft_iface; 1135 1140 struct batadv_priv *bat_priv; 1136 1141 struct batadv_hard_iface *primary_if = NULL; 1137 1142 struct batadv_hashtable *hash; 1138 1143 int ret; 1139 - int ifindex; 1140 1144 int bucket = cb->args[0]; 1141 1145 int idx = cb->args[1]; 1142 1146 int portid = NETLINK_CB(cb->skb).portid; 1143 1147 1144 - ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); 1145 - if (!ifindex) 1146 - return -EINVAL; 1147 - 1148 - soft_iface = dev_get_by_index(net, ifindex); 1149 - if (!soft_iface || !batadv_softif_is_valid(soft_iface)) { 1150 - ret = -ENODEV; 1151 - goto out; 1152 - } 1148 + soft_iface = batadv_netlink_get_softif(cb); 1149 + if (IS_ERR(soft_iface)) 1150 + return PTR_ERR(soft_iface); 1153 1151 1154 1152 bat_priv = netdev_priv(soft_iface); 1155 1153 ··· 1381 1395 kmem_cache_free(batadv_tt_change_cache, entry); 1382 1396 } 1383 1397 1384 - atomic_set(&bat_priv->tt.local_changes, 0); 1398 + WRITE_ONCE(bat_priv->tt.local_changes, 0); 1385 1399 spin_unlock_bh(&bat_priv->tt.changes_list_lock); 1386 1400 } 1387 1401 ··· 1897 1911 */ 1898 1912 int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb) 1899 1913 { 1900 - struct net *net = sock_net(cb->skb->sk); 1901 1914 struct net_device *soft_iface; 1902 1915 struct batadv_priv *bat_priv; 1903 1916 struct batadv_hard_iface *primary_if = NULL; 1904 1917 struct batadv_hashtable *hash; 1905 1918 struct hlist_head *head; 1906 1919 int ret; 1907 - int ifindex; 1908 1920 int bucket = cb->args[0]; 1909 1921 int idx = cb->args[1]; 1910 1922 int sub = cb->args[2]; 1911 1923 int portid = NETLINK_CB(cb->skb).portid; 1912 1924 1913 - ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); 1914 - if (!ifindex) 1915 - return -EINVAL; 1916 - 1917 - soft_iface = dev_get_by_index(net, ifindex); 1918 - if (!soft_iface || !batadv_softif_is_valid(soft_iface)) { 1919 - ret = -ENODEV; 1920 - goto out; 1921 - } 1925 + soft_iface = batadv_netlink_get_softif(cb); 1926 + if (IS_ERR(soft_iface)) 1927 + return PTR_ERR(soft_iface); 1922 1928 1923 1929 bat_priv = netdev_priv(soft_iface); 1924 1930 ··· 3634 3656 { 3635 3657 lockdep_assert_held(&bat_priv->tt.commit_lock); 3636 3658 3637 - if (atomic_read(&bat_priv->tt.local_changes) < 1) { 3659 + if (READ_ONCE(bat_priv->tt.local_changes) == 0) { 3638 3660 if (!batadv_atomic_dec_not_zero(&bat_priv->tt.ogm_append_cnt)) 3639 3661 batadv_tt_tvlv_container_update(bat_priv); 3640 3662 return;
+2 -2
net/batman-adv/types.h
··· 1022 1022 atomic_t ogm_append_cnt; 1023 1023 1024 1024 /** @local_changes: changes registered in an originator interval */ 1025 - atomic_t local_changes; 1025 + size_t local_changes; 1026 1026 1027 1027 /** 1028 1028 * @changes_list: tracks tt local changes within an originator interval ··· 1044 1044 */ 1045 1045 struct list_head roam_list; 1046 1046 1047 - /** @changes_list_lock: lock protecting changes_list */ 1047 + /** @changes_list_lock: lock protecting changes_list & local_changes */ 1048 1048 spinlock_t changes_list_lock; 1049 1049 1050 1050 /** @req_list_lock: lock protecting req_list */