Lines Matching +full:pull +full:- +full:down +full:- +full:adv
1 // SPDX-License-Identifier: GPL-2.0
32 #include "distributed-arp-table.h"
35 #include "hard-interface.h"
37 #include "network-coding.h"
40 #include "soft-interface.h"
41 #include "translation-table.h"
46 * batadv_send_skb_packet() - send an already prepared packet
71 bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_send_skb_packet()
73 if (hard_iface->if_status != BATADV_IF_ACTIVE) in batadv_send_skb_packet()
76 if (unlikely(!hard_iface->net_dev)) in batadv_send_skb_packet()
79 if (!(hard_iface->net_dev->flags & IFF_UP)) { in batadv_send_skb_packet()
80 pr_warn("Interface %s is not up - can't send packet via that interface!\n", in batadv_send_skb_packet()
81 hard_iface->net_dev->name); in batadv_send_skb_packet()
92 ether_addr_copy(ethhdr->h_source, hard_iface->net_dev->dev_addr); in batadv_send_skb_packet()
93 ether_addr_copy(ethhdr->h_dest, dst_addr); in batadv_send_skb_packet()
94 ethhdr->h_proto = htons(ETH_P_BATMAN); in batadv_send_skb_packet()
97 skb->protocol = htons(ETH_P_BATMAN); in batadv_send_skb_packet()
99 skb->dev = hard_iface->net_dev; in batadv_send_skb_packet()
116 * batadv_send_broadcast_skb() - Send broadcast packet via hard interface
131 * batadv_send_unicast_skb() - Send unicast packet to neighbor
147 ret = batadv_send_skb_packet(skb, neigh->if_incoming, neigh->addr); in batadv_send_unicast_skb()
150 hardif_neigh = batadv_hardif_neigh_get(neigh->if_incoming, neigh->addr); in batadv_send_unicast_skb()
153 hardif_neigh->bat_v.last_unicast_tx = jiffies; in batadv_send_unicast_skb()
162 * batadv_send_skb_to_orig() - Lookup next-hop and transmit skb.
167 * Looks up the best next-hop towards the passed originator and passes the
172 * Return: negative errno code on a failure, -EINPROGRESS if the skb is
174 * lower routine if the packet has been passed down.
180 struct batadv_priv *bat_priv = orig_node->bat_priv; in batadv_send_skb_to_orig()
187 ret = -EINVAL; in batadv_send_skb_to_orig()
194 if (atomic_read(&bat_priv->fragmentation) && in batadv_send_skb_to_orig()
195 skb->len > neigh_node->if_incoming->net_dev->mtu) { in batadv_send_skb_to_orig()
209 ret = -EINPROGRESS; in batadv_send_skb_to_orig()
225 * batadv_send_skb_push_fill_unicast() - extend the buffer and initialize the
238 u8 ttvn = (u8)atomic_read(&orig_node->last_ttvn); in batadv_send_skb_push_fill_unicast()
243 unicast_packet = (struct batadv_unicast_packet *)skb->data; in batadv_send_skb_push_fill_unicast()
244 unicast_packet->version = BATADV_COMPAT_VERSION; in batadv_send_skb_push_fill_unicast()
246 unicast_packet->packet_type = BATADV_UNICAST; in batadv_send_skb_push_fill_unicast()
248 unicast_packet->ttl = BATADV_TTL; in batadv_send_skb_push_fill_unicast()
250 ether_addr_copy(unicast_packet->dest, orig_node->orig); in batadv_send_skb_push_fill_unicast()
252 unicast_packet->ttvn = ttvn; in batadv_send_skb_push_fill_unicast()
258 * batadv_send_skb_prepare_unicast() - encapsulate an skb with a unicast header
273 * batadv_send_skb_prepare_unicast_4addr() - encapsulate an skb with a
295 /* Pull the header space and fill the unicast_packet substructure. in batadv_send_skb_prepare_unicast_4addr()
303 uc_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; in batadv_send_skb_prepare_unicast_4addr()
304 uc_4addr_packet->u.packet_type = BATADV_UNICAST_4ADDR; in batadv_send_skb_prepare_unicast_4addr()
305 ether_addr_copy(uc_4addr_packet->src, primary_if->net_dev->dev_addr); in batadv_send_skb_prepare_unicast_4addr()
306 uc_4addr_packet->subtype = packet_subtype; in batadv_send_skb_prepare_unicast_4addr()
307 uc_4addr_packet->reserved = 0; in batadv_send_skb_prepare_unicast_4addr()
316 * batadv_send_skb_unicast() - encapsulate and send an skb via unicast
325 * Wrap the given skb into a batman-adv unicast or unicast-4addr header
362 /* skb->data might have been reallocated by in batadv_send_skb_unicast()
366 unicast_packet = (struct batadv_unicast_packet *)skb->data; in batadv_send_skb_unicast()
373 if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) in batadv_send_skb_unicast()
374 unicast_packet->ttvn = unicast_packet->ttvn - 1; in batadv_send_skb_unicast()
386 * batadv_send_skb_via_tt_generic() - send an skb via TT lookup
396 * header via the translation table. Wrap the given skb into a batman-adv
397 * unicast or unicast-4addr header depending on whether BATADV_UNICAST or
408 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; in batadv_send_skb_via_tt_generic()
413 src = ethhdr->h_source; in batadv_send_skb_via_tt_generic()
414 dst = ethhdr->h_dest; in batadv_send_skb_via_tt_generic()
432 * batadv_send_skb_via_gw() - send an skb via gateway lookup
437 * Look up the currently selected gateway. Wrap the given skb into a batman-adv
458 * batadv_forw_packet_free() - free a forwarding packet
469 kfree_skb(forw_packet->skb); in batadv_forw_packet_free()
471 consume_skb(forw_packet->skb); in batadv_forw_packet_free()
473 batadv_hardif_put(forw_packet->if_incoming); in batadv_forw_packet_free()
474 batadv_hardif_put(forw_packet->if_outgoing); in batadv_forw_packet_free()
475 if (forw_packet->queue_left) in batadv_forw_packet_free()
476 atomic_inc(forw_packet->queue_left); in batadv_forw_packet_free()
481 * batadv_forw_packet_alloc() - allocate a forwarding packet
507 if (queue_left == &bat_priv->bcast_queue_left) in batadv_forw_packet_alloc()
510 if (queue_left == &bat_priv->batman_queue_left) in batadv_forw_packet_alloc()
524 kref_get(&if_incoming->refcount); in batadv_forw_packet_alloc()
527 kref_get(&if_outgoing->refcount); in batadv_forw_packet_alloc()
529 INIT_HLIST_NODE(&forw_packet->list); in batadv_forw_packet_alloc()
530 INIT_HLIST_NODE(&forw_packet->cleanup_list); in batadv_forw_packet_alloc()
531 forw_packet->skb = skb; in batadv_forw_packet_alloc()
532 forw_packet->queue_left = queue_left; in batadv_forw_packet_alloc()
533 forw_packet->if_incoming = if_incoming; in batadv_forw_packet_alloc()
534 forw_packet->if_outgoing = if_outgoing; in batadv_forw_packet_alloc()
535 forw_packet->num_packets = 0; in batadv_forw_packet_alloc()
547 * batadv_forw_packet_was_stolen() - check whether someone stole this packet
558 return !hlist_unhashed(&forw_packet->cleanup_list); in batadv_forw_packet_was_stolen()
562 * batadv_forw_packet_steal() - claim a forw_packet for free()
583 hlist_del_init(&forw_packet->list); in batadv_forw_packet_steal()
586 hlist_add_fake(&forw_packet->cleanup_list); in batadv_forw_packet_steal()
593 * batadv_forw_packet_list_steal() - claim a list of forward packets for free()
619 forw_packet->if_incoming != hard_iface && in batadv_forw_packet_list_steal()
620 forw_packet->if_outgoing != hard_iface) in batadv_forw_packet_list_steal()
623 hlist_del(&forw_packet->list); in batadv_forw_packet_list_steal()
624 hlist_add_head(&forw_packet->cleanup_list, cleanup_list); in batadv_forw_packet_list_steal()
629 * batadv_forw_packet_list_free() - free a list of forward packets
645 cancel_delayed_work_sync(&forw_packet->delayed_work); in batadv_forw_packet_list_free()
647 hlist_del(&forw_packet->cleanup_list); in batadv_forw_packet_list_free()
653 * batadv_forw_packet_queue() - try to queue a forwarding packet
660 * is prevented if the according interface is shutting down
667 * Caller needs to ensure that forw_packet->delayed_work was initialized.
680 WARN_ONCE(hlist_fake(&forw_packet->cleanup_list), in batadv_forw_packet_queue()
687 hlist_del_init(&forw_packet->list); in batadv_forw_packet_queue()
688 hlist_add_head(&forw_packet->list, head); in batadv_forw_packet_queue()
691 &forw_packet->delayed_work, in batadv_forw_packet_queue()
692 send_time - jiffies); in batadv_forw_packet_queue()
697 * batadv_forw_packet_bcast_queue() - try to queue a broadcast packet
704 * Caller needs to ensure that forw_packet->delayed_work was initialized.
711 batadv_forw_packet_queue(forw_packet, &bat_priv->forw_bcast_list_lock, in batadv_forw_packet_bcast_queue()
712 &bat_priv->forw_bcast_list, send_time); in batadv_forw_packet_bcast_queue()
716 * batadv_forw_packet_ogmv1_queue() - try to queue an OGMv1 packet
723 * Caller needs to ensure that forw_packet->delayed_work was initialized.
729 batadv_forw_packet_queue(forw_packet, &bat_priv->forw_bat_list_lock, in batadv_forw_packet_ogmv1_queue()
730 &bat_priv->forw_bat_list, send_time); in batadv_forw_packet_ogmv1_queue()
734 * batadv_forw_bcast_packet_to_list() - queue broadcast packet for transmissions
738 * @own_packet: true if it is a self-generated broadcast packet
767 &bat_priv->bcast_queue_left, in batadv_forw_bcast_packet_to_list()
772 forw_packet->own = own_packet; in batadv_forw_bcast_packet_to_list()
774 INIT_DELAYED_WORK(&forw_packet->delayed_work, in batadv_forw_bcast_packet_to_list()
789 * batadv_forw_bcast_packet_if() - forward and queue a broadcast packet
793 * @own_packet: true if it is a self-generated broadcast packet
814 unsigned int num_bcasts = if_out->num_bcasts; in batadv_forw_bcast_packet_if()
824 num_bcasts--; in batadv_forw_bcast_packet_if()
829 BATADV_SKB_CB(skb)->num_bcasts = num_bcasts; in batadv_forw_bcast_packet_if()
840 * batadv_send_no_broadcast() - check whether (re)broadcast is necessary
843 * @own_packet: true if it is a self-generated broadcast packet
861 neigh_addr = eth_hdr(skb)->h_source; in batadv_send_no_broadcast()
866 bcast_packet = (struct batadv_bcast_packet *)skb->data; in batadv_send_no_broadcast()
867 orig_neigh = neigh_node ? neigh_node->orig : NULL; in batadv_send_no_broadcast()
869 ret = batadv_hardif_no_broadcast(if_out, bcast_packet->orig, in batadv_send_no_broadcast()
895 bcast_packet->orig, in batadv_send_no_broadcast()
896 if_out->net_dev->name, type); in batadv_send_no_broadcast()
902 * __batadv_forw_bcast_packet() - forward and queue a broadcast packet
906 * @own_packet: true if it is a self-generated broadcast packet
933 if (hard_iface->soft_iface != bat_priv->soft_iface) in __batadv_forw_bcast_packet()
936 if (!kref_get_unless_zero(&hard_iface->refcount)) in __batadv_forw_bcast_packet()
960 * batadv_forw_bcast_packet() - forward and queue a broadcast packet
964 * @own_packet: true if it is a self-generated broadcast packet
981 * batadv_send_bcast_packet() - send and queue a broadcast packet
985 * @own_packet: true if it is a self-generated broadcast packet
1003 * batadv_forw_packet_bcasts_left() - check if a retransmission is necessary
1018 return BATADV_SKB_CB(forw_packet->skb)->num_bcasts; in batadv_forw_packet_bcasts_left()
1022 * batadv_forw_packet_bcasts_dec() - decrement retransmission counter of a
1029 BATADV_SKB_CB(forw_packet->skb)->num_bcasts--; in batadv_forw_packet_bcasts_dec()
1033 * batadv_forw_packet_is_rebroadcast() - check packet for previous transmissions
1040 unsigned char num_bcasts = BATADV_SKB_CB(forw_packet->skb)->num_bcasts; in batadv_forw_packet_is_rebroadcast()
1042 return num_bcasts != forw_packet->if_outgoing->num_bcasts; in batadv_forw_packet_is_rebroadcast()
1046 * batadv_send_outstanding_bcast_packet() - transmit a queued broadcast packet
1063 bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface); in batadv_send_outstanding_bcast_packet()
1065 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) { in batadv_send_outstanding_bcast_packet()
1076 skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC); in batadv_send_outstanding_bcast_packet()
1080 batadv_send_broadcast_skb(skb1, forw_packet->if_outgoing); in batadv_send_outstanding_bcast_packet()
1092 &bat_priv->forw_bcast_list_lock)) in batadv_send_outstanding_bcast_packet()
1097 * batadv_purge_outstanding_packets() - stop/purge scheduled bcast/OGMv1 packets
1116 __func__, hard_iface->net_dev->name); in batadv_purge_outstanding_packets()
1122 spin_lock_bh(&bat_priv->forw_bcast_list_lock); in batadv_purge_outstanding_packets()
1123 batadv_forw_packet_list_steal(&bat_priv->forw_bcast_list, &head, in batadv_purge_outstanding_packets()
1125 spin_unlock_bh(&bat_priv->forw_bcast_list_lock); in batadv_purge_outstanding_packets()
1128 spin_lock_bh(&bat_priv->forw_bat_list_lock); in batadv_purge_outstanding_packets()
1129 batadv_forw_packet_list_steal(&bat_priv->forw_bat_list, &head, in batadv_purge_outstanding_packets()
1131 spin_unlock_bh(&bat_priv->forw_bat_list_lock); in batadv_purge_outstanding_packets()