Configuring CoS (PCP, 802.1P) in an Ethernet Frame

Is there any way to manipulate the value of the Priority Code Point (PCP) field in the Ethernet frame from my application (for example, using setsockopt() )? I would like to avoid low level hackers with creating an Ethernet frame from scratch.

I searched on the manual pages for socket(7) and ip(7) , but there is no way to manage the fields of Ethernet frames.

If relevant, I need this for a TCP socket.

+4
source share
2 answers

You can set the vlan priority field 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 priority field skb-> is used for VLAN 802.1Q TCI ...

+4
source

Each VLAN device has inbound and outbound mappings. For instance:

 vconfig add eth0 333 vconfig set_egress_map eth0.333 2 4 vconfig set_egress_map eth0.333 3 5 cat /proc/net/vlan/eth0.333 

You can see the mappings on the last two lines.

+1
source

All Articles