Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting CoS (PCP, 802.1P) in Ethernet frame

Tags:

c

linux

sockets

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.

like image 695
Kylo Avatar asked Dec 07 '12 14:12

Kylo


Video Answer


2 Answers

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...

like image 143
falstaff Avatar answered Sep 18 '22 08:09

falstaff


There are ingress and egress mappings on each VLAN device. For example:

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 mappings on the last two lines.

like image 40
Tel Avatar answered Sep 19 '22 08:09

Tel