zhhyu7 opened a new pull request, #17452:
URL: https://github.com/apache/nuttx/pull/17452

   ## Summary
   Inspired by Linux's way, we also create VLAN devices for managing VLAN,
   which will become interfaces like `eth0.58`.
   
   QinQ is also supported, we can create VLAN devices above another VLAN
   devices, like `eth0.100.101` (or even `eth0.1.2.3.4`, also supported on
   Linux).
   
   Supporting ADD_VLAN_CMD and DEL_VLAN_CMD of SIOCSIFVLAN
   Ref: https://github.com/torvalds/linux/blob/v6.12/net/8021q/vlan.c#L621
   
   We add default PCP because some of our apps may not want to set PCP
   manually (e.g. Our user may just ping with pre-set PCP)
   
   The `vlan_qos` is used as PCP when setting Linux's priority mapping:
   https://github.com/torvalds/linux/blob/v6.12/net/8021q/vlan.c#L590
   Although `vlan_qos` is not used when creating VLAN on Linux, we can
   use it as PCP on creating VLAN (without changing its meaning), and
   keep compatible with Linux's creating (Exactly the same when
   `vlan_qos` is 0).
   
   ## Impact
   Users can create VLAN network device of various priorities through ioctl.
   
   ## Testing
   sim:matter with creates the VLAN network device on the sim eth0 device.
   ```
   int netlib_add_vlan(FAR const char *ifname, int vlanid, int prio)            
   {                                                                            
     int ret = ERROR;                                                           
                                                                                
     if (ifname && vlanid > 0)                                                  
       {                                                                        
         int sockfd = socket(NET_SOCK_FAMILY, NET_SOCK_TYPE, NET_SOCK_PROTOCOL);
         if (sockfd >= 0)                                                       
           {                                                                    
             struct vlan_ioctl_args ifv;                                        
                                                                                
             strlcpy(ifv.device1, ifname, sizeof(ifv.device1));                 
             ifv.u.VID    = vlanid;                                             
             ifv.vlan_qos = prio;                                               
             ifv.cmd      = ADD_VLAN_CMD;                                       
                                                                                
             ret = ioctl(sockfd, SIOCSIFVLAN, &ifv);                            
             close(sockfd);                                                     
           }                                                                    
       }                                                                        
                                                                                
     return ret;                                                                
   }                                                                            
   ```
   Then test the functionality and performance of the VLAN network card using 
tools such as ping and iperf2.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to