Lines Matching +full:re +full:- +full:routed

1 // SPDX-License-Identifier: GPL-2.0
29 #include "distributed-arp-table.h"
31 #include "hard-interface.h"
33 #include "mesh-interface.h"
37 #include "translation-table.h"
44 * _batadv_update_route() - set the router for this originator
64 spin_lock_bh(&orig_node->neigh_list_lock);
65 /* curr_router used earlier may not be the current orig_ifinfo->router
75 kref_get(&neigh_node->refcount);
77 curr_router = rcu_replace_pointer(orig_ifinfo->router, neigh_node,
79 spin_unlock_bh(&orig_node->neigh_list_lock);
85 "Deleting route towards: %pM\n", orig_node->orig);
86 batadv_tt_global_del_orig(bat_priv, orig_node, -1,
93 orig_node->orig, neigh_node->addr);
97 "Changing route towards: %pM (now via %pM - was via %pM)\n",
98 orig_node->orig, neigh_node->addr,
99 curr_router->addr);
107 * batadv_update_route() - set the router for this originator
133 * batadv_window_protected() - checks whether the host restarted and is in the
152 if (seq_num_diff <= -seq_old_max_diff ||
169 * batadv_check_management_packet() - Check preconditions for management packets
189 if (!is_broadcast_ether_addr(ethhdr->h_dest))
193 if (!is_valid_ether_addr(ethhdr->h_source))
208 * batadv_recv_my_icmp_packet() - receive an icmp packet locally
223 icmph = (struct batadv_icmp_header *)skb->data;
225 switch (icmph->msg_type) {
233 orig_node = batadv_orig_hash_find(bat_priv, icmph->orig);
241 icmph = (struct batadv_icmp_header *)skb->data;
243 ether_addr_copy(icmph->dst, icmph->orig);
244 ether_addr_copy(icmph->orig, primary_if->net_dev->dev_addr);
245 icmph->msg_type = BATADV_ECHO_REPLY;
246 icmph->ttl = BATADV_TTL;
285 icmp_packet = (struct batadv_icmp_packet *)skb->data;
288 if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) {
289 pr_debug("Warning - can't forward icmp packet from %pM to %pM: ttl exceeded\n",
290 icmp_packet->orig, icmp_packet->dst);
299 orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->orig);
307 icmp_packet = (struct batadv_icmp_packet *)skb->data;
309 ether_addr_copy(icmp_packet->dst, icmp_packet->orig);
310 ether_addr_copy(icmp_packet->orig, primary_if->net_dev->dev_addr);
311 icmp_packet->msg_type = BATADV_TTL_EXCEEDED;
312 icmp_packet->ttl = BATADV_TTL;
331 * batadv_recv_icmp_packet() - Process incoming icmp packet
340 struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
354 /* packet with unicast indication but non-unicast recipient */
355 if (!is_valid_ether_addr(ethhdr->h_dest))
359 if (is_multicast_ether_addr(ethhdr->h_source))
363 if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest))
366 icmph = (struct batadv_icmp_header *)skb->data;
369 if ((icmph->msg_type == BATADV_ECHO_REPLY ||
370 icmph->msg_type == BATADV_ECHO_REQUEST) &&
371 skb->len >= sizeof(struct batadv_icmp_packet_rr)) {
380 icmph = (struct batadv_icmp_header *)skb->data;
382 if (icmp_packet_rr->rr_cur >= BATADV_RR_LEN)
385 ether_addr_copy(icmp_packet_rr->rr[icmp_packet_rr->rr_cur],
386 ethhdr->h_dest);
387 icmp_packet_rr->rr_cur++;
391 if (batadv_is_my_mac(bat_priv, icmph->dst))
395 if (icmph->ttl < 2)
399 orig_node = batadv_orig_hash_find(bat_priv, icmph->dst);
407 icmph = (struct batadv_icmp_header *)skb->data;
410 icmph->ttl--;
429 * batadv_check_unicast_packet() - Check for malformed unicast packets
437 * depends on the reason: -ENODATA for bad header, -EBADR for broadcast
438 * destination or source, and -EREMOTE for non-local (other host) destination.
447 return -ENODATA;
451 /* packet with unicast indication but non-unicast recipient */
452 if (!is_valid_ether_addr(ethhdr->h_dest))
453 return -EBADR;
456 if (is_multicast_ether_addr(ethhdr->h_source))
457 return -EBADR;
460 if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest))
461 return -EREMOTE;
467 * batadv_last_bonding_get() - Get last_bonding_candidate of orig_node
479 spin_lock_bh(&orig_node->neigh_list_lock);
480 last_bonding_candidate = orig_node->last_bonding_candidate;
483 kref_get(&last_bonding_candidate->refcount);
484 spin_unlock_bh(&orig_node->neigh_list_lock);
490 * batadv_last_bonding_replace() - Replace last_bonding_candidate of orig_node
500 spin_lock_bh(&orig_node->neigh_list_lock);
501 old_candidate = orig_node->last_bonding_candidate;
504 kref_get(&new_candidate->refcount);
505 orig_node->last_bonding_candidate = new_candidate;
506 spin_unlock_bh(&orig_node->neigh_list_lock);
512 * batadv_find_router() - find a suitable router for this originator
525 struct batadv_algo_ops *bao = bat_priv->algo_ops;
546 if (!(recv_if == BATADV_IF_DEFAULT && atomic_read(&bat_priv->bonding)))
555 * router - obviously there are no other candidates.
560 last_cand_router = rcu_dereference(last_candidate->router);
562 hlist_for_each_entry_rcu(cand, &orig_node->ifinfo_list, list) {
564 if (!kref_get_unless_zero(&cand->refcount))
567 cand_router = rcu_dereference(cand->router);
571 if (!kref_get_unless_zero(&cand_router->refcount)) {
579 if (!bao->neigh.is_similar_or_better(cand_router,
580 cand->if_outgoing, router,
590 kref_get(&cand_router->refcount);
591 kref_get(&cand->refcount);
626 kref_get(&next_candidate_router->refcount);
632 kref_get(&first_candidate_router->refcount);
658 struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
665 unicast_packet = (struct batadv_unicast_packet *)skb->data;
668 if (unicast_packet->ttl < 2) {
669 pr_debug("Warning - can't forward unicast packet from %pM to %pM: ttl exceeded\n",
670 ethhdr->h_source, unicast_packet->dest);
675 orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->dest);
685 unicast_packet = (struct batadv_unicast_packet *)skb->data;
686 unicast_packet->ttl--;
688 switch (unicast_packet->packet_type) {
696 /* other packet types not supported - yet */
697 hdr_len = -1;
704 len = skb->len;
728 * batadv_reroute_unicast_packet() - update the unicast header for re-routing
756 orig_addr = primary_if->net_dev->dev_addr;
757 orig_ttvn = (u8)atomic_read(&bat_priv->tt.vn);
764 if (batadv_compare_eth(orig_node->orig, unicast_packet->dest))
767 orig_addr = orig_node->orig;
768 orig_ttvn = (u8)atomic_read(&orig_node->last_ttvn);
773 ether_addr_copy(unicast_packet->dest, orig_addr);
774 unicast_packet->ttvn = orig_ttvn;
800 /* create a copy of the skb (in case of for re-routing) to modify it. */
804 unicast_packet = (struct batadv_unicast_packet *)skb->data;
806 ethhdr = (struct ethhdr *)(skb->data + hdr_len);
809 if (is_multicast_ether_addr(ethhdr->h_dest))
814 * message and that it knows the new destination in the mesh to re-route
817 if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) {
819 ethhdr->h_dest, vid))
823 unicast_packet->dest,
824 ethhdr->h_dest);
834 * value is used later to check if the node which sent (or re-routed
837 curr_ttvn = (u8)atomic_read(&bat_priv->tt.vn);
838 if (!batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
840 unicast_packet->dest);
848 curr_ttvn = (u8)atomic_read(&orig_node->last_ttvn);
855 is_old_ttvn = batadv_seq_before(unicast_packet->ttvn, curr_ttvn);
859 old_ttvn = unicast_packet->ttvn;
865 ethhdr->h_dest, vid)) {
868 unicast_packet->dest, ethhdr->h_dest,
873 /* the packet has not been re-routed: either the destination is
877 if (!batadv_is_my_client(bat_priv, ethhdr->h_dest, vid))
889 ether_addr_copy(unicast_packet->dest, primary_if->net_dev->dev_addr);
890 unicast_packet->ttvn = curr_ttvn;
899 * batadv_recv_unhandled_unicast_packet() - receive and process packets which
911 struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
919 unicast_packet = (struct batadv_unicast_packet *)skb->data;
920 if (batadv_is_my_mac(bat_priv, unicast_packet->dest))
931 * batadv_recv_unicast_packet() - Process incoming unicast packet
940 struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
950 unicast_packet = (struct batadv_unicast_packet *)skb->data;
951 is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
956 /* function returns -EREMOTE for promiscuous packets */
964 unicast_packet = (struct batadv_unicast_packet *)skb->data;
967 if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
971 orig_addr_gw = eth_hdr(skb)->h_source;
987 (struct batadv_unicast_4addr_packet *)skb->data;
988 subtype = unicast_4addr_packet->subtype;
998 orig_addr = unicast_4addr_packet->src;
1013 batadv_interface_rx(recv_if->mesh_iface, skb, hdr_size,
1033 * batadv_recv_unicast_tvlv() - receive and process unicast tvlv packets
1043 struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
1061 unicast_tvlv_packet = (struct batadv_unicast_tvlv_packet *)skb->data;
1063 tvlv_buff = (unsigned char *)(skb->data + hdr_size);
1064 tvlv_buff_len = ntohs(unicast_tvlv_packet->tvlv_len);
1066 if (tvlv_buff_len > skb->len - hdr_size)
1086 * batadv_recv_frag_packet() - process received fragment
1099 struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
1108 frag_packet = (struct batadv_frag_packet *)skb->data;
1109 orig_node_src = batadv_orig_hash_find(bat_priv, frag_packet->orig);
1113 skb->priority = frag_packet->priority + 256;
1116 if (!batadv_is_my_mac(bat_priv, frag_packet->dest) &&
1125 batadv_add_counter(bat_priv, BATADV_CNT_FRAG_RX_BYTES, skb->len);
1135 batadv_batman_skb_recv(skb, recv_if->net_dev,
1136 &recv_if->batman_adv_ptype, NULL);
1152 * batadv_recv_bcast_packet() - Process incoming broadcast packet
1161 struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
1177 if (!is_broadcast_ether_addr(ethhdr->h_dest))
1181 if (is_multicast_ether_addr(ethhdr->h_source))
1185 if (batadv_is_my_mac(bat_priv, ethhdr->h_source))
1188 bcast_packet = (struct batadv_bcast_packet *)skb->data;
1191 if (batadv_is_my_mac(bat_priv, bcast_packet->orig))
1194 if (bcast_packet->ttl-- < 2)
1197 orig_node = batadv_orig_hash_find(bat_priv, bcast_packet->orig);
1202 spin_lock_bh(&orig_node->bcast_seqno_lock);
1204 seqno = ntohl(bcast_packet->seqno);
1206 if (batadv_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno,
1210 seq_diff = seqno - orig_node->last_bcast_seqno;
1215 &orig_node->bcast_seqno_reset, NULL))
1221 if (batadv_bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1))
1222 orig_node->last_bcast_seqno = seqno;
1224 spin_unlock_bh(&orig_node->bcast_seqno_lock);
1251 batadv_interface_rx(recv_if->mesh_iface, skb, hdr_size, orig_node);
1258 spin_unlock_bh(&orig_node->bcast_seqno_lock);
1269 * batadv_recv_mcast_packet() - process received batman-adv multicast packet
1270 * @skb: the received batman-adv multicast packet
1273 * Parses the given, received batman-adv multicast packet. Depending on the
1282 struct batadv_priv *bat_priv = netdev_priv(recv_if->mesh_iface);
1300 mcast_packet = (struct batadv_mcast_packet *)skb->data;
1301 if (mcast_packet->ttl-- < 2)
1304 tvlv_buff = (unsigned char *)(skb->data + hdr_size);
1305 tvlv_buff_len = ntohs(mcast_packet->tvlv_len);
1307 if (tvlv_buff_len > skb->len - hdr_size)
1315 skb->len + ETH_HLEN);
1320 if (ret == NET_RX_SUCCESS && (skb->len - hdr_size >= ETH_HLEN)) {
1323 skb->len - hdr_size);
1325 batadv_interface_rx(bat_priv->mesh_iface, skb, hdr_size, NULL);