diff options
Diffstat (limited to 'net/batman-adv/send.c')
| -rw-r--r-- | net/batman-adv/send.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 570a8bce0364..4425af9dad40 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | #include "main.h" | 20 | #include "main.h" |
| 21 | #include "distributed-arp-table.h" | ||
| 21 | #include "send.h" | 22 | #include "send.h" |
| 22 | #include "routing.h" | 23 | #include "routing.h" |
| 23 | #include "translation-table.h" | 24 | #include "translation-table.h" |
| @@ -27,6 +28,8 @@ | |||
| 27 | #include "gateway_common.h" | 28 | #include "gateway_common.h" |
| 28 | #include "originator.h" | 29 | #include "originator.h" |
| 29 | 30 | ||
| 31 | #include <linux/if_ether.h> | ||
| 32 | |||
| 30 | static void batadv_send_outstanding_bcast_packet(struct work_struct *work); | 33 | static void batadv_send_outstanding_bcast_packet(struct work_struct *work); |
| 31 | 34 | ||
| 32 | /* send out an already prepared packet to the given address via the | 35 | /* send out an already prepared packet to the given address via the |
| @@ -59,11 +62,11 @@ int batadv_send_skb_packet(struct sk_buff *skb, | |||
| 59 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 62 | ethhdr = (struct ethhdr *)skb_mac_header(skb); |
| 60 | memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN); | 63 | memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN); |
| 61 | memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); | 64 | memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); |
| 62 | ethhdr->h_proto = __constant_htons(BATADV_ETH_P_BATMAN); | 65 | ethhdr->h_proto = __constant_htons(ETH_P_BATMAN); |
| 63 | 66 | ||
| 64 | skb_set_network_header(skb, ETH_HLEN); | 67 | skb_set_network_header(skb, ETH_HLEN); |
| 65 | skb->priority = TC_PRIO_CONTROL; | 68 | skb->priority = TC_PRIO_CONTROL; |
| 66 | skb->protocol = __constant_htons(BATADV_ETH_P_BATMAN); | 69 | skb->protocol = __constant_htons(ETH_P_BATMAN); |
| 67 | 70 | ||
| 68 | skb->dev = hard_iface->net_dev; | 71 | skb->dev = hard_iface->net_dev; |
| 69 | 72 | ||
| @@ -77,6 +80,39 @@ send_skb_err: | |||
| 77 | return NET_XMIT_DROP; | 80 | return NET_XMIT_DROP; |
| 78 | } | 81 | } |
| 79 | 82 | ||
| 83 | /** | ||
| 84 | * batadv_send_skb_to_orig - Lookup next-hop and transmit skb. | ||
| 85 | * @skb: Packet to be transmitted. | ||
| 86 | * @orig_node: Final destination of the packet. | ||
| 87 | * @recv_if: Interface used when receiving the packet (can be NULL). | ||
| 88 | * | ||
| 89 | * Looks up the best next-hop towards the passed originator and passes the | ||
| 90 | * skb on for preparation of MAC header. If the packet originated from this | ||
| 91 | * host, NULL can be passed as recv_if and no interface alternating is | ||
| 92 | * attempted. | ||
| 93 | * | ||
| 94 | * Returns TRUE on success; FALSE otherwise. | ||
| 95 | */ | ||
| 96 | bool batadv_send_skb_to_orig(struct sk_buff *skb, | ||
| 97 | struct batadv_orig_node *orig_node, | ||
| 98 | struct batadv_hard_iface *recv_if) | ||
| 99 | { | ||
| 100 | struct batadv_priv *bat_priv = orig_node->bat_priv; | ||
| 101 | struct batadv_neigh_node *neigh_node; | ||
| 102 | |||
| 103 | /* batadv_find_router() increases neigh_nodes refcount if found. */ | ||
| 104 | neigh_node = batadv_find_router(bat_priv, orig_node, recv_if); | ||
| 105 | if (!neigh_node) | ||
| 106 | return false; | ||
| 107 | |||
| 108 | /* route it */ | ||
| 109 | batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); | ||
| 110 | |||
| 111 | batadv_neigh_node_free_ref(neigh_node); | ||
| 112 | |||
| 113 | return true; | ||
| 114 | } | ||
| 115 | |||
| 80 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface) | 116 | void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface) |
| 81 | { | 117 | { |
| 82 | struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); | 118 | struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); |
| @@ -209,6 +245,9 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work) | |||
| 209 | if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) | 245 | if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) |
| 210 | goto out; | 246 | goto out; |
| 211 | 247 | ||
| 248 | if (batadv_dat_drop_broadcast_packet(bat_priv, forw_packet)) | ||
| 249 | goto out; | ||
| 250 | |||
| 212 | /* rebroadcast packet */ | 251 | /* rebroadcast packet */ |
| 213 | rcu_read_lock(); | 252 | rcu_read_lock(); |
| 214 | list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { | 253 | list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { |
