File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_net.cpython-39.pyc
a
�Գf[ � @ sp d dl Z ddlmZ ddlT d dlZd dlmZ d dlm Z d dl
Z
d dlZej�
� ZdZG dd � d ej�ZdS )
� N� )�hotplug)�*)�ethcard)�commandsZpumbagsdc s: e Zd ZdZ� fdd�Zdd� Zdd� Zdd � Zd
d� Z� fdd
�Z dd� Z
dd� Zedd� �Z
edd� �Zedd� �Zedd� �Zedd� �Zdd� Zdd� Zd d!� Zd"d#� Zd$d%� Zd&d'� Zd(d)� Zed*d+� �Zed,d-d.�d/d0� �Zed,�dkd2d3��Zed4�d5d6� �Zed4�d7d8� �Zg fd9d:�Z dld<d=�Z!ed>d-d.�d?d@� �Z"dAdB� Z#ed>�dmdCdD��Z$edEd-d.�dFdG� �Z%edE�dndHdI��Z&dJdK� Z'dLdM� Z(dNdO� Z)dPdQ� Z*dRdS� Z+dTdU� Z,dVdW� Z-dodXdY�Z.dZd[� Z/e0d\d-d.�d]d^� �Z1e0d_d-d.�d`da� �Z2e0dbd-d.�dcdd� �Z3e0ded-d.�dfdg� �Z4e0dhd-d.�didj� �Z5� Z6S )p�NetTuningPlugina�
`net`::
Configures network driver, hardware and Netfilter settings.
Dynamic change of the interface speed according to the interface
utilization is also supported. The dynamic tuning is controlled by
the [option]`dynamic` and the global [option]`dynamic_tuning`
option in `tuned-main.conf`.
+
The [option]`wake_on_lan` option sets wake-on-lan to the specified
value as when using the `ethtool` utility.
+
.Set Wake-on-LAN for device eth0 on MagicPacket(TM)
====
----
[net]
devices=eth0
wake_on_lan=g
----
====
+
The [option]`coalesce` option allows changing coalescing settings
for the specified network devices. The syntax is:
+
[subs="+quotes,+macros"]
----
coalesce=__param1__ __value1__ __param2__ __value2__ ... __paramN__ __valueN__
----
Note that not all the coalescing parameters are supported by all
network cards. For the list of coalescing parameters of your network
device, use `ethtool -c device`.
+
.Setting coalescing parameters rx/tx-usecs for all network devices
====
----
[net]
coalesce=rx-usecs 3 tx-usecs 16
----
====
+
The [option]`features` option allows changing
the offload parameters and other features for the specified
network devices. To query the features of your network device,
use `ethtool -k device`. The syntax of the option is the same as
the [option]`coalesce` option.
+
.Turn off TX checksumming, generic segmentation and receive offload
====
----
[net]
features=tx off gso off gro off
----
====
The [option]`pause` option allows changing the pause parameters for
the specified network devices. To query the pause parameters of your
network device, use `ethtool -a device`. The syntax of the option
is the same as the [option]`coalesce` option.
+
.Disable autonegotiation
====
----
[net]
pause=autoneg off
----
====
+
The [option]`ring` option allows changing the rx/tx ring parameters
for the specified network devices. To query the ring parameters of your
network device, use `ethtool -g device`. The syntax of the option
is the same as the [option]`coalesce` option.
+
.Change the number of ring entries for the Rx/Tx rings to 1024/512 respectively
=====
-----
[net]
ring=rx 1024 tx 512
-----
=====
+
The [option]`channels` option allows changing the numbers of channels
for the specified network device. A channel is an IRQ and the set
of queues that can trigger that IRQ. To query the channels parameters of your
network device, use `ethtool -l device`. The syntax of the option
is the same as the [option]`coalesce` option.
+
.Set the number of multi-purpose channels to 16
=====
-----
[net]
channels=combined 16
-----
=====
+
A network device either supports rx/tx or combined queue
mode. The [option]`channels` option automatically adjusts the
parameters based on the mode supported by the device as long as a
valid configuration is requested.
+
The [option]`nf_conntrack_hashsize` option sets the size of the hash
table which stores lists of conntrack entries by writing to
`/sys/module/nf_conntrack/parameters/hashsize`.
+
.Adjust the size of the conntrack hash table
====
----
[net]
nf_conntrack_hashsize=131072
----
====
+
The [option]`txqueuelen` option allows changing txqueuelen (the length
of the transmit queue). It uses `ip` utility that is in package iproute
recommended for TuneD, so the package needs to be installed for its correct
functionality. To query the txqueuelen parameters of your network device
use `ip link show` and the current value is shown after the qlen column.
+
.Adjust the length of the transmit queue
====
----
[net]
txqueuelen=5000
----
====
+
The [option]`mtu` option allows changing MTU (Maximum Transmission Unit).
It uses `ip` utility that is in package iproute recommended for TuneD, so
the package needs to be installed for its correct functionality. To query
the MTU parameters of your network device use `ip link show` and the
current value is shown after the MTU column.
+
.Adjust the size of the MTU
====
----
[net]
mtu=9000
----
====
c s: t t| �j|i |�� d| _d| _t� | _i | _d| _d S )Ng�������?� T) �superr �__init__�_load_smallest�_level_stepsr �_cmd�_re_ip_link_show�_use_ip)�self�args�kwargs�� __class__� �</usr/lib/python3.9/site-packages/tuned/plugins/plugin_net.pyr
� s zNetTuningPlugin.__init__c C sd d| _ t� | _t� | _t�d�}| j�d�D ]}|�|j �r,| j�
|j� q,t�
dt| j� � d S )NTz(?!.*/virtual/.*)�netzdevices: %s)Z_devices_supported�setZ
_free_devicesZ_assigned_devices�re�compile�_hardware_inventoryZget_devices�matchZdevice_path�addZsys_name�log�debug�str)r Zre_not_virtual�devicer r r �
_init_devices� s
zNetTuningPlugin._init_devicesc s � fdd�|D �S )Nc s g | ]}� j �d |��qS )r )r Z
get_device��.0�x�r r r �
<listcomp>� � z7NetTuningPlugin._get_device_objects.<locals>.<listcomp>r )r Zdevicesr r&