aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/send.c
diff options
context:
space:
mode:
authorMartin Hundebøll <martin@hundeboll.net>2012-10-16 10:13:48 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-11-21 06:34:50 -0500
commitbb351ba0bba23f01af00e36bfe20897201f404fa (patch)
tree7ac84275cfb3f32d0cae0ba854a90298f56e9561 /net/batman-adv/send.c
parent637fbd12947b5645d8c16c982aa15c17ab695b0a (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/send.c')
-rw-r--r--net/batman-adv/send.c33
1 files changed, 33 insertions, 0 deletions
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 */
94bool 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
81void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface) 114void 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);