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

socket: sk_filter deinline

The sk_filter function is too big to be inlined. This saves 2296 bytes
of text on allyesconfig.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Stephen Hemminger and committed by
David S. Miller
43db6d65 b715631f

+36 -35
+1
include/linux/filter.h
··· 142 142 struct sk_buff; 143 143 struct sock; 144 144 145 + extern int sk_filter(struct sock *sk, struct sk_buff *skb); 145 146 extern unsigned int sk_run_filter(struct sk_buff *skb, 146 147 struct sock_filter *filter, int flen); 147 148 extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
-35
include/net/sock.h
··· 928 928 extern void sock_init_data(struct socket *sock, struct sock *sk); 929 929 930 930 /** 931 - * sk_filter - run a packet through a socket filter 932 - * @sk: sock associated with &sk_buff 933 - * @skb: buffer to filter 934 - * @needlock: set to 1 if the sock is not locked by caller. 935 - * 936 - * Run the filter code and then cut skb->data to correct size returned by 937 - * sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller 938 - * than pkt_len we keep whole skb->data. This is the socket level 939 - * wrapper to sk_run_filter. It returns 0 if the packet should 940 - * be accepted or -EPERM if the packet should be tossed. 941 - * 942 - */ 943 - 944 - static inline int sk_filter(struct sock *sk, struct sk_buff *skb) 945 - { 946 - int err; 947 - struct sk_filter *filter; 948 - 949 - err = security_sock_rcv_skb(sk, skb); 950 - if (err) 951 - return err; 952 - 953 - rcu_read_lock_bh(); 954 - filter = rcu_dereference(sk->sk_filter); 955 - if (filter) { 956 - unsigned int pkt_len = sk_run_filter(skb, filter->insns, 957 - filter->len); 958 - err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM; 959 - } 960 - rcu_read_unlock_bh(); 961 - 962 - return err; 963 - } 964 - 965 - /** 966 931 * sk_filter_release: Release a socket filter 967 932 * @sk: socket 968 933 * @fp: filter to remove
+35
net/core/filter.c
··· 64 64 } 65 65 66 66 /** 67 + * sk_filter - run a packet through a socket filter 68 + * @sk: sock associated with &sk_buff 69 + * @skb: buffer to filter 70 + * @needlock: set to 1 if the sock is not locked by caller. 71 + * 72 + * Run the filter code and then cut skb->data to correct size returned by 73 + * sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller 74 + * than pkt_len we keep whole skb->data. This is the socket level 75 + * wrapper to sk_run_filter. It returns 0 if the packet should 76 + * be accepted or -EPERM if the packet should be tossed. 77 + * 78 + */ 79 + int sk_filter(struct sock *sk, struct sk_buff *skb) 80 + { 81 + int err; 82 + struct sk_filter *filter; 83 + 84 + err = security_sock_rcv_skb(sk, skb); 85 + if (err) 86 + return err; 87 + 88 + rcu_read_lock_bh(); 89 + filter = rcu_dereference(sk->sk_filter); 90 + if (filter) { 91 + unsigned int pkt_len = sk_run_filter(skb, filter->insns, 92 + filter->len); 93 + err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM; 94 + } 95 + rcu_read_unlock_bh(); 96 + 97 + return err; 98 + } 99 + EXPORT_SYMBOL(sk_filter); 100 + 101 + /** 67 102 * sk_run_filter - run a filter on a socket 68 103 * @skb: buffer to run the filter on 69 104 * @filter: filter to apply