acrn-kernel/net/netfilter
Patrick McHardy 334a8132d9 [SKBUFF]: Keep track of writable header len of headerless clones
Currently NAT (and others) that want to modify cloned skbs copy them,
even if in the vast majority of cases its not necessary because the
skb is a clone made by TCP and the portion NAT wants to modify is
actually writable because TCP release the header reference before
cloning.

The problem is that there is no clean way for NAT to find out how
long the writable header area is, so this patch introduces skb->hdr_len
to hold this length. When a headerless skb is cloned skb->hdr_len
is set to the current headroom, for regular clones it is copied from
the original. A new function skb_clone_writable(skb, len) returns
whether the skb is writable up to len bytes from skb->data. To avoid
enlarging the skb the mac_len field is reduced to 16 bit and the
new hdr_len field is put in the remaining 16 bit.

I've done a few rough benchmarks of NAT (not with this exact patch,
but a very similar one). As expected it saves huge amounts of system
time in case of sendfile, bringing it down to basically the same
amount as without NAT, with sendmsg it only helps on loopback,
probably because of the large MTU.

Transmit a 1GB file using sendfile/sendmsg over eth0/lo with and
without NAT:

- sendfile eth0, no NAT:	sys     0m0.388s
- sendfile eth0, NAT:		sys     0m1.835s
- sendfile eth0: NAT + path:	sys     0m0.370s	(~ -80%)

- sendfile lo, no NAT:		sys     0m0.258s
- sendfile lo, NAT:		sys     0m2.609s
- sendfile lo, NAT + patch:	sys     0m0.260s	(~ -90%)

- sendmsg eth0, no NAT:		sys     0m2.508s
- sendmsg eth0, NAT:		sys     0m2.539s
- sendmsg eth0, NAT + patch:	sys     0m2.445s	(no change)

- sendmsg lo, no NAT:		sys	0m2.151s
- sendmsg lo, NAT:		sys     0m3.557s
- sendmsg lo, NAT + patch:	sys     0m2.159s	(~ -40%)

I expect other users can see a similar performance improvement,
packet mangling iptables targets, ipip and ip_gre come to mind ..

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-07-10 22:15:37 -07:00
..
Kconfig Fix trivial typos in Kconfig* files 2007-05-09 07:12:20 +02:00
Makefile
core.c [SKBUFF]: Keep track of writable header len of headerless clones 2007-07-10 22:15:37 -07:00
nf_conntrack_amanda.c [NETFILTER]: nf_conntrack_amanda: fix textsearch_prepare() error check 2007-06-07 13:40:38 -07:00
nf_conntrack_core.c [NETFILTER]: nf_conntrack: fix helper module unload races 2007-06-07 13:40:26 -07:00
nf_conntrack_ecache.c
nf_conntrack_expect.c [NETFILTER]: nf_conntrack: fix helper module unload races 2007-06-07 13:40:26 -07:00
nf_conntrack_ftp.c [NETFILTER]: nf_conntrack_ftp: fix newline sequence number calculation 2007-05-24 16:41:50 -07:00
nf_conntrack_h323_asn1.c [NETFILTER]: nf_conntrack_h323: add checking of out-of-range on choices' index values 2007-07-05 17:40:23 -07:00
nf_conntrack_h323_main.c [NETFILTER]: nf_conntrack_h323: add missing T.120 address in OLCA 2007-05-24 16:44:11 -07:00
nf_conntrack_h323_types.c [NETFILTER]: nf_conntrack_h323: fix ASN.1 types 2007-05-24 16:42:26 -07:00
nf_conntrack_helper.c [NETFILTER]: nf_conntrack: fix helper module unload races 2007-06-07 13:40:26 -07:00
nf_conntrack_irc.c
nf_conntrack_l3proto_generic.c
nf_conntrack_netbios_ns.c
nf_conntrack_netlink.c [NETFILTER]: nfctnetlink: Don't allow to change helper 2007-06-22 14:10:22 -07:00
nf_conntrack_pptp.c
nf_conntrack_proto.c [NETLINK]: Possible cleanups. 2007-04-26 00:57:41 -07:00
nf_conntrack_proto_generic.c
nf_conntrack_proto_gre.c [NETFILTER]: nf_conntrack: fix helper module unload races 2007-06-07 13:40:26 -07:00
nf_conntrack_proto_sctp.c
nf_conntrack_proto_tcp.c
nf_conntrack_proto_udp.c
nf_conntrack_sane.c
nf_conntrack_sip.c [NETFILTER]: nf_conntrack_sip: add missing message types containing RTP info 2007-06-22 14:08:17 -07:00
nf_conntrack_standalone.c
nf_conntrack_tftp.c
nf_internals.h
nf_log.c
nf_queue.c
nf_sockopt.c
nf_sysctl.c
nfnetlink.c [NETLINK]: Switch cb_lock spinlock to mutex and allow to override it 2007-04-25 22:29:03 -07:00
nfnetlink_log.c [NETFILTER]: nfnetlink_log: remove fallback to group 0 2007-04-25 22:29:01 -07:00
nfnetlink_queue.c
x_tables.c
xt_CLASSIFY.c
xt_CONNMARK.c
xt_CONNSECMARK.c
xt_DSCP.c
xt_MARK.c
xt_NFLOG.c
xt_NFQUEUE.c
xt_NOTRACK.c
xt_SECMARK.c
xt_TCPMSS.c
xt_comment.c
xt_connbytes.c
xt_connmark.c
xt_conntrack.c [NETFILTER]: xt_conntrack: add compat support 2007-05-10 23:48:00 -07:00
xt_dccp.c
xt_dscp.c
xt_esp.c
xt_hashlimit.c
xt_helper.c
xt_length.c
xt_limit.c
xt_mac.c
xt_mark.c
xt_multiport.c
xt_physdev.c
xt_pkttype.c
xt_policy.c
xt_quota.c
xt_realm.c
xt_sctp.c
xt_state.c
xt_statistic.c
xt_string.c
xt_tcpmss.c
xt_tcpudp.c