Skip to content

Commit 68e8b84

Browse files
Björn TöpelAlexei Starovoitov
authored andcommitted
net: initial AF_XDP skeleton
Buildable skeleton of AF_XDP without any functionality. Just what it takes to register a new address family. Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 03f5781 commit 68e8b84

File tree

7 files changed

+34
-7
lines changed

7 files changed

+34
-7
lines changed

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15424,6 +15424,14 @@ T: git git://linuxtv.org/media_tree.git
1542415424
S: Maintained
1542515425
F: drivers/media/tuners/tuner-xc2028.*
1542615426

15427+
XDP SOCKETS (AF_XDP)
15428+
M: Björn Töpel <bjorn.topel@intel.com>
15429+
M: Magnus Karlsson <magnus.karlsson@intel.com>
15430+
L: netdev@vger.kernel.org
15431+
S: Maintained
15432+
F: kernel/bpf/xskmap.c
15433+
F: net/xdp/
15434+
1542715435
XEN BLOCK SUBSYSTEM
1542815436
M: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
1542915437
M: Roger Pau Monné <roger.pau@citrix.com>

include/linux/socket.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ struct ucred {
207207
* PF_SMC protocol family that
208208
* reuses AF_INET address family
209209
*/
210+
#define AF_XDP 44 /* XDP sockets */
210211

211-
#define AF_MAX 44 /* For now.. */
212+
#define AF_MAX 45 /* For now.. */
212213

213214
/* Protocol families, same as address families. */
214215
#define PF_UNSPEC AF_UNSPEC
@@ -257,6 +258,7 @@ struct ucred {
257258
#define PF_KCM AF_KCM
258259
#define PF_QIPCRTR AF_QIPCRTR
259260
#define PF_SMC AF_SMC
261+
#define PF_XDP AF_XDP
260262
#define PF_MAX AF_MAX
261263

262264
/* Maximum queue length specifiable by listen. */
@@ -338,6 +340,7 @@ struct ucred {
338340
#define SOL_NFC 280
339341
#define SOL_KCM 281
340342
#define SOL_TLS 282
343+
#define SOL_XDP 283
341344

342345
/* IPX options */
343346
#define IPX_TYPE 1

net/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ source "net/tls/Kconfig"
5959
source "net/xfrm/Kconfig"
6060
source "net/iucv/Kconfig"
6161
source "net/smc/Kconfig"
62+
source "net/xdp/Kconfig"
6263

6364
config INET
6465
bool "TCP/IP networking"

net/core/sock.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ static struct lock_class_key af_family_kern_slock_keys[AF_MAX];
226226
x "AF_RXRPC" , x "AF_ISDN" , x "AF_PHONET" , \
227227
x "AF_IEEE802154", x "AF_CAIF" , x "AF_ALG" , \
228228
x "AF_NFC" , x "AF_VSOCK" , x "AF_KCM" , \
229-
x "AF_QIPCRTR", x "AF_SMC" , x "AF_MAX"
229+
x "AF_QIPCRTR", x "AF_SMC" , x "AF_XDP" , \
230+
x "AF_MAX"
230231

231232
static const char *const af_family_key_strings[AF_MAX+1] = {
232233
_sock_locks("sk_lock-")
@@ -262,7 +263,8 @@ static const char *const af_family_rlock_key_strings[AF_MAX+1] = {
262263
"rlock-AF_RXRPC" , "rlock-AF_ISDN" , "rlock-AF_PHONET" ,
263264
"rlock-AF_IEEE802154", "rlock-AF_CAIF" , "rlock-AF_ALG" ,
264265
"rlock-AF_NFC" , "rlock-AF_VSOCK" , "rlock-AF_KCM" ,
265-
"rlock-AF_QIPCRTR", "rlock-AF_SMC" , "rlock-AF_MAX"
266+
"rlock-AF_QIPCRTR", "rlock-AF_SMC" , "rlock-AF_XDP" ,
267+
"rlock-AF_MAX"
266268
};
267269
static const char *const af_family_wlock_key_strings[AF_MAX+1] = {
268270
"wlock-AF_UNSPEC", "wlock-AF_UNIX" , "wlock-AF_INET" ,
@@ -279,7 +281,8 @@ static const char *const af_family_wlock_key_strings[AF_MAX+1] = {
279281
"wlock-AF_RXRPC" , "wlock-AF_ISDN" , "wlock-AF_PHONET" ,
280282
"wlock-AF_IEEE802154", "wlock-AF_CAIF" , "wlock-AF_ALG" ,
281283
"wlock-AF_NFC" , "wlock-AF_VSOCK" , "wlock-AF_KCM" ,
282-
"wlock-AF_QIPCRTR", "wlock-AF_SMC" , "wlock-AF_MAX"
284+
"wlock-AF_QIPCRTR", "wlock-AF_SMC" , "wlock-AF_XDP" ,
285+
"wlock-AF_MAX"
283286
};
284287
static const char *const af_family_elock_key_strings[AF_MAX+1] = {
285288
"elock-AF_UNSPEC", "elock-AF_UNIX" , "elock-AF_INET" ,
@@ -296,7 +299,8 @@ static const char *const af_family_elock_key_strings[AF_MAX+1] = {
296299
"elock-AF_RXRPC" , "elock-AF_ISDN" , "elock-AF_PHONET" ,
297300
"elock-AF_IEEE802154", "elock-AF_CAIF" , "elock-AF_ALG" ,
298301
"elock-AF_NFC" , "elock-AF_VSOCK" , "elock-AF_KCM" ,
299-
"elock-AF_QIPCRTR", "elock-AF_SMC" , "elock-AF_MAX"
302+
"elock-AF_QIPCRTR", "elock-AF_SMC" , "elock-AF_XDP" ,
303+
"elock-AF_MAX"
300304
};
301305

302306
/*

net/xdp/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
config XDP_SOCKETS
2+
bool "XDP sockets"
3+
depends on BPF_SYSCALL
4+
default n
5+
help
6+
XDP sockets allows a channel between XDP programs and
7+
userspace applications.

security/selinux/hooks.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,9 @@ static inline u16 socket_type_to_security_class(int family, int type, int protoc
14711471
return SECCLASS_QIPCRTR_SOCKET;
14721472
case PF_SMC:
14731473
return SECCLASS_SMC_SOCKET;
1474-
#if PF_MAX > 44
1474+
case PF_XDP:
1475+
return SECCLASS_XDP_SOCKET;
1476+
#if PF_MAX > 45
14751477
#error New address family defined, please update this function.
14761478
#endif
14771479
}

security/selinux/include/classmap.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,11 @@ struct security_class_mapping secclass_map[] = {
240240
{ "manage_subnet", NULL } },
241241
{ "bpf",
242242
{"map_create", "map_read", "map_write", "prog_load", "prog_run"} },
243+
{ "xdp_socket",
244+
{ COMMON_SOCK_PERMS, NULL } },
243245
{ NULL }
244246
};
245247

246-
#if PF_MAX > 44
248+
#if PF_MAX > 45
247249
#error New address family defined, please update secclass_map.
248250
#endif

0 commit comments

Comments
 (0)