MOON
Server: Apache
System: Linux s5.yayogua.com.py 6.12.0-124.55.3.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:54:02 EDT 2026 x86_64
User: sanbercountryclu (1012)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: //lib/python3.12/site-packages/tuned/plugins/__pycache__/plugin_net.cpython-312.pyc
�

�@/j�i���ddlZddlmZddl�ddlZddlmZddlm	Z	ddl
Z
ddlZddlZejj�ZdZGd�d	ej"�Zy)
�N�)�hotplug)�*)�ethcard)�commands�pumbagsdc���eZdZdZ�fd�Z�fd�Zd�Zd�Zd�Zd�Z	�fd�Z
�fd	�Z�fd
�Zd�Z
d�Zd
�Zd�Zd�Z�fd�Zd�Z�fd�Zd�Zd�Zed��Zed��Zed��Zed��Zed��Zd�Zd�Zd�Zd�Z d�Z!d�Z"d �Z#ed!��Z$e%d"d#�$�d%��Z&e'd"�dFd&��Z(e%d'�d(��Z)e'd'�d)��Z*gfd*�Z+dGd+�Z,e%d,d#�$�d-��Z-d.�Z.e'd,�dFd/��Z/e%d0d#�$�d1��Z0e'd0�dFd2��Z1d3�Z2d4�Z3d5�Z4d6�Z5d7�Z6d8�Z7d9�Z8	dGd:�Z9d;�Z:e;d<d#�$�d=��Z<e;d>d#�$�d?��Z=e;d@d#�$�dA��Z>e;dBd#�$�dC��Z?e;dDd#�$�dE��Z@�xZAS)H�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�0��tt|�
|i|��d|_d|_t�|_i|_d|_tjd�|_ttjd�r|j|_y|j"|_y)Ng�������?�Tz(?!.*/virtual/.*)�
properties)�superr
�__init__�_load_smallest�_level_stepsr�_cmd�_re_ip_link_show�_use_ip�re�compile�re_not_virtual�hasattr�pyudev�Device�_get_device_property_1�_get_device_property�_get_device_property_2)�self�args�kwargs�	__class__s   ��=/usr/lib/python3.12/site-packages/tuned/plugins/plugin_net.pyrzNetTuningPlugin.__init__�s{������'��8��8��$���$���j�$�)��$���$�,��
�
�#6�7�$���V�]�]�L�)�#�:�:�4��#�:�:�4��c�x��tt|��d|_t	�|_t	�|_|jjd�D]9}|j|�s�|j
j|j��;tjdt|j
�z�y)NT�netzdevices: %s)rr
�
_init_devices�_devices_supported�set�
_free_devices�_assigned_devices�_hardware_inventory�get_devices�_device_is_supported�add�sys_name�log�debug�str)r�devicer!s  �r"r&zNetTuningPlugin._init_devices�s�������,�.� �$���u�$���5�$���(�(�4�4�U�;�f�
����'������6�?�?�+�<��)�)�M�C�� 2� 2�3�3�4r#c�`�|D�cgc]}|jjd|��� c}Scc}w�Nr%)r+�
get_device)r�devices�xs   r"�_get_device_objectsz#NetTuningPlugin._get_device_objects�s-��AH�	I��A�$�
"�
"�
-�
-�e�Q�
7��	I�I��	Is�#+c�L�|jj|j�S�N)r�match�device_path)rr3s  r"r-z$NetTuningPlugin._device_is_supported�s��	
�	�	�	"�	"�6�#5�#5�	6�6r#c�R�|jj|d|j�yr5)r+�	subscribe�_hardware_events_callback�rs r"�_hardware_events_initz%NetTuningPlugin._hardware_events_init�s �����$�$�T�5�$�2P�2P�Qr#c�:�|jj|�yr;)r+�unsubscriberAs r"�_hardware_events_cleanupz(NetTuningPlugin._hardware_events_cleanup�s�����&�&�t�,r#c�R��|j|�rtt|�||�yyr;)r-rr
r@)r�eventr3r!s   �r"r@z)NetTuningPlugin._hardware_events_callback�s'���	���v�&���$�9�%��H�'r#c�|��|j�|jj|�tt|�||�yr;)�
_load_monitor�
add_devicerr
�_added_device_apply_tuning�r�instance�device_namer!s   �r"rKz*NetTuningPlugin._added_device_apply_tuning�s4���
���'����$�$�[�1����9�(�K�Pr#c�|��|j�|jj|�tt|�||�yr;)rI�
remove_devicerr
�_removed_device_unapply_tuningrLs   �r"rQz.NetTuningPlugin._removed_device_unapply_tuning�s4���
���'����'�'��4����=�h��Tr#c�8�|jj|�Sr;)r
�get)r�
pyudev_dev�props   r"rz&NetTuningPlugin._get_device_property_1�s��	�	�	�	"�	"�4�	(�(r#c�N�	|j|�}|S#t$rd}Y|SwxYwr;)�__getitem__�KeyError)rrTrU�ps    r"rz&NetTuningPlugin._get_device_property_2�s9������d�#�1�
�(��
���1�	
�(��s��$�$c
�\�|jjd|�}|r�|j|d�}|ryt|jj��D]R\}}|jj|�}|s�$tjd|�d|�d|�d��||j|<yyyy)Nr%�IFINDEXzRename device, ifindex: 'z', original name 'z
', new name '�')r+r6r�list�
_instances�items�_ifmap_origrSr0r1�
_ifnamemap)rrN�d�i�
instance_namerM�device_name_olds       r"�_move_devicezNetTuningPlugin._move_device�s���
���)�)�%��=�!��� � ��I�.�1��#'����(=�(=�(?�#@��
�x��+�+�/�/��2�_��	�i�i�	�?�K�)�*�-8�h���/�*��
$A��r#c����fd�}|S)Nc�F���jj|�}|r|S|Sr;)rarS)r3rbrMs  �r"�_get_curr_devicezBNetTuningPlugin._get_curr_device_wrapper.<locals>._get_curr_device�s&��������v�&�1��!��f�r#�)rrMris ` r"�_get_curr_device_wrapperz(NetTuningPlugin._get_curr_device_wrapper�s����
�r#c��d|_d|_d|_d|_i|_|j|�|_|j|jd�|_	y)NT�dynamic)
�_has_static_tuningrI�_idle�_statsrarkri�_option_bool�options�_has_dynamic_tuning�rrMs  r"�_instance_initzNetTuningPlugin._instance_init�sY�� $�(���(���(�.��(�/��(��"�;�;�H�E�(��!%�!2�!2�8�3C�3C�I�3N�!O�(�r#c����tt|�|�i|_|j}|D]E}|j
j
d|�}|s�"|j|d�}|s�7||j|<�Gy)Nr%r[)rr
�assign_free_devicesr`�assigned_devicesr+r6r)rrMr7r3rbrcr!s      �r"rwz#NetTuningPlugin.assign_free_devicesso������2�8�<��(���%�%�'��f����*�*�5�&�9�1���!�!�!�Y�/�A��%�X���!��r#c�v�|j�-|jj|j�d|_yyr;)rI�_monitors_repository�deleterts  r"�_instance_cleanupz!NetTuningPlugin._instance_cleanups5��
���'����#�#�H�$:�$:�;� �8��(r#c����tt|�|�i|_i|_|j
j
d|j�|_|jj|j�yr5)rr
�_instance_init_dynamicrorprz�createrxrI�_set_dev_mapri)rrMr!s  �r"r~z&NetTuningPlugin._instance_init_dynamics[������5�h�?��(�.��(�/��4�4�;�;�E�8�C\�C\�]�(��
���%�%�h�&?�&?�@r#c�(�|j||�yr;)�_instance_update_dynamic�rrMr3s   r"�_instance_apply_dynamicz'NetTuningPlugin._instance_apply_dynamics������&�1r#c�,�|jj|�D�cgc]
}t|���}}|�y||jvr|j	||�|j|||�|j
||�|j|}|j|}|ddk(r\|d|jk\rJ|d|jk\r8d|d<tjd|z�t|�jd�nN|ddk(rF|ddk(s|ddk(r6d|d<tjd|z�t|�j�tjd	||d|dfz�tjd
||d|d|dfz�ycc}w)N�levelr�read�writerz%s: setting 100Mbps�d�%s: setting max speedz %s load: read %0.2f, write %0.2fz$%s idle: read %d, write %d, level %d)rI�get_device_load�intrp�_init_stats_and_idle�
_update_stats�_update_idlerorr0�infor�	set_speed�
set_max_speedr1)rrMr3�value�load�stats�idles       r"r�z(NetTuningPlugin._instance_update_dynamics���"*�"8�"8�"H�"H��"P�	Q�"P��#�e�*�"P�$�	Q�	�\�	�	�8�?�?�	"����X�v�.����X�v�t�,����H�f�%�
�/�/�&�
!�%�	����	�$�	�'�]�a��D��L�D�,=�,=�=�$�w�-�SW�Sd�Sd�Bd��4��=��8�8�!�F�*�+�
�6�?���S�!��G�}���t�F�|�q�0�D��M�Q�4F��4��=��8�8�#�f�,�-�
�6�?� � �"��)�)�.�&�%��-��w��1X�X�Y��)�)�2�f�d�6�l�D�QX�M�[_�`g�[h�5i�i�j��-
Rs�Fc��idd�dd�dd�dd�dd�dd�dd�dd�d	d�d
d�dd�dd�d
d�dd�dd�dd�dd�dddddddddd�	�S)Nzadaptive-rxzadaptive-txzcqe-mode-rxzrx-usecsz	rx-frameszrx-usecs-irqz
rx-frames-irqztx-usecsz	tx-framesztx-usecs-irqz
tx-frames-irqzstats-block-usecszpkt-rate-lowzrx-usecs-lowz
rx-frames-lowztx-usecs-lowz
tx-frames-low)	z
pkt-rate-highz
rx-usecs-highzrx-frames-highz
tx-usecs-highztx-frames-highzsample-intervalztx-aggr-max-bytesztx-aggr-max-framesztx-aggr-time-usecsrj��clss r"�_get_config_options_coalescez,NetTuningPlugin._get_config_options_coalesce6s���
��$�
��$�
��$�
��t�	
�
��
��4�

