netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 2/6] socket: sk_filter deinline
Date: Mon, 31 Mar 2008 17:47:10 -0700	[thread overview]
Message-ID: <20080401004724.528304251@vyatta.com> (raw)
In-Reply-To: 20080401004708.009204033@vyatta.com

[-- Attachment #1: sk-filter-deinline --]
[-- Type: text/plain, Size: 3243 bytes --]

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>

--- a/include/linux/filter.h	2008-03-31 10:24:40.000000000 -0700
+++ b/include/linux/filter.h	2008-03-31 10:26:49.000000000 -0700
@@ -142,6 +142,7 @@ static inline unsigned int sk_filter_len
 struct sk_buff;
 struct sock;
 
+extern int sk_filter(struct sock *sk, struct sk_buff *skb);
 extern unsigned int sk_run_filter(struct sk_buff *skb,
 				  struct sock_filter *filter, int flen);
 extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
--- a/include/net/sock.h	2008-03-31 10:23:12.000000000 -0700
+++ b/include/net/sock.h	2008-03-31 10:25:57.000000000 -0700
@@ -927,41 +927,6 @@ extern void sk_common_release(struct soc
 extern void sock_init_data(struct socket *sock, struct sock *sk);
 
 /**
- *	sk_filter - run a packet through a socket filter
- *	@sk: sock associated with &sk_buff
- *	@skb: buffer to filter
- *	@needlock: set to 1 if the sock is not locked by caller.
- *
- * Run the filter code and then cut skb->data to correct size returned by
- * sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller
- * than pkt_len we keep whole skb->data. This is the socket level
- * wrapper to sk_run_filter. It returns 0 if the packet should
- * be accepted or -EPERM if the packet should be tossed.
- *
- */
-
-static inline int sk_filter(struct sock *sk, struct sk_buff *skb)
-{
-	int err;
-	struct sk_filter *filter;
-	
-	err = security_sock_rcv_skb(sk, skb);
-	if (err)
-		return err;
-	
-	rcu_read_lock_bh();
-	filter = rcu_dereference(sk->sk_filter);
-	if (filter) {
-		unsigned int pkt_len = sk_run_filter(skb, filter->insns,
-				filter->len);
-		err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM;
-	}
- 	rcu_read_unlock_bh();
-
-	return err;
-}
-
-/**
  *	sk_filter_release: Release a socket filter
  *	@sk: socket
  *	@fp: filter to remove
--- a/net/core/filter.c	2008-03-31 10:25:29.000000000 -0700
+++ b/net/core/filter.c	2008-03-31 10:27:43.000000000 -0700
@@ -64,6 +64,41 @@ static inline void *load_pointer(struct 
 }
 
 /**
+ *	sk_filter - run a packet through a socket filter
+ *	@sk: sock associated with &sk_buff
+ *	@skb: buffer to filter
+ *	@needlock: set to 1 if the sock is not locked by caller.
+ *
+ * Run the filter code and then cut skb->data to correct size returned by
+ * sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller
+ * than pkt_len we keep whole skb->data. This is the socket level
+ * wrapper to sk_run_filter. It returns 0 if the packet should
+ * be accepted or -EPERM if the packet should be tossed.
+ *
+ */
+int sk_filter(struct sock *sk, struct sk_buff *skb)
+{
+	int err;
+	struct sk_filter *filter;
+
+	err = security_sock_rcv_skb(sk, skb);
+	if (err)
+		return err;
+
+	rcu_read_lock_bh();
+	filter = rcu_dereference(sk->sk_filter);
+	if (filter) {
+		unsigned int pkt_len = sk_run_filter(skb, filter->insns,
+				filter->len);
+		err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM;
+	}
+ 	rcu_read_unlock_bh();
+
+	return err;
+}
+EXPORT_SYMBOL(sk_filter);
+
+/**
  *	sk_run_filter - run a filter on a socket
  *	@skb: buffer to run the filter on
  *	@filter: filter to apply

-- 


  parent reply	other threads:[~2008-04-01  2:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080401004708.009204033@vyatta.com>
2008-04-01  0:47 ` [PATCH 1/6] socket: sk_filter minor cleanups Stephen Hemminger
2008-04-10  8:39   ` David Miller
2008-04-01  0:47 ` Stephen Hemminger [this message]
2008-04-10  8:49   ` [PATCH 2/6] socket: sk_filter deinline David Miller
2008-04-01  0:47 ` [PATCH 3/6] IPV4 : use xor rather than multiple ands for route compare Stephen Hemminger
2008-04-01  5:52   ` Eric Dumazet
2008-04-01 20:08     ` Stephen Hemminger
2008-04-10  8:51       ` David Miller
2008-04-10  9:01         ` YOSHIFUJI Hideaki / 吉藤英明
2008-04-10 10:56           ` David Miller
2008-04-10 12:17             ` YOSHIFUJI Hideaki / 吉藤英明
2008-04-10  9:26         ` Eric Dumazet
2008-04-10 11:00           ` David Miller
2008-04-01  0:47 ` [PATCH 4/6] IPV4: route inline changes Stephen Hemminger
2008-04-10  8:53   ` David Miller
2008-04-01  0:47 ` [PATCH 5/6] IPV4: route use jhash3 Stephen Hemminger
2008-04-10  8:54   ` David Miller
2008-04-01  0:47 ` [PATCH 6/6] IPV4: route rekey timer can be deferrable Stephen Hemminger
2008-04-10  8:55   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080401004724.528304251@vyatta.com \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).