Lines Matching +full:pull +full:- +full:up +full:- +full:adv
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors:
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()
163 * batadv_send_skb_to_orig() - Lookup next-hop and transmit skb.
168 * Looks up the best next-hop towards the passed originator and passes the
173 * Return: negative errno code on a failure, -EINPROGRESS if the skb is
181 struct batadv_priv *bat_priv = orig_node->bat_priv; in batadv_send_skb_to_orig()
188 ret = -EINVAL; in batadv_send_skb_to_orig()
195 if (atomic_read(&bat_priv->fragmentation) && in batadv_send_skb_to_orig()
196 skb->len > neigh_node->if_incoming->net_dev->mtu) { in batadv_send_skb_to_orig()
210 ret = -EINPROGRESS; in batadv_send_skb_to_orig()
226 * batadv_send_skb_push_fill_unicast() - extend the buffer and initialize the
239 u8 ttvn = (u8)atomic_read(&orig_node->last_ttvn); in batadv_send_skb_push_fill_unicast()
244 unicast_packet = (struct batadv_unicast_packet *)skb->data; in batadv_send_skb_push_fill_unicast()
245 unicast_packet->version = BATADV_COMPAT_VERSION; in batadv_send_skb_push_fill_unicast()
247 unicast_packet->packet_type = BATADV_UNICAST; in batadv_send_skb_push_fill_unicast()
249 unicast_packet->ttl = BATADV_TTL; in batadv_send_skb_push_fill_unicast()
251 ether_addr_copy(unicast_packet->dest, orig_node->orig); in batadv_send_skb_push_fill_unicast()
253 unicast_packet->ttvn = ttvn; in batadv_send_skb_push_fill_unicast()
259 * batadv_send_skb_prepare_unicast() - encapsulate an skb with a unicast header
274 * batadv_send_skb_prepare_unicast_4addr() - encapsulate an skb with a
296 /* Pull the header space and fill the unicast_packet substructure. in batadv_send_skb_prepare_unicast_4addr()
304 uc_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; in batadv_send_skb_prepare_unicast_4addr()
305 uc_4addr_packet->u.packet_type = BATADV_UNICAST_4ADDR; in batadv_send_skb_prepare_unicast_4addr()
306 ether_addr_copy(uc_4addr_packet->src, primary_if->net_dev->dev_addr); in batadv_send_skb_prepare_unicast_4addr()
307 uc_4addr_packet->subtype = packet_subtype; in batadv_send_skb_prepare_unicast_4addr()
308 uc_4addr_packet->reserved = 0; in batadv_send_skb_prepare_unicast_4addr()
318 * batadv_send_skb_unicast() - encapsulate and send an skb via unicast
327 * Wrap the given skb into a batman-adv unicast or unicast-4addr header
364 /* skb->data might have been reallocated by in batadv_send_skb_unicast()
368 unicast_packet = (struct batadv_unicast_packet *)skb->data; in batadv_send_skb_unicast()
375 if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) in batadv_send_skb_unicast()
376 unicast_packet->ttvn = unicast_packet->ttvn - 1; in batadv_send_skb_unicast()
388 * batadv_send_skb_via_tt_generic() - send an skb via TT lookup
397 * Look up the recipient node for the destination address in the ethernet
398 * header via the translation table. Wrap the given skb into a batman-adv
399 * unicast or unicast-4addr header depending on whether BATADV_UNICAST or
410 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; in batadv_send_skb_via_tt_generic()
415 src = ethhdr->h_source; in batadv_send_skb_via_tt_generic()
416 dst = ethhdr->h_dest; in batadv_send_skb_via_tt_generic()
435 * batadv_send_skb_via_gw() - send an skb via gateway lookup
440 * Look up the currently selected gateway. Wrap the given skb into a batman-adv
462 * batadv_forw_packet_free() - free a forwarding packet
473 kfree_skb(forw_packet->skb); in batadv_forw_packet_free()
475 consume_skb(forw_packet->skb); in batadv_forw_packet_free()
477 if (forw_packet->if_incoming) in batadv_forw_packet_free()
478 batadv_hardif_put(forw_packet->if_incoming); in batadv_forw_packet_free()
479 if (forw_packet->if_outgoing) in batadv_forw_packet_free()
480 batadv_hardif_put(forw_packet->if_outgoing); in batadv_forw_packet_free()
481 if (forw_packet->queue_left) in batadv_forw_packet_free()
482 atomic_inc(forw_packet->queue_left); in batadv_forw_packet_free()
487 * batadv_forw_packet_alloc() - allocate a forwarding packet
513 if (queue_left == &bat_priv->bcast_queue_left) in batadv_forw_packet_alloc()
516 if (queue_left == &bat_priv->batman_queue_left) in batadv_forw_packet_alloc()
530 kref_get(&if_incoming->refcount); in batadv_forw_packet_alloc()
533 kref_get(&if_outgoing->refcount); in batadv_forw_packet_alloc()
535 INIT_HLIST_NODE(&forw_packet->list); in batadv_forw_packet_alloc()
536 INIT_HLIST_NODE(&forw_packet->cleanup_list); in batadv_forw_packet_alloc()
537 forw_packet->skb = skb; in batadv_forw_packet_alloc()
538 forw_packet->queue_left = queue_left; in batadv_forw_packet_alloc()
539 forw_packet->if_incoming = if_incoming; in batadv_forw_packet_alloc()
540 forw_packet->if_outgoing = if_outgoing; in batadv_forw_packet_alloc()
541 forw_packet->num_packets = 0; in batadv_forw_packet_alloc()
553 * batadv_forw_packet_was_stolen() - check whether someone stole this packet
564 return !hlist_unhashed(&forw_packet->cleanup_list); in batadv_forw_packet_was_stolen()
568 * batadv_forw_packet_steal() - claim a forw_packet for free()
589 hlist_del_init(&forw_packet->list); in batadv_forw_packet_steal()
592 hlist_add_fake(&forw_packet->cleanup_list); in batadv_forw_packet_steal()
599 * batadv_forw_packet_list_steal() - claim a list of forward packets for free()
625 forw_packet->if_incoming != hard_iface && in batadv_forw_packet_list_steal()
626 forw_packet->if_outgoing != hard_iface) in batadv_forw_packet_list_steal()
629 hlist_del(&forw_packet->list); in batadv_forw_packet_list_steal()
630 hlist_add_head(&forw_packet->cleanup_list, cleanup_list); in batadv_forw_packet_list_steal()
635 * batadv_forw_packet_list_free() - free a list of forward packets
651 cancel_delayed_work_sync(&forw_packet->delayed_work); in batadv_forw_packet_list_free()
653 hlist_del(&forw_packet->cleanup_list); in batadv_forw_packet_list_free()
659 * batadv_forw_packet_queue() - try to queue a forwarding packet
673 * Caller needs to ensure that forw_packet->delayed_work was initialized.
686 WARN_ONCE(hlist_fake(&forw_packet->cleanup_list), in batadv_forw_packet_queue()
693 hlist_del_init(&forw_packet->list); in batadv_forw_packet_queue()
694 hlist_add_head(&forw_packet->list, head); in batadv_forw_packet_queue()
697 &forw_packet->delayed_work, in batadv_forw_packet_queue()
698 send_time - jiffies); in batadv_forw_packet_queue()
703 * batadv_forw_packet_bcast_queue() - try to queue a broadcast packet
710 * Caller needs to ensure that forw_packet->delayed_work was initialized.
717 batadv_forw_packet_queue(forw_packet, &bat_priv->forw_bcast_list_lock, in batadv_forw_packet_bcast_queue()
718 &bat_priv->forw_bcast_list, send_time); in batadv_forw_packet_bcast_queue()
722 * batadv_forw_packet_ogmv1_queue() - try to queue an OGMv1 packet
729 * Caller needs to ensure that forw_packet->delayed_work was initialized.
735 batadv_forw_packet_queue(forw_packet, &bat_priv->forw_bat_list_lock, in batadv_forw_packet_ogmv1_queue()
736 &bat_priv->forw_bat_list, send_time); in batadv_forw_packet_ogmv1_queue()
740 * batadv_add_bcast_packet_to_list() - queue broadcast packet for multiple sends
744 * @own_packet: true if it is a self-generated broadcast packet
775 &bat_priv->bcast_queue_left, in batadv_add_bcast_packet_to_list()
782 bcast_packet = (struct batadv_bcast_packet *)newskb->data; in batadv_add_bcast_packet_to_list()
783 bcast_packet->ttl--; in batadv_add_bcast_packet_to_list()
785 forw_packet->own = own_packet; in batadv_add_bcast_packet_to_list()
787 INIT_DELAYED_WORK(&forw_packet->delayed_work, in batadv_add_bcast_packet_to_list()
800 * batadv_forw_packet_bcasts_left() - check if a retransmission is necessary
820 max = hard_iface->num_bcasts; in batadv_forw_packet_bcasts_left()
824 return BATADV_SKB_CB(forw_packet->skb)->num_bcasts < max; in batadv_forw_packet_bcasts_left()
828 * batadv_forw_packet_bcasts_inc() - increment retransmission counter of a
835 BATADV_SKB_CB(forw_packet->skb)->num_bcasts++; in batadv_forw_packet_bcasts_inc()
839 * batadv_forw_packet_is_rebroadcast() - check packet for previous transmissions
846 return BATADV_SKB_CB(forw_packet->skb)->num_bcasts > 0; in batadv_forw_packet_is_rebroadcast()
868 soft_iface = forw_packet->if_incoming->soft_iface; in batadv_send_outstanding_bcast_packet()
871 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) { in batadv_send_outstanding_bcast_packet()
881 bcast_packet = (struct batadv_bcast_packet *)forw_packet->skb->data; in batadv_send_outstanding_bcast_packet()
886 if (hard_iface->soft_iface != soft_iface) in batadv_send_outstanding_bcast_packet()
892 if (forw_packet->own) { in batadv_send_outstanding_bcast_packet()
895 neigh_addr = eth_hdr(forw_packet->skb)->h_source; in batadv_send_outstanding_bcast_packet()
900 orig_neigh = neigh_node ? neigh_node->orig : NULL; in batadv_send_outstanding_bcast_packet()
902 ret = batadv_hardif_no_broadcast(hard_iface, bcast_packet->orig, in batadv_send_outstanding_bcast_packet()
923 bcast_packet->orig, in batadv_send_outstanding_bcast_packet()
924 hard_iface->net_dev->name, type); in batadv_send_outstanding_bcast_packet()
935 if (!kref_get_unless_zero(&hard_iface->refcount)) in batadv_send_outstanding_bcast_packet()
939 skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC); in batadv_send_outstanding_bcast_packet()
959 &bat_priv->forw_bcast_list_lock)) in batadv_send_outstanding_bcast_packet()
964 * batadv_purge_outstanding_packets() - stop/purge scheduled bcast/OGMv1 packets
983 __func__, hard_iface->net_dev->name); in batadv_purge_outstanding_packets()
989 spin_lock_bh(&bat_priv->forw_bcast_list_lock); in batadv_purge_outstanding_packets()
990 batadv_forw_packet_list_steal(&bat_priv->forw_bcast_list, &head, in batadv_purge_outstanding_packets()
992 spin_unlock_bh(&bat_priv->forw_bcast_list_lock); in batadv_purge_outstanding_packets()
995 spin_lock_bh(&bat_priv->forw_bat_list_lock); in batadv_purge_outstanding_packets()
996 batadv_forw_packet_list_steal(&bat_priv->forw_bat_list, &head, in batadv_purge_outstanding_packets()
998 spin_unlock_bh(&bat_priv->forw_bat_list_lock); in batadv_purge_outstanding_packets()