��D�
��t�
���
��4�
��D�
���
��4�
��4�
��D�
� �4�!
�"�D�#
�$���������5
�r#c��dddd�S)N)�autoneg�rx�txrjr�s r"�_get_config_options_pausez)NetTuningPlugin._get_config_options_pauseUs���	
�	
�
�r#c��ddddd�S)N)r��rx-mini�rx-jumbor�rjr�s r"�_get_config_options_ringz(NetTuningPlugin._get_config_options_ring[s�����	
�
�r#c��ddddd�S)N)r�r��other�combinedrjr�s r"�_get_config_options_channelsz,NetTuningPlugin._get_config_options_channelsbs���	
���
�r#c��ddddddddddd�
S)NT)
rm�wake_on_lan�nf_conntrack_hashsize�features�coalesce�pause�ring�channels�
txqueuelen�mturjr�s r"�_get_config_optionsz#NetTuningPlugin._get_config_optionsis,���� �������
�
�r#c���|jt|j|��j��}ddgzd|dgzd�|j|<dddd�|j
|<y)N�r�r)�new�max)r�r�r�)�_calc_speedrri�
get_max_speedrpro)rrMr3�	max_speeds    r"r�z$NetTuningPlugin._init_stats_and_idlexsb�����w�x�'@�'@��'H�I�W�W�Y�Z�)�%&�!��W�Q�)�Q��5G�I�(�/�/�&��&'��Q�@�(�.�.��r#c�,�|j|dx|j|d<}||j|d<t||�D�cgc]
}|d|dz
��}}||j|d<|j|d}t||�D�cgc]
}t|���}	}|	|j|d<t|d�t|	d�z|j|d<t|d�t|	d�z|j|d	<ycc}wcc}w)
Nr��oldrr�diffr�r�r�r�)rp�zipr��float)
rrMr3�new_load�old_load�new_oldr��old_max_load�pair�max_loads
          r"r�zNetTuningPlugin._update_stats}s"��.6�o�o�f�.E�e�.L�L�(�/�/�&��%� �8�#+�(�/�/�&��%� �25�X�x�1H�	I�1H�g�'�!�*�w�q�z�
!�1H�$�	I�$(�(�/�/�&��&�!�����(��/�,�$'��d�$;�
<�$;�D�c�$�i�$;�(�
<�#+�(�/�/�&��%� �&+�4��7�^�e�H�Q�K�6H�%H�(�/�/�&��&�!�%*�4��7�^�e�H�Q�K�6H�%H�(�/�/�&��'�"��
J��
=s�D�Dc��dD]N}|j|||jkr|j||xxdz
cc<�=d|j||<�Py)N)r�r�rr)rprro)rrMr3�	operations    r"r�zNetTuningPlugin._update_idle�sT��$�i��o�o�f��i�(�4�+>�+>�>��N�N�6��9�%��*�%�()�H�N�N�6��9�%�	%r#c���||jvri|j|ddkDrSd|j|d<tjd|z�t|j	|��j�yyy)Nr�rr�)ror0r�rrir�r�s   r"�_instance_unapply_dynamicz)NetTuningPlugin._instance_unapply_dynamic�sm���x�~�~��(�.�.��"8��"A�A�"E�%&�8�>�>�&��'�"��8�8�#�f�,�-�
�8�$�$�V�,�-�;�;�=�#F�r#c�$�td|zdz�S)Ng333333#A�)r�)r�speeds  r"r�zNetTuningPlugin._calc_speed�s��
�!�E�)�A�-�	.�.r#c�x�|jj|�}ttjdd|��j�}t
|�}|dzdk7r&tjd|�dt|��d��y|dk(r
t�Sttt|ddd�|ddd����S)	Nz (:\s*)|(\s+)|(\s*;\s*)|(\s*,\s*)� r�rzinvalid z
 parameter: 'r\r)�
