Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

af_packet: Add Queue mapping mode to af_packet fanout operation

This patch adds a queue mapping mode to the fanout operation of af_packet
sockets. This allows user space af_packet users to better filter on flows
ingressing and egressing via a specific hardware queue, and avoids the potential
packet reordering that can occur when FANOUT_CPU is being used and irq affinity
varies.

Tested successfully by myself. applies to net-next

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Neil Horman and committed by
David S. Miller
2d36097d b414ac9a

+12
+1
include/uapi/linux/if_packet.h
··· 60 60 #define PACKET_FANOUT_CPU 2 61 61 #define PACKET_FANOUT_ROLLOVER 3 62 62 #define PACKET_FANOUT_RND 4 63 + #define PACKET_FANOUT_QM 5 63 64 #define PACKET_FANOUT_FLAG_ROLLOVER 0x1000 64 65 #define PACKET_FANOUT_FLAG_DEFRAG 0x8000 65 66
+11
net/packet/af_packet.c
··· 1312 1312 return idx; 1313 1313 } 1314 1314 1315 + static unsigned int fanout_demux_qm(struct packet_fanout *f, 1316 + struct sk_buff *skb, 1317 + unsigned int num) 1318 + { 1319 + return skb_get_queue_mapping(skb) % num; 1320 + } 1321 + 1315 1322 static bool fanout_has_flag(struct packet_fanout *f, u16 flag) 1316 1323 { 1317 1324 return f->flags & (flag >> 8); ··· 1357 1350 break; 1358 1351 case PACKET_FANOUT_RND: 1359 1352 idx = fanout_demux_rnd(f, skb, num); 1353 + break; 1354 + case PACKET_FANOUT_QM: 1355 + idx = fanout_demux_qm(f, skb, num); 1360 1356 break; 1361 1357 case PACKET_FANOUT_ROLLOVER: 1362 1358 idx = fanout_demux_rollover(f, skb, 0, (unsigned int) -1, num); ··· 1431 1421 case PACKET_FANOUT_LB: 1432 1422 case PACKET_FANOUT_CPU: 1433 1423 case PACKET_FANOUT_RND: 1424 + case PACKET_FANOUT_QM: 1434 1425 break; 1435 1426 default: 1436 1427 return -EINVAL;