diff options
author | Denis V. Lunev <den@openvz.org> | 2007-10-11 00:15:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-10-11 00:15:29 -0400 |
commit | cd40b7d3983c708aabe3d3008ec64ffce56d33b0 (patch) | |
tree | 0d6fe9cfd2f03fdeee126e317d4bfb145afc458d /net/ipv4 | |
parent | aed815601f3f95281ab3a01f7e2cbe1bd54285a0 (diff) |
[NET]: make netlink user -> kernel interface synchronious
This patch make processing netlink user -> kernel messages synchronious.
This change was inspired by the talk with Alexey Kuznetsov about current
netlink messages processing. He says that he was badly wrong when introduced
asynchronious user -> kernel communication.
The call netlink_unicast is the only path to send message to the kernel
netlink socket. But, unfortunately, it is also used to send data to the
user.
Before this change the user message has been attached to the socket queue
and sk->sk_data_ready was called. The process has been blocked until all
pending messages were processed. The bad thing is that this processing
may occur in the arbitrary process context.
This patch changes nlk->data_ready callback to get 1 skb and force packet
processing right in the netlink_unicast.
Kernel -> user path in netlink_unicast remains untouched.
EINTR processing for in netlink_run_queue was changed. It forces rtnl_lock
drop, but the process remains in the cycle until the message will be fully
processed. So, there is no need to use this kludges now.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/fib_frontend.c | 9 | ||||
-rw-r--r-- | net/ipv4/inet_diag.c | 12 | ||||
-rw-r--r-- | net/ipv4/netfilter/ip_queue.c | 17 |
3 files changed, 14 insertions, 24 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index f823ca34cb12..a5cba2349605 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -62,6 +62,9 @@ static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ]; | |||
62 | #define FIB_TABLE_HASHSZ 256 | 62 | #define FIB_TABLE_HASHSZ 256 |
63 | static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ]; | 63 | static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ]; |
64 | 64 | ||
65 | static struct sock *fibnl = NULL; | ||
66 | |||
67 | |||
65 | struct fib_table *fib_new_table(u32 id) | 68 | struct fib_table *fib_new_table(u32 id) |
66 | { | 69 | { |
67 | struct fib_table *tb; | 70 | struct fib_table *tb; |
@@ -811,13 +814,13 @@ static void nl_fib_input(struct sock *sk, int len) | |||
811 | pid = NETLINK_CB(skb).pid; /* pid of sending process */ | 814 | pid = NETLINK_CB(skb).pid; /* pid of sending process */ |
812 | NETLINK_CB(skb).pid = 0; /* from kernel */ | 815 | NETLINK_CB(skb).pid = 0; /* from kernel */ |
813 | NETLINK_CB(skb).dst_group = 0; /* unicast */ | 816 | NETLINK_CB(skb).dst_group = 0; /* unicast */ |
814 | netlink_unicast(sk, skb, pid, MSG_DONTWAIT); | 817 | netlink_unicast(fibnl, skb, pid, MSG_DONTWAIT); |
815 | } | 818 | } |
816 | 819 | ||
817 | static void nl_fib_lookup_init(void) | 820 | static void nl_fib_lookup_init(void) |
818 | { | 821 | { |
819 | netlink_kernel_create(&init_net, NETLINK_FIB_LOOKUP, 0, nl_fib_input, | 822 | fibnl = netlink_kernel_create(&init_net, NETLINK_FIB_LOOKUP, 0, |
820 | NULL, THIS_MODULE); | 823 | nl_fib_input, NULL, THIS_MODULE); |
821 | } | 824 | } |
822 | 825 | ||
823 | static void fib_disable_ip(struct net_device *dev, int force) | 826 | static void fib_disable_ip(struct net_device *dev, int force) |
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index b04a6ee5a9a1..7eb83ebed2ec 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -839,15 +839,11 @@ static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
839 | 839 | ||
840 | static DEFINE_MUTEX(inet_diag_mutex); | 840 | static DEFINE_MUTEX(inet_diag_mutex); |
841 | 841 | ||
842 | static void inet_diag_rcv(struct sock *sk, int len) | 842 | static void inet_diag_rcv(struct sk_buff *skb) |
843 | { | 843 | { |
844 | unsigned int qlen = 0; | 844 | mutex_lock(&inet_diag_mutex); |
845 | 845 | netlink_rcv_skb(skb, &inet_diag_rcv_msg); | |
846 | do { | 846 | mutex_unlock(&inet_diag_mutex); |
847 | mutex_lock(&inet_diag_mutex); | ||
848 | qlen = netlink_run_queue(sk, qlen, &inet_diag_rcv_msg); | ||
849 | mutex_unlock(&inet_diag_mutex); | ||
850 | } while (qlen); | ||
851 | } | 847 | } |
852 | 848 | ||
853 | static DEFINE_SPINLOCK(inet_diag_register_lock); | 849 | static DEFINE_SPINLOCK(inet_diag_register_lock); |
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c index aaa3f5c56761..23cbfc7c80fd 100644 --- a/net/ipv4/netfilter/ip_queue.c +++ b/net/ipv4/netfilter/ip_queue.c | |||
@@ -475,7 +475,7 @@ ipq_dev_drop(int ifindex) | |||
475 | #define RCV_SKB_FAIL(err) do { netlink_ack(skb, nlh, (err)); return; } while (0) | 475 | #define RCV_SKB_FAIL(err) do { netlink_ack(skb, nlh, (err)); return; } while (0) |
476 | 476 | ||
477 | static inline void | 477 | static inline void |
478 | ipq_rcv_skb(struct sk_buff *skb) | 478 | __ipq_rcv_skb(struct sk_buff *skb) |
479 | { | 479 | { |
480 | int status, type, pid, flags, nlmsglen, skblen; | 480 | int status, type, pid, flags, nlmsglen, skblen; |
481 | struct nlmsghdr *nlh; | 481 | struct nlmsghdr *nlh; |
@@ -533,19 +533,10 @@ ipq_rcv_skb(struct sk_buff *skb) | |||
533 | } | 533 | } |
534 | 534 | ||
535 | static void | 535 | static void |
536 | ipq_rcv_sk(struct sock *sk, int len) | 536 | ipq_rcv_skb(struct sk_buff *skb) |
537 | { | 537 | { |
538 | struct sk_buff *skb; | ||
539 | unsigned int qlen; | ||
540 | |||
541 | mutex_lock(&ipqnl_mutex); | 538 | mutex_lock(&ipqnl_mutex); |
542 | 539 | __ipq_rcv_skb(skb); | |
543 | for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) { | ||
544 | skb = skb_dequeue(&sk->sk_receive_queue); | ||
545 | ipq_rcv_skb(skb); | ||
546 | kfree_skb(skb); | ||
547 | } | ||
548 | |||
549 | mutex_unlock(&ipqnl_mutex); | 540 | mutex_unlock(&ipqnl_mutex); |
550 | } | 541 | } |
551 | 542 | ||
@@ -670,7 +661,7 @@ static int __init ip_queue_init(void) | |||
670 | 661 | ||
671 | netlink_register_notifier(&ipq_nl_notifier); | 662 | netlink_register_notifier(&ipq_nl_notifier); |
672 | ipqnl = netlink_kernel_create(&init_net, NETLINK_FIREWALL, 0, | 663 | ipqnl = netlink_kernel_create(&init_net, NETLINK_FIREWALL, 0, |
673 | ipq_rcv_sk, NULL, THIS_MODULE); | 664 | ipq_rcv_skb, NULL, THIS_MODULE); |
674 | if (ipqnl == NULL) { | 665 | if (ipqnl == NULL) { |
675 | printk(KERN_ERR "ip_queue: failed to create netlink socket\n"); | 666 | printk(KERN_ERR "ip_queue: failed to create netlink socket\n"); |
676 | goto cleanup_netlink_notifier; | 667 | goto cleanup_netlink_notifier; |