_variables�expandr2r�sub�split�lenr0�error�dictr]r�)rr��context�v�lvs     r"�_parse_config_parametersz(NetTuningPlugin._parse_config_parameters�s���
�/�/�
 �
 ��
'�%�	�"�&�&�4�c�5�
A�B�H�H�J�!�
�1�v�"��!�V�q�[��9�9�W�c�%�j�
A�B�
��1�W�
�&�=�	
�d�3�q��1��v�q���A��w�'�(�	)�)r#c�>�|jjidd�dd�dd�dd�d	d
�dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd �d!d"�d#d$d%��|�}|jd&�D�cgc]<}tt	|��d'kDs�tjd(t	|��r�;|��>}}t|�d)kryt|d*dD�cgc]!}tjd+t	|����#c}D�cgc]}t|�d)k(s�|��c}�Scc}wcc}wcc}w),NzAdaptive RX:zadaptive-rx:z\s+TX:z
adaptive-tx:zCQE mode RX:zcqe-mode-rx:z
rx-frame-low:zrx-frames-low:zrx-frame-high:zrx-frames-high:z
tx-frame-low:ztx-frames-low:ztx-frame-high:ztx-frames-high:zlarge-receive-offload:zlro:zrx-checksumming:zrx:ztx-checksumming:ztx:zscatter-gather:zsg:ztcp-segmentation-offload:ztso:zudp-fragmentation-offload:zufo:zgeneric-segmentation-offload:zgso:zgeneric-receive-offload:zgro:zrx-vlan-offload:zrxvlan:ztx-vlan-offload:ztxvlan:zntuple:zrxhash:)zntuple-filters:zreceive-hashing:�
rz
\[fixed\]$r�r�:\s*)r�multiple_re_replacer�r�r2r�searchr�)rr�r��vl�us     r"�_parse_device_parametersz(NetTuningPlugin._parse_device_parameters�s����)�)�
'�
'�)��>�)���)��>�)��$�	)�
�&�)��$�
)��&�)��V�)��u�)��u�)��e�)���)� ��)�#�F�)��v�)� �y�!)�"�y�#)�$ � �')�(�)�%�,�;�;�t�$�a�$�a��C��F��a���	�	�-�Y\�]^�Y_�@`��$�"�a���W�q�[�
�
�b���f�E�f��2�8�8�G�S��V�4�f�E�U�E�Q��Q��ST��q�E�U�	V�V��b��
F��Us$�(D�D�%D�&D�1D�Dc��y)Nz,/sys/module/nf_conntrack/parameters/hashsizerjrAs r"�_nf_conntrack_hashsize_pathz+NetTuningPlugin._nf_conntrack_hashsize_path�s��	7r#r�T)�
per_devicec��|�ytjddt|��}tjdtzdz|�st
j
d�y|s/|jjdd|j|�d|g�|S)	N�0rbz^[z]+$zIncorrect 'wake_on_lan' value.�ethtoolz-s�wol)
rr�r2r<�
WOL_VALUESr0�warningr�executeri)rr�r3rM�sim�removes      r"�_set_wake_on_lanz NetTuningPlugin._set_wake_on_lan�s{��
�]�
�
�&�&��s�C��J�
'�%�	���%�*�$�v�-�u�	5��;�;�/�0�
�	��9�9���i��x�'@�'@��'H�%�QV�W�X�	�,r#c	�
�d}	tjdtzdz|jj	d|j|�g�dtj�}|r|jd�}|S#t$rY|SwxYw)Nz.*Wake-on:\s*([z]+).*r�r)	rr<r�rr�ri�S�group�IOError)rr3rM�ignore_missingr��ms      r"�_get_wake_on_lanz NetTuningPlugin._get_wake_on_lan�s���
�%��	�x�x�"�Z�/�'�9��I�I���y�(�";�";�F�"C�D�E�a�H�"�$�$�P�1��
�G�G�A�J�E�
�,��
���	�,��s�A/A5�5	B�Br�c��|�yt|�}|dk\rC|s?|jj|j�||rtj
gnd��|Sy)NrF)�no_error)r�r�
write_to_filer��errno�ENOENT)rr�rMr�r��hashsizes      r"�_set_nf_conntrack_hashsizez*NetTuningPlugin._set_nf_conntrack_hashsize�sV��
�]�
�
��Z�(�
��]�

