Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'kill_sk_protinfo'

David Miller says:

====================
Get rid of sock->sk_protinfo.

These two patches get rid of the last remaining user of sk_protinfo
(ax25) and then really gets rid of the struct member.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+31 -26
+15 -1
include/net/ax25.h
··· 13 13 #include <linux/slab.h> 14 14 #include <linux/atomic.h> 15 15 #include <net/neighbour.h> 16 + #include <net/sock.h> 16 17 17 18 #define AX25_T1CLAMPLO 1 18 19 #define AX25_T1CLAMPHI (30 * HZ) ··· 247 246 atomic_t refcount; 248 247 } ax25_cb; 249 248 250 - #define ax25_sk(__sk) ((ax25_cb *)(__sk)->sk_protinfo) 249 + struct ax25_sock { 250 + struct sock sk; 251 + struct ax25_cb *cb; 252 + }; 253 + 254 + static inline struct ax25_sock *ax25_sk(const struct sock *sk) 255 + { 256 + return (struct ax25_sock *) sk; 257 + } 258 + 259 + static inline struct ax25_cb *sk_to_ax25(const struct sock *sk) 260 + { 261 + return ax25_sk(sk)->cb; 262 + } 251 263 252 264 #define ax25_for_each(__ax25, list) \ 253 265 hlist_for_each_entry(__ax25, list, ax25_node)
-2
include/net/sock.h
··· 277 277 * @sk_incoming_cpu: record cpu processing incoming packets 278 278 * @sk_txhash: computed flow hash for use on transmit 279 279 * @sk_filter: socket filtering instructions 280 - * @sk_protinfo: private area, net family specific, when not using slab 281 280 * @sk_timer: sock cleanup timer 282 281 * @sk_stamp: time stamp of last packet received 283 282 * @sk_tsflags: SO_TIMESTAMPING socket options ··· 415 416 const struct cred *sk_peer_cred; 416 417 long sk_rcvtimeo; 417 418 long sk_sndtimeo; 418 - void *sk_protinfo; 419 419 struct timer_list sk_timer; 420 420 ktime_t sk_stamp; 421 421 u16 sk_tsflags;
+15 -15
net/ax25/af_ax25.c
··· 57 57 58 58 static void ax25_free_sock(struct sock *sk) 59 59 { 60 - ax25_cb_put(ax25_sk(sk)); 60 + ax25_cb_put(sk_to_ax25(sk)); 61 61 } 62 62 63 63 /* ··· 306 306 while ((skb = skb_dequeue(&ax25->sk->sk_receive_queue)) != NULL) { 307 307 if (skb->sk != ax25->sk) { 308 308 /* A pending connection */ 309 - ax25_cb *sax25 = ax25_sk(skb->sk); 309 + ax25_cb *sax25 = sk_to_ax25(skb->sk); 310 310 311 311 /* Queue the unaccepted socket for death */ 312 312 sock_orphan(skb->sk); ··· 551 551 return -EFAULT; 552 552 553 553 lock_sock(sk); 554 - ax25 = ax25_sk(sk); 554 + ax25 = sk_to_ax25(sk); 555 555 556 556 switch (optname) { 557 557 case AX25_WINDOW: ··· 697 697 length = min_t(unsigned int, maxlen, sizeof(int)); 698 698 699 699 lock_sock(sk); 700 - ax25 = ax25_sk(sk); 700 + ax25 = sk_to_ax25(sk); 701 701 702 702 switch (optname) { 703 703 case AX25_WINDOW: ··· 796 796 static struct proto ax25_proto = { 797 797 .name = "AX25", 798 798 .owner = THIS_MODULE, 799 - .obj_size = sizeof(struct sock), 799 + .obj_size = sizeof(struct ax25_sock), 800 800 }; 801 801 802 802 static int ax25_create(struct net *net, struct socket *sock, int protocol, ··· 858 858 if (sk == NULL) 859 859 return -ENOMEM; 860 860 861 - ax25 = sk->sk_protinfo = ax25_create_cb(); 861 + ax25 = ax25_sk(sk)->cb = ax25_create_cb(); 862 862 if (!ax25) { 863 863 sk_free(sk); 864 864 return -ENOMEM; ··· 910 910 sk->sk_state = TCP_ESTABLISHED; 911 911 sock_copy_flags(sk, osk); 912 912 913 - oax25 = ax25_sk(osk); 913 + oax25 = sk_to_ax25(osk); 914 914 915 915 ax25->modulus = oax25->modulus; 916 916 ax25->backoff = oax25->backoff; ··· 938 938 } 939 939 } 940 940 941 - sk->sk_protinfo = ax25; 941 + ax25_sk(sk)->cb = ax25; 942 942 sk->sk_destruct = ax25_free_sock; 943 943 ax25->sk = sk; 944 944 ··· 956 956 sock_hold(sk); 957 957 sock_orphan(sk); 958 958 lock_sock(sk); 959 - ax25 = ax25_sk(sk); 959 + ax25 = sk_to_ax25(sk); 960 960 961 961 if (sk->sk_type == SOCK_SEQPACKET) { 962 962 switch (ax25->state) { ··· 1066 1066 1067 1067 lock_sock(sk); 1068 1068 1069 - ax25 = ax25_sk(sk); 1069 + ax25 = sk_to_ax25(sk); 1070 1070 if (!sock_flag(sk, SOCK_ZAPPED)) { 1071 1071 err = -EINVAL; 1072 1072 goto out; ··· 1113 1113 struct sockaddr *uaddr, int addr_len, int flags) 1114 1114 { 1115 1115 struct sock *sk = sock->sk; 1116 - ax25_cb *ax25 = ax25_sk(sk), *ax25t; 1116 + ax25_cb *ax25 = sk_to_ax25(sk), *ax25t; 1117 1117 struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)uaddr; 1118 1118 ax25_digi *digi = NULL; 1119 1119 int ct = 0, err = 0; ··· 1394 1394 1395 1395 memset(fsa, 0, sizeof(*fsa)); 1396 1396 lock_sock(sk); 1397 - ax25 = ax25_sk(sk); 1397 + ax25 = sk_to_ax25(sk); 1398 1398 1399 1399 if (peer != 0) { 1400 1400 if (sk->sk_state != TCP_ESTABLISHED) { ··· 1446 1446 return -EINVAL; 1447 1447 1448 1448 lock_sock(sk); 1449 - ax25 = ax25_sk(sk); 1449 + ax25 = sk_to_ax25(sk); 1450 1450 1451 1451 if (sock_flag(sk, SOCK_ZAPPED)) { 1452 1452 err = -EADDRNOTAVAIL; ··· 1621 1621 if (skb == NULL) 1622 1622 goto out; 1623 1623 1624 - if (!ax25_sk(sk)->pidincl) 1624 + if (!sk_to_ax25(sk)->pidincl) 1625 1625 skb_pull(skb, 1); /* Remove PID */ 1626 1626 1627 1627 skb_reset_transport_header(skb); ··· 1762 1762 1763 1763 case SIOCAX25GETINFO: 1764 1764 case SIOCAX25GETINFOOLD: { 1765 - ax25_cb *ax25 = ax25_sk(sk); 1765 + ax25_cb *ax25 = sk_to_ax25(sk); 1766 1766 struct ax25_info_struct ax25_info; 1767 1767 1768 1768 ax25_info.t1 = ax25->t1 / HZ;
+1 -1
net/ax25/ax25_in.c
··· 353 353 return 0; 354 354 } 355 355 356 - ax25 = ax25_sk(make); 356 + ax25 = sk_to_ax25(make); 357 357 skb_set_owner_r(skb, make); 358 358 skb_queue_head(&sk->sk_receive_queue, skb); 359 359
-1
net/core/sock.c
··· 2269 2269 2270 2270 static void sock_def_destruct(struct sock *sk) 2271 2271 { 2272 - kfree(sk->sk_protinfo); 2273 2272 } 2274 2273 2275 2274 void sk_send_sigurg(struct sock *sk)
-6
net/sctp/socket.c
··· 2121 2121 if (sp->subscribe.sctp_data_io_event) 2122 2122 sctp_ulpevent_read_sndrcvinfo(event, msg); 2123 2123 2124 - #if 0 2125 - /* FIXME: we should be calling IP/IPv6 layers. */ 2126 - if (sk->sk_protinfo.af_inet.cmsg_flags) 2127 - ip_cmsg_recv(msg, skb); 2128 - #endif 2129 - 2130 2124 err = copied; 2131 2125 2132 2126 /* If skb's length exceeds the user's buffer, update the skb and