Skip to content

Commit 4e1beec

Browse files
Tariq Toukandavem330
authored andcommitted
net/sock: Add kernel config SOCK_RX_QUEUE_MAPPING
Use a new config SOCK_RX_QUEUE_MAPPING to compile-in the socket RX queue field and logic, instead of the XPS config. This breaks dependency in XPS, and allows selecting it from non-XPS use cases, as we do in the next patch. In addition, use the new flag to wrap the logic in sk_rx_queue_get() and protect access to the sk_rx_queue_mapping field, while keeping the function exposed unconditionally, just like sk_rx_queue_set() and sk_rx_queue_clear(). Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Maxim Mikityanskiy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3c5a2fd commit 4e1beec

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

include/net/sock.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ struct sock_common {
226226
struct hlist_nulls_node skc_nulls_node;
227227
};
228228
unsigned short skc_tx_queue_mapping;
229-
#ifdef CONFIG_XPS
229+
#ifdef CONFIG_SOCK_RX_QUEUE_MAPPING
230230
unsigned short skc_rx_queue_mapping;
231231
#endif
232232
union {
@@ -356,7 +356,7 @@ struct sock {
356356
#define sk_nulls_node __sk_common.skc_nulls_node
357357
#define sk_refcnt __sk_common.skc_refcnt
358358
#define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping
359-
#ifdef CONFIG_XPS
359+
#ifdef CONFIG_SOCK_RX_QUEUE_MAPPING
360360
#define sk_rx_queue_mapping __sk_common.skc_rx_queue_mapping
361361
#endif
362362

@@ -1838,7 +1838,7 @@ static inline int sk_tx_queue_get(const struct sock *sk)
18381838

18391839
static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb)
18401840
{
1841-
#ifdef CONFIG_XPS
1841+
#ifdef CONFIG_SOCK_RX_QUEUE_MAPPING
18421842
if (skb_rx_queue_recorded(skb)) {
18431843
u16 rx_queue = skb_get_rx_queue(skb);
18441844

@@ -1852,20 +1852,20 @@ static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb)
18521852

18531853
static inline void sk_rx_queue_clear(struct sock *sk)
18541854
{
1855-
#ifdef CONFIG_XPS
1855+
#ifdef CONFIG_SOCK_RX_QUEUE_MAPPING
18561856
sk->sk_rx_queue_mapping = NO_QUEUE_MAPPING;
18571857
#endif
18581858
}
18591859

1860-
#ifdef CONFIG_XPS
18611860
static inline int sk_rx_queue_get(const struct sock *sk)
18621861
{
1862+
#ifdef CONFIG_SOCK_RX_QUEUE_MAPPING
18631863
if (sk && sk->sk_rx_queue_mapping != NO_QUEUE_MAPPING)
18641864
return sk->sk_rx_queue_mapping;
1865+
#endif
18651866

18661867
return -1;
18671868
}
1868-
#endif
18691869

18701870
static inline void sk_set_socket(struct sock *sk, struct socket *sock)
18711871
{

net/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,13 @@ config RFS_ACCEL
256256
select CPU_RMAP
257257
default y
258258

259+
config SOCK_RX_QUEUE_MAPPING
260+
bool
261+
259262
config XPS
260263
bool
261264
depends on SMP
265+
select SOCK_RX_QUEUE_MAPPING
262266
default y
263267

264268
config HWBM

net/core/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8814,7 +8814,7 @@ u32 bpf_sock_convert_ctx_access(enum bpf_access_type type,
88148814
target_size));
88158815
break;
88168816
case offsetof(struct bpf_sock, rx_queue_mapping):
8817-
#ifdef CONFIG_XPS
8817+
#ifdef CONFIG_SOCK_RX_QUEUE_MAPPING
88188818
*insn++ = BPF_LDX_MEM(
88198819
BPF_FIELD_SIZEOF(struct sock, sk_rx_queue_mapping),
88208820
si->dst_reg, si->src_reg,

0 commit comments

Comments
 (0)