��I�I���D�<�<�>��"(�����e��5�
�?�
r#c��|jj|j��}t|�dkDrt	|�Sy)Nr)r�	read_filer�r�r�)rrMr�s   r"�_get_nf_conntrack_hashsizez*NetTuningPlugin._get_nf_conntrack_hashsizes7��
�)�)�
�
�d�>�>�@�
A�%���Z�!�^�

�e�*��	
r#c�Z�|jsyddg|z}|jj|tjgd��\}}}|tjk(rt
j
d�d|_y|r2t
jd�t
jd|�d	|�d
��y|S)N�ip�linkT)�	no_errors�
return_errz0ip command not found, ignoring for other devicesFzProblem calling ip commandz(rc: z, msg: 'z'))	rrr�r�r�r0r�r�r1)rr�rc�out�err_msgs     r"�
_call_ip_linkzNetTuningPlugin._call_ip_link
s���	
���
�
���$�	�$��y�y�(�(��%�,�,��TX�(�Y��2�s�G��E�L�L�=���;�;�A�B��4�<�
�	��8�8�(�)��9�9�b�'�
2�3�
�	�*r#c�P�dg}|r|j|�|j|�S)N�show)�appendr)rr3rs   r"�
_ip_link_showzNetTuningPlugin._ip_link_shows)��
��$���;�;�v��	
�	�	�D�	!�!r#r�c��|�y	t|�|sO|j	dd|j|�d|g�}|�(tjd|j|�z�y|S#t$rtjd|z�YywxYw)Nz$txqueuelen value '%s' is not integerr(�devr�z%Cannot set txqueuelen for device '%s'�r��
ValueErrorr0r�rri�rr�r3rMr�r��ress       r"�_set_txqueuelenzNetTuningPlugin._set_txqueuelens���
�]�
���u�:�

�	
�	�	�U�E�8�+D�+D�V�+L�l�\a�b�	c�3�	�k��K�K�7�(�:S�:S�TZ�:[�[�\��	�,��
���;�;�5��=�>�
����A#�#!B�Bc��||jvr%tjd|z�|j|<|j|S)z@
		Return regex for int arg value from "ip link show" command
		z.*\s+%s\s+(\d+))rrr)r�args  r"�_get_re_ip_link_showz$NetTuningPlugin._get_re_ip_link_show0sB��	��%�%�%� "�
�
�+=��+C� D�4�����	
�	�	�s�	#�#r#c�T�|j|j|��}|�*|s'tjd|j|�z�y|j	d�j|�}|�*|s'tjd|j|�z�y|j
d�S)NzECannot get 'ip link show' result for txqueuelen value for device '%s'�qlenzFCannot get txqueuelen value from 'ip link show' result for device '%s'r�rrir0r�rr�r��rr3rMr�rrs      r"�_get_txqueuelenzNetTuningPlugin._get_txqueuelen8s������8�4�4�V�<�=�#��[�
��H�H�
T�
���v�&�'�(�
��!�!�&�)�0�0��5�#��[�
��H�H�
U�
���v�&�'�(�
�	���1��r#r�c��|�y	t|�|sO|j	dd|j|�d|g�}|�(tjd|j|�z�y|S#t$rtjd|z�YywxYw)Nzmtu value '%s' is not integerr(rr�zCannot set mtu for device '%s'rrs       r"�_set_mtuzNetTuningPlugin._set_mtuIs���
�]�
���u�:�

