Setting CoS (PCP, 802.1P) in Ethernet frame
c, linux, sockets
Solution
You can set the vlan priority field by using sockopt():
int priority = 7;
setsockopt(sfd, SOL_SOCKET, SO_PRIORITY, &priority, sizeof(priority));
In the file net/8021q/vlan_dev.c you can see, that the skb->priority field is used for the VLAN 802.1Q TCI...
Problem
Is there any way I can manipulate the value of Priority Code Point (PCP) field in the Ethernet frame from my application (e.g. using `setsockopt()`)? I would like to avoid low level hacks with creating Ethernet frame from scratch. I've searched in manual pages `socket(7)` and `ip(7)` but there is no option for controlling Ethernet frames fields. If this is relevant I need it for TCP socket.