Lines Matching +full:buffered +full:- +full:negative

1 // SPDX-License-Identifier: GPL-2.0
31 #include "distributed-arp-table.h"
34 #include "hard-interface.h"
36 #include "mesh-interface.h"
39 #include "translation-table.h"
44 * batadv_send_skb_packet() - send an already prepared packet
57 * Return: A negative errno code is returned on a failure. A success does not
68 if (hard_iface->if_status != BATADV_IF_ACTIVE)
71 if (unlikely(!hard_iface->net_dev))
74 if (!(hard_iface->net_dev->flags & IFF_UP)) {
75 pr_warn("Interface %s is not up - can't send packet via that interface!\n",
76 hard_iface->net_dev->name);
87 ether_addr_copy(ethhdr->h_source, hard_iface->net_dev->dev_addr);
88 ether_addr_copy(ethhdr->h_dest, dst_addr);
89 ethhdr->h_proto = htons(ETH_P_BATMAN);
92 skb->protocol = htons(ETH_P_BATMAN);
94 skb->dev = hard_iface->net_dev;
96 /* dev_queue_xmit() returns a negative result on error. However on
108 * batadv_send_broadcast_skb() - Send broadcast packet via hard interface
112 * Return: A negative errno code is returned on a failure. A success does not
125 * batadv_send_unicast_skb() - Send unicast packet to neighbor
129 * Return: A negative errno code is returned on a failure. A success does not
141 ret = batadv_send_skb_packet(skb, neigh->if_incoming, neigh->addr);
144 hardif_neigh = batadv_hardif_neigh_get(neigh->if_incoming, neigh->addr);
147 hardif_neigh->bat_v.last_unicast_tx = jiffies;
156 * batadv_send_skb_to_orig() - Lookup next-hop and transmit skb.
161 * Looks up the best next-hop towards the passed originator and passes the
166 * Return: negative errno code on a failure, -EINPROGRESS if the skb is
167 * buffered for later transmit or the NET_XMIT status returned by the
174 struct batadv_priv *bat_priv = orig_node->bat_priv;
181 ret = -EINVAL;
188 if (atomic_read(&bat_priv->fragmentation) &&
189 skb->len > neigh_node->if_incoming->net_dev->mtu) {
212 * batadv_send_skb_push_fill_unicast() - extend the buffer and initialize the
225 u8 ttvn = (u8)atomic_read(&orig_node->last_ttvn);
230 unicast_packet = (struct batadv_unicast_packet *)skb->data;
231 unicast_packet->version = BATADV_COMPAT_VERSION;
233 unicast_packet->packet_type = BATADV_UNICAST;
235 unicast_packet->ttl = BATADV_TTL;
237 ether_addr_copy(unicast_packet->dest, orig_node->orig);
239 unicast_packet->ttvn = ttvn;
245 * batadv_send_skb_prepare_unicast() - encapsulate an skb with a unicast header
260 * batadv_send_skb_prepare_unicast_4addr() - encapsulate an skb with a
290 uc_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
291 uc_4addr_packet->u.packet_type = BATADV_UNICAST_4ADDR;
292 ether_addr_copy(uc_4addr_packet->src, primary_if->net_dev->dev_addr);
293 uc_4addr_packet->subtype = packet_subtype;
294 uc_4addr_packet->reserved = 0;
303 * batadv_send_skb_unicast() - encapsulate and send an skb via unicast
312 * Wrap the given skb into a batman-adv unicast or unicast-4addr header
349 /* skb->data might have been reallocated by
353 unicast_packet = (struct batadv_unicast_packet *)skb->data;
360 if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest, vid))
361 unicast_packet->ttvn = unicast_packet->ttvn - 1;
373 * batadv_send_skb_via_tt_generic() - send an skb via TT lookup
383 * header via the translation table. Wrap the given skb into a batman-adv
384 * unicast or unicast-4addr header depending on whether BATADV_UNICAST or
395 struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
400 src = ethhdr->h_source;
401 dst = ethhdr->h_dest;
419 * batadv_send_skb_via_gw() - send an skb via gateway lookup
424 * Look up the currently selected gateway. Wrap the given skb into a batman-adv
445 * batadv_forw_packet_free() - free a forwarding packet
456 kfree_skb(forw_packet->skb);
458 consume_skb(forw_packet->skb);
460 batadv_hardif_put(forw_packet->if_incoming);
461 batadv_hardif_put(forw_packet->if_outgoing);
462 if (forw_packet->queue_left)
463 atomic_inc(forw_packet->queue_left);
468 * batadv_forw_packet_alloc() - allocate a forwarding packet
494 if (queue_left == &bat_priv->bcast_queue_left)
497 if (queue_left == &bat_priv->batman_queue_left)
511 kref_get(&if_incoming->refcount);
514 kref_get(&if_outgoing->refcount);
516 INIT_HLIST_NODE(&forw_packet->list);
517 INIT_HLIST_NODE(&forw_packet->cleanup_list);
518 forw_packet->skb = skb;
519 forw_packet->queue_left = queue_left;
520 forw_packet->if_incoming = if_incoming;
521 forw_packet->if_outgoing = if_outgoing;
522 forw_packet->num_packets = 1;
534 * batadv_forw_packet_was_stolen() - check whether someone stole this packet
545 return !hlist_unhashed(&forw_packet->cleanup_list);
549 * batadv_forw_packet_steal() - claim a forw_packet for free()
570 hlist_del_init(&forw_packet->list);
573 hlist_add_fake(&forw_packet->cleanup_list);
580 * batadv_forw_packet_list_steal() - claim a list of forward packets for free()
606 forw_packet->if_incoming != hard_iface &&
607 forw_packet->if_outgoing != hard_iface)
610 hlist_del(&forw_packet->list);
611 hlist_add_head(&forw_packet->cleanup_list, cleanup_list);
616 * batadv_forw_packet_list_free() - free a list of forward packets
632 cancel_delayed_work_sync(&forw_packet->delayed_work);
634 hlist_del(&forw_packet->cleanup_list);
640 * batadv_forw_packet_queue() - try to queue a forwarding packet
654 * Caller needs to ensure that forw_packet->delayed_work was initialized.
667 WARN_ONCE(hlist_fake(&forw_packet->cleanup_list),
674 hlist_del_init(&forw_packet->list);
675 hlist_add_head(&forw_packet->list, head);
678 &forw_packet->delayed_work,
679 send_time - jiffies);
684 * batadv_forw_packet_bcast_queue() - try to queue a broadcast packet
691 * Caller needs to ensure that forw_packet->delayed_work was initialized.
698 batadv_forw_packet_queue(forw_packet, &bat_priv->forw_bcast_list_lock,
699 &bat_priv->forw_bcast_list, send_time);
703 * batadv_forw_packet_ogmv1_queue() - try to queue an OGMv1 packet
710 * Caller needs to ensure that forw_packet->delayed_work was initialized.
716 batadv_forw_packet_queue(forw_packet, &bat_priv->forw_bat_list_lock,
717 &bat_priv->forw_bat_list, send_time);
721 * batadv_forw_bcast_packet_to_list() - queue broadcast packet for transmissions
725 * @own_packet: true if it is a self-generated broadcast packet
754 &bat_priv->bcast_queue_left,
759 forw_packet->own = own_packet;
761 INIT_DELAYED_WORK(&forw_packet->delayed_work,
776 * batadv_forw_bcast_packet_if() - forward and queue a broadcast packet
780 * @own_packet: true if it is a self-generated broadcast packet
801 unsigned int num_bcasts = if_out->num_bcasts;
811 num_bcasts--;
816 BATADV_SKB_CB(skb)->num_bcasts = num_bcasts;
827 * batadv_send_no_broadcast() - check whether (re)broadcast is necessary
830 * @own_packet: true if it is a self-generated broadcast packet
848 neigh_addr = eth_hdr(skb)->h_source;
853 bcast_packet = (struct batadv_bcast_packet *)skb->data;
854 orig_neigh = neigh_node ? neigh_node->orig : NULL;
856 ret = batadv_hardif_no_broadcast(if_out, bcast_packet->orig,
882 bcast_packet->orig,
883 if_out->net_dev->name, type);
889 * __batadv_forw_bcast_packet() - forward and queue a broadcast packet
893 * @own_packet: true if it is a self-generated broadcast packet
920 netdev_for_each_lower_private_rcu(bat_priv->mesh_iface, hard_iface, iter) {
921 if (!kref_get_unless_zero(&hard_iface->refcount))
945 * batadv_forw_bcast_packet() - forward and queue a broadcast packet
949 * @own_packet: true if it is a self-generated broadcast packet
966 * batadv_send_bcast_packet() - send and queue a broadcast packet
970 * @own_packet: true if it is a self-generated broadcast packet
988 * batadv_forw_packet_bcasts_left() - check if a retransmission is necessary
1003 return BATADV_SKB_CB(forw_packet->skb)->num_bcasts;
1007 * batadv_forw_packet_bcasts_dec() - decrement retransmission counter of a
1014 BATADV_SKB_CB(forw_packet->skb)->num_bcasts--;
1018 * batadv_forw_packet_is_rebroadcast() - check packet for previous transmissions
1025 unsigned char num_bcasts = BATADV_SKB_CB(forw_packet->skb)->num_bcasts;
1027 return num_bcasts != forw_packet->if_outgoing->num_bcasts;
1031 * batadv_send_outstanding_bcast_packet() - transmit a queued broadcast packet
1048 bat_priv = netdev_priv(forw_packet->if_incoming->mesh_iface);
1050 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) {
1061 skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC);
1065 batadv_send_broadcast_skb(skb1, forw_packet->if_outgoing);
1077 &bat_priv->forw_bcast_list_lock))
1082 * batadv_purge_outstanding_packets() - stop/purge scheduled bcast/OGMv1 packets
1101 __func__, hard_iface->net_dev->name);
1107 spin_lock_bh(&bat_priv->forw_bcast_list_lock);
1108 batadv_forw_packet_list_steal(&bat_priv->forw_bcast_list, &head,
1110 spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
1113 spin_lock_bh(&bat_priv->forw_bat_list_lock);
1114 batadv_forw_packet_list_steal(&bat_priv->forw_bat_list, &head,
1116 spin_unlock_bh(&bat_priv->forw_bat_list_lock);