�	
�	�	�U�E�8�+D�+D�V�+L�e�UZ�[�	\�3�	�k��K�K�0�8�3L�3L�V�3T�T�U��	�,��
���;�;�.��6�7�
��rc�T�|j|j|��}|�*|s'tjd|j|�z�y|j	d�j|�}|�*|s'tjd|j|�z�y|j
d�S)Nz>Cannot get 'ip link show' result for mtu value for device '%s'r�z?Cannot get mtu value from 'ip link show' result for device '%s'rrrs      r"�_get_mtuzNetTuningPlugin._get_mtuYs������8�4�4�V�<�=�#��[�
��H�H�
M�
���v�&�'�(�
��!�!�%�(�/�/��4�#��[�
��H�H�
N�
���v�&�'�(�
�	���1��r#c	��|dk(r|St|j��}|j|j|j|j
d�}t||�j��}|j
|�s'tjd|�dt||z
����|j�D��cic]
\}}||vs�||��c}}Scc}}w)Nr�)r�r�r�r�zignoring unknown z parameter(s): )r(�keysr�r�r�r��issubsetr0r�r2r_)rr�rb�params�supported_getter�	supported�kr�s        r"�_check_parametersz!NetTuningPlugin._check_parametersks����
��
�8��q�v�v�x�=�&�#'�#D�#D�
�
+�
+��)�)��1�1�4���+�"�7�+�-�2�2�4�5�)�	����	#��;�;��#�f�y�FX�BY�Z�[��7�7�9�	7�9�4�1�a��Y��!�Q�$�9�	7�7��	7s�<C�	Cc	�t�|jjdddd�|�}|jd�dd}|D�cgc]!}|dk7s�	tjd|�r� |��#}}t|D�cgc]}tjd	|���c}D�cgc]}t
|�d
k(s�|��c}�Scc}wcc}wcc}w)Nr�r�r�)�
Autonegotiate�RX�TXr�r�z	\[fixed\]r�r�)rr�r�rr�r�r�)r�s�lr8s    r"�_parse_pause_parametersz'NetTuningPlugin._parse_pause_parametersys���
�i�i�#�#��
�
����!��g�g�d�m�A�B��!��B�!�Q�q�B�w�r�y�y��q�'A�q�!�!�B�	
��;��A�2�8�8�G�Q�/��;�K�;�Q�s�1�v��{�q�;�K�	L�L��C��;��Ks#�
B+�B+�B+�*B0�B5� B5c��tjd|tj��}|d}|jj	ddddd�|�}|jd	�}|D�cgc]
}|d
k7s�	|��}}|D�cgc]}tjd|���c}D�cgc]}t|�dk(s�|��}}t
|�Scc}wcc}wcc}w)
N�^Current hardware settings:$��flagsrr�r�r�r�)r+zRX MinizRX Jumbor,r�r-r�r��rr��	MULTILINErr�r�r��rr.�ar/r8s     r"�_parse_ring_parametersz&NetTuningPlugin._parse_ring_parameters�s����h�h�.�����F�!���d�!�
�i�i�#�#����
���	�!�
�g�g�d�m�!���!�Q�q�B�w�q�!�!��12�3��A�2�8�8�G�Q�'��3�C�3�Q�s�1�v��{�q�3�!�C�	
�a��.�� ��3��C��"
B>�-B>�7C�C�-Cc��tjd|tj��}|d}|jj	ddddd�|�}|jd	�}|D�cgc]
}|d
k7s�	|��}}|D�cgc]}tjd|���c}D�cgc]}t|�dk(s�|��}}t
|�Scc}wcc}wcc}w)
Nr2r3rr�r�r�r�)r+r,�Other�Combinedr�r-r�r�r5r7s     r"�_parse_channels_parametersz*NetTuningPlugin._parse_channels_parameters�s����h�h�.�����F�!���d�!�
�i�i�#�#��
�
����	 �!�
�g�g�d�m�!���!�Q�q�B�w�q�!�!��12�3��A�2�8�8�G�Q�'��3�C�3�Q�s�1�v��{�q�3�!�C�	
�a��.�� ��3��Cr:c��g}d|vr|jd|dd|dg�n@ttt|d�t|d���}|jd|g�t	tt
|ddd�|ddd����S)Nr�r�rr��r�)�extendr2r�r�r�r]r�)rr��params_list�
dev_params�mod_params_list�cnts      r"�_replace_channels_parametersz,NetTuningPlugin._replace_channels_parameters�s����/��;�����4��Q���{�1�~�F�G�	�S��[��^�$�c�+�a�.�&9�
:�	;�3����:�s�+�,�	
�d�3��s��s�+�_�Q�T��T�-B�C�D�	E�Er#c
��t|j��}t|j��}||z
}|D]@}	tj|�d|	�d|j	|����|j|	d��By)a:Filter unsupported parameters and log warnings about it

		Positional parameters:
		instance -- instance calling it
		context -- context of change
		parameters -- parameters to change
		device -- name of device on which should be parameters set
		dev_params -- dictionary of currently known parameters of device
		z parameter z is not supported by device N)r(r"r0r�ri�pop)
rrMr��
parametersr3rC�supported_parameters�parameters_to_change�unsupported_parameters�params
          r"�_check_device_supportz%NetTuningPlugin._check_device_support�sw���Z�_�_�.�/���Z�_�_�.�/��1����%�e��;�;��	����f�%���
�>�>�%���
&r#c�V�dddddd�}||}|jjd||j|�g�\}}|dk7st|�dk(ry|j|j|j
|j|jd�}||}	|	|�}
|j||
�S)	Nz-cz-kz-az-gz-l�r�r�r�r�r�r�r)	rr�rir�r�r0r9r>r()rrMr�r3�context2opt�opt�retr��context2parser�parserrbs           r"�_get_device_parametersz&NetTuningPlugin._get_device_parameters�s���"��t�T���+��G��#��y�y� � �)�S�(�2K�2K�F�2S�!T�U�*�#�u��A�X��U��q��
�!%�!>�!>��-�-�
�
)�
)��'�'��/�/�	2�.�
�'�"�&��U�m�!�	
�	�	���	+�+r#c�Z�|�t|�dk(ry|j||j||��}|rh|j|||||�|dk(rNt	|tt
|���dvr,|j||jj|�|�}|s�t|�dk7r}tjd|�dt	|����dddd	d
d�}||}	|jjd|	|j|�g|jj|�zd
g��|S)Nrr�)zn/ar�zsetting z: z-Cz-Kz-Az-Gz-LrPr��P)r)r�r(r�rNr2�next�iterrFr�	dict2listr0r1r�ri)
rrMr�r�r3r�rCrbrQrRs
          r"�_set_device_parametersz&NetTuningPlugin._set_device_parameters�s��
