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/routing.c | |
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/routing.c')
-rw-r--r-- | net/batman-adv/routing.c | 37 |
1 files changed, 8 insertions, 29 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) |