netdev
[Top] [All Lists]

Re: [NETLINK] introduce netlink bucket

To: "David S. Miller" <davem@xxxxxxxxxxxxx>
Subject: Re: [NETLINK] introduce netlink bucket
From: Pablo Neira <pablo@xxxxxxxxxxx>
Date: Sun, 21 Nov 2004 23:24:35 +0100
Cc: netdev@xxxxxxxxxxx, davem@xxxxxxxxxx, herbert@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20041103154833.164e33f5.davem@xxxxxxxxxxxxx>
References: <4187FF18.5050608@xxxxxxxxxxx> <20041103154833.164e33f5.davem@xxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Debian/1.6-5
David S. Miller wrote:

On Tue, 02 Nov 2004 22:41:44 +0100
Pablo Neira <pablo@xxxxxxxxxxx> 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@xxxxxxxxxxx>

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
===== 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));
<Prev in Thread] Current Thread [Next in Thread>