__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
�

���g�R����SSKrSSKrSSKrSSKrSSKrSSKJrJrJrJr SSK	J
r
 SSKJr SSK
r
"SS\5rS	\R \4S
jrS	\R \S\R \4SjrS
\
R&S\S\4SjrS
\
R&S\\4SjrSrS\
R2S\\\44SjrS\
R2S\\\44SjrS\
R2S\\4SjrSrSrSSjr SSjr!g)�N)�Dict�List�Optional�Set�)�utils�)�ConfigurationErrorc�*�\rSrSrSrS\4Sjr\S\4Sj5r\S\4Sj5r	S\S\4S	jr
\S\4S
j5r\S\4Sj5r
\S\4Sj5r\S\4S
j5r\S\4Sj5r\S\4Sj5rS\S\S\4SjrS\4SjrS\4SjrSrg)�	PCIDevice�"z.Helper class for interaction with a PCI device�pci_addrc��Xlg)zVInitialise a new PCI device handler
:param pci_addr: PCI address of device
:type: str
N�r)�selfrs  �+/usr/share/netplan/netplan_cli/cli/sriov.py�__init__�PCIDevice.__init__%s	��
!�
��returnc��g)z]sysfs path (can be overridden for testing)
:return: full path to /sys filesystem
:rtype: str
z/sys��rs r�sys�
PCIDevice.sys,s��rc�l�[RRURSUR5$)zY/sys path for PCI device
:return: full path to PCI device in /sys filesystem
:rtype: str
zbus/pci/devices)�os�path�joinrrrs rr�PCIDevice.path4s$���w�w�|�|�D�H�H�&7����G�Gr�subpathc�V�[RRURU5$)z�/sys subpath helper for PCI device
:param subpath: subpath to construct path for
:type: str
:return: self.path + subpath
:rtype: str
)rrr)rr!s  rr!�PCIDevice.subpath<s���w�w�|�|�D�I�I�w�/�/rc���Sn[RRURS55(aB[RR	[R
"URS555nU$)zRKernel driver for PCI device
:return: kernel driver in use for device
:rtype: str
��driver)rr�existsr!�basename�readlink)rr&s  rr&�PCIDevice.driverEsP����
�7�7�>�>�$�,�,�x�0�1�1��W�W�%�%�b�k�k�$�,�,�x�2H�&I�J�F��
rc�^�[RRURS55$)zqDetermine if device is bound to a kernel driver
:return: whether device is bound to a kernel driver
:rtype: bool
r&�rrr'r!rs r�bound�PCIDevice.boundP� ���w�w�~�~�d�l�l�8�4�5�5rc�^�[RRURS55$)z_Determine if device is a SR-IOV Physical Function
:return: whether device is a PF
:rtype: bool
�sriov_numvfsr,rs r�is_pf�PCIDevice.is_pfXs ���w�w�~�~�d�l�l�>�:�;�;rc�^�[RRURS55$)z^Determine if device is a SR-IOV Virtual Function
:return: whether device is a VF
:rtype: bool
�physfnr,rs r�is_vf�PCIDevice.is_vf`r/rc��/nSnUR[RR[R"URSR
U55555 US-
nMh![a U$f=f)z�List Virtual Function addresses associated with a Physical Function
:return: List of PCI addresses of Virtual Functions
:rtype: list[str]
rzvirtfn{}r)�appendrrr(r)r!�format�FileNotFoundError)r�vf_addrs�is   rr<�PCIDevice.vf_addrshs}����
���
�����G�G�$�$����D�L�L��1B�1B�1�1E�$F�G���
��F�A���%�
����
�s�A A.�.
A<�;A<c�X�URVs/sHn[U5PM sn$s snf)z�List Virtual Function associated with a Physical Function
:return: List of PCI devices of Virtual Functions
:rtype: list[PCIDevice]
)r<r)r�addrs  r�vfs�
PCIDevice.vfs|s$��-1�M�M�:�M�D�	�$��M�:�:��:s�'�obj_name�prop�valuec	�p�[R"SSUSSRUR5UU/5 g)z�Set devlink options for the PCI device
:param obj_name: devlink object to set options on
:type: str
:param prop: property to set
:type: str
:param value: value to set for property
:type: str
�
/sbin/devlink�dev�setzpci/{}N)�
subprocess�
check_callr:r)rrCrDrEs    r�devlink_set�PCIDevice.devlink_set�s9��	�����������
�
�.���
�
	
rc�8�SUR3n[R"SSSSSU/[RS9n[
R"U5nURS05RU05RS	S5$![Ra gf=f)
z�Query eswitch mode via devlink for the PCI device
:return: the eswitch mode or '__undetermined' if it can't be retrieved
:rtype: str
zpci/rGz-jrH�eswitch�show)�stderr�__undetermined�mode)rrJ�check_output�DEVNULL�CalledProcessError�json�loads�get)r�pci�output�json_outputs    r�devlink_eswitch_mode�PCIDevice.devlink_eswitch_mode�s���
�T�]�]�O�$��
	$��,�,�#������
�"�)�)�
�F��j�j��(�����u�b�)�-�-�c�2�6�:�:�6�CS�T�T���,�,�	$�#�	$�s�)B�B�Bc��UR$)zJString represenation of object
:return: PCI address of string
:rtype: str
rrs r�__str__�PCIDevice.__str__�s��
�}�}�rrN)�__name__�
__module__�__qualname__�__firstlineno__�__doc__�strr�propertyrrr!r&�boolr-r2r6�listr<rArLr]r`�__static_attributes__rrrrr"s3��8�!��!���S�����H�c�H��H�0�s�0�s�0��������6�t�6��6��<�t�<��<��6�t�6��6���$����&�;�T�;��;�
�C�
�s�
�3�
�*U�c�U�:��rrrAc��/nUHfnUR(aM[SRU5S5nURUR5 URU5 SSS5 Mh U$!,(df   M{=f)zBind unbound VFs to driver.z/sys/bus/pci/drivers/{}/bind�wtN�r-�openr:�writerr9)rAr&�	bound_vfs�vf�fs     r�bind_vfsrt�sk���I����x�x�x��4�;�;�F�C�T�J�a�������$�� � ��$�K�J��
��K�J���-A1�1
B	rc��/nUHfnUR(dM[SRU5S5nURUR5 URU5 SSS5 Mh U$!,(df   M{=f)zUnbind bound VFs from driver.z/sys/bus/pci/drivers/{}/unbindrmNrn)rAr&�unbound_vfsrrrss     r�
unbind_vfsrx�sl���K���
�8�8�8��6�=�=�f�E�t�L�PQ�������$��"�"�2�&�M�L��
��M�L�ru�netdef�	interfacec�t�URU[R"U5[R"U5S9$)N)�
iface_name�iface_driver�	iface_mac)�_match_interfacer�get_interface_driver_name�get_interface_macaddress)ryrzs  r�_interface_matchesr��s9���"�"���4�4�Y�?��0�0��;�#�=�=rc��[R"5nUR(a�URnU(aX!;aU$[	5nUHMn[X5(dM[
U5S:�a[SUR-5eURU5 MO U(a[U5S$gURU;aUR$g)zz
Try to match a netdef with the real system network interface.
Throws ConfigurationError if there is more than one match.
rz3matched more than one interface for a PF device: %srN)r�get_interfaces�
_has_match�set_namerIr��lenr
�id�addrj)ry�
interfacesr��matchesrzs     r�_get_interface_name_for_netdefr��s���
"�0�0�2�J�
���������.��O� #��G�(�	�)�&�<�<���w�<�!�#�,�-b�ek�en�en�-n�o�o����I�&�(���G�}�Q�'�'����9�9�
�"��9�9��rc	��[RRSUS5n[U5nSnUR	5HKnUR5nUR
S5(dM+URSS5SnUs sSSS5 $ SSS5 g!,(df   g=f![a!n[SU<S	[U5<35eSnAff=f)
z-
Read PCI slot name for given interface name
�/sys/class/netz
device/ueventNzPCI_SLOT_NAME=�=r	rz!failed parsing PCI slot name for �: )rrrro�	readlines�strip�
startswith�split�IOError�RuntimeErrorrg)�netdev�uevent_pathrs�
pci_slot_name�line�es      r�_get_pci_slot_namer��s����'�'�,�,�/���I�K�	Y�
�+�
�!� �M����
���z�z�|���?�?�#3�4�4�$(�J�J�s�A�$6�q�$9�M�(�(�
�
�%��
�
���Y���PS�TU�PV�W�X�X��Y�sF�B*�:B�,B�	B*�B�B*�
B'�#B*�'B*�*
C�4C�C�np_statec� �0nURR5H�nURRS5=n(a0[	XR
5=n(aXAUR
'MSMUUR(a [	U5=n(aXAUR
'URnUS:�dM�[	U5=n(dM�XAUR
'M� U$![Ran[[U55eSnAff=f)zz
Go through the list of netplan ethernet devices and identify which are
PFs matching them with actual network interfaces.
�sriovNr)�	ethernets�values�linksrYr�r��_embedded_switch_mode�	_vf_count�netplan�NetplanExceptionr
rg)r��pfsry�link�iface�countr�s       r�_get_physical_functionsr�s���

�C��$�$�+�+�-���<�<�#�#�G�,�,�4�,�6�x���7H�I�I�u�I�$�D�G�G��J�
�+�+�:�6�B�B�5�B�%*��	�	�N�
1��(�(���q�y�:�6�B�B�5�B�%*��	�	�N�'.�*�J��
�+�+�
1�(��Q��0�0��
1�s�$C � D
�4D�D
c��0nURR5H0nURnUS:�dM[U5=n(dM,X1U'M2 U$![Ran[[
U55eSnAff=f)z�
Go through the list of netplan ethernet devices and identify which ones
have VFs. netdef._vf_count ultimately calls _netplan_state_get_vf_count_for_def
from libnetplan which return MAX(sriov_explicit_vf_count, number of VF netdefs).
Nr)r�r�r�r�r�r
rgr�)r��	vf_countsryr�r�r�s      r�_get_vf_number_per_pfr�.s����I��$�$�+�+�-��	-��$�$�E��1�9�6�v�>�>�u�>�#(�%� �.����
�'�'�	-�$�S��V�,�,��	-�s�A�B�'A;�;Bc��[5nURR5H`nURR	S5=n(dM'[XR5(dMEURUR5 Mb U$)z_
Go through the list of netplan ethernet devices and identify which ones
are virtual functions
r�)rIr�r�r�rYr�r�r�)r�rAryr�s    r�_get_virtual_functionsr�Asg��
�%�C��$�$�+�+�-���<�<�#�#�G�,�,�4�,�-�h�w�w�.?�@�@�����	�	�"�	.�
�Jrc���US:�a[SU<SU<S35e[RRSUS5n[RRUS5n[RRUS5n[	U5n[UR
5R55nS	S	S	5 UW:�a[SU<S
U<SU<S35e[	US5nUR[U55 S	S	S	5 g!,(df   N]=f![a!n[S
U<S[U5<35eS	nAf[a [SU-5ef=f!,(df   g=f![a�nSnURS:Xa�[R"SU-5 [	US5nURS5 S	S	S	5 O!,(df   O=f[	US5nUR[U55 S	S	S	5 O!,(df   O=fSnO![an	U	nS	n	A	OS	n	A	ff=fU(a [SU<SU<S[U5<35eS	nAgS	nAff=f)z:
Allocate the required number of VFs for the selected PF.
�z cannot allocate more VFs for PF z than the SR-IOV maximum: z > 256r��devicer1�sriov_totalvfsNz"failed parsing sriov_totalvfs for r�z#invalid sriov_totalvfs value for %sz than supported: z > z (sriov_totalvfs)�wT�zLdevice or resource busy while setting sriov_numvfs for %s, trying workaround�0Fzfailed setting sriov_numvfs to z for )r
rrrro�int�readr�r�r�rg�
ValueErrorrp�errno�logging�warning)
�pf�vf_count�devdir�numvfs_path�
totalvfs_pathrs�vf_maxr��bail�e_inners
          r�set_numvfs_for_pfr�Os
���#�~� �VX�Zb�c�e�	e��W�W�\�\�*�B��
9�F��'�'�,�,�v�~�6�K��G�G�L�L��)9�:�M�G�
�-�
 �A��������)�*�F�!��&�� �]_�ai�kq�r�t�	t�h�
�+�s�
#�q�
�G�G�C��M�"�$�(�A!�
 ���V���S�QR�V�T�U�U���G��@�2�E�F�F�G��$�
#�(��%�h����7�7�b�=��O�O�j�mo�o�p�

��+�s�+�q��G�G�C�L�,�+�+���+�s�+�q��G�G�C��M�*�,�+�+��
����
����
����QY�[]�_b�cd�_e�f�g�g����%h�s��=D�(D�0D�E.�#E�>E.�
D�D�D�
E�"D>�>E�
E+�'E.�+E.�.
I*�8+I%�$H �0G�	H �
G	�H �(H�	H �
H	�H �I%� 
H6�*H1�,I%�1H6�6*I%�%I*c	�j�[RRSUS5n[[RRUS55nUR	5R5SSnSSS5 [[RRUS55nUR	5R5SSnSSS5 SRWW/5nS	nXg;agg!,(df   N}=f!,(df   N;=f![a!n[SU<S[U5<35eSnAff=f)
zu
Perform any hardware-specific quirks for the given SR-IOV device to make
sure all the VF-count changes are applied.
r�r��vendorr	Nz,could not determine vendor and device ID of r��:r)	rrrror�r�r�r�rg)r�r�rs�	device_id�	vendor_idr��combined_id�
quirk_devicess        r� perform_hardware_specific_quirksr�~s���
�W�W�\�\�*�B��
9�F�`�
�"�'�'�,�,�v�x�0�
1�Q�������(���,�I�2�
�"�'�'�,�,�v�x�0�
1�Q�������(���,�I�2�
�(�(�I�y�1�2�K��M��#�	
�$�2�
1��
1�
1���`��SU�WZ�[\�W]�^�_�_��`�sM�)D�"C%�.1D�"C6�D�%
C3�/D�6
D�D�D�
D2�D-�-D2c
��Sn[RRUSUS5n[RR[R"U55n[RRUSUS5n[R
"U5Hin	SU	;dM[RRX�5n
[RR[R"U
55nX�:XdMdU	SSn O U(d[
SU<SU<35e[R"SS	S
SUSUS
[U5/	[R[RS9 g![Ra [
SU-5ef=f)z8
Apply the hardware VLAN filtering for the selected VF.
Nz
sys/class/netr��virtfn�z%could not determine the VF index for z while configuring vlan �ipr�rIrHrr�vlan)�stdoutrQzJfailed setting SR-IOV VLAN filter for vlan %s (ip link set command failed))rrrr(r)�listdirr�rJrKrgrUrV)r�rr�	vlan_name�vlan_id�prefix�vf_index�	vf_devdir�	vf_dev_id�	pf_devdirrs�dev_path�dev_ids            r�apply_vlan_filter_for_vfr��sG���H������V�_�b�(�C�I���� � ����Y�!7�8�I������V�_�b�(�C�I�
�Z�Z�	�
"���q�=��w�w�|�|�I�1�H��W�W�%�%�b�k�k�(�&;�<�F��"��Q�R�5���
#���SU�W`�a�c�	c�	f����t�V�U�$�b�#�X�%�s�7�|�5�&0�%7�%7�%/�%7�%7�	9���(�(�f��X�[d�d�f�	f�f�s
�AE�#Fc
���UR5 [R"5nURn[	U5n[U5n[
U5n/nU(a<UR5H(up�[X�5(dMURU5 M* U(a)UHn[U5 M [R"5n0n
UHdnX;nUR(aAUH9n
URU
S9(dMX�;aX�(a[SU-5eX�U'M; MYX�;dM`X�U'Mf UR5GH;up�X>nURnUS;dM[U5n[!U5nUR#5nUU:wdMLUR$(dM_[&R("SR+UUR,55 UR.(a![1UR.UR25 [&R("SUS	US
U35 UR;SSU5 UR.(dGMUR<(aGM[?UR.UR25 GM> [A5nURBR5GHunnURD(dMURFRIS
5nURJnU
RIURL5nU(d+[&R6"SU<SURL<S35 M�URIURFRIS5RL5nUU;a"[SU<SURL<SU<S35e[OX�UU5 URQU5 GM g![4a0n[&R6"SUS[9U535 SnAGN�SnAff=f)zs
Go through all interfaces, identify which ones are SR-IOV VFs, create
them and perform all other necessary setup.
)r|z3matched more than one interface for a VF device: %s)�	switchdev�legacyzFound VFs of {}: {}zUnbinding of VFs for z	 failed: NzChanging eswitch mode from z to z for: rOrSr�zSR-IOV vlan defined for z
 but link z% is either not a VF or has no matchesr�z
interface z for netplan device z (z$) already has an SR-IOV vlan defined))�parserr�r�r�r�r��itemsr�r9r�r�rr
r�r�rr]r2r��debugr:r<rArxr&�	Exceptionr�rgrL�_delay_virtual_functions_rebindrtrI�vlans�_has_sriov_vlan_filterr�rY�_vlan_idr�r�r�)�config_manager�rootdirr�r�r��vfs_setr��vf_count_changedr�r�rArrryrz�	netdef_idr��eswitch_moder�pcidev�current_eswitch_mode_systemr��filtered_vlans_setr�r�r�s                         r�apply_sriov_configr��sT��
�����%�%�'�J��&�&�H�&�h�/�I�%�X�.�G�
!�(�
+�C�
���%�O�O�-�L�B�$�R�2�2���#�#�B�'�	.��#�B�,�R�0�#�
�)�)�+�
�
�C���������
(�	��*�*�i�*�@�@��y�S�W�0�1f�ik�1k�l�l�'��G�	(����B���" �I�I�K��	��$���3�3���2�2�)�%�0�H��x�(�F�*0�*E�*E�*G�'��:�:��<�<�<��M�M�"7�">�">�v�v���"W�X��z�z�b�&�v�z�z�6�=�=�A��M�M�$?�@[�?\�\`�am�`n�nt�u~�t�#A�B��&�&�y�&�,�G��z�z�z�%�E�E�E�$�V�Z�Z����?�+(�.��� ���,�,�.���f��(�(�(��<�<�#�#�F�+�D��o�o�G�������!�B�����ei�ko�kr�kr�s�u��
���������0�3�3�4�B��'�'�(�df�hl�ho�ho�qu�v�x�x�
%�R�T�7�;��"�"�2�&�9/�� )�b�#�O�O�.C�I�;�i�X[�\]�X^�W_�,`�a�a��b�s�% N6�6
O0�%O+�+O0)�/)"rWr�rrJ�typingrrrrr%r�
configmanagerr
r��objectr�Iterablertrx�
NetDefinitionrgrir�r�r��Stater�r�r�r�r�r�r�r�rrr�<module>r�s#��&��	��
�,�,��.��Y��Y�x�&�/�/�)�,���F�O�O�I�.��6�?�?�9�;U��=�w�4�4�=��=��=�!�7�+@�+@�!�X�c�]�!�HY�"�g�m�m���S�#�X���<�G�M�M��d�3��8�n��&�W�]�]��s�3�x��,�^
�:$f�Ns'r

Filemanager

Name Type Size Permission Actions
__init__.cpython-313.pyc File 143 B 0644
core.cpython-313.pyc File 2.77 KB 0644
ovs.cpython-313.pyc File 7.62 KB 0644
sriov.cpython-313.pyc File 22.89 KB 0644
state.cpython-313.pyc File 35.3 KB 0644
state_diff.cpython-313.pyc File 38.25 KB 0644
utils.cpython-313.pyc File 17.91 KB 0644
Filemanager