net: initial AF_XDP skeleton
authorBjörn Töpel <bjorn.topel@intel.com>
Wed, 2 May 2018 11:01:22 +0000 (13:01 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 3 May 2018 22:55:23 +0000 (15:55 -0700)
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>
MAINTAINERS
include/linux/socket.h
net/Kconfig
net/core/sock.c
net/xdp/Kconfig [new file with mode: 0644]
security/selinux/hooks.c
security/selinux/include/classmap.h

index 537fd17a211b51230f1fdc7fe6c21c98a2fcf1fc..52d246fd29c949e1de0052ea034ba47666b3e33d 100644 (file)
@@ -15424,6 +15424,14 @@ T:     git git://linuxtv.org/media_tree.git
 S:     Maintained
 F:     drivers/media/tuners/tuner-xc2028.*
 
+XDP SOCKETS (AF_XDP)
+M:     Björn Töpel <bjorn.topel@intel.com>
+M:     Magnus Karlsson <magnus.karlsson@intel.com>
+L:     netdev@vger.kernel.org
+S:     Maintained
+F:     kernel/bpf/xskmap.c
+F:     net/xdp/
+
 XEN BLOCK SUBSYSTEM
 M:     Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
 M:     Roger Pau Monné <roger.pau@citrix.com>
index ea50f4a6581622be6d6246b0d604fdb911a6e441..7ed4713d533727ff53d199e4982139d93e16ec7b 100644 (file)
@@ -207,8 +207,9 @@ struct ucred {
                                 * PF_SMC protocol family that
                                 * reuses AF_INET address family
                                 */
+#define AF_XDP         44      /* XDP sockets                  */
 
-#define AF_MAX         44      /* For now.. */
+#define AF_MAX         45      /* For now.. */
 
 /* Protocol families, same as address families. */
 #define PF_UNSPEC      AF_UNSPEC
@@ -257,6 +258,7 @@ struct ucred {
 #define PF_KCM         AF_KCM
 #define PF_QIPCRTR     AF_QIPCRTR
 #define PF_SMC         AF_SMC
+#define PF_XDP         AF_XDP
 #define PF_MAX         AF_MAX
 
 /* Maximum queue length specifiable by listen.  */
@@ -338,6 +340,7 @@ struct ucred {
 #define SOL_NFC                280
 #define SOL_KCM                281
 #define SOL_TLS                282
+#define SOL_XDP                283
 
 /* IPX options */
 #define IPX_TYPE       1
index 6fa1a4493b8c7233053a4976fdb3671cfb584fbd..86471a1c1ed4c8fd6040ecf62a1927077b1d9bfc 100644 (file)
@@ -59,6 +59,7 @@ source "net/tls/Kconfig"
 source "net/xfrm/Kconfig"
 source "net/iucv/Kconfig"
 source "net/smc/Kconfig"
+source "net/xdp/Kconfig"
 
 config INET
        bool "TCP/IP networking"
index b2c3db169ca1892c4d624fc5e30af12f4eed0adb..e7d8b6c955c68da6d6c18cf04beb662adab20b1f 100644 (file)
@@ -226,7 +226,8 @@ static struct lock_class_key af_family_kern_slock_keys[AF_MAX];
   x "AF_RXRPC" ,       x "AF_ISDN"     ,       x "AF_PHONET"   , \
   x "AF_IEEE802154",   x "AF_CAIF"     ,       x "AF_ALG"      , \
   x "AF_NFC"   ,       x "AF_VSOCK"    ,       x "AF_KCM"      , \
-  x "AF_QIPCRTR",      x "AF_SMC"      ,       x "AF_MAX"
+  x "AF_QIPCRTR",      x "AF_SMC"      ,       x "AF_XDP"      , \
+  x "AF_MAX"
 
 static const char *const af_family_key_strings[AF_MAX+1] = {
        _sock_locks("sk_lock-")
@@ -262,7 +263,8 @@ static const char *const af_family_rlock_key_strings[AF_MAX+1] = {
   "rlock-AF_RXRPC" , "rlock-AF_ISDN"     , "rlock-AF_PHONET"   ,
   "rlock-AF_IEEE802154", "rlock-AF_CAIF" , "rlock-AF_ALG"      ,
   "rlock-AF_NFC"   , "rlock-AF_VSOCK"    , "rlock-AF_KCM"      ,
-  "rlock-AF_QIPCRTR", "rlock-AF_SMC"     , "rlock-AF_MAX"
+  "rlock-AF_QIPCRTR", "rlock-AF_SMC"     , "rlock-AF_XDP"      ,
+  "rlock-AF_MAX"
 };
 static const char *const af_family_wlock_key_strings[AF_MAX+1] = {
   "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] = {
   "wlock-AF_RXRPC" , "wlock-AF_ISDN"     , "wlock-AF_PHONET"   ,
   "wlock-AF_IEEE802154", "wlock-AF_CAIF" , "wlock-AF_ALG"      ,
   "wlock-AF_NFC"   , "wlock-AF_VSOCK"    , "wlock-AF_KCM"      ,
-  "wlock-AF_QIPCRTR", "wlock-AF_SMC"     , "wlock-AF_MAX"
+  "wlock-AF_QIPCRTR", "wlock-AF_SMC"     , "wlock-AF_XDP"      ,
+  "wlock-AF_MAX"
 };
 static const char *const af_family_elock_key_strings[AF_MAX+1] = {
   "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] = {
   "elock-AF_RXRPC" , "elock-AF_ISDN"     , "elock-AF_PHONET"   ,
   "elock-AF_IEEE802154", "elock-AF_CAIF" , "elock-AF_ALG"      ,
   "elock-AF_NFC"   , "elock-AF_VSOCK"    , "elock-AF_KCM"      ,
-  "elock-AF_QIPCRTR", "elock-AF_SMC"     , "elock-AF_MAX"
+  "elock-AF_QIPCRTR", "elock-AF_SMC"     , "elock-AF_XDP"      ,
+  "elock-AF_MAX"
 };
 
 /*
diff --git a/net/xdp/Kconfig b/net/xdp/Kconfig
new file mode 100644 (file)
index 0000000..90e4a71
--- /dev/null
@@ -0,0 +1,7 @@
+config XDP_SOCKETS
+       bool "XDP sockets"
+       depends on BPF_SYSCALL
+       default n
+       help
+         XDP sockets allows a channel between XDP programs and
+         userspace applications.
index 4cafe6a19167613cb64b29ac59c895e91285b390..5c508d26b3675908f7301efca40fbdcbcf6b0d3b 100644 (file)
@@ -1471,7 +1471,9 @@ static inline u16 socket_type_to_security_class(int family, int type, int protoc
                        return SECCLASS_QIPCRTR_SOCKET;
                case PF_SMC:
                        return SECCLASS_SMC_SOCKET;
-#if PF_MAX > 44
+               case PF_XDP:
+                       return SECCLASS_XDP_SOCKET;
+#if PF_MAX > 45
 #error New address family defined, please update this function.
 #endif
                }
index 7f0372426494827a57f598412c0228c79d9ba42d..bd5fe0d3204ae98b67b234a1459f01f01ddc1d78 100644 (file)
@@ -240,9 +240,11 @@ struct security_class_mapping secclass_map[] = {
          { "manage_subnet", NULL } },
        { "bpf",
          {"map_create", "map_read", "map_write", "prog_load", "prog_run"} },
+       { "xdp_socket",
+         { COMMON_SOCK_PERMS, NULL } },
        { NULL }
   };
 
-#if PF_MAX > 44
+#if PF_MAX > 45
 #error New address family defined, please update secclass_map.
 #endif