netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira <pablo@eurodev.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@oss.sgi.com, davem@redhat.com, herbert@gondor.apana.org.au
Subject: Re: [NETLINK] introduce netlink bucket
Date: Sun, 21 Nov 2004 23:24:35 +0100	[thread overview]
Message-ID: <41A115A3.3020509@eurodev.net> (raw)
In-Reply-To: <20041103154833.164e33f5.davem@davemloft.net>

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

David S. Miller wrote:

>On Tue, 02 Nov 2004 22:41:44 +0100
>Pablo Neira <pablo@eurodev.net> wrote:
>
>  
>
>>This patch introduces the netlink bucket struct, it joins three arrays 
>>into an array of netlink bucket.
>>
>>Signed-off-by: Pablo Neira Ayuso <pablo@eurodev.net>
>>    
>>
>
>Here is the work Herbert and I were talking about.  It kind
>of makes your patch taken care of already :-)
>  
>

Move netlink_kernel and nl_nonroot arrays to nl_table structure. Do you 
like it?

--
Pablo

[-- Attachment #2: X --]
[-- Type: text/plain, Size: 1991 bytes --]

===== net/netlink/af_netlink.c 1.62 vs edited =====
--- 1.62/net/netlink/af_netlink.c	2004-11-15 23:57:51 +01:00
+++ edited/net/netlink/af_netlink.c	2004-11-21 20:43:06 +01:00
@@ -91,16 +91,15 @@
 struct netlink_table {
 	struct nl_pid_hash hash;
 	struct hlist_head mc_list;
+	unsigned int nl_nonroot;
+#ifdef NL_EMULATE_DEV
+	struct socket *netlink_kernel;
+#endif
 };
 
 static struct netlink_table *nl_table;
 
 static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait);
-static unsigned int nl_nonroot[MAX_LINKS];
-
-#ifdef NL_EMULATE_DEV
-static struct socket *netlink_kernel[MAX_LINKS];
-#endif
 
 static int netlink_dump(struct sock *sk);
 static void netlink_destroy_callback(struct netlink_callback *cb);
@@ -442,7 +441,7 @@
 
 static inline int netlink_capable(struct socket *sock, unsigned int flag) 
 { 
-	return (nl_nonroot[sock->sk->sk_protocol] & flag) ||
+	return (nl_table[sock->sk->sk_protocol].nl_nonroot & flag) ||
 	       capable(CAP_NET_ADMIN);
 } 
 
@@ -1066,7 +1065,7 @@
 void netlink_set_nonroot(int protocol, unsigned int flags)
 { 
 	if ((unsigned int)protocol < MAX_LINKS) 
-		nl_nonroot[protocol] = flags;
+		nl_table[protocol].nl_nonroot = flags;
 } 
 
 static void netlink_destroy_callback(struct netlink_callback *cb)
@@ -1217,7 +1216,7 @@
 		return -ENOBUFS;
 	nlk_sk(sk)->handler = function;
 	write_lock_bh(&nl_emu_lock);
-	netlink_kernel[unit] = sk->sk_socket;
+	nl_table[unit].netlink_kernel = sk->sk_socket;
 	write_unlock_bh(&nl_emu_lock);
 	return 0;
 }
@@ -1227,8 +1226,8 @@
 	struct socket *sock;
 
 	write_lock_bh(&nl_emu_lock);
-	sock = netlink_kernel[unit];
-	netlink_kernel[unit] = NULL;
+	sock = nl_table[unit].netlink_kernel;
+	nl_table[unit].netlink_kernel = NULL;
 	write_unlock_bh(&nl_emu_lock);
 
 	sock_release(sock);
@@ -1239,7 +1238,7 @@
 	struct socket *sock;
 
 	read_lock(&nl_emu_lock);
-	sock = netlink_kernel[unit];
+	sock = nl_table[unit].netlink_kernel;
 	if (sock) {
 		struct sock *sk = sock->sk;
 		memset(skb->cb, 0, sizeof(skb->cb));

      reply	other threads:[~2004-11-21 22:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-02 21:41 [NETLINK] introduce netlink bucket Pablo Neira
2004-11-02 22:16 ` Herbert Xu
2004-11-02 22:22   ` Pablo Neira
2004-11-02 22:16     ` David S. Miller
2004-11-03 23:48 ` David S. Miller
2004-11-21 22:24   ` Pablo Neira [this message]

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=41A115A3.3020509@eurodev.net \
    --to=pablo@eurodev.net \
    --cc=davem@davemloft.net \
    --cc=davem@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@oss.sgi.com \
    /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).