linux/net
Johannes Berg 59ae1d127a networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.

An spatch similar to the one for skb_put_zero() converts many
of the places using it:

    @@
    identifier p, p2;
    expression len, skb, data;
    type t, t2;
    @@
    (
    -p = skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    |
    -p = (t)skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, len);
    |
    -memcpy(p, data, len);
    )

    @@
    type t, t2;
    identifier p, p2;
    expression skb, data;
    @@
    t *p;
    ...
    (
    -p = skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    |
    -p = (t *)skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, sizeof(*p));
    |
    -memcpy(p, data, sizeof(*p));
    )

    @@
    expression skb, len, data;
    @@
    -memcpy(skb_put(skb, len), data, len);
    +skb_put_data(skb, data, len);

(again, manually post-processed to retain some comments)

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 11:48:37 -04:00
..
6lowpan
9p xen: fixes for 4.12 rc2 2017-05-19 15:06:48 -07:00
802
8021q Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-06-15 11:59:32 -04:00
appletalk
atm networking: convert many more places to skb_put_zero() 2017-06-16 11:48:35 -04:00
ax25
batman-adv networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
bluetooth networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
bpf
bridge networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
caif Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-06-15 11:59:32 -04:00
can networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
ceph libceph: cleanup old messages according to reconnect seq 2017-05-24 18:10:51 +02:00
core networking: convert many more places to skb_put_zero() 2017-06-16 11:48:35 -04:00
dcb dcb: enforce minimum length on IEEE_APPS attribute 2017-05-21 13:42:33 -04:00
dccp
decnet networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
dns_resolver
dsa net: dsa: assign default CPU port to all ports 2017-06-15 17:23:35 -04:00
ethernet
hsr hsr: fix incorrect warning 2017-06-12 15:21:20 -04:00
ieee802154 networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
ife
ipv4 networking: convert many more places to skb_put_zero() 2017-06-16 11:48:35 -04:00
ipv6 networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
ipx
irda networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
iucv
kcm
key networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
l2tp l2tp: cast l2tp traffic counter to unsigned 2017-06-10 16:14:27 -04:00
l3mdev
lapb
llc net: llc: add lock_sock in llc_ui_bind to avoid a race condition 2017-05-26 14:20:29 -04:00
mac80211 networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
mac802154 net: Fix inconsistent teardown and release of private netdev state. 2017-06-07 15:53:24 -04:00
mpls Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-06-06 22:20:08 -04:00
ncsi networking: convert many more places to skb_put_zero() 2017-06-16 11:48:35 -04:00
netfilter Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-06-06 22:20:08 -04:00
netlabel
netlink networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
netrom
nfc networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
openvswitch networking: convert many more places to skb_put_zero() 2017-06-16 11:48:35 -04:00
packet net/packet: remove unneeded declaraion of tpacket_snd(). 2017-06-10 16:15:25 -04:00
phonet net: Fix inconsistent teardown and release of private netdev state. 2017-06-07 15:53:24 -04:00
psample
qrtr networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
rds
rfkill net: rfkill: gpio: Switch to devm_acpi_dev_add_driver_gpios() 2017-06-13 11:07:51 +02:00
rose
rxrpc networking: convert many more places to skb_put_zero() 2017-06-16 11:48:35 -04:00
sched net: sched: act_tunnel_key: make UDP checksum configurable 2017-06-15 14:21:03 -04:00
sctp networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
smc
strparser
sunrpc SUNRPC: ensure correct error is reported by xs_tcp_setup_socket() 2017-05-31 12:26:44 -04:00
switchdev net: switchdev: Change notifier chain to be atomic 2017-06-08 14:16:24 -04:00
tipc net: tipc: Fix a sleep-in-atomic bug in tipc_msg_reverse 2017-06-10 18:20:38 -04:00
tls tls: Depend upon INET not plain NET. 2017-06-16 11:28:49 -04:00
unix af_unix: Add sockaddr length checks before accessing sa_family in bind and connect handlers 2017-06-09 10:10:24 -04:00
vmw_vsock networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
wimax
wireless nl80211: add authorized flag to ROAM event 2017-06-13 11:04:37 +02:00
x25 networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
xfrm xfrm: fix state migration copy replay sequence numbers 2017-05-19 12:49:13 +02:00
Kconfig tls: kernel TLS support 2017-06-15 12:12:40 -04:00
Makefile tls: kernel TLS support 2017-06-15 12:12:40 -04:00
compat.c
socket.c net: socket: fix a typo in sockfd_lookup(). 2017-05-22 12:14:04 -04:00
sysctl_net.c