net/batman-adv/netlink.c

Source file repositories/reference/linux-study-clean/net/batman-adv/netlink.c

File Facts

System
Linux kernel
Corpus path
net/batman-adv/netlink.c
Extension
.c
Size
43730 bytes
Lines
1568
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

if (gw_mode <= BATADV_GW_MODE_SERVER) {
			/* Invoking batadv_gw_reselect() is not enough to really
			 * de-select the current GW. It will only instruct the
			 * gateway client code to perform a re-election the next
			 * time that this is needed.
			 *
			 * When gw client mode is being switched off the current
			 * GW must be de-selected explicitly otherwise no GW_ADD
			 * uevent is thrown on client mode re-activation. This
			 * is operation is performed in
			 * batadv_gw_check_client_stop().
			 */
			batadv_gw_reselect(bat_priv);

			/* always call batadv_gw_check_client_stop() before
			 * changing the gateway state
			 */
			batadv_gw_check_client_stop(bat_priv);
			WRITE_ONCE(bat_priv->gw.mode, gw_mode);
			batadv_gw_tvlv_container_update(bat_priv);
		}
	}

	if (info->attrs[BATADV_ATTR_GW_SEL_CLASS] &&
	    bat_priv->algo_ops->gw.get_best_gw_node &&
	    bat_priv->algo_ops->gw.is_eligible) {
		/* setting the GW selection class is allowed only if the routing
		 * algorithm in use implements the GW API
		 */

		u32 sel_class_max = bat_priv->algo_ops->gw.sel_class_max;
		u32 sel_class;

		attr = info->attrs[BATADV_ATTR_GW_SEL_CLASS];
		sel_class = nla_get_u32(attr);

		if (sel_class >= 1 && sel_class <= sel_class_max) {
			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];

		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];

		WRITE_ONCE(bat_priv->log_level,
			   nla_get_u32(attr) & BATADV_DBG_ALL);
	}
#endif /* CONFIG_BATMAN_ADV_DEBUG */

#ifdef CONFIG_BATMAN_ADV_MCAST
	if (info->attrs[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED]) {
		attr = info->attrs[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED];

		WRITE_ONCE(bat_priv->multicast_mode, !nla_get_u8(attr));
	}

	if (info->attrs[BATADV_ATTR_MULTICAST_FANOUT]) {
		attr = info->attrs[BATADV_ATTR_MULTICAST_FANOUT];

		WRITE_ONCE(bat_priv->multicast_fanout, nla_get_u32(attr));
	}
#endif /* CONFIG_BATMAN_ADV_MCAST */

	if (info->attrs[BATADV_ATTR_ORIG_INTERVAL]) {
		u32 orig_interval;

		attr = info->attrs[BATADV_ATTR_ORIG_INTERVAL];
		orig_interval = nla_get_u32(attr);

		orig_interval = min_t(u32, orig_interval, INT_MAX);
		orig_interval = max_t(u32, orig_interval, 2 * BATADV_JITTER);

		WRITE_ONCE(bat_priv->orig_interval, orig_interval);
	}

	batadv_netlink_notify_mesh(bat_priv);

	return 0;
}

/**
 * batadv_netlink_tp_meter_put() - Fill information of started tp_meter session

Annotation

Implementation Notes