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-20241015' of git://git.open-mesh.org/linux-merge

Simon Wunderlich says:

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

- bump version strings, by Simon Wunderlich

- Add flex array to struct batadv_tvlv_tt_data, by Erick Archer

- Use string choice helper to print booleans, by Sven Eckelmann

- replace call_rcu by kfree_rcu for simple kmem_cache_free callback,
by Julia Lawall

* tag 'batadv-next-pullrequest-20241015' of git://git.open-mesh.org/linux-merge:
batman-adv: replace call_rcu by kfree_rcu for simple kmem_cache_free callback
batman-adv: Use string choice helper to print booleans
batman-adv: Add flex array to struct batadv_tvlv_tt_data
batman-adv: Start new development cycle
====================

Link: https://patch.msgid.link/20241015073946.46613-1-sw@simonwunderlich.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+46 -93
+16 -13
include/uapi/linux/batadv_packet.h
··· 9 9 10 10 #include <asm/byteorder.h> 11 11 #include <linux/if_ether.h> 12 + #include <linux/stddef.h> 12 13 #include <linux/types.h> 13 14 14 15 /** ··· 594 593 }; 595 594 596 595 /** 597 - * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container 598 - * @flags: translation table flags (see batadv_tt_data_flags) 599 - * @ttvn: translation table version number 600 - * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by 601 - * one batadv_tvlv_tt_vlan_data object per announced vlan 602 - */ 603 - struct batadv_tvlv_tt_data { 604 - __u8 flags; 605 - __u8 ttvn; 606 - __be16 num_vlan; 607 - }; 608 - 609 - /** 610 596 * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through 611 597 * the tt tvlv container 612 598 * @crc: crc32 checksum of the entries belonging to this vlan ··· 604 616 __be32 crc; 605 617 __be16 vid; 606 618 __u16 reserved; 619 + }; 620 + 621 + /** 622 + * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container 623 + * @flags: translation table flags (see batadv_tt_data_flags) 624 + * @ttvn: translation table version number 625 + * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by 626 + * one batadv_tvlv_tt_vlan_data object per announced vlan 627 + * @vlan_data: array of batadv_tvlv_tt_vlan_data objects 628 + */ 629 + struct batadv_tvlv_tt_data { 630 + __u8 flags; 631 + __u8 ttvn; 632 + __be16 num_vlan; 633 + struct batadv_tvlv_tt_vlan_data vlan_data[] __counted_by_be(num_vlan); 607 634 }; 608 635 609 636 /**
+2 -2
net/batman-adv/bat_iv_ogm.c
··· 36 36 #include <linux/spinlock.h> 37 37 #include <linux/stddef.h> 38 38 #include <linux/string.h> 39 + #include <linux/string_choices.h> 39 40 #include <linux/types.h> 40 41 #include <linux/workqueue.h> 41 42 #include <net/genetlink.h> ··· 372 371 batadv_ogm_packet->orig, 373 372 ntohl(batadv_ogm_packet->seqno), 374 373 batadv_ogm_packet->tq, batadv_ogm_packet->ttl, 375 - ((batadv_ogm_packet->flags & BATADV_DIRECTLINK) ? 376 - "on" : "off"), 374 + str_on_off(batadv_ogm_packet->flags & BATADV_DIRECTLINK), 377 375 hard_iface->net_dev->name, 378 376 hard_iface->net_dev->dev_addr); 379 377
+4 -4
net/batman-adv/bridge_loop_avoidance.c
··· 33 33 #include <linux/sprintf.h> 34 34 #include <linux/stddef.h> 35 35 #include <linux/string.h> 36 + #include <linux/string_choices.h> 36 37 #include <linux/workqueue.h> 37 38 #include <net/arp.h> 38 39 #include <net/genetlink.h> ··· 1947 1946 claim = batadv_claim_hash_find(bat_priv, &search_claim); 1948 1947 1949 1948 if (!claim) { 1949 + bool local = batadv_is_my_client(bat_priv, ethhdr->h_source, vid); 1950 + 1950 1951 /* possible optimization: race for a claim */ 1951 1952 /* No claim exists yet, claim it for us! 1952 1953 */ 1953 1954 1954 1955 batadv_dbg(BATADV_DBG_BLA, bat_priv, 1955 1956 "%s(): Unclaimed MAC %pM found. Claim it. Local: %s\n", 1956 - __func__, ethhdr->h_source, 1957 - batadv_is_my_client(bat_priv, 1958 - ethhdr->h_source, vid) ? 1959 - "yes" : "no"); 1957 + __func__, ethhdr->h_source, str_yes_no(local)); 1960 1958 batadv_handle_claim(bat_priv, primary_if, 1961 1959 primary_if->net_dev->dev_addr, 1962 1960 ethhdr->h_source, vid);
+1 -1
net/batman-adv/main.h
··· 13 13 #define BATADV_DRIVER_DEVICE "batman-adv" 14 14 15 15 #ifndef BATADV_SOURCE_VERSION 16 - #define BATADV_SOURCE_VERSION "2024.2" 16 + #define BATADV_SOURCE_VERSION "2024.3" 17 17 #endif 18 18 19 19 /* B.A.T.M.A.N. parameters */
+23 -73
net/batman-adv/translation-table.c
··· 28 28 #include <linux/net.h> 29 29 #include <linux/netdevice.h> 30 30 #include <linux/netlink.h> 31 + #include <linux/overflow.h> 31 32 #include <linux/rculist.h> 32 33 #include <linux/rcupdate.h> 33 34 #include <linux/skbuff.h> ··· 210 209 } 211 210 212 211 /** 213 - * batadv_tt_local_entry_free_rcu() - free the tt_local_entry 214 - * @rcu: rcu pointer of the tt_local_entry 215 - */ 216 - static void batadv_tt_local_entry_free_rcu(struct rcu_head *rcu) 217 - { 218 - struct batadv_tt_local_entry *tt_local_entry; 219 - 220 - tt_local_entry = container_of(rcu, struct batadv_tt_local_entry, 221 - common.rcu); 222 - 223 - kmem_cache_free(batadv_tl_cache, tt_local_entry); 224 - } 225 - 226 - /** 227 212 * batadv_tt_local_entry_release() - release tt_local_entry from lists and queue 228 213 * for free after rcu grace period 229 214 * @ref: kref pointer of the nc_node ··· 223 236 224 237 batadv_softif_vlan_put(tt_local_entry->vlan); 225 238 226 - call_rcu(&tt_local_entry->common.rcu, batadv_tt_local_entry_free_rcu); 239 + kfree_rcu(tt_local_entry, common.rcu); 227 240 } 228 241 229 242 /** ··· 242 255 } 243 256 244 257 /** 245 - * batadv_tt_global_entry_free_rcu() - free the tt_global_entry 246 - * @rcu: rcu pointer of the tt_global_entry 247 - */ 248 - static void batadv_tt_global_entry_free_rcu(struct rcu_head *rcu) 249 - { 250 - struct batadv_tt_global_entry *tt_global_entry; 251 - 252 - tt_global_entry = container_of(rcu, struct batadv_tt_global_entry, 253 - common.rcu); 254 - 255 - kmem_cache_free(batadv_tg_cache, tt_global_entry); 256 - } 257 - 258 - /** 259 258 * batadv_tt_global_entry_release() - release tt_global_entry from lists and 260 259 * queue for free after rcu grace period 261 260 * @ref: kref pointer of the nc_node ··· 255 282 256 283 batadv_tt_global_del_orig_list(tt_global_entry); 257 284 258 - call_rcu(&tt_global_entry->common.rcu, batadv_tt_global_entry_free_rcu); 285 + kfree_rcu(tt_global_entry, common.rcu); 259 286 } 260 287 261 288 /** ··· 381 408 } 382 409 383 410 /** 384 - * batadv_tt_orig_list_entry_free_rcu() - free the orig_entry 385 - * @rcu: rcu pointer of the orig_entry 386 - */ 387 - static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu) 388 - { 389 - struct batadv_tt_orig_list_entry *orig_entry; 390 - 391 - orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu); 392 - 393 - kmem_cache_free(batadv_tt_orig_cache, orig_entry); 394 - } 395 - 396 - /** 397 411 * batadv_tt_orig_list_entry_release() - release tt orig entry from lists and 398 412 * queue for free after rcu grace period 399 413 * @ref: kref pointer of the tt orig entry ··· 393 433 refcount); 394 434 395 435 batadv_orig_node_put(orig_entry->orig_node); 396 - call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu); 436 + kfree_rcu(orig_entry, rcu); 397 437 } 398 438 399 439 /** ··· 816 856 num_entries += atomic_read(&vlan->tt.num_entries); 817 857 } 818 858 819 - change_offset = sizeof(**tt_data); 820 - change_offset += num_vlan * sizeof(*tt_vlan); 859 + change_offset = struct_size(*tt_data, vlan_data, num_vlan); 821 860 822 861 /* if tt_len is negative, allocate the space needed by the full table */ 823 862 if (*tt_len < 0) ··· 835 876 (*tt_data)->ttvn = atomic_read(&orig_node->last_ttvn); 836 877 (*tt_data)->num_vlan = htons(num_vlan); 837 878 838 - tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data + 1); 879 + tt_vlan = (*tt_data)->vlan_data; 839 880 hlist_for_each_entry(vlan, &orig_node->vlan_list, list) { 840 881 tt_vlan->vid = htons(vlan->vid); 841 882 tt_vlan->crc = htonl(vlan->tt.crc); ··· 895 936 total_entries += vlan_entries; 896 937 } 897 938 898 - change_offset = sizeof(**tt_data); 899 - change_offset += num_vlan * sizeof(*tt_vlan); 939 + change_offset = struct_size(*tt_data, vlan_data, num_vlan); 900 940 901 941 /* if tt_len is negative, allocate the space needed by the full table */ 902 942 if (*tt_len < 0) ··· 914 956 (*tt_data)->ttvn = atomic_read(&bat_priv->tt.vn); 915 957 (*tt_data)->num_vlan = htons(num_vlan); 916 958 917 - tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data + 1); 959 + tt_vlan = (*tt_data)->vlan_data; 918 960 hlist_for_each_entry(vlan, &bat_priv->softif_vlan_list, list) { 919 961 vlan_entries = atomic_read(&vlan->tt.num_entries); 920 962 if (vlan_entries < 1) ··· 2874 2916 { 2875 2917 struct batadv_tvlv_tt_data *tvlv_tt_data = NULL; 2876 2918 struct batadv_tt_req_node *tt_req_node = NULL; 2877 - struct batadv_tvlv_tt_vlan_data *tt_vlan_req; 2878 2919 struct batadv_hard_iface *primary_if; 2879 2920 bool ret = false; 2880 2921 int i, size; ··· 2889 2932 if (!tt_req_node) 2890 2933 goto out; 2891 2934 2892 - size = sizeof(*tvlv_tt_data) + sizeof(*tt_vlan_req) * num_vlan; 2935 + size = struct_size(tvlv_tt_data, vlan_data, num_vlan); 2893 2936 tvlv_tt_data = kzalloc(size, GFP_ATOMIC); 2894 2937 if (!tvlv_tt_data) 2895 2938 goto out; ··· 2901 2944 /* send all the CRCs within the request. This is needed by intermediate 2902 2945 * nodes to ensure they have the correct table before replying 2903 2946 */ 2904 - tt_vlan_req = (struct batadv_tvlv_tt_vlan_data *)(tvlv_tt_data + 1); 2905 2947 for (i = 0; i < num_vlan; i++) { 2906 - tt_vlan_req->vid = tt_vlan->vid; 2907 - tt_vlan_req->crc = tt_vlan->crc; 2948 + tvlv_tt_data->vlan_data[i].vid = tt_vlan->vid; 2949 + tvlv_tt_data->vlan_data[i].crc = tt_vlan->crc; 2908 2950 2909 - tt_vlan_req++; 2910 2951 tt_vlan++; 2911 2952 } 2912 2953 ··· 2956 3001 struct batadv_orig_node *res_dst_orig_node = NULL; 2957 3002 struct batadv_tvlv_tt_change *tt_change; 2958 3003 struct batadv_tvlv_tt_data *tvlv_tt_data = NULL; 2959 - struct batadv_tvlv_tt_vlan_data *tt_vlan; 2960 3004 bool ret = false, full_table; 2961 3005 u8 orig_ttvn, req_ttvn; 2962 3006 u16 tvlv_len; ··· 2978 3024 orig_ttvn = (u8)atomic_read(&req_dst_orig_node->last_ttvn); 2979 3025 req_ttvn = tt_data->ttvn; 2980 3026 2981 - tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(tt_data + 1); 2982 3027 /* this node doesn't have the requested data */ 2983 3028 if (orig_ttvn != req_ttvn || 2984 - !batadv_tt_global_check_crc(req_dst_orig_node, tt_vlan, 3029 + !batadv_tt_global_check_crc(req_dst_orig_node, tt_data->vlan_data, 2985 3030 ntohs(tt_data->num_vlan))) 2986 3031 goto out; 2987 3032 ··· 3323 3370 struct batadv_orig_node *orig_node = NULL; 3324 3371 struct batadv_tvlv_tt_change *tt_change; 3325 3372 u8 *tvlv_ptr = (u8 *)tt_data; 3326 - u16 change_offset; 3327 3373 3328 3374 batadv_dbg(BATADV_DBG_TT, bat_priv, 3329 3375 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", ··· 3335 3383 3336 3384 spin_lock_bh(&orig_node->tt_lock); 3337 3385 3338 - change_offset = sizeof(struct batadv_tvlv_tt_vlan_data); 3339 - change_offset *= ntohs(tt_data->num_vlan); 3340 - change_offset += sizeof(*tt_data); 3341 - tvlv_ptr += change_offset; 3386 + tvlv_ptr += struct_size(tt_data, vlan_data, ntohs(tt_data->num_vlan)); 3342 3387 3343 3388 tt_change = (struct batadv_tvlv_tt_change *)tvlv_ptr; 3344 3389 if (tt_data->flags & BATADV_TT_FULL_TABLE) { ··· 3934 3985 u8 flags, void *tvlv_value, 3935 3986 u16 tvlv_value_len) 3936 3987 { 3937 - struct batadv_tvlv_tt_vlan_data *tt_vlan; 3938 3988 struct batadv_tvlv_tt_change *tt_change; 3939 3989 struct batadv_tvlv_tt_data *tt_data; 3940 3990 u16 num_entries, num_vlan; 3991 + size_t flex_size; 3941 3992 3942 3993 if (tvlv_value_len < sizeof(*tt_data)) 3943 3994 return; ··· 3947 3998 3948 3999 num_vlan = ntohs(tt_data->num_vlan); 3949 4000 3950 - if (tvlv_value_len < sizeof(*tt_vlan) * num_vlan) 4001 + flex_size = flex_array_size(tt_data, vlan_data, num_vlan); 4002 + if (tvlv_value_len < flex_size) 3951 4003 return; 3952 4004 3953 - tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(tt_data + 1); 3954 - tt_change = (struct batadv_tvlv_tt_change *)(tt_vlan + num_vlan); 3955 - tvlv_value_len -= sizeof(*tt_vlan) * num_vlan; 4005 + tt_change = (struct batadv_tvlv_tt_change *)((void *)tt_data 4006 + + flex_size); 4007 + tvlv_value_len -= flex_size; 3956 4008 3957 4009 num_entries = batadv_tt_entries(tvlv_value_len); 3958 4010 3959 - batadv_tt_update_orig(bat_priv, orig, tt_vlan, num_vlan, tt_change, 3960 - num_entries, tt_data->ttvn); 4011 + batadv_tt_update_orig(bat_priv, orig, tt_data->vlan_data, num_vlan, 4012 + tt_change, num_entries, tt_data->ttvn); 3961 4013 } 3962 4014 3963 4015 /** ··· 3989 4039 tt_data = tvlv_value; 3990 4040 tvlv_value_len -= sizeof(*tt_data); 3991 4041 3992 - tt_vlan_len = sizeof(struct batadv_tvlv_tt_vlan_data); 3993 - tt_vlan_len *= ntohs(tt_data->num_vlan); 4042 + tt_vlan_len = flex_array_size(tt_data, vlan_data, 4043 + ntohs(tt_data->num_vlan)); 3994 4044 3995 4045 if (tvlv_value_len < tt_vlan_len) 3996 4046 return NET_RX_SUCCESS;