diff options
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/network-coding.c | 5 | ||||
-rw-r--r-- | net/batman-adv/network-coding.h | 6 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 23 | ||||
-rw-r--r-- | net/batman-adv/send.c | 27 | ||||
-rw-r--r-- | net/batman-adv/send.h | 6 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 12 | ||||
-rw-r--r-- | net/batman-adv/unicast.c | 2 | ||||
-rw-r--r-- | net/batman-adv/vis.c | 7 |
8 files changed, 51 insertions, 37 deletions
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 22cd51fea730..a487d46e0aec 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c | |||
@@ -1359,18 +1359,17 @@ static bool batadv_nc_skb_add_to_path(struct sk_buff *skb, | |||
1359 | * buffer | 1359 | * buffer |
1360 | * @skb: data skb to forward | 1360 | * @skb: data skb to forward |
1361 | * @neigh_node: next hop to forward packet to | 1361 | * @neigh_node: next hop to forward packet to |
1362 | * @ethhdr: pointer to the ethernet header inside the skb | ||
1363 | * | 1362 | * |
1364 | * Returns true if the skb was consumed (encoded packet sent) or false otherwise | 1363 | * Returns true if the skb was consumed (encoded packet sent) or false otherwise |
1365 | */ | 1364 | */ |
1366 | bool batadv_nc_skb_forward(struct sk_buff *skb, | 1365 | bool batadv_nc_skb_forward(struct sk_buff *skb, |
1367 | struct batadv_neigh_node *neigh_node, | 1366 | struct batadv_neigh_node *neigh_node) |
1368 | struct ethhdr *ethhdr) | ||
1369 | { | 1367 | { |
1370 | const struct net_device *netdev = neigh_node->if_incoming->soft_iface; | 1368 | const struct net_device *netdev = neigh_node->if_incoming->soft_iface; |
1371 | struct batadv_priv *bat_priv = netdev_priv(netdev); | 1369 | struct batadv_priv *bat_priv = netdev_priv(netdev); |
1372 | struct batadv_unicast_packet *packet; | 1370 | struct batadv_unicast_packet *packet; |
1373 | struct batadv_nc_path *nc_path; | 1371 | struct batadv_nc_path *nc_path; |
1372 | struct ethhdr *ethhdr = eth_hdr(skb); | ||
1374 | __be32 packet_id; | 1373 | __be32 packet_id; |
1375 | u8 *payload; | 1374 | u8 *payload; |
1376 | 1375 | ||
diff --git a/net/batman-adv/network-coding.h b/net/batman-adv/network-coding.h index 4fa6d0caddbd..85a4ec81ad50 100644 --- a/net/batman-adv/network-coding.h +++ b/net/batman-adv/network-coding.h | |||
@@ -36,8 +36,7 @@ void batadv_nc_purge_orig(struct batadv_priv *bat_priv, | |||
36 | void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv); | 36 | void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv); |
37 | void batadv_nc_init_orig(struct batadv_orig_node *orig_node); | 37 | void batadv_nc_init_orig(struct batadv_orig_node *orig_node); |
38 | bool batadv_nc_skb_forward(struct sk_buff *skb, | 38 | bool batadv_nc_skb_forward(struct sk_buff *skb, |
39 | struct batadv_neigh_node *neigh_node, | 39 | struct batadv_neigh_node *neigh_node); |
40 | struct ethhdr *ethhdr); | ||
41 | void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv, | 40 | void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv, |
42 | struct sk_buff *skb); | 41 | struct sk_buff *skb); |
43 | void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv, | 42 | void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv, |
@@ -87,8 +86,7 @@ static inline void batadv_nc_init_orig(struct batadv_orig_node *orig_node) | |||
87 | } | 86 | } |
88 | 87 | ||
89 | static inline bool batadv_nc_skb_forward(struct sk_buff *skb, | 88 | static inline bool batadv_nc_skb_forward(struct sk_buff *skb, |
90 | struct batadv_neigh_node *neigh_node, | 89 | struct batadv_neigh_node *neigh_node) |
91 | struct ethhdr *ethhdr) | ||
92 | { | 90 | { |
93 | return false; | 91 | return false; |
94 | } | 92 | } |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index fad08469767d..2f0bd3ffe6e8 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -285,7 +285,7 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv, | |||
285 | icmp_packet->msg_type = BATADV_ECHO_REPLY; | 285 | icmp_packet->msg_type = BATADV_ECHO_REPLY; |
286 | icmp_packet->header.ttl = BATADV_TTL; | 286 | icmp_packet->header.ttl = BATADV_TTL; |
287 | 287 | ||
288 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) | 288 | if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP) |
289 | ret = NET_RX_SUCCESS; | 289 | ret = NET_RX_SUCCESS; |
290 | 290 | ||
291 | out: | 291 | out: |
@@ -333,7 +333,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv, | |||
333 | icmp_packet->msg_type = BATADV_TTL_EXCEEDED; | 333 | icmp_packet->msg_type = BATADV_TTL_EXCEEDED; |
334 | icmp_packet->header.ttl = BATADV_TTL; | 334 | icmp_packet->header.ttl = BATADV_TTL; |
335 | 335 | ||
336 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) | 336 | if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP) |
337 | ret = NET_RX_SUCCESS; | 337 | ret = NET_RX_SUCCESS; |
338 | 338 | ||
339 | out: | 339 | out: |
@@ -410,7 +410,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, | |||
410 | icmp_packet->header.ttl--; | 410 | icmp_packet->header.ttl--; |
411 | 411 | ||
412 | /* route it */ | 412 | /* route it */ |
413 | if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) | 413 | if (batadv_send_skb_to_orig(skb, orig_node, recv_if) != NET_XMIT_DROP) |
414 | ret = NET_RX_SUCCESS; | 414 | ret = NET_RX_SUCCESS; |
415 | 415 | ||
416 | out: | 416 | out: |
@@ -775,7 +775,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, | |||
775 | struct batadv_neigh_node *neigh_node = NULL; | 775 | struct batadv_neigh_node *neigh_node = NULL; |
776 | struct batadv_unicast_packet *unicast_packet; | 776 | struct batadv_unicast_packet *unicast_packet; |
777 | struct ethhdr *ethhdr = eth_hdr(skb); | 777 | struct ethhdr *ethhdr = eth_hdr(skb); |
778 | int ret = NET_RX_DROP; | 778 | int res, ret = NET_RX_DROP; |
779 | struct sk_buff *new_skb; | 779 | struct sk_buff *new_skb; |
780 | 780 | ||
781 | unicast_packet = (struct batadv_unicast_packet *)skb->data; | 781 | unicast_packet = (struct batadv_unicast_packet *)skb->data; |
@@ -835,16 +835,19 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, | |||
835 | /* decrement ttl */ | 835 | /* decrement ttl */ |
836 | unicast_packet->header.ttl--; | 836 | unicast_packet->header.ttl--; |
837 | 837 | ||
838 | /* network code packet if possible */ | 838 | res = batadv_send_skb_to_orig(skb, orig_node, recv_if); |
839 | if (batadv_nc_skb_forward(skb, neigh_node, ethhdr)) { | ||
840 | ret = NET_RX_SUCCESS; | ||
841 | } else if (batadv_send_skb_to_orig(skb, orig_node, recv_if)) { | ||
842 | ret = NET_RX_SUCCESS; | ||
843 | 839 | ||
844 | /* Update stats counter */ | 840 | /* translate transmit result into receive result */ |
841 | if (res == NET_XMIT_SUCCESS) { | ||
842 | /* skb was transmitted and consumed */ | ||
845 | batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD); | 843 | batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD); |
846 | batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES, | 844 | batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES, |
847 | skb->len + ETH_HLEN); | 845 | skb->len + ETH_HLEN); |
846 | |||
847 | ret = NET_RX_SUCCESS; | ||
848 | } else if (res == NET_XMIT_POLICED) { | ||
849 | /* skb was buffered and consumed */ | ||
850 | ret = NET_RX_SUCCESS; | ||
848 | } | 851 | } |
849 | 852 | ||
850 | out: | 853 | out: |
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index ce69f458a754..e9ff8d801201 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c | |||
@@ -96,26 +96,37 @@ send_skb_err: | |||
96 | * host, NULL can be passed as recv_if and no interface alternating is | 96 | * host, NULL can be passed as recv_if and no interface alternating is |
97 | * attempted. | 97 | * attempted. |
98 | * | 98 | * |
99 | * Returns TRUE on success; FALSE otherwise. | 99 | * Returns NET_XMIT_SUCCESS on success, NET_XMIT_DROP on failure, or |
100 | * NET_XMIT_POLICED if the skb is buffered for later transmit. | ||
100 | */ | 101 | */ |
101 | bool batadv_send_skb_to_orig(struct sk_buff *skb, | 102 | int batadv_send_skb_to_orig(struct sk_buff *skb, |
102 | struct batadv_orig_node *orig_node, | 103 | struct batadv_orig_node *orig_node, |
103 | struct batadv_hard_iface *recv_if) | 104 | struct batadv_hard_iface *recv_if) |
104 | { | 105 | { |
105 | struct batadv_priv *bat_priv = orig_node->bat_priv; | 106 | struct batadv_priv *bat_priv = orig_node->bat_priv; |
106 | struct batadv_neigh_node *neigh_node; | 107 | struct batadv_neigh_node *neigh_node; |
108 | int ret = NET_XMIT_DROP; | ||
107 | 109 | ||
108 | /* batadv_find_router() increases neigh_nodes refcount if found. */ | 110 | /* batadv_find_router() increases neigh_nodes refcount if found. */ |
109 | neigh_node = batadv_find_router(bat_priv, orig_node, recv_if); | 111 | neigh_node = batadv_find_router(bat_priv, orig_node, recv_if); |
110 | if (!neigh_node) | 112 | if (!neigh_node) |
111 | return false; | 113 | return ret; |
112 | 114 | ||
113 | /* route it */ | 115 | /* try to network code the packet, if it is received on an interface |
114 | batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); | 116 | * (i.e. being forwarded). If the packet originates from this node or if |
117 | * network coding fails, then send the packet as usual. | ||
118 | */ | ||
119 | if (recv_if && batadv_nc_skb_forward(skb, neigh_node)) { | ||
120 | ret = NET_XMIT_POLICED; | ||
121 | } else { | ||
122 | batadv_send_skb_packet(skb, neigh_node->if_incoming, | ||
123 | neigh_node->addr); | ||
124 | ret = NET_XMIT_SUCCESS; | ||
125 | } | ||
115 | 126 | ||
116 | batadv_neigh_node_free_ref(neigh_node); | 127 | batadv_neigh_node_free_ref(neigh_node); |
117 | 128 | ||
118 | return true; | 129 | return ret; |
119 | } | 130 | } |
120 | 131 | ||
121 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface) | 132 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface) |
diff --git a/net/batman-adv/send.h b/net/batman-adv/send.h index 38e662f619ac..e7b17880fca4 100644 --- a/net/batman-adv/send.h +++ b/net/batman-adv/send.h | |||
@@ -23,9 +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, | 26 | int batadv_send_skb_to_orig(struct sk_buff *skb, |
27 | struct batadv_orig_node *orig_node, | 27 | struct batadv_orig_node *orig_node, |
28 | struct batadv_hard_iface *recv_if); | 28 | struct batadv_hard_iface *recv_if); |
29 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface); | 29 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface); |
30 | 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, |
31 | 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 e272f68e1b08..429aeef3d8b2 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -1713,7 +1713,7 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv, | |||
1713 | 1713 | ||
1714 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_TX); | 1714 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_TX); |
1715 | 1715 | ||
1716 | if (batadv_send_skb_to_orig(skb, dst_orig_node, NULL)) | 1716 | if (batadv_send_skb_to_orig(skb, dst_orig_node, NULL) != NET_XMIT_DROP) |
1717 | ret = 0; | 1717 | ret = 0; |
1718 | 1718 | ||
1719 | out: | 1719 | out: |
@@ -1737,7 +1737,7 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1737 | struct batadv_orig_node *req_dst_orig_node; | 1737 | struct batadv_orig_node *req_dst_orig_node; |
1738 | struct batadv_orig_node *res_dst_orig_node = NULL; | 1738 | struct batadv_orig_node *res_dst_orig_node = NULL; |
1739 | uint8_t orig_ttvn, req_ttvn, ttvn; | 1739 | uint8_t orig_ttvn, req_ttvn, ttvn; |
1740 | int ret = false; | 1740 | int res, ret = false; |
1741 | unsigned char *tt_buff; | 1741 | unsigned char *tt_buff; |
1742 | bool full_table; | 1742 | bool full_table; |
1743 | uint16_t tt_len, tt_tot; | 1743 | uint16_t tt_len, tt_tot; |
@@ -1832,8 +1832,10 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1832 | 1832 | ||
1833 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); | 1833 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); |
1834 | 1834 | ||
1835 | if (batadv_send_skb_to_orig(skb, res_dst_orig_node, NULL)) | 1835 | res = batadv_send_skb_to_orig(skb, res_dst_orig_node, NULL); |
1836 | if (res != NET_XMIT_DROP) | ||
1836 | ret = true; | 1837 | ret = true; |
1838 | |||
1837 | goto out; | 1839 | goto out; |
1838 | 1840 | ||
1839 | unlock: | 1841 | unlock: |
@@ -1947,7 +1949,7 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1947 | 1949 | ||
1948 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); | 1950 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); |
1949 | 1951 | ||
1950 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) | 1952 | if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP) |
1951 | ret = true; | 1953 | ret = true; |
1952 | goto out; | 1954 | goto out; |
1953 | 1955 | ||
@@ -2260,7 +2262,7 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client, | |||
2260 | 2262 | ||
2261 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX); | 2263 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX); |
2262 | 2264 | ||
2263 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) | 2265 | if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP) |
2264 | ret = 0; | 2266 | ret = 0; |
2265 | 2267 | ||
2266 | out: | 2268 | out: |
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index 0bb3b5982f94..dc8b5d4dd636 100644 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c | |||
@@ -464,7 +464,7 @@ find_router: | |||
464 | goto out; | 464 | goto out; |
465 | } | 465 | } |
466 | 466 | ||
467 | if (batadv_send_skb_to_orig(skb, orig_node, NULL)) | 467 | if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP) |
468 | ret = 0; | 468 | ret = 0; |
469 | 469 | ||
470 | out: | 470 | out: |
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index 94eaeb521c17..4983340f1943 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -697,7 +697,7 @@ static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv, | |||
697 | struct batadv_orig_node *orig_node; | 697 | struct batadv_orig_node *orig_node; |
698 | struct batadv_vis_packet *packet; | 698 | struct batadv_vis_packet *packet; |
699 | struct sk_buff *skb; | 699 | struct sk_buff *skb; |
700 | uint32_t i; | 700 | uint32_t i, res; |
701 | 701 | ||
702 | 702 | ||
703 | packet = (struct batadv_vis_packet *)info->skb_packet->data; | 703 | packet = (struct batadv_vis_packet *)info->skb_packet->data; |
@@ -724,7 +724,8 @@ static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv, | |||
724 | if (!skb) | 724 | if (!skb) |
725 | continue; | 725 | continue; |
726 | 726 | ||
727 | if (!batadv_send_skb_to_orig(skb, orig_node, NULL)) | 727 | res = batadv_send_skb_to_orig(skb, orig_node, NULL); |
728 | if (res == NET_XMIT_DROP) | ||
728 | kfree_skb(skb); | 729 | kfree_skb(skb); |
729 | } | 730 | } |
730 | rcu_read_unlock(); | 731 | rcu_read_unlock(); |
@@ -748,7 +749,7 @@ static void batadv_unicast_vis_packet(struct batadv_priv *bat_priv, | |||
748 | if (!skb) | 749 | if (!skb) |
749 | goto out; | 750 | goto out; |
750 | 751 | ||
751 | if (!batadv_send_skb_to_orig(skb, orig_node, NULL)) | 752 | if (batadv_send_skb_to_orig(skb, orig_node, NULL) == NET_XMIT_DROP) |
752 | kfree_skb(skb); | 753 | kfree_skb(skb); |
753 | 754 | ||
754 | out: | 755 | out: |