Netchannel implementation. Netfilter and userspace netchannels.
Subsystems (3)
Network channel [1] is peer-to-peer protocol agnostic communication channel between hardware and userspace. It uses unified cache to store it's channels, allows to allocate buffers for data from userspace mapped area or from other preallocated set of pages (like VFS cache). All protocol processing happens in process' context.
Netchannel features:
o multidimensional wildcards support
o RCU searching
o single multidimensional trie for different kinds of dataflows
o dedicated processing threads with possibility to schedule processing on different CPUs for those netchannel types which are not acked with processing context
o userspace netchannel backend (allows to receive packets to userspace), which can be used for:
* high-performance sniffers
* tun/tap device replacement
* packet socket replacement (note, that netchannels steal packets from main stack)
* userspace network stack implementation [2]
* own protocol stack implementaion (from VPN tunnels to TOE)
o netfilter netchannel backend (only NAT is supported as the most interesting user, NAT caches appropriate route, so essentially routing becomes part of the netchannel trie)
Multidimensional wildcard is implemented as trie, details can be found in development track on the netchannels site [1].
Some testing was done in 'emulator', i.e. pre-netchannel userspace multidimensional trie implementation. Results are here [3].
1. Netchannel homepage.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=netchannel
2. Userspace network stack with bechmarks [not yet updated to curent API changes]. New version will be available around Dec 21.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=unetstack
3. Multidemnsional trie testing.
http://tservice.net.ru/~s0mbre/blog/2006/12/02#2006_12_02
Code is in development state, but I would like to hear comments about overall design, features, usefullness for the kernel and get feedback on kernel side.
Thank you.
arch/i386/kernel/syscall_table.S +1 -0
@@ -319,3 +319,4 @@ ENTRY(sys_call_table) .long sys_move_pages .long sys_getcpu .long sys_epoll_pwait + .long sys_netchannel_control
arch/x86_64/ia32/ia32entry.S +1 -0
@@ -718,4 +718,5 @@ ia32_sys_call_table: .quad compat_sys_vmsplice .quad compat_sys_move_pages .quad sys_getcpu + .quad sys_netchannel_control ia32_syscall_end:
include/asm-i386/unistd.h +2 -1
@@ -325,10 +325,11 @@#define __NR_move_pages 317#define __NR_getcpu 318#define __NR_epoll_pwait 319 +#define __NR_netchannel_control 320#ifdef __KERNEL__ -#define NR_syscalls 320 +#define NR_syscalls 321#include <linux/err.h> /*
include/asm-x86_64/unistd.h +3 -1
@@ -619,8 +619,10 @@ __SYSCALL(__NR_sync_file_range, sys_sync_file_range) __SYSCALL(__NR_vmsplice, sys_vmsplice)#define __NR_move_pages 279 __SYSCALL(__NR_move_pages, sys_move_pages) +#define __NR_netchannel_control 280 +__SYSCALL(__NR_netchannel_control, sys_netchannel_control) -#define __NR_syscall_max __NR_move_pages +#define __NR_syscall_max __NR_netchannel_control#ifdef __KERNEL__#include <linux/err.h>
include/linux/connector.h +3 -1
@@ -36,9 +36,11 @@#define CN_VAL_CIFS 0x1#define CN_W1_IDX 0x3/* w1 communication */ #define CN_W1_VAL 0x1 +#define CN_NETCHANNELS_IDX 0x04/* Netchannels connection control */ +#define CN_NETCHANNELS_VAL 0x01 -#define CN_NETLINK_USERS 4 +#define CN_NETLINK_USERS 5/* * Maximum connector's message size.
include/linux/netchannel.h new file +176 -0
176 lines not on this page · raw message
include/linux/netdevice.h +9 -0
@@ -707,6 +707,15 @@ extern int dev_hard_start_xmit(struct sk_buff *skb,extern void dev_init (void ); +#ifdef CONFIG_NETCHANNEL +extern int netchannel_recv (struct sk_buff *skb); +#else +static inline int netchannel_recv (struct sk_buff *skb) +{ +return -1 ; +} +#endif +extern int netdev_budget;/* Called by rtnetlink.c:rtnl_unlock() */
include/linux/skbuff.h +12 -0
@@ -338,6 +338,18 @@ static inline struct sk_buff *alloc_skb(unsigned int size,return __alloc_skb (size, priority,0 ); } +#ifdef CONFIG_NETCHANNEL +struct unetchannel ; +extern struct sk_buff *netchannel_alloc (struct unetchannel *unc,unsigned int header_size, +unsigned int total_size,gfp_t gfp_mask); +#else +static struct sk_buff *netchannel_alloc (void *unc,unsigned int header_size, +unsigned int total_size,gfp_t gfp_mask) +{ +return NULL ; +} +#endif +static inline struct sk_buff *alloc_skb_fclone (unsigned int size,gfp_t priority) {
include/linux/syscalls.h +2 -0
@@ -605,4 +605,6 @@ asmlinkage long sys_getcpu(unsigned __user *cpu, unsigned __user *node, struct gint kernel_execve (const char *filename,char *const argv[],char *const envp[]); +asmlinkage long sys_netchannel_control (void __user *arg); +#endif
kernel/sys_ni.c +3 -0
@@ -134,9 +134,12 @@ cond_syscall(sys_mincore);cond_syscall (sys_madvise);cond_syscall (sys_mremap);cond_syscall (sys_remap_file_pages); +cond_syscall (compat_sys_move_pages);/* block-layer dependent */ cond_syscall (sys_bdflush);cond_syscall (sys_ioprio_set);cond_syscall (sys_ioprio_get); + +cond_syscall (sys_netchannel_control);
net/Kconfig +2 -0
@@ -66,6 +66,8 @@ source "net/ipv6/Kconfig" endif # if INET +source "net/core/netchannel/Kconfig" + config NETWORK_SECMARK bool "Security Marking" help
net/core/Makefile +1 -0
@@ -16,5 +16,6 @@ obj-$(CONFIG_NET_DIVERT) += dv.o obj-$(CONFIG_NET_PKTGEN) += pktgen.o obj-$(CONFIG_WIRELESS_EXT) += wireless.o obj-$(CONFIG_NETPOLL) += netpoll.o +obj-$(CONFIG_NETCHANNEL) += netchannel/ obj-$(CONFIG_NET_DMA) += user_dma.o obj-$(CONFIG_FIB_RULES) += fib_rules.o
net/core/dev.c +4 -0
@@ -1808,6 +1808,10 @@ int netif_receive_skb(struct sk_buff *skb) } } + ret =netchannel_recv (skb); +if (!ret) + goto out; +#ifdef CONFIG_NET_CLS_ACT if (pt_prev) { ret =deliver_skb (skb, pt_prev, orig_dev);
net/core/netchannel/Kconfig new file +23 -0
@@ -0,0 +1,23 @@ +config NETCHANNEL + bool "Network channels" + ---help--- + Network channels are peer-to-peer abstraction, which allows to create + high performance communications. + Main advantages are unified address cache, protocol processing moved + to userspace, receiving zero-copy support and other interesting features. + +config NETCHANNEL_NAT + bool "NAT over netchannels" + depends on NETCHANNEL && CONNECTOR=y + ---help--- + Network address translation mechanism based on netchannels. + Initialization works over connector. + +config NETCHANNEL_USERSPACE + bool "Userspace netchannels" + depends on NETCHANNEL + ---help--- + Userspace interface (file descriptor) for netchannels, which allows to implement + network stack in userspace, packet-socket-like interface - when userspace can select + set of IP addressed to work with without main kernel stack - like BGP/OSPF daemons, + TUN/TAP interface, VPN proxies and much more.
net/core/netchannel/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-y += netchannel.o trie.o +obj-$(CONFIG_NETCHANNEL_NAT) += nat.o +obj-$(CONFIG_NETCHANNEL_USERSPACE) += user.o
net/core/netchannel/nat.c new file +484 -0
484 lines not on this page · raw message
net/core/netchannel/netchannel.c new file +607 -0
607 lines not on this page · raw message
net/core/netchannel/trie.c new file +415 -0
415 lines not on this page · raw message
net/core/netchannel/user.c new file +391 -0
391 lines not on this page · raw message
Signature · 1 line
Evgeniy Polyakov
[Netchannels] Userspace network stack performance.
Userspace network stack over new netchannels performance.
Sending:
o 128 bytes writing:
* netchannels: 27-28 MB/sec, 20-30 % CPU usage
* sockets: 7-8 MB/sec, 80-90 % CPU usage
o 4096 bytes writing:
* netchannels: 27-28 MB/sec, 20-30 % CPU usage
* sockets: 30-31 MB/sec, 30-40 % CPU usage
Receiving:
o 128 bytes reading:
* netchannels: 70-71 MB/sec, 80-90 % CPU usage
* sockets: 24-25 MB/sec, 80-90 % CPU usage
o 4096 bytes reading:
* netchannels: 73-74 MB/sec, 80-90 % CPU usage
* sockets: 79-80 MB/sec, 80-90 % CPU usage
Stack is available from project homepage at
http://tservice.net.ru/~s0mbre/old/?section=projects&item=unetstack
Signature · 1 line
Evgeniy Polyakov
[Netchannels] netchannels scalability.
In reply to Evgeniy PolyakovScript has create 22k wildcard (only one dimension (source address) is wildcard to save some mem) NAT rules
(16k $rand.$rand.$rand.$rand/255.255.248.0 rules and
(6k $rand.$rand.$rand.$rand/255.255.255.$rand).
I.e. it is equal to 22k following netfilter rules:
iptables -t nat -I POSTROUTING \ -s $rand.$rand.$rand.$rand/255.255.248.0 \ -d $static/$some_wildcard_mask \ --sport $static_num/$some_wildcard_mask \ --dport $static_num/$some_wildcard_mask \ --proto $static_num/$some_wildcard_mask \ -j SNAT --to-source $static_num
$static_num and $some_wildcard_mask are different on each line, but are the same for different commands.
Raw send/recv performance over gigabit link is the same as described in previous mail in this thread.
I can not test NAT processing speed itself (I do not have enough test machines :).
Userspace trie tests included 1-2 millions insertions/searches.
Network performance of the netchannels userspace network stack remains the same (userspace netchannel is one of the about thousands).
But I managed to crash test system with the latest patchset (netchannel addition is not protected against removing as must be done according to RCU rules).
19 version of the netchannels subsystem patch only contains API cleanup used with provided test case.
Signature · 1 line
Evgeniy Polyakov
[Netchannels take19] new netchannel release.
In reply to Evgeniy PolyakovNetwork channel [1] is peer-to-peer protocol agnostic communication channel between hardware and userspace. It uses unified cache to store it's channels, allows to allocate buffers for data from userspace mapped area or from other preallocated set of pages (like VFS cache). All protocol processing happens in process' context.
Netchannel features:
o multidimensional wildcards support
o RCU searching
o single multidimensional trie for different kinds of dataflows
o dedicated processing threads with possibility to schedule processing on different CPUs for those netchannel types which are not acked with processing context
o userspace netchannel backend (allows to receive packets to userspace), which can be used for:
* high-performance sniffers
* tun/tap device replacement
* packet socket replacement (note, that netchannels steal packets from main stack)
* userspace network stack implementation [2]
* own protocol stack implementaion (from VPN tunnels to TOE)
o netfilter netchannel backend (only NAT is supported as the most interesting user, NAT caches appropriate route, so essentially routing becomes part of the netchannel trie)
Multidimensional wildcard is implemented as trie, details can be found in development track on the netchannels site [1].
Some testing was done in 'emulator', i.e. pre-netchannel userspace multidimensional trie implementation. Results are here [3].
1. Netchannel homepage.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=netchannel
2. Userspace network stack with bechmarks [not yet updated to curent API changes]. New version will be available around Dec 21.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=unetstack
3. Multidemnsional trie testing.
http://tservice.net.ru/~s0mbre/blog/2006/12/02#2006_12_02
Code is in development state, but I would like to hear comments about overall design, features, usefullness for the kernel and get feedback on kernel side.
Thank you.
arch/i386/kernel/syscall_table.S +1 -0
@@ -319,3 +319,4 @@ ENTRY(sys_call_table) .long sys_move_pages .long sys_getcpu .long sys_epoll_pwait + .long sys_netchannel_control
arch/x86_64/ia32/ia32entry.S +1 -0
@@ -718,4 +718,5 @@ ia32_sys_call_table: .quad compat_sys_vmsplice .quad compat_sys_move_pages .quad sys_getcpu + .quad sys_netchannel_control ia32_syscall_end:
include/asm-i386/unistd.h +2 -1
@@ -325,10 +325,11 @@#define __NR_move_pages 317#define __NR_getcpu 318#define __NR_epoll_pwait 319 +#define __NR_netchannel_control 320#ifdef __KERNEL__ -#define NR_syscalls 320 +#define NR_syscalls 321#include <linux/err.h> /*
include/asm-x86_64/unistd.h +3 -1
@@ -619,8 +619,10 @@ __SYSCALL(__NR_sync_file_range, sys_sync_file_range) __SYSCALL(__NR_vmsplice, sys_vmsplice)#define __NR_move_pages 279 __SYSCALL(__NR_move_pages, sys_move_pages) +#define __NR_netchannel_control 280 +__SYSCALL(__NR_netchannel_control, sys_netchannel_control) -#define __NR_syscall_max __NR_move_pages +#define __NR_syscall_max __NR_netchannel_control#ifdef __KERNEL__#include <linux/err.h>
include/linux/connector.h +3 -1
@@ -36,9 +36,11 @@#define CN_VAL_CIFS 0x1#define CN_W1_IDX 0x3/* w1 communication */ #define CN_W1_VAL 0x1 +#define CN_NETCHANNELS_IDX 0x04/* Netchannels connection control */ +#define CN_NETCHANNELS_VAL 0x01 -#define CN_NETLINK_USERS 4 +#define CN_NETLINK_USERS 5/* * Maximum connector's message size.
include/linux/netchannel.h new file +175 -0
175 lines not on this page · raw message
include/linux/netdevice.h +9 -0
@@ -707,6 +707,15 @@ extern int dev_hard_start_xmit(struct sk_buff *skb,extern void dev_init (void ); +#ifdef CONFIG_NETCHANNEL +extern int netchannel_recv (struct sk_buff *skb); +#else +static inline int netchannel_recv (struct sk_buff *skb) +{ +return -1 ; +} +#endif +extern int netdev_budget;/* Called by rtnetlink.c:rtnl_unlock() */
include/linux/skbuff.h +12 -0
@@ -338,6 +338,18 @@ static inline struct sk_buff *alloc_skb(unsigned int size,return __alloc_skb (size, priority,0 ); } +#ifdef CONFIG_NETCHANNEL +struct unetchannel ; +extern struct sk_buff *netchannel_alloc (struct unetchannel *unc,unsigned int header_size, +unsigned int total_size,gfp_t gfp_mask); +#else +static struct sk_buff *netchannel_alloc (void *unc,unsigned int header_size, +unsigned int total_size,gfp_t gfp_mask) +{ +return NULL ; +} +#endif +static inline struct sk_buff *alloc_skb_fclone (unsigned int size,gfp_t priority) {
include/linux/syscalls.h +2 -0
@@ -605,4 +605,6 @@ asmlinkage long sys_getcpu(unsigned __user *cpu, unsigned __user *node, struct gint kernel_execve (const char *filename,char *const argv[],char *const envp[]); +asmlinkage long sys_netchannel_control (void __user *arg); +#endif
kernel/sys_ni.c +3 -0
@@ -134,9 +134,12 @@ cond_syscall(sys_mincore);cond_syscall (sys_madvise);cond_syscall (sys_mremap);cond_syscall (sys_remap_file_pages); +cond_syscall (compat_sys_move_pages);/* block-layer dependent */ cond_syscall (sys_bdflush);cond_syscall (sys_ioprio_set);cond_syscall (sys_ioprio_get); + +cond_syscall (sys_netchannel_control);
net/Kconfig +2 -0
@@ -66,6 +66,8 @@ source "net/ipv6/Kconfig" endif # if INET +source "net/core/netchannel/Kconfig" + config NETWORK_SECMARK bool "Security Marking" help
net/core/Makefile +1 -0
@@ -16,5 +16,6 @@ obj-$(CONFIG_NET_DIVERT) += dv.o obj-$(CONFIG_NET_PKTGEN) += pktgen.o obj-$(CONFIG_WIRELESS_EXT) += wireless.o obj-$(CONFIG_NETPOLL) += netpoll.o +obj-$(CONFIG_NETCHANNEL) += netchannel/ obj-$(CONFIG_NET_DMA) += user_dma.o obj-$(CONFIG_FIB_RULES) += fib_rules.o
net/core/dev.c +4 -0
@@ -1808,6 +1808,10 @@ int netif_receive_skb(struct sk_buff *skb) } } + ret =netchannel_recv (skb); +if (!ret) + goto out; +#ifdef CONFIG_NET_CLS_ACT if (pt_prev) { ret =deliver_skb (skb, pt_prev, orig_dev);
net/core/netchannel/Kconfig new file +23 -0
@@ -0,0 +1,23 @@ +config NETCHANNEL + bool "Network channels" + ---help--- + Network channels are peer-to-peer abstraction, which allows to create + high performance communications. + Main advantages are unified address cache, protocol processing moved + to userspace, receiving zero-copy support and other interesting features. + +config NETCHANNEL_NAT + bool "NAT over netchannels" + depends on NETCHANNEL && CONNECTOR=y + ---help--- + Network address translation mechanism based on netchannels. + Initialization works over connector. + +config NETCHANNEL_USERSPACE + bool "Userspace netchannels" + depends on NETCHANNEL + ---help--- + Userspace interface (file descriptor) for netchannels, which allows to implement + network stack in userspace, packet-socket-like interface - when userspace can select + set of IP addressed to work with without main kernel stack - like BGP/OSPF daemons, + TUN/TAP interface, VPN proxies and much more.
net/core/netchannel/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-y += netchannel.o trie.o +obj-$(CONFIG_NETCHANNEL_NAT) += nat.o +obj-$(CONFIG_NETCHANNEL_USERSPACE) += user.o
net/core/netchannel/nat.c new file +480 -0
480 lines not on this page · raw message
net/core/netchannel/netchannel.c new file +608 -0
608 lines not on this page · raw message
net/core/netchannel/trie.c new file +415 -0
415 lines not on this page · raw message
net/core/netchannel/user.c new file +395 -0
395 lines not on this page · raw message
Signature · 1 line
Evgeniy Polyakov
Re: [Netchannels take19] new netchannel release.
Quoted 31 lines · Evgeniy Polyakov
Network channel [1] is peer-to-peer protocol agnostic communication channel between hardware and userspace. It uses unified cache to store it's channels, allows to allocate buffers for data from userspace mapped area or from other preallocated set of pages (like VFS cache). All protocol processing happens in process' context.
Netchannel features:
o multidimensional wildcards support
o RCU searching
o single multidimensional trie for different kinds of dataflows
o dedicated processing threads with possibility to schedule processing on different CPUs for those netchannel types which are not acked with processing context
o userspace netchannel backend (allows to receive packets to userspace), which can be used for:
* high-performance sniffers
* tun/tap device replacement
* packet socket replacement (note, that netchannels steal packets from main stack)
* userspace network stack implementation [2]
* own protocol stack implementaion (from VPN tunnels to TOE)
o netfilter netchannel backend (only NAT is supported as the most interesting user, NAT caches appropriate route, so essentially routing becomes part of the netchannel trie)Multidimensional wildcard is implemented as trie, details can be found in development track on the netchannels site [1].
Some testing was done in 'emulator', i.e. pre-netchannel userspace multidimensional trie implementation. Results are here [3].
Quoted 4 lines
1. Netchannel homepage.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=netchannel2. Userspace network stack with bechmarks [not yet updated to curent API
changes].
Quoted 9 lines
New version will be available around Dec 21.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=unetstack3. Multidemnsional trie testing.
http://tservice.net.ru/~s0mbre/blog/2006/12/02#2006_12_02Code is in development state, but I would like to hear comments about overall design, features, usefullness for the kernel and get feedback on kernel side.
I follow your work with great interest, even though my kernel coding experience isn't great. When I get the time I would like to actually try it out and provide some feedback.
For now I only follow your progress by reading your web page to get the big picture. I must admit it is not easy to get the overall picture from reading that, because it is mostly about small details. I think you would get a lot more enthusiasm from people, if you described your work top-down. Much of the work is about new interfaces and it would be very helpfull with detailed descriptions of these.
I think kevent has arrived to a level of documentation, which makes it possible to get the bigger picture before digging into the code.
I know documentation is boring, especially for people who actually put their ideas into code (some people like to rant about their ideas forever, without actually showing any results). So don't get me wrong; I like your work, but if you want more people to get excited about it, I think you need to communicate it better.
Anyway, keep up the good work!
Hans Henrik
Re: [Netchannels take19] new netchannel release.
Quoted 15 lines · Hans Henrik Happe
Quoted 3 lines
Code is in development state, but I would like to hear comments about overall design, features, usefullness for the kernel and get feedback on kernel side.
I follow your work with great interest, even though my kernel coding experience isn't great. When I get the time I would like to actually try it out and provide some feedback.
For now I only follow your progress by reading your web page to get the big picture. I must admit it is not easy to get the overall picture from reading that, because it is mostly about small details. I think you would get a lot more enthusiasm from people, if you described your work top-down. Much of the work is about new interfaces and it would be very helpfull with detailed descriptions of these.
Quoted 2 lines
I think kevent has arrived to a level of documentation, which makes it possible to get the bigger picture before digging into the code.
Although kevent has documentation, it does not help it, as we can see :)
Quoted 5 lines
I know documentation is boring, especially for people who actually put their ideas into code (some people like to rant about their ideas forever, without actually showing any results). So don't get me wrong; I like your work, but if you want more people to get excited about it, I think you need to communicate it better.
I will write some documentation about overall design and interfaces (it is a bit easier than kevent, since there is only one syscall with everyone-likes-it multiplexor inside, and one connector based interface for netfilter (NAT)).
Quoted 1 line
Anyway, keep up the good work!
Thank you.
Quoted 1 line
Hans Henrik
Signature · 1 line
Evgeniy Polyakov