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/vis.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/vis.c')
-rw-r--r-- | net/batman-adv/vis.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index ad14a6c91d6..0f65a9de5f7 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 | } |