History

netfilter: nft_queue: add _SREG_QNUM attr to select the queue number

Currently, the user can specify the queue numbers by _QUEUE_NUM and _QUEUE_TOTAL attributes, this is enough in most situations. But acctually, it is not very flexible, for example: tcp dport 80 mapped to queue0 tcp dport 81 mapped to queue1 tcp dport 82 mapped to queue2 In order to do this thing, we must add 3 nft rules, and more mapping meant more rules ... So take one register to select the queue number, then we can add one simple rule to mapping queues, maybe like this: queue num tcp dport map { 80:0, 81:1, 82:2 ... } Florian Westphal also proposed wider usage scenarios: queue num jhash ip saddr . ip daddr mod ... queue num meta cpu ... queue num meta mark ... The last point is how to load a queue number from sreg, although we can use *(u16*)&regs->data[reg] to load the queue number, just like nat expr to load its l4port do. But we will cooperate with hash expr, meta cpu, meta mark expr and so on. They all store the result to u32 type, so cast it to u16 pointer and dereference it will generate wrong result in the big endian system. So just keep it simple, we treat queue number as u32 type, although u16 type is already enough.

Liping Zhang committed 10 years ago

Commit 8061bb51 parent 36b701f2 files · +92 −12Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/netfilter/nf_tables.h+2−0
@@ -894,12 +894,14 @@ enum nft_log_attributes { · 893 unmodified lines
894 * @NFTA_QUEUE_NUM: netlink queue to send messages to (NLA_U16)894 * @NFTA_QUEUE_NUM: netlink queue to send messages to (NLA_U16)
895 * @NFTA_QUEUE_TOTAL: number of queues to load balance packets on (NLA_U16)895 * @NFTA_QUEUE_TOTAL: number of queues to load balance packets on (NLA_U16)
896 * @NFTA_QUEUE_FLAGS: various flags (NLA_U16)896 * @NFTA_QUEUE_FLAGS: various flags (NLA_U16)
897 * @NFTA_QUEUE_SREG_QNUM: source register of queue number (NLA_U32: nft_registers)
897 */898 */
898enum nft_queue_attributes {899enum nft_queue_attributes {
899 NFTA_QUEUE_UNSPEC,900 NFTA_QUEUE_UNSPEC,
900 NFTA_QUEUE_NUM,901 NFTA_QUEUE_NUM,
901 NFTA_QUEUE_TOTAL,902 NFTA_QUEUE_TOTAL,
902 NFTA_QUEUE_FLAGS,903 NFTA_QUEUE_FLAGS,
904 NFTA_QUEUE_SREG_QNUM,
903 __NFTA_QUEUE_MAX905 __NFTA_QUEUE_MAX
904};906};
905#define NFTA_QUEUE_MAX (__NFTA_QUEUE_MAX - 1)907#define NFTA_QUEUE_MAX (__NFTA_QUEUE_MAX - 1)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t