On Fri, Dec 07, 2018 at 12:44:24PM +0100, Björn Töpel wrote: > From: Björn Töpel <bjorn.to...@intel.com> > > Hi! > > This patch set adds support for a new XDP socket bind option, > XDP_ATTACH. > > The rationale behind attach is performance and ease of use. Many XDP > socket users just need a simple way of creating/binding a socket and > receiving frames right away without loading an XDP program. > > XDP_ATTACH adds a mechanism we call "builtin XDP program" that simply > is a kernel provided XDP program that is installed to the netdev when > XDP_ATTACH is being passed as a bind() flag. > > The builtin program is the simplest program possible to redirect a > frame to an attached socket. In restricted C it would look like this: > > SEC("xdp") > int xdp_prog(struct xdp_md *ctx) > { > return bpf_xsk_redirect(ctx); > } > > The builtin program loaded via XDP_ATTACH behaves, from an > install-to-netdev/uninstall-from-netdev point of view, differently > from regular XDP programs. The easiest way to look at it is as a > 2-level hierarchy, where regular XDP programs has precedence over the > builtin one.
The feature makes sense to me. May be XDP_ATTACH_BUILTIN would be a better name ? Also I think it needs another parameter to say which builtin program to use. This unconditional xsk_redirect is fine for performance benchmarking, but for production I suspect the users would want an easy way to stay safe when they're playing with AF_XDP. So another builtin program that redirects ssh and ping traffic back to the kernel would be a nice addition.