• Home
  • Raw
  • Download

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:
19 #include "soft-interface.h"
57 #include "distributed-arp-table.h"
60 #include "hard-interface.h"
62 #include "network-coding.h"
66 #include "translation-table.h"
69 * batadv_skb_head_push() - Increase header size and move (push) head pointer
79 /* TODO: We must check if we can release all references to non-payload in batadv_skb_head_push()
82 * or write any data which is before the current position of skb->data in batadv_skb_head_push()
107 * batadv_sum_counter() - Sum the cpu-local counters for index 'idx'
109 * @idx: index of counter to sum up
111 * Return: sum of all cpu-local counters
119 counters = per_cpu_ptr(bat_priv->bat_counters, cpu); in batadv_sum_counter()
129 struct net_device_stats *stats = &dev->stats; in batadv_interface_stats()
131 stats->tx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_TX); in batadv_interface_stats()
132 stats->tx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_TX_BYTES); in batadv_interface_stats()
133 stats->tx_dropped = batadv_sum_counter(bat_priv, BATADV_CNT_TX_DROPPED); in batadv_interface_stats()
134 stats->rx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_RX); in batadv_interface_stats()
135 stats->rx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_RX_BYTES); in batadv_interface_stats()
146 if (!is_valid_ether_addr(addr->sa_data)) in batadv_interface_set_mac_addr()
147 return -EADDRNOTAVAIL; in batadv_interface_set_mac_addr()
149 ether_addr_copy(old_addr, dev->dev_addr); in batadv_interface_set_mac_addr()
150 ether_addr_copy(dev->dev_addr, addr->sa_data); in batadv_interface_set_mac_addr()
153 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_interface_set_mac_addr()
157 hlist_for_each_entry_rcu(vlan, &bat_priv->softif_vlan_list, list) { in batadv_interface_set_mac_addr()
158 batadv_tt_local_remove(bat_priv, old_addr, vlan->vid, in batadv_interface_set_mac_addr()
160 batadv_tt_local_add(dev, addr->sa_data, vlan->vid, in batadv_interface_set_mac_addr()
172 return -EINVAL; in batadv_interface_change_mtu()
174 dev->mtu = new_mtu; in batadv_interface_change_mtu()
180 * batadv_interface_set_rx_mode() - set the rx mode of a device
206 int data_len = skb->len, ret; in batadv_interface_tx()
216 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_interface_tx()
220 memset(skb->cb, 0, sizeof(struct batadv_skb_cb)); in batadv_interface_tx()
228 switch (ntohs(ethhdr->h_proto)) { in batadv_interface_tx()
234 /* drop batman-in-batman packets to prevent loops */ in batadv_interface_tx()
235 if (vhdr->h_vlan_encapsulated_proto != htons(ETH_P_BATMAN)) { in batadv_interface_tx()
250 /* skb->data might have been reallocated by batadv_bla_tx() */ in batadv_interface_tx()
254 if (!is_multicast_ether_addr(ethhdr->h_source) && in batadv_interface_tx()
255 !batadv_bla_is_loopdetect_mac(ethhdr->h_source)) { in batadv_interface_tx()
256 client_added = batadv_tt_local_add(soft_iface, ethhdr->h_source, in batadv_interface_tx()
257 vid, skb->skb_iif, in batadv_interface_tx()
258 skb->mark); in batadv_interface_tx()
269 if (batadv_compare_eth(ethhdr->h_dest, stp_addr)) in batadv_interface_tx()
272 if (batadv_compare_eth(ethhdr->h_dest, ectp_addr)) in batadv_interface_tx()
275 gw_mode = atomic_read(&bat_priv->gw.mode); in batadv_interface_tx()
276 if (is_multicast_ether_addr(ethhdr->h_dest)) { in batadv_interface_tx()
285 /* skb->data may have been modified by in batadv_interface_tx()
289 /* if gw_mode is on, broadcast any non-DHCP message. in batadv_interface_tx()
307 if (do_bcast && !is_broadcast_ether_addr(ethhdr->h_dest)) { in batadv_interface_tx()
336 bcast_packet = (struct batadv_bcast_packet *)skb->data; in batadv_interface_tx()
337 bcast_packet->version = BATADV_COMPAT_VERSION; in batadv_interface_tx()
338 bcast_packet->ttl = BATADV_TTL; in batadv_interface_tx()
341 bcast_packet->packet_type = BATADV_BCAST; in batadv_interface_tx()
342 bcast_packet->reserved = 0; in batadv_interface_tx()
347 ether_addr_copy(bcast_packet->orig, in batadv_interface_tx()
348 primary_if->net_dev->dev_addr); in batadv_interface_tx()
351 seqno = atomic_inc_return(&bat_priv->bcast_seqno); in batadv_interface_tx()
352 bcast_packet->seqno = htonl(seqno); in batadv_interface_tx()
404 * batadv_interface_rx() - receive ethernet frame on local batman-adv interface
407 * @hdr_size: size of already parsed batman-adv header
408 * @orig_node: originator from which the batman-adv packet was sent
411 * skb->data has still point to the batman-adv header with the size @hdr_size.
413 * @hdr_size bytes are still available for pull in @skb.
416 * ethernet frame is invalid or contains again an batman-adv packet. Also
431 batadv_bcast_packet = (struct batadv_bcast_packet *)skb->data; in batadv_interface_rx()
432 packet_type = batadv_bcast_packet->packet_type; in batadv_interface_rx()
437 /* clean the netfilter state now that the batman-adv header has been in batadv_interface_rx()
448 switch (ntohs(ethhdr->h_proto)) { in batadv_interface_rx()
453 vhdr = (struct vlan_ethhdr *)skb->data; in batadv_interface_rx()
455 /* drop batman-in-batman packets to prevent loops */ in batadv_interface_rx()
456 if (vhdr->h_vlan_encapsulated_proto != htons(ETH_P_BATMAN)) in batadv_interface_rx()
464 /* skb->dev & skb->pkt_type are set here */ in batadv_interface_rx()
465 skb->protocol = eth_type_trans(skb, soft_iface); in batadv_interface_rx()
470 skb->len + ETH_HLEN); in batadv_interface_rx()
473 * not handle it, we can safely push it up. in batadv_interface_rx()
480 ethhdr->h_source, vid); in batadv_interface_rx()
482 if (is_multicast_ether_addr(ethhdr->h_dest)) { in batadv_interface_rx()
487 batadv_tt_global_is_isolated(bat_priv, ethhdr->h_source, in batadv_interface_rx()
489 /* save bits in skb->mark not covered by the mask and in batadv_interface_rx()
492 skb->mark &= ~bat_priv->isolation_mark_mask; in batadv_interface_rx()
493 skb->mark |= bat_priv->isolation_mark; in batadv_interface_rx()
495 } else if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, in batadv_interface_rx()
496 ethhdr->h_dest, vid)) { in batadv_interface_rx()
510 * batadv_softif_vlan_release() - release vlan from lists and queue for free
520 spin_lock_bh(&vlan->bat_priv->softif_vlan_list_lock); in batadv_softif_vlan_release()
521 hlist_del_rcu(&vlan->list); in batadv_softif_vlan_release()
522 spin_unlock_bh(&vlan->bat_priv->softif_vlan_list_lock); in batadv_softif_vlan_release()
528 * batadv_softif_vlan_put() - decrease the vlan object refcounter and
537 kref_put(&vlan->refcount, batadv_softif_vlan_release); in batadv_softif_vlan_put()
541 * batadv_softif_vlan_get() - get the vlan object for a specific vid
554 hlist_for_each_entry_rcu(vlan_tmp, &bat_priv->softif_vlan_list, list) { in batadv_softif_vlan_get()
555 if (vlan_tmp->vid != vid) in batadv_softif_vlan_get()
558 if (!kref_get_unless_zero(&vlan_tmp->refcount)) in batadv_softif_vlan_get()
570 * batadv_softif_create_vlan() - allocate the needed resources for a new vlan
581 spin_lock_bh(&bat_priv->softif_vlan_list_lock); in batadv_softif_create_vlan()
586 spin_unlock_bh(&bat_priv->softif_vlan_list_lock); in batadv_softif_create_vlan()
587 return -EEXIST; in batadv_softif_create_vlan()
592 spin_unlock_bh(&bat_priv->softif_vlan_list_lock); in batadv_softif_create_vlan()
593 return -ENOMEM; in batadv_softif_create_vlan()
596 vlan->bat_priv = bat_priv; in batadv_softif_create_vlan()
597 vlan->vid = vid; in batadv_softif_create_vlan()
598 kref_init(&vlan->refcount); in batadv_softif_create_vlan()
600 atomic_set(&vlan->ap_isolation, 0); in batadv_softif_create_vlan()
602 kref_get(&vlan->refcount); in batadv_softif_create_vlan()
603 hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); in batadv_softif_create_vlan()
604 spin_unlock_bh(&bat_priv->softif_vlan_list_lock); in batadv_softif_create_vlan()
609 err = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan); in batadv_softif_create_vlan()
622 batadv_tt_local_add(bat_priv->soft_iface, in batadv_softif_create_vlan()
623 bat_priv->soft_iface->dev_addr, vid, in batadv_softif_create_vlan()
633 * batadv_softif_destroy_vlan() - remove and destroy a softif_vlan object
643 batadv_tt_local_remove(bat_priv, bat_priv->soft_iface->dev_addr, in batadv_softif_destroy_vlan()
644 vlan->vid, "vlan interface destroyed", false); in batadv_softif_destroy_vlan()
651 * batadv_interface_add_vid() - ndo_add_vid API implementation
656 * Set up all the internal structures for handling the new vlan on top of the
669 * batman-adv does not know how to handle other types in batadv_interface_add_vid()
672 return -EINVAL; in batadv_interface_add_vid()
689 if (!vlan->kobj) { in batadv_interface_add_vid()
690 ret = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan); in batadv_interface_add_vid()
701 batadv_tt_local_add(bat_priv->soft_iface, in batadv_interface_add_vid()
702 bat_priv->soft_iface->dev_addr, vid, in batadv_interface_add_vid()
709 * batadv_interface_kill_vid() - ndo_kill_vid API implementation
717 * Return: 0 on success, -EINVAL if the specified prototype is not ETH_P_8021Q
718 * or -ENOENT if the specified vlan id wasn't registered.
726 /* only 802.1Q vlans are supported. batman-adv does not know how to in batadv_interface_kill_vid()
730 return -EINVAL; in batadv_interface_kill_vid()
734 return -ENOENT; in batadv_interface_kill_vid()
744 /* batman-adv network devices have devices nesting below it and are a special
752 * batadv_set_lockdep_class_one() - Set lockdep class for a single tx queue
761 lockdep_set_class(&txq->_xmit_lock, &batadv_netdev_xmit_lock_key); in batadv_set_lockdep_class_one()
765 * batadv_set_lockdep_class() - Set txq and addr_list lockdep class
770 lockdep_set_class(&dev->addr_list_lock, &batadv_netdev_addr_lock_key); in batadv_set_lockdep_class()
775 * batadv_softif_init_late() - late stage initialization of soft interface
790 bat_priv->soft_iface = dev; in batadv_softif_init_late()
795 bat_priv->bat_counters = __alloc_percpu(cnt_len, __alignof__(u64)); in batadv_softif_init_late()
796 if (!bat_priv->bat_counters) in batadv_softif_init_late()
797 return -ENOMEM; in batadv_softif_init_late()
799 atomic_set(&bat_priv->aggregated_ogms, 1); in batadv_softif_init_late()
800 atomic_set(&bat_priv->bonding, 0); in batadv_softif_init_late()
802 atomic_set(&bat_priv->bridge_loop_avoidance, 1); in batadv_softif_init_late()
805 atomic_set(&bat_priv->distributed_arp_table, 1); in batadv_softif_init_late()
808 bat_priv->mcast.querier_ipv4.exists = false; in batadv_softif_init_late()
809 bat_priv->mcast.querier_ipv4.shadowing = false; in batadv_softif_init_late()
810 bat_priv->mcast.querier_ipv6.exists = false; in batadv_softif_init_late()
811 bat_priv->mcast.querier_ipv6.shadowing = false; in batadv_softif_init_late()
812 bat_priv->mcast.flags = BATADV_NO_FLAGS; in batadv_softif_init_late()
813 atomic_set(&bat_priv->multicast_mode, 1); in batadv_softif_init_late()
814 atomic_set(&bat_priv->mcast.num_want_all_unsnoopables, 0); in batadv_softif_init_late()
815 atomic_set(&bat_priv->mcast.num_want_all_ipv4, 0); in batadv_softif_init_late()
816 atomic_set(&bat_priv->mcast.num_want_all_ipv6, 0); in batadv_softif_init_late()
818 atomic_set(&bat_priv->gw.mode, BATADV_GW_MODE_OFF); in batadv_softif_init_late()
819 atomic_set(&bat_priv->gw.bandwidth_down, 100); in batadv_softif_init_late()
820 atomic_set(&bat_priv->gw.bandwidth_up, 20); in batadv_softif_init_late()
821 atomic_set(&bat_priv->orig_interval, 1000); in batadv_softif_init_late()
822 atomic_set(&bat_priv->hop_penalty, 30); in batadv_softif_init_late()
824 atomic_set(&bat_priv->log_level, 0); in batadv_softif_init_late()
826 atomic_set(&bat_priv->fragmentation, 1); in batadv_softif_init_late()
827 atomic_set(&bat_priv->packet_size_max, ETH_DATA_LEN); in batadv_softif_init_late()
828 atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN); in batadv_softif_init_late()
829 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN); in batadv_softif_init_late()
831 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); in batadv_softif_init_late()
832 atomic_set(&bat_priv->bcast_seqno, 1); in batadv_softif_init_late()
833 atomic_set(&bat_priv->tt.vn, 0); in batadv_softif_init_late()
834 atomic_set(&bat_priv->tt.local_changes, 0); in batadv_softif_init_late()
835 atomic_set(&bat_priv->tt.ogm_append_cnt, 0); in batadv_softif_init_late()
837 atomic_set(&bat_priv->bla.num_requests, 0); in batadv_softif_init_late()
839 atomic_set(&bat_priv->tp_num, 0); in batadv_softif_init_late()
841 bat_priv->tt.last_changeset = NULL; in batadv_softif_init_late()
842 bat_priv->tt.last_changeset_len = 0; in batadv_softif_init_late()
843 bat_priv->isolation_mark = 0; in batadv_softif_init_late()
844 bat_priv->isolation_mark_mask = 0; in batadv_softif_init_late()
848 atomic_set(&bat_priv->frag_seqno, random_seqno); in batadv_softif_init_late()
850 bat_priv->primary_if = NULL; in batadv_softif_init_late()
851 bat_priv->num_ifaces = 0; in batadv_softif_init_late()
872 free_percpu(bat_priv->bat_counters); in batadv_softif_init_late()
873 bat_priv->bat_counters = NULL; in batadv_softif_init_late()
879 * batadv_softif_slave_add() - Add a slave interface to a batadv_soft_interface
892 int ret = -EINVAL; in batadv_softif_slave_add()
895 if (!hard_iface || hard_iface->soft_iface) in batadv_softif_slave_add()
898 ret = batadv_hardif_enable_interface(hard_iface, net, dev->name); in batadv_softif_slave_add()
907 * batadv_softif_slave_del() - Delete a slave iface from a batadv_soft_interface
917 int ret = -EINVAL; in batadv_softif_slave_del()
921 if (!hard_iface || hard_iface->soft_iface != dev) in batadv_softif_slave_del()
952 strlcpy(info->driver, "B.A.T.M.A.N. advanced", sizeof(info->driver)); in batadv_get_drvinfo()
953 strlcpy(info->version, BATADV_SOURCE_VERSION, sizeof(info->version)); in batadv_get_drvinfo()
954 strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); in batadv_get_drvinfo()
955 strlcpy(info->bus_info, "batman", sizeof(info->bus_info)); in batadv_get_drvinfo()
1030 return -EOPNOTSUPP; in batadv_get_sset_count()
1042 * batadv_softif_free() - Deconstructor of batadv_soft_interface
1058 * batadv_softif_init_early() - early stage initialization of soft interface
1065 dev->netdev_ops = &batadv_netdev_ops; in batadv_softif_init_early()
1066 dev->needs_free_netdev = true; in batadv_softif_init_early()
1067 dev->priv_destructor = batadv_softif_free; in batadv_softif_init_early()
1068 dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_NETNS_LOCAL; in batadv_softif_init_early()
1069 dev->priv_flags |= IFF_NO_QUEUE; in batadv_softif_init_early()
1074 dev->mtu = ETH_DATA_LEN; in batadv_softif_init_early()
1079 dev->ethtool_ops = &batadv_ethtool_ops; in batadv_softif_init_early()
1083 * batadv_softif_create() - Create and register soft interface
1101 soft_iface->rtnl_link_ops = &batadv_link_ops; in batadv_softif_create()
1115 * batadv_softif_destroy_sysfs() - deletion of batadv_soft_interface via sysfs
1116 * @soft_iface: the to-be-removed batman-adv interface
1137 * batadv_softif_destroy_netlink() - deletion of batadv_soft_interface via
1139 * @soft_iface: the to-be-removed batman-adv interface
1150 if (hard_iface->soft_iface == soft_iface) in batadv_softif_destroy_netlink()
1167 * batadv_softif_is_valid() - Check whether device is a batadv soft interface
1170 * Return: true when net_dev is a batman-adv interface, false otherwise
1174 if (net_dev->netdev_ops->ndo_start_xmit == batadv_interface_tx) in batadv_softif_is_valid()