�]�c�%�j�A�o�
�
���W�d�&C�&C�E�7�&S�T�!�����h���F�J�G�
����J�t�D��G�}�$=� >�,� N��)�)�'�4�9�9�3F�3F�q�3I�:�V�A�	��Q��1���9�9��#�a�&�
1�2�#���d�,0�2�;�	�W�	�3��9�9���i��h�&?�&?��&G�H��I�I������)+���.�	
�(r#c	���|j||��}|�r$|j|||�}|�t|�dk(ry|j||||||��}	|	�t|	�dk(ry|j	�D�
�cgc]
\}
}|
|	vr|
|f��}}
}t|�}|r^|jj|	�|jj|�k(}|j|||	||j|���|S|jj|dj|jj|���y|jj|�}
|j|||
|d�ycc}}
w)N)�command_namerNrF)rC)r3r�)�_storage_keyrVr�r\r_r�rr[�_log_verification_resultri�_storager(�joinrS)rr��startr�r3�verifyrM�storage_key�params_current�
params_setrM�relevant_params_currentr�original_values              r"�_custom_parametersz"NetTuningPlugin._custom_parameters�s����!�!���"��+���/�/��'�6�J�>����N� 3�q� 8���+�+�H�g�
�F�F� �,�"�:�
��C�
�O�q�0��������2>���
��� %�e�n����"�"9�:����9�9���z�*�	
���	�	�4�	5�6�C��!�!�'�3����(�(��0�"�2��J��=�=���[�#�(�(�	�Y�Y���0�1�#3�4�
�	�M�M�%�%�k�2�>����x��.�&�%�P�	
��)s�6E,r�c�.�|jd|||||�S)Nr��rj�rrcr�r3rdr�rMs       r"�	_featureszNetTuningPlugin._features
���	
�	 �	 ��U�E�6�6�8�	T�Tr#r�c�.�|jd|||||�S)Nr�rlrms       r"�	_coalescezNetTuningPlugin._coalesceror#r�c�.�|jd|||||�S)Nr�rlrms       r"�_pausezNetTuningPlugin._pauses��	
�	 �	 ��%�����	Q�Qr#r�c�.�|jd|||||�S)Nr�rlrms       r"�_ringzNetTuningPlugin._rings��	
�	 �	 ����v�v�x�	P�Pr#r�c�.�|jd|||||�S)Nr�rlrms       r"�	_channelszNetTuningPlugin._channelsror#)Fr;)B�__name__�
__module__�__qualname__�__doc__rr&r9r-rBrEr@rKrQrrrfrkrurwr|r~r�r��classmethodr�r�r�r�r�r�r�r�r�r�r�r�r��command_setr��command_getr�r�r�rrrrrrr r(r0r9r>rFrNrVr\rj�command_customrnrqrsrurw�
__classcell__)r!s@r"r
r
s����R�h;�
6�J�7�R�-�I�Q�
U�)����P�	&�!�
A�2�k�2����<����
������������A�
I�$*�>�/�*�W�B�8��8��m��-��.���m��	��	��%�&��'���%�&��'��!�

�"��l�t�,��-�� $��l����� �e��%�
�&�
��e�����"8�M���F��0,�"��,#�J��$�/�U�0�U���$�/�U�0�U���t�,�R�-�R���d�+�Q�,�Q���$�/�U�0�Ur#r
)r�r-r�
decorators�
tuned.logs�tuned�tuned.utils.nettoolr�tuned.utils.commandsr�osrr�logsrSr0r��Pluginr
rjr#r"�<module>r�sI������'�)�	�	�
��j�j�n�n���
�
�MU�g�n�n�MUr#