Lines Matching +full:pull +full:- +full:up +full:- +full:adv
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2007-2018 B.A.T.M.A.N. contributors:
44 #include "distributed-arp-table.h"
47 #include "hard-interface.h"
49 #include "network-coding.h"
52 #include "soft-interface.h"
53 #include "translation-table.h"
58 * batadv_send_skb_packet() - send an already prepared packet
83 bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_send_skb_packet()
85 if (hard_iface->if_status != BATADV_IF_ACTIVE) in batadv_send_skb_packet()
88 if (unlikely(!hard_iface->net_dev)) in batadv_send_skb_packet()
91 if (!(hard_iface->net_dev->flags & IFF_UP)) { in batadv_send_skb_packet()
92 pr_warn("Interface %s is not up - can't send packet via that interface!\n", in batadv_send_skb_packet()
93 hard_iface->net_dev->name); in batadv_send_skb_packet()
104 ether_addr_copy(ethhdr->h_source, hard_iface->net_dev->dev_addr); in batadv_send_skb_packet()
105 ether_addr_copy(ethhdr->h_dest, dst_addr); in batadv_send_skb_packet()
106 ethhdr->h_proto = htons(ETH_P_BATMAN); in batadv_send_skb_packet()
109 skb->protocol = htons(ETH_P_BATMAN); in batadv_send_skb_packet()
111 skb->dev = hard_iface->net_dev; in batadv_send_skb_packet()
128 * batadv_send_broadcast_skb() - Send broadcast packet via hard interface
143 * batadv_send_unicast_skb() - Send unicast packet to neighbor
159 ret = batadv_send_skb_packet(skb, neigh->if_incoming, neigh->addr); in batadv_send_unicast_skb()
162 hardif_neigh = batadv_hardif_neigh_get(neigh->if_incoming, neigh->addr); in batadv_send_unicast_skb()
165 hardif_neigh->bat_v.last_unicast_tx = jiffies; in batadv_send_unicast_skb()
175 * batadv_send_skb_to_orig() - Lookup next-hop and transmit skb.
180 * Looks up the best next-hop towards the passed originator and passes the
185 * Return: negative errno code on a failure, -EINPROGRESS if the skb is
193 struct batadv_priv *bat_priv = orig_node->bat_priv; in batadv_send_skb_to_orig()
200 ret = -EINVAL; in batadv_send_skb_to_orig()
207 if (atomic_read(&bat_priv->fragmentation) && in batadv_send_skb_to_orig()
208 skb->len > neigh_node->if_incoming->net_dev->mtu) { in batadv_send_skb_to_orig()
222 ret = -EINPROGRESS; in batadv_send_skb_to_orig()
238 * batadv_send_skb_push_fill_unicast() - extend the buffer and initialize the
251 u8 ttvn = (u8)atomic_read(&orig_node->last_ttvn); in batadv_send_skb_push_fill_unicast()
256 unicast_packet = (struct batadv_unicast_packet *)skb->data; in batadv_send_skb_push_fill_unicast()
257 unicast_packet->version = BATADV_COMPAT_VERSION; in batadv_send_skb_push_fill_unicast()
259 unicast_packet->packet_type = BATADV_UNICAST; in batadv_send_skb_push_fill_unicast()
261 unicast_packet->ttl = BATADV_TTL; in batadv_send_skb_push_fill_unicast()
263 ether_addr_copy(unicast_packet->dest, orig_node->orig); in batadv_send_skb_push_fill_unicast()
265 unicast_packet->ttvn = ttvn; in batadv_send_skb_push_fill_unicast()
271 * batadv_send_skb_prepare_unicast() - encapsulate an skb with a unicast header
286 * batadv_send_skb_prepare_unicast_4addr() - encapsulate an skb with a
308 /* Pull the header space and fill the unicast_packet substructure. in batadv_send_skb_prepare_unicast_4addr()
316 uc_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; in batadv_send_skb_prepare_unicast_4addr()
317 uc_4addr_packet->u.packet_type = BATADV_UNICAST_4ADDR; in batadv_send_skb_prepare_unicast_4addr()
318 ether_addr_copy(uc_4addr_packet->src, primary_if->net_dev->dev_addr); in batadv_send_skb_prepare_unicast_4addr()
319 uc_4addr_packet->subtype = packet_subtype; in batadv_send_skb_prepare_unicast_4addr()
320 uc_4addr_packet->reserved = 0; in batadv_send_skb_prepare_unicast_4addr()
330 * batadv_send_skb_unicast() - encapsulate and send an skb via unicast
339 * Wrap the given skb into a batman-adv unicast or unicast-4addr header
376 /* skb->data might have been reallocated by in batadv_send_skb_unicast()
380 unicast_packet = (struct batadv_unicast_packet *)skb->data; in batadv_send_skb_unicast()
387 if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) in batadv_send_skb_unicast()
388 unicast_packet->ttvn = unicast_packet->ttvn - 1; in batadv_send_skb_unicast()
400 * batadv_send_skb_via_tt_generic() - send an skb via TT lookup
409 * Look up the recipient node for the destination address in the ethernet
410 * header via the translation table. Wrap the given skb into a batman-adv
411 * unicast or unicast-4addr header depending on whether BATADV_UNICAST or
422 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; in batadv_send_skb_via_tt_generic()
427 src = ethhdr->h_source; in batadv_send_skb_via_tt_generic()
428 dst = ethhdr->h_dest; in batadv_send_skb_via_tt_generic()
447 * batadv_send_skb_via_gw() - send an skb via gateway lookup
452 * Look up the currently selected gateway. Wrap the given skb into a batman-adv
474 * batadv_forw_packet_free() - free a forwarding packet
485 kfree_skb(forw_packet->skb); in batadv_forw_packet_free()
487 consume_skb(forw_packet->skb); in batadv_forw_packet_free()
489 if (forw_packet->if_incoming) in batadv_forw_packet_free()
490 batadv_hardif_put(forw_packet->if_incoming); in batadv_forw_packet_free()
491 if (forw_packet->if_outgoing) in batadv_forw_packet_free()
492 batadv_hardif_put(forw_packet->if_outgoing); in batadv_forw_packet_free()
493 if (forw_packet->queue_left) in batadv_forw_packet_free()
494 atomic_inc(forw_packet->queue_left); in batadv_forw_packet_free()
499 * batadv_forw_packet_alloc() - allocate a forwarding packet
525 if (queue_left == &bat_priv->bcast_queue_left) in batadv_forw_packet_alloc()
528 if (queue_left == &bat_priv->batman_queue_left) in batadv_forw_packet_alloc()
542 kref_get(&if_incoming->refcount); in batadv_forw_packet_alloc()
545 kref_get(&if_outgoing->refcount); in batadv_forw_packet_alloc()
547 INIT_HLIST_NODE(&forw_packet->list); in batadv_forw_packet_alloc()
548 INIT_HLIST_NODE(&forw_packet->cleanup_list); in batadv_forw_packet_alloc()
549 forw_packet->skb = skb; in batadv_forw_packet_alloc()
550 forw_packet->queue_left = queue_left; in batadv_forw_packet_alloc()
551 forw_packet->if_incoming = if_incoming; in batadv_forw_packet_alloc()
552 forw_packet->if_outgoing = if_outgoing; in batadv_forw_packet_alloc()
553 forw_packet->num_packets = 0; in batadv_forw_packet_alloc()
565 * batadv_forw_packet_was_stolen() - check whether someone stole this packet
576 return !hlist_unhashed(&forw_packet->cleanup_list); in batadv_forw_packet_was_stolen()
580 * batadv_forw_packet_steal() - claim a forw_packet for free()
601 hlist_del_init(&forw_packet->list); in batadv_forw_packet_steal()
604 hlist_add_fake(&forw_packet->cleanup_list); in batadv_forw_packet_steal()
611 * batadv_forw_packet_list_steal() - claim a list of forward packets for free()
637 forw_packet->if_incoming != hard_iface && in batadv_forw_packet_list_steal()
638 forw_packet->if_outgoing != hard_iface) in batadv_forw_packet_list_steal()
641 hlist_del(&forw_packet->list); in batadv_forw_packet_list_steal()
642 hlist_add_head(&forw_packet->cleanup_list, cleanup_list); in batadv_forw_packet_list_steal()
647 * batadv_forw_packet_list_free() - free a list of forward packets
663 cancel_delayed_work_sync(&forw_packet->delayed_work); in batadv_forw_packet_list_free()
665 hlist_del(&forw_packet->cleanup_list); in batadv_forw_packet_list_free()
671 * batadv_forw_packet_queue() - try to queue a forwarding packet
685 * Caller needs to ensure that forw_packet->delayed_work was initialized.
698 WARN_ONCE(hlist_fake(&forw_packet->cleanup_list), in batadv_forw_packet_queue()
705 hlist_del_init(&forw_packet->list); in batadv_forw_packet_queue()
706 hlist_add_head(&forw_packet->list, head); in batadv_forw_packet_queue()
709 &forw_packet->delayed_work, in batadv_forw_packet_queue()
710 send_time - jiffies); in batadv_forw_packet_queue()
715 * batadv_forw_packet_bcast_queue() - try to queue a broadcast packet
722 * Caller needs to ensure that forw_packet->delayed_work was initialized.
729 batadv_forw_packet_queue(forw_packet, &bat_priv->forw_bcast_list_lock, in batadv_forw_packet_bcast_queue()
730 &bat_priv->forw_bcast_list, send_time); in batadv_forw_packet_bcast_queue()
734 * batadv_forw_packet_ogmv1_queue() - try to queue an OGMv1 packet
741 * Caller needs to ensure that forw_packet->delayed_work was initialized.
747 batadv_forw_packet_queue(forw_packet, &bat_priv->forw_bat_list_lock, in batadv_forw_packet_ogmv1_queue()
748 &bat_priv->forw_bat_list, send_time); in batadv_forw_packet_ogmv1_queue()
752 * batadv_add_bcast_packet_to_list() - queue broadcast packet for multiple sends
756 * @own_packet: true if it is a self-generated broadcast packet
787 &bat_priv->bcast_queue_left, in batadv_add_bcast_packet_to_list()
794 bcast_packet = (struct batadv_bcast_packet *)newskb->data; in batadv_add_bcast_packet_to_list()
795 bcast_packet->ttl--; in batadv_add_bcast_packet_to_list()
797 forw_packet->own = own_packet; in batadv_add_bcast_packet_to_list()
799 INIT_DELAYED_WORK(&forw_packet->delayed_work, in batadv_add_bcast_packet_to_list()
812 * batadv_forw_packet_bcasts_left() - check if a retransmission is necessary
832 max = hard_iface->num_bcasts; in batadv_forw_packet_bcasts_left()
836 return BATADV_SKB_CB(forw_packet->skb)->num_bcasts < max; in batadv_forw_packet_bcasts_left()
840 * batadv_forw_packet_bcasts_inc() - increment retransmission counter of a
847 BATADV_SKB_CB(forw_packet->skb)->num_bcasts++; in batadv_forw_packet_bcasts_inc()
851 * batadv_forw_packet_is_rebroadcast() - check packet for previous transmissions
858 return BATADV_SKB_CB(forw_packet->skb)->num_bcasts > 0; in batadv_forw_packet_is_rebroadcast()
880 soft_iface = forw_packet->if_incoming->soft_iface; in batadv_send_outstanding_bcast_packet()
883 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) { in batadv_send_outstanding_bcast_packet()
893 bcast_packet = (struct batadv_bcast_packet *)forw_packet->skb->data; in batadv_send_outstanding_bcast_packet()
898 if (hard_iface->soft_iface != soft_iface) in batadv_send_outstanding_bcast_packet()
904 if (forw_packet->own) { in batadv_send_outstanding_bcast_packet()
907 neigh_addr = eth_hdr(forw_packet->skb)->h_source; in batadv_send_outstanding_bcast_packet()
912 orig_neigh = neigh_node ? neigh_node->orig : NULL; in batadv_send_outstanding_bcast_packet()
914 ret = batadv_hardif_no_broadcast(hard_iface, bcast_packet->orig, in batadv_send_outstanding_bcast_packet()
935 bcast_packet->orig, in batadv_send_outstanding_bcast_packet()
936 hard_iface->net_dev->name, type); in batadv_send_outstanding_bcast_packet()
947 if (!kref_get_unless_zero(&hard_iface->refcount)) in batadv_send_outstanding_bcast_packet()
951 skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC); in batadv_send_outstanding_bcast_packet()
971 &bat_priv->forw_bcast_list_lock)) in batadv_send_outstanding_bcast_packet()
976 * batadv_purge_outstanding_packets() - stop/purge scheduled bcast/OGMv1 packets
995 __func__, hard_iface->net_dev->name); in batadv_purge_outstanding_packets()
1001 spin_lock_bh(&bat_priv->forw_bcast_list_lock); in batadv_purge_outstanding_packets()
1002 batadv_forw_packet_list_steal(&bat_priv->forw_bcast_list, &head, in batadv_purge_outstanding_packets()
1004 spin_unlock_bh(&bat_priv->forw_bcast_list_lock); in batadv_purge_outstanding_packets()
1007 spin_lock_bh(&bat_priv->forw_bat_list_lock); in batadv_purge_outstanding_packets()
1008 batadv_forw_packet_list_steal(&bat_priv->forw_bat_list, &head, in batadv_purge_outstanding_packets()
1010 spin_unlock_bh(&bat_priv->forw_bat_list_lock); in batadv_purge_outstanding_packets()