openmainframeproject / feilong

Feilong is a open source z/VM cloud connector project under the Open Mainframe Project umbrella that will accelerate the z/VM adoption, extending its ecosystem and its user experience. It provides a set of APIs to operate z/VM including guest, image, network, volume etc.
https://www.openmainframeproject.org/projects/feilong
Apache License 2.0
36 stars 70 forks source link

Avoid the duplicated granting userid to vswitch #810

Closed SeanHQF closed 8 months ago

SeanHQF commented 9 months ago

Check if the userid has already been granted for the vswitch, if yes, then do nothing. Otherwise, it will cause the existing NICs in the VM down on the vswitch.

SeanHQF commented 9 months ago

@jichenjc @bjhuangr @zhshuj pls help review, thx

SeanHQF commented 9 months ago

pls help review and merge, thx

jichenjc commented 9 months ago

mostly good

@zhshuj please help review as well especially the logic then we can merge this

zhshuj commented 9 months ago

mostly good

@zhshuj please help review as well especially the logic then we can merge this

I also have the same confusion about user access to vswitch when attaching interface with differnt vlan ids. At last found it is the Virtual_Network_Adapter_Connect_Vswitch SMAPI call that connect to vswitch and also grant access to vswitch at the same time.

So the code changes LGTM.

Some info, fyi. Before the Virtual_Network_Adapter_Connect_Vswitch call in attaching NIC operation; the ZSJA002B only access to vswitch VSICICA with VLAN ID 100.

VSWITCH SYSTEM VSICICA    Type: QDIO    Connected: 1    Maxconn: INFINITE    
  PERSISTENT  RESTRICTED    ETHERNET                  Accounting: OFF        
  USERBASED LOCAL                                                            
  VLAN Aware  Default VLAN: NONE    Default Porttype: Access  GVRP: Enabled  
              Native  VLAN: 0001    VLAN Counters: OFF                       
  MAC address: 02-01-0C-00-00-03    MAC Protection: Unspecified              
  IPTimeout: 5         QueueStorage: 8                                       
  Isolation Status: OFF        VEPA Status: OFF                              
  Unicast IP address count: 1                                                
 Uplink Port:                                                                
  State: Ready                         PriQueuing: OFF                       
  PMTUD setting: EXTERNAL   PMTUD value: 9000     Trace Pages: 8             
  RDEV: 3600.P00 VDEV: 0606 Controller: DTCVSW1  ACTIVE                      
        Adapter ID: 8561000282A8.01CC                                        
    Uplink Port Connection:                                                  
      RX Packets: 37484242   Discarded: 124712     Errors: 0                 
      TX Packets: 61870      Discarded: 0          Errors: 0                 
      RX Bytes: 2222979161           TX Bytes: 4158249                       
      Device: 0606  Unit: 000   Role: DATA       Port: 2049                  
      Partner Switch Capabilities: No_Reflective_Relay                       
  RDEV: 3700.P00 VDEV: 0600 Controller: DTCVSW4  BACKUP
  Adapter ID: 8561000282A8.01EC                      
 Adapter Connections:                            Connected: 1            
    Adapter Owner: ZSJA002B NIC: 1000.P00 Name: HYD1G1      Type: QDIO   
      PQUplinkTX: Normal                                                 
      Porttype: Access                                                   
      RX Packets: 0          Discarded: 0          Errors: 0             
      TX Packets: 26         Discarded: 0          Errors: 0             
      RX Bytes: 0                    TX Bytes: 1600                      
      Device: 1002  Unit: 002   Role: DATA       Port: 2176              
      VLAN: 0100                                                         
      Options: Ethernet Broadcast                                        
        Unicast MAC Addresses:                                           
          02-01-0C-07-64-D7 IP: 10.10.100.3                              
        Multicast MAC Addresses:                                         
          01-00-5E-00-00-01                                              
          33-33-00-00-00-01                                              
          33-33-FF-07-64-D7   

Exactly after the call, it has added another connection with vlan 726, which is the vlan network I attached to VM zsja002B.

Adapter Connections:                            Connected: 2            
   Adapter Owner: ZSJA002B NIC: 1000.P00 Name: HYD1G1      Type: QDIO   
     PQUplinkTX: Normal                                                 
     Porttype: Access                                                   
     RX Packets: 0          Discarded: 0          Errors: 0             
     TX Packets: 28         Discarded: 0          Errors: 0             
     RX Bytes: 0                    TX Bytes: 1748                      
     Device: 1002  Unit: 002   Role: DATA       Port: 2176              
     VLAN: 0100                                                         
     Options: Ethernet Broadcast                                        
       Unicast MAC Addresses:                                           
         02-01-0C-07-64-D7 IP: 10.10.100.3                              
       Multicast MAC Addresses:                                         
         01-00-5E-00-00-01                                              
         33-33-00-00-00-01                                              
 Adapter Owner: ZSJA002B NIC: 1003.P00 Name: HYD1G1      Type: QDIO    
   PQUplinkTX: Normal                                                  
   Porttype: Access                                                    
   RX Packets: 356        Discarded: 0          Errors: 0              
   TX Packets: 0          Discarded: 0          Errors: 0              
   RX Bytes: 19208                TX Bytes: 0                          
   Device: 1005  Unit: 002   Role: DATA       Port: 2177               
   VLAN: 0726                                                          
   Options: Ethernet Broadcast    
        Unicast MAC Addresses:       
          02-01-0C-00-00-55          
        Multicast MAC Addresses:     
          01-00-5E-00-00-01          
          33-33-00-00-00-01          
SeanHQF commented 9 months ago

At last found it is the Virtual_Network_Adapter_Connect_Vswitch SMAPI call that connect to vswitch and also grant access to vswitch at the same time.

To confirm, this is done by the zcc call guest_nic_couple_to_vswitch which is also from neutron zvm agent, right? So there are 2 steps: the 1st is grant VM's userid to the vswitch and the 2nd is couple the nic to it?

zhshuj commented 9 months ago

At last found it is the Virtual_Network_Adapter_Connect_Vswitch SMAPI call that connect to vswitch and also grant access to vswitch at the same time.

To confirm, this is done by the zcc call guest_nic_couple_to_vswitch which is also from neutron zvm agent, right? So there are 2 steps: the 1st is grant VM's userid to the vswitch and the 2nd is couple the nic to it?

Yes. But seems grant VM's userid is not necessary any more. we can check later.