File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_net.cpython-39.pyc
a
,�g�i � @ sx d dl Z ddlmZ ddlT d dlZd dlmZ d dlm Z d dl
Z
d dlZd dlZej
�� ZdZG dd � d ej�ZdS )
� N� )�hotplug)�*)�ethcard)�commandsZpumbagsdc s� e Zd ZdZ� fdd�Z� fdd�Zdd� Zdd � Zd
d� Zdd
� Z � fdd�Z
� fdd�Z� fdd�Zdd� Z
dd� Zdd� Zdd� Zdd� Z� fdd�Zd d!� Z� fd"d#�Zd$d%� Zd&d'� Zed(d)� �Zed*d+� �Zed,d-� �Zed.d/� �Zed0d1� �Zd2d3� Zd4d5� Zd6d7� Zd8d9� Z d:d;� Z!d<d=� Z"d>d?� Z#ed@dA� �Z$e%dBdCdD�dEdF� �Z&e'dB�d�dHdI��Z(e%dJ�dKdL� �Z)e'dJ�dMdN� �Z*g fdOdP�Z+d�dRdS�Z,e%dTdCdD�dUdV� �Z-dWdX� Z.e'dT�d�dYdZ��Z/e%d[dCdD�d\d]� �Z0e'd[�d�d^d_��Z1d`da� Z2dbdc� Z3ddde� Z4dfdg� Z5dhdi� Z6djdk� Z7dldm� Z8d�dndo�Z9dpdq� Z:e;drdCdD�dsdt� �Z<e;dudCdD�dvdw� �Z=e;dxdCdD�dydz� �Z>e;d{dCdD�d|d}� �Z?e;d~dCdD�dd�� �Z@� ZAS )��NetTuningPluginaO
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`.
`wake_on_lan`:::
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
----
====
`coalesce`:::
The [option]`coalesce` option allows changing coalescing settings
for the specified network devices. The syntax is:
+
[subs="quotes"]
----
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
----
====
`features`:::
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
----
====
`pause`:::
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
----
====
`ring`:::
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
-----
=====
`channels`:::
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.
`nf_conntrack_hashsize`:::
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
----
====
`txqueuelen`:::
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
----
====
`mtu`:::
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 sd t t| �j|i |�� d| _d| _t� | _i | _d| _t �
d�| _tt
jd�rX| j| _n| j| _d S )Ng�������?� Tz(?!.*/virtual/.*)�
properties)�superr �__init__�_load_smallest�_level_stepsr �_cmd�_re_ip_link_show�_use_ip�re�compile�re_not_virtual�hasattr�pyudevZDevice�_get_device_property_1�_get_device_property�_get_device_property_2)�self�args�kwargs�� __class__� �</usr/lib/python3.9/site-packages/tuned/plugins/plugin_net.pyr � s
zNetTuningPlugin.__init__c sf t t| ��� d| _t� | _t� | _| j�d�D ]}| � |�r0| j�
|j� q0t�
dt| j� � d S )NT�netzdevices: %s)r
r �
_init_devicesZ_devices_supported�setZ
_free_devicesZ_assigned_devices�_hardware_inventoryZget_devices�_device_is_supported�addZsys_name�log�debug�str�r �devicer r r r! � s
zNetTuningPlugin._init_devicesc s � fdd�|D �S )Nc s g | ]}� j �d |��qS )r )r# �
get_device��.0�x�r r r �
<listcomp>� � z7NetTuningPlugin._get_device_objects.<locals>.<listcomp>r )r �devicesr r/ r �_get_device_objects� s z#NetTuningPlugin._get_device_objectsc C s | j �|j�S �N)r �matchZdevice_pathr) r r r r$ � s z$NetTuningPlugin._device_is_supportedc C s | j �| d| j� d S �Nr )r# Z subscribe�_hardware_events_callbackr/ r r r �_hardware_events_init� s z%NetTuningPlugin._hardware_events_initc C s | j �| � d S r4 )r# Zunsubscriber/ r r r �_hardware_events_cleanup� s z(NetTuningPlugin._hardware_events_cleanupc s | � |�rtt| ��||� d S r4 )r$ r
r r7 )r Zeventr* r r r r7 � s
z)NetTuningPlugin._hardware_events_callbackc s, |j d ur|j �|� tt| ��||� d S r4 )�
_load_monitorZ
add_devicer
r �_added_device_apply_tuning�r �instance�device_namer r r r; � s
z*NetTuningPlugin._added_device_apply_tuningc s, |j d ur|j �|� tt| ��||� d S r4 )r: Z
remove_devicer
r �_removed_device_unapply_tuningr<