diff options
author | Octavian Purdila <opurdila@ixiacom.com> | 2009-12-26 06:51:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-26 23:43:57 -0500 |
commit | 6d2e3ea284463d5ab34e9cf2a41d0b8627b95d02 (patch) | |
tree | 86ee780b06adfe388ac64dd66ece598be69b29ec | |
parent | 0f7b67dd9e1192976f5e5a78934c7a339ff7c45f (diff) |
llc: use a device based hash table to speed up multicast delivery
This patch adds a per SAP device based hash table to solve the
multicast delivery scalability issue when we have large number of
interfaces and a large number of sockets bound to the same SAP.
Signed-off-by: Octavian Purdila <opurdila@ixiacom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/llc.h | 11 | ||||
-rw-r--r-- | include/net/llc_conn.h | 1 | ||||
-rw-r--r-- | net/llc/llc_conn.c | 10 | ||||
-rw-r--r-- | net/llc/llc_sap.c | 8 |
4 files changed, 27 insertions, 3 deletions
diff --git a/include/net/llc.h b/include/net/llc.h index 1559cf10e874..dbef5917905b 100644 --- a/include/net/llc.h +++ b/include/net/llc.h | |||
@@ -32,6 +32,9 @@ struct llc_addr { | |||
32 | #define LLC_SAP_STATE_INACTIVE 1 | 32 | #define LLC_SAP_STATE_INACTIVE 1 |
33 | #define LLC_SAP_STATE_ACTIVE 2 | 33 | #define LLC_SAP_STATE_ACTIVE 2 |
34 | 34 | ||
35 | #define LLC_SK_DEV_HASH_BITS 6 | ||
36 | #define LLC_SK_DEV_HASH_ENTRIES (1<<LLC_SK_DEV_HASH_BITS) | ||
37 | |||
35 | /** | 38 | /** |
36 | * struct llc_sap - Defines the SAP component | 39 | * struct llc_sap - Defines the SAP component |
37 | * | 40 | * |
@@ -56,8 +59,16 @@ struct llc_sap { | |||
56 | struct list_head node; | 59 | struct list_head node; |
57 | spinlock_t sk_lock; | 60 | spinlock_t sk_lock; |
58 | struct hlist_nulls_head sk_list; | 61 | struct hlist_nulls_head sk_list; |
62 | struct hlist_head sk_dev_hash[LLC_SK_DEV_HASH_ENTRIES]; | ||
59 | }; | 63 | }; |
60 | 64 | ||
65 | static inline | ||
66 | struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex) | ||
67 | { | ||
68 | return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES]; | ||
69 | } | ||
70 | |||
71 | |||
61 | #define LLC_DEST_INVALID 0 /* Invalid LLC PDU type */ | 72 | #define LLC_DEST_INVALID 0 /* Invalid LLC PDU type */ |
62 | #define LLC_DEST_SAP 1 /* Type 1 goes here */ | 73 | #define LLC_DEST_SAP 1 /* Type 1 goes here */ |
63 | #define LLC_DEST_CONN 2 /* Type 2 goes here */ | 74 | #define LLC_DEST_CONN 2 /* Type 2 goes here */ |
diff --git a/include/net/llc_conn.h b/include/net/llc_conn.h index fe982fd94c4a..2f97d8ddce92 100644 --- a/include/net/llc_conn.h +++ b/include/net/llc_conn.h | |||
@@ -77,6 +77,7 @@ struct llc_sock { | |||
77 | received and caused sending FRMR. | 77 | received and caused sending FRMR. |
78 | Used for resending FRMR */ | 78 | Used for resending FRMR */ |
79 | u32 cmsg_flags; | 79 | u32 cmsg_flags; |
80 | struct hlist_node dev_hash_node; | ||
80 | }; | 81 | }; |
81 | 82 | ||
82 | static inline struct llc_sock *llc_sk(const struct sock *sk) | 83 | static inline struct llc_sock *llc_sk(const struct sock *sk) |
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c index 77bb3816655e..10cdfe2db830 100644 --- a/net/llc/llc_conn.c +++ b/net/llc/llc_conn.c | |||
@@ -682,10 +682,15 @@ static int llc_find_offset(int state, int ev_type) | |||
682 | */ | 682 | */ |
683 | void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) | 683 | void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) |
684 | { | 684 | { |
685 | struct llc_sock *llc = llc_sk(sk); | ||
686 | struct hlist_head *dev_hb = llc_sk_dev_hash(sap, llc->dev->ifindex); | ||
687 | |||
685 | llc_sap_hold(sap); | 688 | llc_sap_hold(sap); |
686 | spin_lock_bh(&sap->sk_lock); | ||
687 | llc_sk(sk)->sap = sap; | 689 | llc_sk(sk)->sap = sap; |
690 | |||
691 | spin_lock_bh(&sap->sk_lock); | ||
688 | sk_nulls_add_node_rcu(sk, &sap->sk_list); | 692 | sk_nulls_add_node_rcu(sk, &sap->sk_list); |
693 | hlist_add_head(&llc->dev_hash_node, dev_hb); | ||
689 | spin_unlock_bh(&sap->sk_lock); | 694 | spin_unlock_bh(&sap->sk_lock); |
690 | } | 695 | } |
691 | 696 | ||
@@ -699,8 +704,11 @@ void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) | |||
699 | */ | 704 | */ |
700 | void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk) | 705 | void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk) |
701 | { | 706 | { |
707 | struct llc_sock *llc = llc_sk(sk); | ||
708 | |||
702 | spin_lock_bh(&sap->sk_lock); | 709 | spin_lock_bh(&sap->sk_lock); |
703 | sk_nulls_del_node_init_rcu(sk); | 710 | sk_nulls_del_node_init_rcu(sk); |
711 | hlist_del(&llc->dev_hash_node); | ||
704 | spin_unlock_bh(&sap->sk_lock); | 712 | spin_unlock_bh(&sap->sk_lock); |
705 | llc_sap_put(sap); | 713 | llc_sap_put(sap); |
706 | } | 714 | } |
diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c index 94790e60d072..94cb706f6cc4 100644 --- a/net/llc/llc_sap.c +++ b/net/llc/llc_sap.c | |||
@@ -387,10 +387,14 @@ static void llc_sap_mcast(struct llc_sap *sap, | |||
387 | { | 387 | { |
388 | int i = 0, count = 256 / sizeof(struct sock *); | 388 | int i = 0, count = 256 / sizeof(struct sock *); |
389 | struct sock *sk, *stack[count]; | 389 | struct sock *sk, *stack[count]; |
390 | struct hlist_nulls_node *node; | 390 | struct hlist_node *node; |
391 | struct llc_sock *llc; | ||
392 | struct hlist_head *dev_hb = llc_sk_dev_hash(sap, skb->dev->ifindex); | ||
391 | 393 | ||
392 | spin_lock_bh(&sap->sk_lock); | 394 | spin_lock_bh(&sap->sk_lock); |
393 | sk_nulls_for_each_rcu(sk, node, &sap->sk_list) { | 395 | hlist_for_each_entry(llc, node, dev_hb, dev_hash_node) { |
396 | |||
397 | sk = &llc->sk; | ||
394 | 398 | ||
395 | if (!llc_mcast_match(sap, laddr, skb, sk)) | 399 | if (!llc_mcast_match(sap, laddr, skb, sk)) |
396 | continue; | 400 | continue; |