net/vlan: fix issue of vlan pcp config

Fix a issue of vlan pcp config.
`vconfig add eth0 10` will create eth0.10 with VID=10 and no PCP(0)
`vconfig add eth0 10 3` will create eth0.10 with VID=10 and PCP=3

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
This commit is contained in:
gaohedong 2026-01-11 11:51:54 +08:00 committed by Xiang Xiao
parent 21f4156048
commit d594c953a1

View file

@ -42,13 +42,14 @@
* Parameters:
* ifname - The name of the existing network device
* vlanid - The VLAN identifier to be added
* prio - The default VLAN priority (PCP)
*
* Return:
* 0 on success; -1 on failure
*
****************************************************************************/
int netlib_add_vlan(FAR const char *ifname, int vlanid)
int netlib_add_vlan(FAR const char *ifname, int vlanid, int prio)
{
int ret = ERROR;
@ -60,8 +61,9 @@ int netlib_add_vlan(FAR const char *ifname, int vlanid)
struct vlan_ioctl_args ifv;
strlcpy(ifv.device1, ifname, sizeof(ifv.device1));
ifv.u.VID = vlanid;
ifv.cmd = ADD_VLAN_CMD;
ifv.u.VID = vlanid;
ifv.vlan_qos = prio;
ifv.cmd = ADD_VLAN_CMD;
ret = ioctl(sockfd, SIOCSIFVLAN, &ifv);
close(sockfd);