diff options
-rw-r--r-- | net/batman-adv/distributed-arp-table.c | 22 | ||||
-rw-r--r-- | net/batman-adv/sysfs.c | 10 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 25 |
3 files changed, 11 insertions, 46 deletions
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index d54188a112ea..8e15d966d9b0 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c | |||
@@ -816,7 +816,6 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, | |||
816 | bool ret = false; | 816 | bool ret = false; |
817 | struct batadv_dat_entry *dat_entry = NULL; | 817 | struct batadv_dat_entry *dat_entry = NULL; |
818 | struct sk_buff *skb_new; | 818 | struct sk_buff *skb_new; |
819 | struct batadv_hard_iface *primary_if = NULL; | ||
820 | 819 | ||
821 | if (!atomic_read(&bat_priv->distributed_arp_table)) | 820 | if (!atomic_read(&bat_priv->distributed_arp_table)) |
822 | goto out; | 821 | goto out; |
@@ -838,22 +837,18 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, | |||
838 | 837 | ||
839 | dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst); | 838 | dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst); |
840 | if (dat_entry) { | 839 | if (dat_entry) { |
841 | primary_if = batadv_primary_if_get_selected(bat_priv); | ||
842 | if (!primary_if) | ||
843 | goto out; | ||
844 | |||
845 | skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src, | 840 | skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src, |
846 | primary_if->soft_iface, ip_dst, hw_src, | 841 | bat_priv->soft_iface, ip_dst, hw_src, |
847 | dat_entry->mac_addr, hw_src); | 842 | dat_entry->mac_addr, hw_src); |
848 | if (!skb_new) | 843 | if (!skb_new) |
849 | goto out; | 844 | goto out; |
850 | 845 | ||
851 | skb_reset_mac_header(skb_new); | 846 | skb_reset_mac_header(skb_new); |
852 | skb_new->protocol = eth_type_trans(skb_new, | 847 | skb_new->protocol = eth_type_trans(skb_new, |
853 | primary_if->soft_iface); | 848 | bat_priv->soft_iface); |
854 | bat_priv->stats.rx_packets++; | 849 | bat_priv->stats.rx_packets++; |
855 | bat_priv->stats.rx_bytes += skb->len + ETH_HLEN; | 850 | bat_priv->stats.rx_bytes += skb->len + ETH_HLEN; |
856 | primary_if->soft_iface->last_rx = jiffies; | 851 | bat_priv->soft_iface->last_rx = jiffies; |
857 | 852 | ||
858 | netif_rx(skb_new); | 853 | netif_rx(skb_new); |
859 | batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n"); | 854 | batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n"); |
@@ -866,8 +861,6 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, | |||
866 | out: | 861 | out: |
867 | if (dat_entry) | 862 | if (dat_entry) |
868 | batadv_dat_entry_free_ref(dat_entry); | 863 | batadv_dat_entry_free_ref(dat_entry); |
869 | if (primary_if) | ||
870 | batadv_hardif_free_ref(primary_if); | ||
871 | return ret; | 864 | return ret; |
872 | } | 865 | } |
873 | 866 | ||
@@ -887,7 +880,6 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, | |||
887 | __be32 ip_src, ip_dst; | 880 | __be32 ip_src, ip_dst; |
888 | uint8_t *hw_src; | 881 | uint8_t *hw_src; |
889 | struct sk_buff *skb_new; | 882 | struct sk_buff *skb_new; |
890 | struct batadv_hard_iface *primary_if = NULL; | ||
891 | struct batadv_dat_entry *dat_entry = NULL; | 883 | struct batadv_dat_entry *dat_entry = NULL; |
892 | bool ret = false; | 884 | bool ret = false; |
893 | int err; | 885 | int err; |
@@ -912,12 +904,8 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, | |||
912 | if (!dat_entry) | 904 | if (!dat_entry) |
913 | goto out; | 905 | goto out; |
914 | 906 | ||
915 | primary_if = batadv_primary_if_get_selected(bat_priv); | ||
916 | if (!primary_if) | ||
917 | goto out; | ||
918 | |||
919 | skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src, | 907 | skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src, |
920 | primary_if->soft_iface, ip_dst, hw_src, | 908 | bat_priv->soft_iface, ip_dst, hw_src, |
921 | dat_entry->mac_addr, hw_src); | 909 | dat_entry->mac_addr, hw_src); |
922 | 910 | ||
923 | if (!skb_new) | 911 | if (!skb_new) |
@@ -941,8 +929,6 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, | |||
941 | out: | 929 | out: |
942 | if (dat_entry) | 930 | if (dat_entry) |
943 | batadv_dat_entry_free_ref(dat_entry); | 931 | batadv_dat_entry_free_ref(dat_entry); |
944 | if (primary_if) | ||
945 | batadv_hardif_free_ref(primary_if); | ||
946 | if (ret) | 932 | if (ret) |
947 | kfree_skb(skb); | 933 | kfree_skb(skb); |
948 | return ret; | 934 | return ret; |
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index afbba319d73a..6a44fed12837 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c | |||
@@ -688,15 +688,10 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type, | |||
688 | enum batadv_uev_action action, const char *data) | 688 | enum batadv_uev_action action, const char *data) |
689 | { | 689 | { |
690 | int ret = -ENOMEM; | 690 | int ret = -ENOMEM; |
691 | struct batadv_hard_iface *primary_if; | ||
692 | struct kobject *bat_kobj; | 691 | struct kobject *bat_kobj; |
693 | char *uevent_env[4] = { NULL, NULL, NULL, NULL }; | 692 | char *uevent_env[4] = { NULL, NULL, NULL, NULL }; |
694 | 693 | ||
695 | primary_if = batadv_primary_if_get_selected(bat_priv); | 694 | bat_kobj = &bat_priv->soft_iface->dev.kobj; |
696 | if (!primary_if) | ||
697 | goto out; | ||
698 | |||
699 | bat_kobj = &primary_if->soft_iface->dev.kobj; | ||
700 | 695 | ||
701 | uevent_env[0] = kmalloc(strlen(BATADV_UEV_TYPE_VAR) + | 696 | uevent_env[0] = kmalloc(strlen(BATADV_UEV_TYPE_VAR) + |
702 | strlen(batadv_uev_type_str[type]) + 1, | 697 | strlen(batadv_uev_type_str[type]) + 1, |
@@ -732,9 +727,6 @@ out: | |||
732 | kfree(uevent_env[1]); | 727 | kfree(uevent_env[1]); |
733 | kfree(uevent_env[2]); | 728 | kfree(uevent_env[2]); |
734 | 729 | ||
735 | if (primary_if) | ||
736 | batadv_hardif_free_ref(primary_if); | ||
737 | |||
738 | if (ret) | 730 | if (ret) |
739 | batadv_dbg(BATADV_DBG_BATMAN, bat_priv, | 731 | batadv_dbg(BATADV_DBG_BATMAN, bat_priv, |
740 | "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", | 732 | "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 98a66a021a60..7e9e264cb4df 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -385,25 +385,19 @@ static void batadv_tt_prepare_packet_buff(struct batadv_priv *bat_priv, | |||
385 | int *packet_buff_len, | 385 | int *packet_buff_len, |
386 | int min_packet_len) | 386 | int min_packet_len) |
387 | { | 387 | { |
388 | struct batadv_hard_iface *primary_if; | ||
389 | int req_len; | 388 | int req_len; |
390 | 389 | ||
391 | primary_if = batadv_primary_if_get_selected(bat_priv); | ||
392 | |||
393 | req_len = min_packet_len; | 390 | req_len = min_packet_len; |
394 | req_len += batadv_tt_len(atomic_read(&bat_priv->tt.local_changes)); | 391 | req_len += batadv_tt_len(atomic_read(&bat_priv->tt.local_changes)); |
395 | 392 | ||
396 | /* if we have too many changes for one packet don't send any | 393 | /* if we have too many changes for one packet don't send any |
397 | * and wait for the tt table request which will be fragmented | 394 | * and wait for the tt table request which will be fragmented |
398 | */ | 395 | */ |
399 | if ((!primary_if) || (req_len > primary_if->soft_iface->mtu)) | 396 | if (req_len > bat_priv->soft_iface->mtu) |
400 | req_len = min_packet_len; | 397 | req_len = min_packet_len; |
401 | 398 | ||
402 | batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len, | 399 | batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len, |
403 | min_packet_len, req_len); | 400 | min_packet_len, req_len); |
404 | |||
405 | if (primary_if) | ||
406 | batadv_hardif_free_ref(primary_if); | ||
407 | } | 401 | } |
408 | 402 | ||
409 | static int batadv_tt_changes_fill_buff(struct batadv_priv *bat_priv, | 403 | static int batadv_tt_changes_fill_buff(struct batadv_priv *bat_priv, |
@@ -1580,7 +1574,7 @@ static int batadv_tt_global_valid(const void *entry_ptr, | |||
1580 | static struct sk_buff * | 1574 | static struct sk_buff * |
1581 | batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, | 1575 | batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, |
1582 | struct batadv_hashtable *hash, | 1576 | struct batadv_hashtable *hash, |
1583 | struct batadv_hard_iface *primary_if, | 1577 | struct batadv_priv *bat_priv, |
1584 | int (*valid_cb)(const void *, const void *), | 1578 | int (*valid_cb)(const void *, const void *), |
1585 | void *cb_data) | 1579 | void *cb_data) |
1586 | { | 1580 | { |
@@ -1594,8 +1588,8 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, | |||
1594 | uint32_t i; | 1588 | uint32_t i; |
1595 | size_t len; | 1589 | size_t len; |
1596 | 1590 | ||
1597 | if (tt_query_size + tt_len > primary_if->soft_iface->mtu) { | 1591 | if (tt_query_size + tt_len > bat_priv->soft_iface->mtu) { |
1598 | tt_len = primary_if->soft_iface->mtu - tt_query_size; | 1592 | tt_len = bat_priv->soft_iface->mtu - tt_query_size; |
1599 | tt_len -= tt_len % sizeof(struct batadv_tt_change); | 1593 | tt_len -= tt_len % sizeof(struct batadv_tt_change); |
1600 | } | 1594 | } |
1601 | tt_tot = tt_len / sizeof(struct batadv_tt_change); | 1595 | tt_tot = tt_len / sizeof(struct batadv_tt_change); |
@@ -1715,7 +1709,6 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1715 | { | 1709 | { |
1716 | struct batadv_orig_node *req_dst_orig_node; | 1710 | struct batadv_orig_node *req_dst_orig_node; |
1717 | struct batadv_orig_node *res_dst_orig_node = NULL; | 1711 | struct batadv_orig_node *res_dst_orig_node = NULL; |
1718 | struct batadv_hard_iface *primary_if = NULL; | ||
1719 | uint8_t orig_ttvn, req_ttvn, ttvn; | 1712 | uint8_t orig_ttvn, req_ttvn, ttvn; |
1720 | int ret = false; | 1713 | int ret = false; |
1721 | unsigned char *tt_buff; | 1714 | unsigned char *tt_buff; |
@@ -1740,10 +1733,6 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1740 | if (!res_dst_orig_node) | 1733 | if (!res_dst_orig_node) |
1741 | goto out; | 1734 | goto out; |
1742 | 1735 | ||
1743 | primary_if = batadv_primary_if_get_selected(bat_priv); | ||
1744 | if (!primary_if) | ||
1745 | goto out; | ||
1746 | |||
1747 | orig_ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); | 1736 | orig_ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); |
1748 | req_ttvn = tt_request->ttvn; | 1737 | req_ttvn = tt_request->ttvn; |
1749 | 1738 | ||
@@ -1791,7 +1780,7 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1791 | 1780 | ||
1792 | skb = batadv_tt_response_fill_table(tt_len, ttvn, | 1781 | skb = batadv_tt_response_fill_table(tt_len, ttvn, |
1793 | bat_priv->tt.global_hash, | 1782 | bat_priv->tt.global_hash, |
1794 | primary_if, | 1783 | bat_priv, |
1795 | batadv_tt_global_valid, | 1784 | batadv_tt_global_valid, |
1796 | req_dst_orig_node); | 1785 | req_dst_orig_node); |
1797 | if (!skb) | 1786 | if (!skb) |
@@ -1828,8 +1817,6 @@ out: | |||
1828 | batadv_orig_node_free_ref(res_dst_orig_node); | 1817 | batadv_orig_node_free_ref(res_dst_orig_node); |
1829 | if (req_dst_orig_node) | 1818 | if (req_dst_orig_node) |
1830 | batadv_orig_node_free_ref(req_dst_orig_node); | 1819 | batadv_orig_node_free_ref(req_dst_orig_node); |
1831 | if (primary_if) | ||
1832 | batadv_hardif_free_ref(primary_if); | ||
1833 | if (!ret) | 1820 | if (!ret) |
1834 | kfree_skb(skb); | 1821 | kfree_skb(skb); |
1835 | return ret; | 1822 | return ret; |
@@ -1907,7 +1894,7 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1907 | 1894 | ||
1908 | skb = batadv_tt_response_fill_table(tt_len, ttvn, | 1895 | skb = batadv_tt_response_fill_table(tt_len, ttvn, |
1909 | bat_priv->tt.local_hash, | 1896 | bat_priv->tt.local_hash, |
1910 | primary_if, | 1897 | bat_priv, |
1911 | batadv_tt_local_valid_entry, | 1898 | batadv_tt_local_valid_entry, |
1912 | NULL); | 1899 | NULL); |
1913 | if (!skb) | 1900 | if (!skb) |