#include <linux/bug.h>
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
+#include <linux/compiler.h>
#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
{
unsigned int msecs;
- msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
+ msecs = READ_ONCE(bat_priv->orig_interval) - BATADV_JITTER;
msecs += get_random_u32_below(2 * BATADV_JITTER);
return jiffies + msecs_to_jiffies(msecs);
/* apply hop penalty for a normal link */
static u8 batadv_hop_penalty(u8 tq, const struct batadv_priv *bat_priv)
{
- int hop_penalty = atomic_read(&bat_priv->hop_penalty);
+ int hop_penalty = READ_ONCE(bat_priv->hop_penalty);
int new_tq;
new_tq = tq * (BATADV_TQ_MAX_VALUE - hop_penalty);
unsigned int skb_size;
atomic_t *queue_left = own_packet ? NULL : &bat_priv->batman_queue_left;
- if (atomic_read(&bat_priv->aggregated_ogms))
+ if (READ_ONCE(bat_priv->aggregated_ogms))
skb_size = max_t(unsigned int, BATADV_MAX_AGGREGATION_BYTES,
packet_len);
else
struct batadv_ogm_packet *batadv_ogm_packet;
bool direct_link;
unsigned long max_aggregation_jiffies;
+ bool aggregated_ogms;
batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff;
direct_link = !!(batadv_ogm_packet->flags & BATADV_DIRECTLINK);
/* find position for the packet in the forward queue */
spin_lock_bh(&bat_priv->forw_bat_list_lock);
+ aggregated_ogms = READ_ONCE(bat_priv->aggregated_ogms);
+
/* own packets are not to be aggregated */
- if (atomic_read(&bat_priv->aggregated_ogms) && !own_packet) {
+ if (aggregated_ogms && !own_packet) {
hlist_for_each_entry(forw_packet_pos,
&bat_priv->forw_bat_list, list) {
if (batadv_iv_ogm_can_aggregate(batadv_ogm_packet,
* we hold it back for a while, so that it might be aggregated
* later on
*/
- if (!own_packet && atomic_read(&bat_priv->aggregated_ogms))
+ if (!own_packet && aggregated_ogms)
send_time += max_aggregation_jiffies;
return batadv_iv_ogm_aggregate_new(packet_buff, packet_len,
*/
queue_delayed_work(batadv_event_workqueue,
&hard_iface->bat_iv.reschedule_work,
- msecs_to_jiffies(atomic_read(&bat_priv->orig_interval)));
+ msecs_to_jiffies(READ_ONCE(bat_priv->orig_interval)));
}
batadv_hardif_put(primary_if);
static void batadv_iv_init_sel_class(struct batadv_priv *bat_priv)
{
/* set default TQ difference threshold to 20 */
- atomic_set(&bat_priv->gw.sel_class, 20);
+ WRITE_ONCE(bat_priv->gw.sel_class, 20);
}
static struct batadv_gw_node *
tq_avg = router_ifinfo->bat_iv.tq_avg;
- switch (atomic_read(&bat_priv->gw.sel_class)) {
+ switch (READ_ONCE(bat_priv->gw.sel_class)) {
case 1: /* fast connection */
tmp_gw_factor = tq_avg * tq_avg;
tmp_gw_factor *= gw_node->bandwidth_down;
{
struct batadv_neigh_ifinfo *router_orig_ifinfo = NULL;
struct batadv_neigh_ifinfo *router_gw_ifinfo = NULL;
+ u32 sel_class = READ_ONCE(bat_priv->gw.sel_class);
struct batadv_neigh_node *router_gw = NULL;
struct batadv_neigh_node *router_orig = NULL;
u8 gw_tq_avg, orig_tq_avg;
bool ret = false;
/* dynamic re-election is performed only on fast or late switch */
- if (atomic_read(&bat_priv->gw.sel_class) <= 2)
+ if (sel_class <= 2)
return false;
router_gw = batadv_orig_router_get(curr_gw_orig, BATADV_IF_DEFAULT);
/* if the routing class is greater than 3 the value tells us how much
* greater the TQ value of the new gateway must be
*/
- if ((atomic_read(&bat_priv->gw.sel_class) > 3) &&
- (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw.sel_class)))
+ if (sel_class > 3 && orig_tq_avg - gw_tq_avg < sel_class)
goto out;
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
#include <linux/atomic.h>
#include <linux/cache.h>
+#include <linux/compiler.h>
#include <linux/errno.h>
#include <linux/if_ether.h>
#include <linux/init.h>
static void batadv_v_init_sel_class(struct batadv_priv *bat_priv)
{
/* set default throughput difference threshold to 5Mbps */
- atomic_set(&bat_priv->gw.sel_class, 50);
+ WRITE_ONCE(bat_priv->gw.sel_class, 50);
}
/**
u32 gw_throughput, orig_throughput, threshold;
bool ret = false;
- threshold = atomic_read(&bat_priv->gw.sel_class);
+ threshold = READ_ONCE(bat_priv->gw.sel_class);
curr_gw = batadv_gw_node_get(bat_priv, curr_gw_orig);
if (!curr_gw) {
#include <linux/atomic.h>
#include <linux/bug.h>
#include <linux/byteorder/generic.h>
+#include <linux/compiler.h>
#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
if (delayed_work_pending(&bat_priv->bat_v.ogm_wq))
return;
- msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
+ msecs = READ_ONCE(bat_priv->orig_interval) - BATADV_JITTER;
msecs += get_random_u32_below(2 * BATADV_JITTER);
queue_delayed_work(batadv_event_workqueue, &bat_priv->bat_v.ogm_wq,
msecs_to_jiffies(msecs));
return;
}
- if (!atomic_read(&bat_priv->aggregated_ogms)) {
+ if (!READ_ONCE(bat_priv->aggregated_ogms)) {
batadv_v_ogm_send_to_if(bat_priv, skb, hard_iface);
return;
}
u32 throughput)
{
int if_hop_penalty = atomic_read(&if_incoming->hop_penalty);
- int hop_penalty = atomic_read(&bat_priv->hop_penalty);
+ int hop_penalty = READ_ONCE(bat_priv->hop_penalty);
int hop_penalty_max = BATADV_TQ_MAX_VALUE;
/* Apply per hardif hop penalty */
bat_priv->bla.claim_dest.group = group;
/* purge everything when bridge loop avoidance is turned off */
- if (!atomic_read(&bat_priv->bridge_loop_avoidance))
+ if (!READ_ONCE(bat_priv->bridge_loop_avoidance))
oldif = NULL;
if (!oldif) {
batadv_bla_purge_claims(bat_priv, primary_if, 0);
batadv_bla_purge_backbone_gw(bat_priv, 0);
- if (!atomic_read(&bat_priv->bridge_loop_avoidance))
+ if (!READ_ONCE(bat_priv->bridge_loop_avoidance))
goto out;
if (atomic_dec_and_test(&bat_priv->bla.loopdetect_next)) {
struct batadv_bla_backbone_gw *backbone_gw;
int i;
- if (!atomic_read(&bat_priv->bridge_loop_avoidance))
+ if (!READ_ONCE(bat_priv->bridge_loop_avoidance))
return false;
if (!hash)
struct batadv_bla_backbone_gw *backbone_gw;
unsigned short vid;
- if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance))
+ if (!READ_ONCE(orig_node->bat_priv->bridge_loop_avoidance))
return false;
/* first, find out the vid. */
if (!primary_if)
goto handled;
- if (!atomic_read(&bat_priv->bridge_loop_avoidance))
+ if (!READ_ONCE(bat_priv->bridge_loop_avoidance))
goto allow;
if (batadv_bla_loopdetect_check(bat_priv, skb, primary_if, vid))
if (!primary_if)
goto out;
- if (!atomic_read(&bat_priv->bridge_loop_avoidance))
+ if (!READ_ONCE(bat_priv->bridge_loop_avoidance))
goto allow;
if (batadv_bla_process_claim(bat_priv, primary_if, skb))
struct batadv_hard_iface *primary_if = NULL;
bool ret = true;
- if (!atomic_read(&bat_priv->bridge_loop_avoidance))
+ if (!READ_ONCE(bat_priv->bridge_loop_avoidance))
return ret;
primary_if = batadv_primary_if_get_selected(bat_priv);
{
char dat_mode;
- dat_mode = atomic_read(&bat_priv->distributed_arp_table);
+ dat_mode = READ_ONCE(bat_priv->distributed_arp_table);
switch (dat_mode) {
case 0:
int hdr_size = 0;
unsigned short vid;
- if (!atomic_read(&bat_priv->distributed_arp_table))
+ if (!READ_ONCE(bat_priv->distributed_arp_table))
goto out;
vid = batadv_dat_get_vid(skb, &hdr_size);
unsigned short vid;
int err;
- if (!atomic_read(&bat_priv->distributed_arp_table))
+ if (!READ_ONCE(bat_priv->distributed_arp_table))
goto out;
vid = batadv_dat_get_vid(skb, &hdr_size);
int hdr_size = 0;
unsigned short vid;
- if (!atomic_read(&bat_priv->distributed_arp_table))
+ if (!READ_ONCE(bat_priv->distributed_arp_table))
return;
vid = batadv_dat_get_vid(skb, &hdr_size);
bool dropped = false;
unsigned short vid;
- if (!atomic_read(&bat_priv->distributed_arp_table))
+ if (!READ_ONCE(bat_priv->distributed_arp_table))
goto out;
vid = batadv_dat_get_vid(skb, &hdr_size);
u8 chaddr[BATADV_DHCP_CHADDR_LEN];
__be32 ip_src, yiaddr;
- if (!atomic_read(&bat_priv->distributed_arp_table))
+ if (!READ_ONCE(bat_priv->distributed_arp_table))
return;
if (!batadv_dat_check_dhcp_ack(skb, proto, &ip_src, chaddr, &yiaddr))
__be16 proto;
u8 *hw_src;
- if (!atomic_read(&bat_priv->distributed_arp_table))
+ if (!READ_ONCE(bat_priv->distributed_arp_table))
return;
if (unlikely(!pskb_may_pull(skb, hdr_size + ETH_HLEN)))
int hdr_size = sizeof(struct batadv_bcast_packet);
unsigned short vid;
- if (!atomic_read(&bat_priv->distributed_arp_table))
+ if (!READ_ONCE(bat_priv->distributed_arp_table))
goto out;
/* If this packet is an ARP_REQUEST and the node already has the
{
struct batadv_gw_node *curr_gw;
- if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
+ if (READ_ONCE(bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
return;
curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
struct batadv_neigh_ifinfo *router_ifinfo = NULL;
char gw_addr[18] = { '\0' };
- if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
+ if (READ_ONCE(bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
goto out;
if (!bat_priv->algo_ops->gw.get_best_gw_node)
if (!gw_node)
goto out;
- switch (atomic_read(&bat_priv->gw.mode)) {
+ switch (READ_ONCE(bat_priv->gw.mode)) {
case BATADV_GW_MODE_SERVER:
/* If we are a GW then we are our best GW. We can artificially
* set the tq towards ourself as the maximum value
#include "gateway_common.h"
#include "main.h"
-#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
+#include <linux/compiler.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <uapi/linux/batadv_packet.h>
void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv)
{
struct batadv_tvlv_gateway_data gw;
+ enum batadv_gw_modes gw_mode;
u32 down, up;
- char gw_mode;
- gw_mode = atomic_read(&bat_priv->gw.mode);
+ gw_mode = READ_ONCE(bat_priv->gw.mode);
switch (gw_mode) {
case BATADV_GW_MODE_OFF:
batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_GW, 1);
break;
case BATADV_GW_MODE_SERVER:
- down = atomic_read(&bat_priv->gw.bandwidth_down);
- up = atomic_read(&bat_priv->gw.bandwidth_up);
+ down = READ_ONCE(bat_priv->gw.bandwidth_down);
+ up = READ_ONCE(bat_priv->gw.bandwidth_up);
gw.bandwidth_down = htonl(down);
gw.bandwidth_up = htonl(up);
batadv_tvlv_container_register(bat_priv, BATADV_TVLV_GW, 1,
/* restart gateway selection */
if (gateway.bandwidth_down != 0 &&
- atomic_read(&bat_priv->gw.mode) == BATADV_GW_MODE_CLIENT)
+ READ_ONCE(bat_priv->gw.mode) == BATADV_GW_MODE_CLIENT)
batadv_gw_check_election(bat_priv, orig);
}
if (bat_priv->algo_ops->gw.init_sel_class)
bat_priv->algo_ops->gw.init_sel_class(bat_priv);
else
- atomic_set(&bat_priv->gw.sel_class, 1);
+ WRITE_ONCE(bat_priv->gw.sel_class, 1);
batadv_tvlv_handler_register(bat_priv, batadv_gw_tvlv_ogm_handler_v1,
NULL, NULL, BATADV_TVLV_GW, 1,
}
rcu_read_unlock();
- if (atomic_read(&bat_priv->fragmentation) == 0)
+ if (READ_ONCE(bat_priv->fragmentation) == 0)
goto out;
/* with fragmentation enabled the maximum size of internally generated
int max_header_len = batadv_max_header_len();
unsigned int required_mtu;
unsigned int hardif_mtu;
+ bool fragmentation;
int ret;
hardif_mtu = READ_ONCE(hard_iface->net_dev->mtu);
batadv_info(hard_iface->mesh_iface, "Adding interface: %s\n",
hard_iface->net_dev->name);
- if (atomic_read(&bat_priv->fragmentation) &&
- hardif_mtu < required_mtu)
+ fragmentation = READ_ONCE(bat_priv->fragmentation);
+ if (fragmentation && hardif_mtu < required_mtu)
batadv_info(hard_iface->mesh_iface,
"The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %i would solve the problem.\n",
hard_iface->net_dev->name, hardif_mtu,
required_mtu);
- if (!atomic_read(&bat_priv->fragmentation) &&
- hardif_mtu < required_mtu)
+ if (!fragmentation && hardif_mtu < required_mtu)
batadv_info(hard_iface->mesh_iface,
"The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %i.\n",
hard_iface->net_dev->name, hardif_mtu,
#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \
do { \
struct batadv_priv *__batpriv = (bat_priv); \
- if (atomic_read(&__batpriv->log_level) & (type) && \
+ if (READ_ONCE(__batpriv->log_level) & (type) && \
(!(ratelimited) || net_ratelimit())) \
batadv_debug_log(__batpriv, fmt, ## arg); \
} \
if (batadv_compare_eth(ethhdr->h_dest, ectp_addr))
goto dropped;
- gw_mode = atomic_read(&bat_priv->gw.mode);
+ gw_mode = READ_ONCE(bat_priv->gw.mode);
if (is_multicast_ether_addr(ethhdr->h_dest)) {
/* if gw mode is off, broadcast every packet */
if (gw_mode == BATADV_GW_MODE_OFF) {
if (!bat_priv->bat_counters)
return -ENOMEM;
- atomic_set(&bat_priv->aggregated_ogms, 1);
- atomic_set(&bat_priv->bonding, 0);
+ WRITE_ONCE(bat_priv->aggregated_ogms, 1);
+ WRITE_ONCE(bat_priv->bonding, 0);
#ifdef CONFIG_BATMAN_ADV_BLA
- atomic_set(&bat_priv->bridge_loop_avoidance, 1);
+ WRITE_ONCE(bat_priv->bridge_loop_avoidance, 1);
#endif
#ifdef CONFIG_BATMAN_ADV_DAT
- atomic_set(&bat_priv->distributed_arp_table, 1);
+ WRITE_ONCE(bat_priv->distributed_arp_table, 1);
#endif
#ifdef CONFIG_BATMAN_ADV_MCAST
- atomic_set(&bat_priv->multicast_mode, 1);
- atomic_set(&bat_priv->multicast_fanout, 16);
+ WRITE_ONCE(bat_priv->multicast_mode, 1);
+ WRITE_ONCE(bat_priv->multicast_fanout, 16);
atomic_set(&bat_priv->mcast.num_want_all_unsnoopables, 0);
atomic_set(&bat_priv->mcast.num_want_all_ipv4, 0);
atomic_set(&bat_priv->mcast.num_want_all_ipv6, 0);
atomic_set(&bat_priv->mcast.num_no_mc_ptype_capa, 0);
#endif
- atomic_set(&bat_priv->gw.mode, BATADV_GW_MODE_OFF);
- atomic_set(&bat_priv->gw.bandwidth_down, 100);
- atomic_set(&bat_priv->gw.bandwidth_up, 20);
- atomic_set(&bat_priv->orig_interval, 1000);
- atomic_set(&bat_priv->hop_penalty, 30);
+ WRITE_ONCE(bat_priv->gw.mode, BATADV_GW_MODE_OFF);
+ WRITE_ONCE(bat_priv->gw.bandwidth_down, 100);
+ WRITE_ONCE(bat_priv->gw.bandwidth_up, 20);
+ WRITE_ONCE(bat_priv->orig_interval, 1000);
+ WRITE_ONCE(bat_priv->hop_penalty, 30);
#ifdef CONFIG_BATMAN_ADV_DEBUG
- atomic_set(&bat_priv->log_level, 0);
+ WRITE_ONCE(bat_priv->log_level, 0);
#endif
- atomic_set(&bat_priv->fragmentation, 1);
+ WRITE_ONCE(bat_priv->fragmentation, 1);
atomic_set(&bat_priv->packet_size_max, BATADV_MAX_MTU);
atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN);
atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
{
struct ethhdr *ethhdr = eth_hdr(skb);
- if (!atomic_read(&bat_priv->multicast_mode))
+ if (!READ_ONCE(bat_priv->multicast_mode))
return -EINVAL;
switch (ntohs(ethhdr->h_proto)) {
batadv_mcast_forw_push(bat_priv, skb, vid, is_routable, count))
return BATADV_FORW_MCAST;
- if (count <= atomic_read(&bat_priv->multicast_fanout))
+ if (count <= READ_ONCE(bat_priv->multicast_fanout))
return BATADV_FORW_UCASTS;
return BATADV_FORW_BCAST;
#include <linux/bug.h>
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
+#include <linux/compiler.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/gfp.h>
}
if (nla_put_u8(msg, BATADV_ATTR_AGGREGATED_OGMS_ENABLED,
- !!atomic_read(&bat_priv->aggregated_ogms)))
+ !!READ_ONCE(bat_priv->aggregated_ogms)))
goto nla_put_failure;
if (batadv_netlink_mesh_fill_ap_isolation(msg, bat_priv))
goto nla_put_failure;
if (nla_put_u8(msg, BATADV_ATTR_BONDING_ENABLED,
- !!atomic_read(&bat_priv->bonding)))
+ !!READ_ONCE(bat_priv->bonding)))
goto nla_put_failure;
#ifdef CONFIG_BATMAN_ADV_BLA
if (nla_put_u8(msg, BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED,
- !!atomic_read(&bat_priv->bridge_loop_avoidance)))
+ !!READ_ONCE(bat_priv->bridge_loop_avoidance)))
goto nla_put_failure;
#endif /* CONFIG_BATMAN_ADV_BLA */
#ifdef CONFIG_BATMAN_ADV_DAT
if (nla_put_u8(msg, BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED,
- !!atomic_read(&bat_priv->distributed_arp_table)))
+ !!READ_ONCE(bat_priv->distributed_arp_table)))
goto nla_put_failure;
#endif /* CONFIG_BATMAN_ADV_DAT */
if (nla_put_u8(msg, BATADV_ATTR_FRAGMENTATION_ENABLED,
- !!atomic_read(&bat_priv->fragmentation)))
+ !!READ_ONCE(bat_priv->fragmentation)))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_GW_BANDWIDTH_DOWN,
- atomic_read(&bat_priv->gw.bandwidth_down)))
+ READ_ONCE(bat_priv->gw.bandwidth_down)))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_GW_BANDWIDTH_UP,
- atomic_read(&bat_priv->gw.bandwidth_up)))
+ READ_ONCE(bat_priv->gw.bandwidth_up)))
goto nla_put_failure;
if (nla_put_u8(msg, BATADV_ATTR_GW_MODE,
- atomic_read(&bat_priv->gw.mode)))
+ READ_ONCE(bat_priv->gw.mode)))
goto nla_put_failure;
if (bat_priv->algo_ops->gw.get_best_gw_node &&
* in use does not implement the GW API
*/
if (nla_put_u32(msg, BATADV_ATTR_GW_SEL_CLASS,
- atomic_read(&bat_priv->gw.sel_class)))
+ READ_ONCE(bat_priv->gw.sel_class)))
goto nla_put_failure;
}
if (nla_put_u8(msg, BATADV_ATTR_HOP_PENALTY,
- atomic_read(&bat_priv->hop_penalty)))
+ READ_ONCE(bat_priv->hop_penalty)))
goto nla_put_failure;
#ifdef CONFIG_BATMAN_ADV_DEBUG
if (nla_put_u32(msg, BATADV_ATTR_LOG_LEVEL,
- atomic_read(&bat_priv->log_level)))
+ READ_ONCE(bat_priv->log_level)))
goto nla_put_failure;
#endif /* CONFIG_BATMAN_ADV_DEBUG */
#ifdef CONFIG_BATMAN_ADV_MCAST
if (nla_put_u8(msg, BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED,
- !atomic_read(&bat_priv->multicast_mode)))
+ !READ_ONCE(bat_priv->multicast_mode)))
goto nla_put_failure;
if (nla_put_u32(msg, BATADV_ATTR_MULTICAST_FANOUT,
- atomic_read(&bat_priv->multicast_fanout)))
+ READ_ONCE(bat_priv->multicast_fanout)))
goto nla_put_failure;
#endif /* CONFIG_BATMAN_ADV_MCAST */
if (nla_put_u32(msg, BATADV_ATTR_ORIG_INTERVAL,
- atomic_read(&bat_priv->orig_interval)))
+ READ_ONCE(bat_priv->orig_interval)))
goto nla_put_failure;
batadv_hardif_put(primary_if);
if (info->attrs[BATADV_ATTR_AGGREGATED_OGMS_ENABLED]) {
attr = info->attrs[BATADV_ATTR_AGGREGATED_OGMS_ENABLED];
- atomic_set(&bat_priv->aggregated_ogms, !!nla_get_u8(attr));
+ WRITE_ONCE(bat_priv->aggregated_ogms, !!nla_get_u8(attr));
}
if (info->attrs[BATADV_ATTR_AP_ISOLATION_ENABLED]) {
if (info->attrs[BATADV_ATTR_BONDING_ENABLED]) {
attr = info->attrs[BATADV_ATTR_BONDING_ENABLED];
- atomic_set(&bat_priv->bonding, !!nla_get_u8(attr));
+ WRITE_ONCE(bat_priv->bonding, !!nla_get_u8(attr));
}
#ifdef CONFIG_BATMAN_ADV_BLA
if (info->attrs[BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED]) {
attr = info->attrs[BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED];
- atomic_set(&bat_priv->bridge_loop_avoidance,
+ WRITE_ONCE(bat_priv->bridge_loop_avoidance,
!!nla_get_u8(attr));
batadv_bla_status_update(bat_priv->mesh_iface);
}
if (info->attrs[BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED]) {
attr = info->attrs[BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED];
- atomic_set(&bat_priv->distributed_arp_table,
+ WRITE_ONCE(bat_priv->distributed_arp_table,
!!nla_get_u8(attr));
batadv_dat_status_update(bat_priv->mesh_iface);
}
if (info->attrs[BATADV_ATTR_FRAGMENTATION_ENABLED]) {
attr = info->attrs[BATADV_ATTR_FRAGMENTATION_ENABLED];
- atomic_set(&bat_priv->fragmentation, !!nla_get_u8(attr));
+ WRITE_ONCE(bat_priv->fragmentation, !!nla_get_u8(attr));
rtnl_lock();
batadv_update_min_mtu(bat_priv->mesh_iface);
if (info->attrs[BATADV_ATTR_GW_BANDWIDTH_DOWN]) {
attr = info->attrs[BATADV_ATTR_GW_BANDWIDTH_DOWN];
- atomic_set(&bat_priv->gw.bandwidth_down, nla_get_u32(attr));
+ WRITE_ONCE(bat_priv->gw.bandwidth_down, nla_get_u32(attr));
batadv_gw_tvlv_container_update(bat_priv);
}
if (info->attrs[BATADV_ATTR_GW_BANDWIDTH_UP]) {
attr = info->attrs[BATADV_ATTR_GW_BANDWIDTH_UP];
- atomic_set(&bat_priv->gw.bandwidth_up, nla_get_u32(attr));
+ WRITE_ONCE(bat_priv->gw.bandwidth_up, nla_get_u32(attr));
batadv_gw_tvlv_container_update(bat_priv);
}
* changing the gateway state
*/
batadv_gw_check_client_stop(bat_priv);
- atomic_set(&bat_priv->gw.mode, gw_mode);
+ WRITE_ONCE(bat_priv->gw.mode, gw_mode);
batadv_gw_tvlv_container_update(bat_priv);
}
}
sel_class = nla_get_u32(attr);
if (sel_class >= 1 && sel_class <= sel_class_max) {
- atomic_set(&bat_priv->gw.sel_class, sel_class);
+ WRITE_ONCE(bat_priv->gw.sel_class, sel_class);
batadv_gw_reselect(bat_priv);
}
}
if (info->attrs[BATADV_ATTR_HOP_PENALTY]) {
attr = info->attrs[BATADV_ATTR_HOP_PENALTY];
- atomic_set(&bat_priv->hop_penalty, nla_get_u8(attr));
+ WRITE_ONCE(bat_priv->hop_penalty, nla_get_u8(attr));
}
#ifdef CONFIG_BATMAN_ADV_DEBUG
if (info->attrs[BATADV_ATTR_LOG_LEVEL]) {
attr = info->attrs[BATADV_ATTR_LOG_LEVEL];
- atomic_set(&bat_priv->log_level,
+ WRITE_ONCE(bat_priv->log_level,
nla_get_u32(attr) & BATADV_DBG_ALL);
}
#endif /* CONFIG_BATMAN_ADV_DEBUG */
if (info->attrs[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED]) {
attr = info->attrs[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED];
- atomic_set(&bat_priv->multicast_mode, !nla_get_u8(attr));
+ WRITE_ONCE(bat_priv->multicast_mode, !nla_get_u8(attr));
}
if (info->attrs[BATADV_ATTR_MULTICAST_FANOUT]) {
attr = info->attrs[BATADV_ATTR_MULTICAST_FANOUT];
- atomic_set(&bat_priv->multicast_fanout, nla_get_u32(attr));
+ WRITE_ONCE(bat_priv->multicast_fanout, nla_get_u32(attr));
}
#endif /* CONFIG_BATMAN_ADV_MCAST */
orig_interval = min_t(u32, orig_interval, INT_MAX);
orig_interval = max_t(u32, orig_interval, 2 * BATADV_JITTER);
- atomic_set(&bat_priv->orig_interval, orig_interval);
+ WRITE_ONCE(bat_priv->orig_interval, orig_interval);
}
batadv_netlink_notify_mesh(bat_priv);
#include "originator.h"
#include "main.h"
-#include <linux/atomic.h>
#include <linux/container_of.h>
#include <linux/err.h>
#include <linux/errno.h>
/* only consider bonding for recv_if == BATADV_IF_DEFAULT (first hop)
* and if activated.
*/
- if (!(recv_if == BATADV_IF_DEFAULT && atomic_read(&bat_priv->bonding)))
+ if (!(recv_if == BATADV_IF_DEFAULT && READ_ONCE(bat_priv->bonding)))
return router;
/* bonding: loop through the list of possible routers found
/* Check if the skb is too large to send in one piece and fragment
* it if needed.
*/
- if (atomic_read(&bat_priv->fragmentation) &&
+ if (READ_ONCE(bat_priv->fragmentation) &&
skb->len > neigh_node->if_incoming->net_dev->mtu) {
/* Fragment and send packet. */
ret = batadv_frag_send_packet(skb, orig_node, neigh_node);
/**
* @mode: gateway operation: off, client or server (see batadv_gw_modes)
*/
- atomic_t mode;
+ enum batadv_gw_modes mode;
/** @sel_class: gateway selection class (applies if gw_mode client) */
- atomic_t sel_class;
+ u32 sel_class;
/**
* @bandwidth_down: advertised uplink download bandwidth (if gw_mode
* server)
*/
- atomic_t bandwidth_down;
+ u32 bandwidth_down;
/**
* @bandwidth_up: advertised uplink upload bandwidth (if gw_mode server)
*/
- atomic_t bandwidth_up;
+ u32 bandwidth_up;
/** @reselect: bool indicating a gateway re-selection is in progress */
atomic_t reselect;
/**
* @aggregated_ogms: bool indicating whether OGM aggregation is enabled
*/
- atomic_t aggregated_ogms;
+ u8 aggregated_ogms;
/** @bonding: bool indicating whether traffic bonding is enabled */
- atomic_t bonding;
+ u8 bonding;
/**
* @fragmentation: bool indicating whether traffic fragmentation is
* enabled
*/
- atomic_t fragmentation;
-
- /**
- * @packet_size_max: max packet size that can be transmitted via
- * multiple fragmented skbs or a single frame if fragmentation is
- * disabled
- */
- atomic_t packet_size_max;
-
- /**
- * @frag_seqno: incremental counter to identify chains of egress
- * fragments
- */
- atomic_t frag_seqno;
+ u8 fragmentation;
#ifdef CONFIG_BATMAN_ADV_BLA
/**
* @bridge_loop_avoidance: bool indicating whether bridge loop
* avoidance is enabled
*/
- atomic_t bridge_loop_avoidance;
+ u8 bridge_loop_avoidance;
#endif
#ifdef CONFIG_BATMAN_ADV_DAT
* @distributed_arp_table: bool indicating whether distributed ARP table
* is enabled
*/
- atomic_t distributed_arp_table;
+ u8 distributed_arp_table;
#endif
#ifdef CONFIG_BATMAN_ADV_MCAST
* @multicast_mode: Enable or disable multicast optimizations on this
* node's sender/originating side
*/
- atomic_t multicast_mode;
+ u8 multicast_mode;
/**
* @multicast_fanout: Maximum number of packet copies to generate for a
* multicast-to-unicast conversion
*/
- atomic_t multicast_fanout;
+ u32 multicast_fanout;
#endif
+ /**
+ * @packet_size_max: max packet size that can be transmitted via
+ * multiple fragmented skbs or a single frame if fragmentation is
+ * disabled
+ */
+ atomic_t packet_size_max;
+
+ /**
+ * @frag_seqno: incremental counter to identify chains of egress
+ * fragments
+ */
+ atomic_t frag_seqno;
+
/** @orig_interval: OGM broadcast interval in milliseconds */
- atomic_t orig_interval;
+ u32 orig_interval;
/**
* @hop_penalty: penalty which will be applied to an OGM's tq-field on
* every hop
*/
- atomic_t hop_penalty;
+ u8 hop_penalty;
#ifdef CONFIG_BATMAN_ADV_DEBUG
/** @log_level: configured log level (see batadv_dbg_level) */
- atomic_t log_level;
+ u32 log_level;
#endif
/**