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

Merge tag 'batadv-net-for-davem-20180302' of git://git.open-mesh.org/linux-merge

Simon Wunderlich says:

====================
Here are some batman-adv bugfixes:

- fix skb checksum issues, by Matthias Schiffer (2 patches)

- fix exception handling when dumping data objects through netlink,
by Sven Eckelmann (4 patches)

- fix handling of interface indices, by Sven Eckelmann
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+50 -39
+15 -11
net/batman-adv/bat_iv_ogm.c
··· 157 157 * Return: 0 on success, a negative error code otherwise. 158 158 */ 159 159 static int batadv_iv_ogm_orig_add_if(struct batadv_orig_node *orig_node, 160 - int max_if_num) 160 + unsigned int max_if_num) 161 161 { 162 162 void *data_ptr; 163 163 size_t old_size; ··· 201 201 */ 202 202 static void 203 203 batadv_iv_ogm_drop_bcast_own_entry(struct batadv_orig_node *orig_node, 204 - int max_if_num, int del_if_num) 204 + unsigned int max_if_num, 205 + unsigned int del_if_num) 205 206 { 206 207 size_t chunk_size; 207 208 size_t if_offset; ··· 240 239 */ 241 240 static void 242 241 batadv_iv_ogm_drop_bcast_own_sum_entry(struct batadv_orig_node *orig_node, 243 - int max_if_num, int del_if_num) 242 + unsigned int max_if_num, 243 + unsigned int del_if_num) 244 244 { 245 245 size_t if_offset; 246 246 void *data_ptr; ··· 278 276 * Return: 0 on success, a negative error code otherwise. 279 277 */ 280 278 static int batadv_iv_ogm_orig_del_if(struct batadv_orig_node *orig_node, 281 - int max_if_num, int del_if_num) 279 + unsigned int max_if_num, 280 + unsigned int del_if_num) 282 281 { 283 282 spin_lock_bh(&orig_node->bat_iv.ogm_cnt_lock); 284 283 ··· 314 311 batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr) 315 312 { 316 313 struct batadv_orig_node *orig_node; 317 - int size, hash_added; 314 + int hash_added; 315 + size_t size; 318 316 319 317 orig_node = batadv_orig_hash_find(bat_priv, addr); 320 318 if (orig_node) ··· 897 893 u32 i; 898 894 size_t word_index; 899 895 u8 *w; 900 - int if_num; 896 + unsigned int if_num; 901 897 902 898 for (i = 0; i < hash->size; i++) { 903 899 head = &hash->table[i]; ··· 1027 1023 struct batadv_neigh_node *tmp_neigh_node = NULL; 1028 1024 struct batadv_neigh_node *router = NULL; 1029 1025 struct batadv_orig_node *orig_node_tmp; 1030 - int if_num; 1026 + unsigned int if_num; 1031 1027 u8 sum_orig, sum_neigh; 1032 1028 u8 *neigh_addr; 1033 1029 u8 tq_avg; ··· 1186 1182 u8 total_count; 1187 1183 u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own; 1188 1184 unsigned int neigh_rq_inv_cube, neigh_rq_max_cube; 1189 - int if_num; 1185 + unsigned int if_num; 1190 1186 unsigned int tq_asym_penalty, inv_asym_penalty; 1191 1187 unsigned int combined_tq; 1192 1188 unsigned int tq_iface_penalty; ··· 1706 1702 1707 1703 if (is_my_orig) { 1708 1704 unsigned long *word; 1709 - int offset; 1705 + size_t offset; 1710 1706 s32 bit_pos; 1711 - s16 if_num; 1707 + unsigned int if_num; 1712 1708 u8 *weight; 1713 1709 1714 1710 orig_neigh_node = batadv_iv_ogm_orig_get(bat_priv, ··· 2733 2729 struct batadv_neigh_ifinfo *router_ifinfo = NULL; 2734 2730 struct batadv_neigh_node *router; 2735 2731 struct batadv_gw_node *curr_gw; 2736 - int ret = -EINVAL; 2732 + int ret = 0; 2737 2733 void *hdr; 2738 2734 2739 2735 router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT);
+1 -1
net/batman-adv/bat_v.c
··· 928 928 struct batadv_neigh_ifinfo *router_ifinfo = NULL; 929 929 struct batadv_neigh_node *router; 930 930 struct batadv_gw_node *curr_gw; 931 - int ret = -EINVAL; 931 + int ret = 0; 932 932 void *hdr; 933 933 934 934 router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT);
+14 -8
net/batman-adv/bridge_loop_avoidance.c
··· 2161 2161 { 2162 2162 struct batadv_bla_claim *claim; 2163 2163 int idx = 0; 2164 + int ret = 0; 2164 2165 2165 2166 rcu_read_lock(); 2166 2167 hlist_for_each_entry_rcu(claim, head, hash_entry) { 2167 2168 if (idx++ < *idx_skip) 2168 2169 continue; 2169 - if (batadv_bla_claim_dump_entry(msg, portid, seq, 2170 - primary_if, claim)) { 2170 + 2171 + ret = batadv_bla_claim_dump_entry(msg, portid, seq, 2172 + primary_if, claim); 2173 + if (ret) { 2171 2174 *idx_skip = idx - 1; 2172 2175 goto unlock; 2173 2176 } 2174 2177 } 2175 2178 2176 - *idx_skip = idx; 2179 + *idx_skip = 0; 2177 2180 unlock: 2178 2181 rcu_read_unlock(); 2179 - return 0; 2182 + return ret; 2180 2183 } 2181 2184 2182 2185 /** ··· 2394 2391 { 2395 2392 struct batadv_bla_backbone_gw *backbone_gw; 2396 2393 int idx = 0; 2394 + int ret = 0; 2397 2395 2398 2396 rcu_read_lock(); 2399 2397 hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) { 2400 2398 if (idx++ < *idx_skip) 2401 2399 continue; 2402 - if (batadv_bla_backbone_dump_entry(msg, portid, seq, 2403 - primary_if, backbone_gw)) { 2400 + 2401 + ret = batadv_bla_backbone_dump_entry(msg, portid, seq, 2402 + primary_if, backbone_gw); 2403 + if (ret) { 2404 2404 *idx_skip = idx - 1; 2405 2405 goto unlock; 2406 2406 } 2407 2407 } 2408 2408 2409 - *idx_skip = idx; 2409 + *idx_skip = 0; 2410 2410 unlock: 2411 2411 rcu_read_unlock(); 2412 - return 0; 2412 + return ret; 2413 2413 } 2414 2414 2415 2415 /**
+2 -1
net/batman-adv/fragmentation.c
··· 288 288 /* Move the existing MAC header to just before the payload. (Override 289 289 * the fragment header.) 290 290 */ 291 - skb_pull_rcsum(skb_out, hdr_size); 291 + skb_pull(skb_out, hdr_size); 292 + skb_out->ip_summed = CHECKSUM_NONE; 292 293 memmove(skb_out->data - ETH_HLEN, skb_mac_header(skb_out), ETH_HLEN); 293 294 skb_set_mac_header(skb_out, -ETH_HLEN); 294 295 skb_reset_network_header(skb_out);
+7 -2
net/batman-adv/hard-interface.c
··· 763 763 hard_iface->soft_iface = soft_iface; 764 764 bat_priv = netdev_priv(hard_iface->soft_iface); 765 765 766 + if (bat_priv->num_ifaces >= UINT_MAX) { 767 + ret = -ENOSPC; 768 + goto err_dev; 769 + } 770 + 766 771 ret = netdev_master_upper_dev_link(hard_iface->net_dev, 767 772 soft_iface, NULL, NULL, NULL); 768 773 if (ret) ··· 881 876 batadv_hardif_recalc_extra_skbroom(hard_iface->soft_iface); 882 877 883 878 /* nobody uses this interface anymore */ 884 - if (!bat_priv->num_ifaces) { 879 + if (bat_priv->num_ifaces == 0) { 885 880 batadv_gw_check_client_stop(bat_priv); 886 881 887 882 if (autodel == BATADV_IF_CLEANUP_AUTO) ··· 917 912 if (ret) 918 913 goto free_if; 919 914 920 - hard_iface->if_num = -1; 915 + hard_iface->if_num = 0; 921 916 hard_iface->net_dev = net_dev; 922 917 hard_iface->soft_iface = NULL; 923 918 hard_iface->if_status = BATADV_IF_NOT_IN_USE;
+2 -2
net/batman-adv/originator.c
··· 1569 1569 * Return: 0 on success or negative error number in case of failure 1570 1570 */ 1571 1571 int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, 1572 - int max_if_num) 1572 + unsigned int max_if_num) 1573 1573 { 1574 1574 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 1575 1575 struct batadv_algo_ops *bao = bat_priv->algo_ops; ··· 1611 1611 * Return: 0 on success or negative error number in case of failure 1612 1612 */ 1613 1613 int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, 1614 - int max_if_num) 1614 + unsigned int max_if_num) 1615 1615 { 1616 1616 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 1617 1617 struct batadv_hashtable *hash = bat_priv->orig_hash;
+2 -2
net/batman-adv/originator.h
··· 73 73 int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb); 74 74 int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset); 75 75 int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, 76 - int max_if_num); 76 + unsigned int max_if_num); 77 77 int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, 78 - int max_if_num); 78 + unsigned int max_if_num); 79 79 struct batadv_orig_node_vlan * 80 80 batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, 81 81 unsigned short vid);
+1 -7
net/batman-adv/soft-interface.c
··· 459 459 460 460 /* skb->dev & skb->pkt_type are set here */ 461 461 skb->protocol = eth_type_trans(skb, soft_iface); 462 - 463 - /* should not be necessary anymore as we use skb_pull_rcsum() 464 - * TODO: please verify this and remove this TODO 465 - * -- Dec 21st 2009, Simon Wunderlich 466 - */ 467 - 468 - /* skb->ip_summed = CHECKSUM_UNNECESSARY; */ 462 + skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); 469 463 470 464 batadv_inc_counter(bat_priv, BATADV_CNT_RX); 471 465 batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
+6 -5
net/batman-adv/types.h
··· 167 167 struct list_head list; 168 168 169 169 /** @if_num: identificator of the interface */ 170 - s16 if_num; 170 + unsigned int if_num; 171 171 172 172 /** @if_status: status of the interface for batman-adv */ 173 173 char if_status; ··· 1596 1596 atomic_t batman_queue_left; 1597 1597 1598 1598 /** @num_ifaces: number of interfaces assigned to this mesh interface */ 1599 - char num_ifaces; 1599 + unsigned int num_ifaces; 1600 1600 1601 1601 /** @mesh_obj: kobject for sysfs mesh subdirectory */ 1602 1602 struct kobject *mesh_obj; ··· 2186 2186 * orig_node due to a new hard-interface being added into the mesh 2187 2187 * (optional) 2188 2188 */ 2189 - int (*add_if)(struct batadv_orig_node *orig_node, int max_if_num); 2189 + int (*add_if)(struct batadv_orig_node *orig_node, 2190 + unsigned int max_if_num); 2190 2191 2191 2192 /** 2192 2193 * @del_if: ask the routing algorithm to apply the needed changes to the 2193 2194 * orig_node due to an hard-interface being removed from the mesh 2194 2195 * (optional) 2195 2196 */ 2196 - int (*del_if)(struct batadv_orig_node *orig_node, int max_if_num, 2197 - int del_if_num); 2197 + int (*del_if)(struct batadv_orig_node *orig_node, 2198 + unsigned int max_if_num, unsigned int del_if_num); 2198 2199 2199 2200 #ifdef CONFIG_BATMAN_ADV_DEBUGFS 2200 2201 /** @print: print the originator table (optional) */