diff options
author | Martin Hundebøll <martin@hundeboll.net> | 2012-10-16 10:13:48 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-11-21 06:34:50 -0500 |
commit | bb351ba0bba23f01af00e36bfe20897201f404fa (patch) | |
tree | 7ac84275cfb3f32d0cae0ba854a90298f56e9561 /net/batman-adv | |
parent | 637fbd12947b5645d8c16c982aa15c17ab695b0a (diff) |
batman-adv: Add wrapper to look up neighbor and send skb
By adding batadv_send_skb_to_orig() in send.c, we can remove duplicate
code that looks up the next hop and then calls batadv_send_skb_packet().
Furthermore, this prepares the upcoming new implementation of
fragmentation, which requires the next hop to route packets.
Please note that this doesn't entirely remove the next-hop lookup in
routing.c and unicast.c, since it is used by the current fragmentation
code.
Also note that the next-hop info is removed from debug messages in
translation-table.c, since it is looked up elsewhere.
Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/routing.c | 37 | ||||
-rw-r--r-- | net/batman-adv/send.c | 33 | ||||
-rw-r--r-- | net/batman-adv/send.h | 3 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 65 | ||||
-rw-r--r-- | net/batman-adv/unicast.c | 8 | ||||
-rw-r--r-- | net/batman-adv/vis.c | 35 |
6 files changed, 74 insertions, 107 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 78d657264cbf..8d64348e3cc0 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -285,7 +285,6 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv, | |||
285 | { | 285 | { |
286 | struct batadv_hard_iface *primary_if = NULL; | 286 | struct batadv_hard_iface *primary_if = NULL; |
287 | struct batadv_orig_node *orig_node = NULL; | 287 | struct batadv_orig_node *orig_node = NULL; |
288 | struct batadv_neigh_node *router = NULL; | ||
289 | struct batadv_icmp_packet_rr *icmp_packet; | 288 | struct batadv_icmp_packet_rr *icmp_packet; |
290 | int ret = NET_RX_DROP; | 289 | int ret = NET_RX_DROP; |
291 | 290 | ||
@@ -307,10 +306,6 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv, | |||
307 | if (!orig_node) | 306 | if (!orig_node) |
308 | goto out; | 307 | goto out; |
309 | 308 | ||
310 | router = batadv_orig_node_get_router(orig_node); | ||
311 | if (!router) | ||
312 | goto out; | ||
313 | |||
314 | /* create a copy of the skb, if needed, to modify it. */ | 309 | /* create a copy of the skb, if needed, to modify it. */ |
315 | if (skb_cow(skb, ETH_HLEN) < 0) | 310 | if (skb_cow(skb, ETH_HLEN) < 0) |
316 | goto out; | 311 | goto out; |
@@ -322,14 +317,12 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv, | |||
322 | icmp_packet->msg_type = BATADV_ECHO_REPLY; | 317 | icmp_packet->msg_type = BATADV_ECHO_REPLY; |
323 | icmp_packet->header.ttl = BATADV_TTL; | 318 | icmp_packet->header.ttl = BATADV_TTL; |
324 | 319 | ||
325 | batadv_send_skb_packet(skb, router->if_incoming, router->addr); | 320 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) |
326 | ret = NET_RX_SUCCESS; | 321 | ret = NET_RX_SUCCESS; |
327 | 322 | ||
328 | out: | 323 | out: |
329 | if (primary_if) | 324 | if (primary_if) |
330 | batadv_hardif_free_ref(primary_if); | 325 | batadv_hardif_free_ref(primary_if); |
331 | if (router) | ||
332 | batadv_neigh_node_free_ref(router); | ||
333 | if (orig_node) | 326 | if (orig_node) |
334 | batadv_orig_node_free_ref(orig_node); | 327 | batadv_orig_node_free_ref(orig_node); |
335 | return ret; | 328 | return ret; |
@@ -340,7 +333,6 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv, | |||
340 | { | 333 | { |
341 | struct batadv_hard_iface *primary_if = NULL; | 334 | struct batadv_hard_iface *primary_if = NULL; |
342 | struct batadv_orig_node *orig_node = NULL; | 335 | struct batadv_orig_node *orig_node = NULL; |
343 | struct batadv_neigh_node *router = NULL; | ||
344 | struct batadv_icmp_packet *icmp_packet; | 336 | struct batadv_icmp_packet *icmp_packet; |
345 | int ret = NET_RX_DROP; | 337 | int ret = NET_RX_DROP; |
346 | 338 | ||
@@ -362,10 +354,6 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv, | |||
362 | if (!orig_node) | 354 | if (!orig_node) |
363 | goto out; | 355 | goto out; |
364 | 356 | ||
365 | router = batadv_orig_node_get_router(orig_node); | ||
366 | if (!router) | ||
367 | goto out; | ||
368 | |||
369 | /* create a copy of the skb, if needed, to modify it. */ | 357 | /* create a copy of the skb, if needed, to modify it. */ |
370 | if (skb_cow(skb, ETH_HLEN) < 0) | 358 | if (skb_cow(skb, ETH_HLEN) < 0) |
371 | goto out; | 359 | goto out; |
@@ -377,14 +365,12 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv, | |||
377 | icmp_packet->msg_type = BATADV_TTL_EXCEEDED; | 365 | icmp_packet->msg_type = BATADV_TTL_EXCEEDED; |
378 | icmp_packet->header.ttl = BATADV_TTL; | 366 | icmp_packet->header.ttl = BATADV_TTL; |
379 | 367 | ||
380 | batadv_send_skb_packet(skb, router->if_incoming, router->addr); | 368 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) |
381 | ret = NET_RX_SUCCESS; | 369 | ret = NET_RX_SUCCESS; |
382 | 370 | ||
383 | out: | 371 | out: |
384 | if (primary_if) | 372 | if (primary_if) |
385 | batadv_hardif_free_ref(primary_if); | 373 | batadv_hardif_free_ref(primary_if); |
386 | if (router) | ||
387 | batadv_neigh_node_free_ref(router); | ||
388 | if (orig_node) | 374 | if (orig_node) |
389 | batadv_orig_node_free_ref(orig_node); | 375 | batadv_orig_node_free_ref(orig_node); |
390 | return ret; | 376 | return ret; |
@@ -398,7 +384,6 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, | |||
398 | struct batadv_icmp_packet_rr *icmp_packet; | 384 | struct batadv_icmp_packet_rr *icmp_packet; |
399 | struct ethhdr *ethhdr; | 385 | struct ethhdr *ethhdr; |
400 | struct batadv_orig_node *orig_node = NULL; | 386 | struct batadv_orig_node *orig_node = NULL; |
401 | struct batadv_neigh_node *router = NULL; | ||
402 | int hdr_size = sizeof(struct batadv_icmp_packet); | 387 | int hdr_size = sizeof(struct batadv_icmp_packet); |
403 | int ret = NET_RX_DROP; | 388 | int ret = NET_RX_DROP; |
404 | 389 | ||
@@ -447,10 +432,6 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, | |||
447 | if (!orig_node) | 432 | if (!orig_node) |
448 | goto out; | 433 | goto out; |
449 | 434 | ||
450 | router = batadv_orig_node_get_router(orig_node); | ||
451 | if (!router) | ||
452 | goto out; | ||
453 | |||
454 | /* create a copy of the skb, if needed, to modify it. */ | 435 | /* create a copy of the skb, if needed, to modify it. */ |
455 | if (skb_cow(skb, ETH_HLEN) < 0) | 436 | if (skb_cow(skb, ETH_HLEN) < 0) |
456 | goto out; | 437 | goto out; |
@@ -461,12 +442,10 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, | |||
461 | icmp_packet->header.ttl--; | 442 | icmp_packet->header.ttl--; |
462 | 443 | ||
463 | /* route it */ | 444 | /* route it */ |
464 | batadv_send_skb_packet(skb, router->if_incoming, router->addr); | 445 | if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) |
465 | ret = NET_RX_SUCCESS; | 446 | ret = NET_RX_SUCCESS; |
466 | 447 | ||
467 | out: | 448 | out: |
468 | if (router) | ||
469 | batadv_neigh_node_free_ref(router); | ||
470 | if (orig_node) | 449 | if (orig_node) |
471 | batadv_orig_node_free_ref(orig_node); | 450 | batadv_orig_node_free_ref(orig_node); |
472 | return ret; | 451 | return ret; |
@@ -882,8 +861,8 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, | |||
882 | skb->len + ETH_HLEN); | 861 | skb->len + ETH_HLEN); |
883 | 862 | ||
884 | /* route it */ | 863 | /* route it */ |
885 | batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); | 864 | if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) |
886 | ret = NET_RX_SUCCESS; | 865 | ret = NET_RX_SUCCESS; |
887 | 866 | ||
888 | out: | 867 | out: |
889 | if (neigh_node) | 868 | if (neigh_node) |
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 660d9bf7d219..c7f702376535 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c | |||
@@ -78,6 +78,39 @@ send_skb_err: | |||
78 | return NET_XMIT_DROP; | 78 | return NET_XMIT_DROP; |
79 | } | 79 | } |
80 | 80 | ||
81 | /** | ||
82 | * batadv_send_skb_to_orig - Lookup next-hop and transmit skb. | ||
83 | * @skb: Packet to be transmitted. | ||
84 | * @orig_node: Final destination of the packet. | ||
85 | * @recv_if: Interface used when receiving the packet (can be NULL). | ||
86 | * | ||
87 | * Looks up the best next-hop towards the passed originator and passes the | ||
88 | * skb on for preparation of MAC header. If the packet originated from this | ||
89 | * host, NULL can be passed as recv_if and no interface alternating is | ||
90 | * attempted. | ||
91 | * | ||
92 | * Returns TRUE on success; FALSE otherwise. | ||
93 | */ | ||
94 | bool batadv_send_skb_to_orig(struct sk_buff *skb, | ||
95 | struct batadv_orig_node *orig_node, | ||
96 | struct batadv_hard_iface *recv_if) | ||
97 | { | ||
98 | struct batadv_priv *bat_priv = orig_node->bat_priv; | ||
99 | struct batadv_neigh_node *neigh_node; | ||
100 | |||
101 | /* batadv_find_router() increases neigh_nodes refcount if found. */ | ||
102 | neigh_node = batadv_find_router(bat_priv, orig_node, recv_if); | ||
103 | if (!neigh_node) | ||
104 | return false; | ||
105 | |||
106 | /* route it */ | ||
107 | batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); | ||
108 | |||
109 | batadv_neigh_node_free_ref(neigh_node); | ||
110 | |||
111 | return true; | ||
112 | } | ||
113 | |||
81 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface) | 114 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface) |
82 | { | 115 | { |
83 | struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); | 116 | struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); |
diff --git a/net/batman-adv/send.h b/net/batman-adv/send.h index 643329b787ed..0078dece1abc 100644 --- a/net/batman-adv/send.h +++ b/net/batman-adv/send.h | |||
@@ -23,6 +23,9 @@ | |||
23 | int batadv_send_skb_packet(struct sk_buff *skb, | 23 | int batadv_send_skb_packet(struct sk_buff *skb, |
24 | struct batadv_hard_iface *hard_iface, | 24 | struct batadv_hard_iface *hard_iface, |
25 | const uint8_t *dst_addr); | 25 | const uint8_t *dst_addr); |
26 | bool batadv_send_skb_to_orig(struct sk_buff *skb, | ||
27 | struct batadv_orig_node *orig_node, | ||
28 | struct batadv_hard_iface *recv_if); | ||
26 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface); | 29 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface); |
27 | int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, | 30 | int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, |
28 | const struct sk_buff *skb, | 31 | const struct sk_buff *skb, |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index cdad824a0014..22457a7952ba 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -1642,7 +1642,6 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv, | |||
1642 | { | 1642 | { |
1643 | struct sk_buff *skb = NULL; | 1643 | struct sk_buff *skb = NULL; |
1644 | struct batadv_tt_query_packet *tt_request; | 1644 | struct batadv_tt_query_packet *tt_request; |
1645 | struct batadv_neigh_node *neigh_node = NULL; | ||
1646 | struct batadv_hard_iface *primary_if; | 1645 | struct batadv_hard_iface *primary_if; |
1647 | struct batadv_tt_req_node *tt_req_node = NULL; | 1646 | struct batadv_tt_req_node *tt_req_node = NULL; |
1648 | int ret = 1; | 1647 | int ret = 1; |
@@ -1680,23 +1679,15 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv, | |||
1680 | if (full_table) | 1679 | if (full_table) |
1681 | tt_request->flags |= BATADV_TT_FULL_TABLE; | 1680 | tt_request->flags |= BATADV_TT_FULL_TABLE; |
1682 | 1681 | ||
1683 | neigh_node = batadv_orig_node_get_router(dst_orig_node); | 1682 | batadv_dbg(BATADV_DBG_TT, bat_priv, "Sending TT_REQUEST to %pM [%c]\n", |
1684 | if (!neigh_node) | 1683 | dst_orig_node->orig, (full_table ? 'F' : '.')); |
1685 | goto out; | ||
1686 | |||
1687 | batadv_dbg(BATADV_DBG_TT, bat_priv, | ||
1688 | "Sending TT_REQUEST to %pM via %pM [%c]\n", | ||
1689 | dst_orig_node->orig, neigh_node->addr, | ||
1690 | (full_table ? 'F' : '.')); | ||
1691 | 1684 | ||
1692 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_TX); | 1685 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_TX); |
1693 | 1686 | ||
1694 | batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); | 1687 | if (batadv_send_skb_to_orig(skb, dst_orig_node, NULL)) |
1695 | ret = 0; | 1688 | ret = 0; |
1696 | 1689 | ||
1697 | out: | 1690 | out: |
1698 | if (neigh_node) | ||
1699 | batadv_neigh_node_free_ref(neigh_node); | ||
1700 | if (primary_if) | 1691 | if (primary_if) |
1701 | batadv_hardif_free_ref(primary_if); | 1692 | batadv_hardif_free_ref(primary_if); |
1702 | if (ret) | 1693 | if (ret) |
@@ -1716,7 +1707,6 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1716 | { | 1707 | { |
1717 | struct batadv_orig_node *req_dst_orig_node; | 1708 | struct batadv_orig_node *req_dst_orig_node; |
1718 | struct batadv_orig_node *res_dst_orig_node = NULL; | 1709 | struct batadv_orig_node *res_dst_orig_node = NULL; |
1719 | struct batadv_neigh_node *neigh_node = NULL; | ||
1720 | struct batadv_hard_iface *primary_if = NULL; | 1710 | struct batadv_hard_iface *primary_if = NULL; |
1721 | uint8_t orig_ttvn, req_ttvn, ttvn; | 1711 | uint8_t orig_ttvn, req_ttvn, ttvn; |
1722 | int ret = false; | 1712 | int ret = false; |
@@ -1742,10 +1732,6 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1742 | if (!res_dst_orig_node) | 1732 | if (!res_dst_orig_node) |
1743 | goto out; | 1733 | goto out; |
1744 | 1734 | ||
1745 | neigh_node = batadv_orig_node_get_router(res_dst_orig_node); | ||
1746 | if (!neigh_node) | ||
1747 | goto out; | ||
1748 | |||
1749 | primary_if = batadv_primary_if_get_selected(bat_priv); | 1735 | primary_if = batadv_primary_if_get_selected(bat_priv); |
1750 | if (!primary_if) | 1736 | if (!primary_if) |
1751 | goto out; | 1737 | goto out; |
@@ -1817,14 +1803,13 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1817 | tt_response->flags |= BATADV_TT_FULL_TABLE; | 1803 | tt_response->flags |= BATADV_TT_FULL_TABLE; |
1818 | 1804 | ||
1819 | batadv_dbg(BATADV_DBG_TT, bat_priv, | 1805 | batadv_dbg(BATADV_DBG_TT, bat_priv, |
1820 | "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n", | 1806 | "Sending TT_RESPONSE %pM for %pM (ttvn: %u)\n", |
1821 | res_dst_orig_node->orig, neigh_node->addr, | 1807 | res_dst_orig_node->orig, req_dst_orig_node->orig, req_ttvn); |
1822 | req_dst_orig_node->orig, req_ttvn); | ||
1823 | 1808 | ||
1824 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); | 1809 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); |
1825 | 1810 | ||
1826 | batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); | 1811 | if (batadv_send_skb_to_orig(skb, res_dst_orig_node, NULL)) |
1827 | ret = true; | 1812 | ret = true; |
1828 | goto out; | 1813 | goto out; |
1829 | 1814 | ||
1830 | unlock: | 1815 | unlock: |
@@ -1835,8 +1820,6 @@ out: | |||
1835 | batadv_orig_node_free_ref(res_dst_orig_node); | 1820 | batadv_orig_node_free_ref(res_dst_orig_node); |
1836 | if (req_dst_orig_node) | 1821 | if (req_dst_orig_node) |
1837 | batadv_orig_node_free_ref(req_dst_orig_node); | 1822 | batadv_orig_node_free_ref(req_dst_orig_node); |
1838 | if (neigh_node) | ||
1839 | batadv_neigh_node_free_ref(neigh_node); | ||
1840 | if (primary_if) | 1823 | if (primary_if) |
1841 | batadv_hardif_free_ref(primary_if); | 1824 | batadv_hardif_free_ref(primary_if); |
1842 | if (!ret) | 1825 | if (!ret) |
@@ -1850,7 +1833,6 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1850 | struct batadv_tt_query_packet *tt_request) | 1833 | struct batadv_tt_query_packet *tt_request) |
1851 | { | 1834 | { |
1852 | struct batadv_orig_node *orig_node; | 1835 | struct batadv_orig_node *orig_node; |
1853 | struct batadv_neigh_node *neigh_node = NULL; | ||
1854 | struct batadv_hard_iface *primary_if = NULL; | 1836 | struct batadv_hard_iface *primary_if = NULL; |
1855 | uint8_t my_ttvn, req_ttvn, ttvn; | 1837 | uint8_t my_ttvn, req_ttvn, ttvn; |
1856 | int ret = false; | 1838 | int ret = false; |
@@ -1875,10 +1857,6 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1875 | if (!orig_node) | 1857 | if (!orig_node) |
1876 | goto out; | 1858 | goto out; |
1877 | 1859 | ||
1878 | neigh_node = batadv_orig_node_get_router(orig_node); | ||
1879 | if (!neigh_node) | ||
1880 | goto out; | ||
1881 | |||
1882 | primary_if = batadv_primary_if_get_selected(bat_priv); | 1860 | primary_if = batadv_primary_if_get_selected(bat_priv); |
1883 | if (!primary_if) | 1861 | if (!primary_if) |
1884 | goto out; | 1862 | goto out; |
@@ -1942,14 +1920,14 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1942 | tt_response->flags |= BATADV_TT_FULL_TABLE; | 1920 | tt_response->flags |= BATADV_TT_FULL_TABLE; |
1943 | 1921 | ||
1944 | batadv_dbg(BATADV_DBG_TT, bat_priv, | 1922 | batadv_dbg(BATADV_DBG_TT, bat_priv, |
1945 | "Sending TT_RESPONSE to %pM via %pM [%c]\n", | 1923 | "Sending TT_RESPONSE to %pM [%c]\n", |
1946 | orig_node->orig, neigh_node->addr, | 1924 | orig_node->orig, |
1947 | (tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); | 1925 | (tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); |
1948 | 1926 | ||
1949 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); | 1927 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); |
1950 | 1928 | ||
1951 | batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); | 1929 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) |
1952 | ret = true; | 1930 | ret = true; |
1953 | goto out; | 1931 | goto out; |
1954 | 1932 | ||
1955 | unlock: | 1933 | unlock: |
@@ -1957,8 +1935,6 @@ unlock: | |||
1957 | out: | 1935 | out: |
1958 | if (orig_node) | 1936 | if (orig_node) |
1959 | batadv_orig_node_free_ref(orig_node); | 1937 | batadv_orig_node_free_ref(orig_node); |
1960 | if (neigh_node) | ||
1961 | batadv_neigh_node_free_ref(neigh_node); | ||
1962 | if (primary_if) | 1938 | if (primary_if) |
1963 | batadv_hardif_free_ref(primary_if); | 1939 | batadv_hardif_free_ref(primary_if); |
1964 | if (!ret) | 1940 | if (!ret) |
@@ -2223,7 +2199,6 @@ unlock: | |||
2223 | static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client, | 2199 | static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client, |
2224 | struct batadv_orig_node *orig_node) | 2200 | struct batadv_orig_node *orig_node) |
2225 | { | 2201 | { |
2226 | struct batadv_neigh_node *neigh_node = NULL; | ||
2227 | struct sk_buff *skb = NULL; | 2202 | struct sk_buff *skb = NULL; |
2228 | struct batadv_roam_adv_packet *roam_adv_packet; | 2203 | struct batadv_roam_adv_packet *roam_adv_packet; |
2229 | int ret = 1; | 2204 | int ret = 1; |
@@ -2256,23 +2231,17 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client, | |||
2256 | memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN); | 2231 | memcpy(roam_adv_packet->dst, orig_node->orig, ETH_ALEN); |
2257 | memcpy(roam_adv_packet->client, client, ETH_ALEN); | 2232 | memcpy(roam_adv_packet->client, client, ETH_ALEN); |
2258 | 2233 | ||
2259 | neigh_node = batadv_orig_node_get_router(orig_node); | ||
2260 | if (!neigh_node) | ||
2261 | goto out; | ||
2262 | |||
2263 | batadv_dbg(BATADV_DBG_TT, bat_priv, | 2234 | batadv_dbg(BATADV_DBG_TT, bat_priv, |
2264 | "Sending ROAMING_ADV to %pM (client %pM) via %pM\n", | 2235 | "Sending ROAMING_ADV to %pM (client %pM)\n", |
2265 | orig_node->orig, client, neigh_node->addr); | 2236 | orig_node->orig, client); |
2266 | 2237 | ||
2267 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX); | 2238 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX); |
2268 | 2239 | ||
2269 | batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); | 2240 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) |
2270 | ret = 0; | 2241 | ret = 0; |
2271 | 2242 | ||
2272 | out: | 2243 | out: |
2273 | if (neigh_node) | 2244 | if (ret && skb) |
2274 | batadv_neigh_node_free_ref(neigh_node); | ||
2275 | if (ret) | ||
2276 | kfree_skb(skb); | 2245 | kfree_skb(skb); |
2277 | return; | 2246 | return; |
2278 | } | 2247 | } |
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index c9a1f6523c36..10aff49fcf25 100644 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c | |||
@@ -402,7 +402,7 @@ int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv, | |||
402 | struct batadv_orig_node *orig_node; | 402 | struct batadv_orig_node *orig_node; |
403 | struct batadv_neigh_node *neigh_node; | 403 | struct batadv_neigh_node *neigh_node; |
404 | int data_len = skb->len; | 404 | int data_len = skb->len; |
405 | int ret = 1; | 405 | int ret = NET_RX_DROP; |
406 | unsigned int dev_mtu; | 406 | unsigned int dev_mtu; |
407 | 407 | ||
408 | /* get routing information */ | 408 | /* get routing information */ |
@@ -466,15 +466,15 @@ find_router: | |||
466 | goto out; | 466 | goto out; |
467 | } | 467 | } |
468 | 468 | ||
469 | batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); | 469 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) |
470 | ret = 0; | 470 | ret = 0; |
471 | 471 | ||
472 | out: | 472 | out: |
473 | if (neigh_node) | 473 | if (neigh_node) |
474 | batadv_neigh_node_free_ref(neigh_node); | 474 | batadv_neigh_node_free_ref(neigh_node); |
475 | if (orig_node) | 475 | if (orig_node) |
476 | batadv_orig_node_free_ref(orig_node); | 476 | batadv_orig_node_free_ref(orig_node); |
477 | if (ret == 1) | 477 | if (ret == NET_RX_DROP) |
478 | kfree_skb(skb); | 478 | kfree_skb(skb); |
479 | return ret; | 479 | return ret; |
480 | } | 480 | } |
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index ad14a6c91d6a..0f65a9de5f74 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -698,15 +698,12 @@ static void batadv_purge_vis_packets(struct batadv_priv *bat_priv) | |||
698 | static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv, | 698 | static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv, |
699 | struct batadv_vis_info *info) | 699 | struct batadv_vis_info *info) |
700 | { | 700 | { |
701 | struct batadv_neigh_node *router; | ||
702 | struct batadv_hashtable *hash = bat_priv->orig_hash; | 701 | struct batadv_hashtable *hash = bat_priv->orig_hash; |
703 | struct hlist_node *node; | 702 | struct hlist_node *node; |
704 | struct hlist_head *head; | 703 | struct hlist_head *head; |
705 | struct batadv_orig_node *orig_node; | 704 | struct batadv_orig_node *orig_node; |
706 | struct batadv_vis_packet *packet; | 705 | struct batadv_vis_packet *packet; |
707 | struct sk_buff *skb; | 706 | struct sk_buff *skb; |
708 | struct batadv_hard_iface *hard_iface; | ||
709 | uint8_t dstaddr[ETH_ALEN]; | ||
710 | uint32_t i; | 707 | uint32_t i; |
711 | 708 | ||
712 | 709 | ||
@@ -722,30 +719,20 @@ static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv, | |||
722 | if (!(orig_node->flags & BATADV_VIS_SERVER)) | 719 | if (!(orig_node->flags & BATADV_VIS_SERVER)) |
723 | continue; | 720 | continue; |
724 | 721 | ||
725 | router = batadv_orig_node_get_router(orig_node); | ||
726 | if (!router) | ||
727 | continue; | ||
728 | |||
729 | /* don't send it if we already received the packet from | 722 | /* don't send it if we already received the packet from |
730 | * this node. | 723 | * this node. |
731 | */ | 724 | */ |
732 | if (batadv_recv_list_is_in(bat_priv, &info->recv_list, | 725 | if (batadv_recv_list_is_in(bat_priv, &info->recv_list, |
733 | orig_node->orig)) { | 726 | orig_node->orig)) |
734 | batadv_neigh_node_free_ref(router); | ||
735 | continue; | 727 | continue; |
736 | } | ||
737 | 728 | ||
738 | memcpy(packet->target_orig, orig_node->orig, ETH_ALEN); | 729 | memcpy(packet->target_orig, orig_node->orig, ETH_ALEN); |
739 | hard_iface = router->if_incoming; | ||
740 | memcpy(dstaddr, router->addr, ETH_ALEN); | ||
741 | |||
742 | batadv_neigh_node_free_ref(router); | ||
743 | |||
744 | skb = skb_clone(info->skb_packet, GFP_ATOMIC); | 730 | skb = skb_clone(info->skb_packet, GFP_ATOMIC); |
745 | if (skb) | 731 | if (!skb) |
746 | batadv_send_skb_packet(skb, hard_iface, | 732 | continue; |
747 | dstaddr); | ||
748 | 733 | ||
734 | if (!batadv_send_skb_to_orig(skb, orig_node, NULL)) | ||
735 | kfree_skb(skb); | ||
749 | } | 736 | } |
750 | rcu_read_unlock(); | 737 | rcu_read_unlock(); |
751 | } | 738 | } |
@@ -755,7 +742,6 @@ static void batadv_unicast_vis_packet(struct batadv_priv *bat_priv, | |||
755 | struct batadv_vis_info *info) | 742 | struct batadv_vis_info *info) |
756 | { | 743 | { |
757 | struct batadv_orig_node *orig_node; | 744 | struct batadv_orig_node *orig_node; |
758 | struct batadv_neigh_node *router = NULL; | ||
759 | struct sk_buff *skb; | 745 | struct sk_buff *skb; |
760 | struct batadv_vis_packet *packet; | 746 | struct batadv_vis_packet *packet; |
761 | 747 | ||
@@ -765,17 +751,14 @@ static void batadv_unicast_vis_packet(struct batadv_priv *bat_priv, | |||
765 | if (!orig_node) | 751 | if (!orig_node) |
766 | goto out; | 752 | goto out; |
767 | 753 | ||
768 | router = batadv_orig_node_get_router(orig_node); | 754 | skb = skb_clone(info->skb_packet, GFP_ATOMIC); |
769 | if (!router) | 755 | if (!skb) |
770 | goto out; | 756 | goto out; |
771 | 757 | ||
772 | skb = skb_clone(info->skb_packet, GFP_ATOMIC); | 758 | if (!batadv_send_skb_to_orig(skb, orig_node, NULL)) |
773 | if (skb) | 759 | kfree_skb(skb); |
774 | batadv_send_skb_packet(skb, router->if_incoming, router->addr); | ||
775 | 760 | ||
776 | out: | 761 | out: |
777 | if (router) | ||
778 | batadv_neigh_node_free_ref(router); | ||
779 | if (orig_node) | 762 | if (orig_node) |
780 | batadv_orig_node_free_ref(orig_node); | 763 | batadv_orig_node_free_ref(orig_node); |
781 | } | 764 | } |