Skip to content

Commit b5eff71

Browse files
lxindavem330
authored andcommitted
sctp: drop the old assoc hashtable of sctp
transport hashtable will replace the association hashtable, so association hashtable is not used in sctp any more, so drop the codes about that. Signed-off-by: Xin Long <[email protected]> Signed-off-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 39f66a7 commit b5eff71

File tree

6 files changed

+3
-122
lines changed

6 files changed

+3
-122
lines changed

include/net/sctp/sctp.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ int sctp_primitive_ASCONF(struct net *, struct sctp_association *, void *arg);
126126
*/
127127
int sctp_rcv(struct sk_buff *skb);
128128
void sctp_v4_err(struct sk_buff *skb, u32 info);
129-
void sctp_hash_established(struct sctp_association *);
130-
void sctp_unhash_established(struct sctp_association *);
131129
void sctp_hash_endpoint(struct sctp_endpoint *);
132130
void sctp_unhash_endpoint(struct sctp_endpoint *);
133131
struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *,
@@ -530,25 +528,6 @@ static inline int sctp_ep_hashfn(struct net *net, __u16 lport)
530528
return (net_hash_mix(net) + lport) & (sctp_ep_hashsize - 1);
531529
}
532530

533-
/* This is the hash function for the association hash table. */
534-
static inline int sctp_assoc_hashfn(struct net *net, __u16 lport, __u16 rport)
535-
{
536-
int h = (lport << 16) + rport + net_hash_mix(net);
537-
h ^= h>>8;
538-
return h & (sctp_assoc_hashsize - 1);
539-
}
540-
541-
/* This is the hash function for the association hash table. This is
542-
* not used yet, but could be used as a better hash function when
543-
* we have a vtag.
544-
*/
545-
static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag)
546-
{
547-
int h = (lport << 16) + rport;
548-
h ^= vtag;
549-
return h & (sctp_assoc_hashsize - 1);
550-
}
551-
552531
#define sctp_for_each_hentry(epb, head) \
553532
hlist_for_each_entry(epb, head, node)
554533

include/net/sctp/structs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,13 @@ extern struct sctp_globals {
120120

121121
/* This is the hash of all endpoints. */
122122
struct sctp_hashbucket *ep_hashtable;
123-
/* This is the hash of all associations. */
124-
struct sctp_hashbucket *assoc_hashtable;
125123
/* This is the sctp port control hash. */
126124
struct sctp_bind_hashbucket *port_hashtable;
127125
/* This is the hash of all transports. */
128126
struct rhashtable transport_hashtable;
129127

130128
/* Sizes of above hashtables. */
131129
int ep_hashsize;
132-
int assoc_hashsize;
133130
int port_hashsize;
134131

135132
/* Default initialization values to be applied to new associations. */
@@ -146,8 +143,6 @@ extern struct sctp_globals {
146143
#define sctp_address_families (sctp_globals.address_families)
147144
#define sctp_ep_hashsize (sctp_globals.ep_hashsize)
148145
#define sctp_ep_hashtable (sctp_globals.ep_hashtable)
149-
#define sctp_assoc_hashsize (sctp_globals.assoc_hashsize)
150-
#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)
151146
#define sctp_port_hashsize (sctp_globals.port_hashsize)
152147
#define sctp_port_hashtable (sctp_globals.port_hashtable)
153148
#define sctp_transport_hashtable (sctp_globals.transport_hashtable)

net/sctp/input.c

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -913,67 +913,6 @@ struct sctp_transport *sctp_epaddr_lookup_transport(
913913
return sctp_addrs_lookup_transport(net, &addr->a, paddr);
914914
}
915915

916-
/* Insert association into the hash table. */
917-
static void __sctp_hash_established(struct sctp_association *asoc)
918-
{
919-
struct net *net = sock_net(asoc->base.sk);
920-
struct sctp_ep_common *epb;
921-
struct sctp_hashbucket *head;
922-
923-
epb = &asoc->base;
924-
925-
/* Calculate which chain this entry will belong to. */
926-
epb->hashent = sctp_assoc_hashfn(net, epb->bind_addr.port,
927-
asoc->peer.port);
928-
929-
head = &sctp_assoc_hashtable[epb->hashent];
930-
931-
write_lock(&head->lock);
932-
hlist_add_head(&epb->node, &head->chain);
933-
write_unlock(&head->lock);
934-
}
935-
936-
/* Add an association to the hash. Local BH-safe. */
937-
void sctp_hash_established(struct sctp_association *asoc)
938-
{
939-
if (asoc->temp)
940-
return;
941-
942-
local_bh_disable();
943-
__sctp_hash_established(asoc);
944-
local_bh_enable();
945-
}
946-
947-
/* Remove association from the hash table. */
948-
static void __sctp_unhash_established(struct sctp_association *asoc)
949-
{
950-
struct net *net = sock_net(asoc->base.sk);
951-
struct sctp_hashbucket *head;
952-
struct sctp_ep_common *epb;
953-
954-
epb = &asoc->base;
955-
956-
epb->hashent = sctp_assoc_hashfn(net, epb->bind_addr.port,
957-
asoc->peer.port);
958-
959-
head = &sctp_assoc_hashtable[epb->hashent];
960-
961-
write_lock(&head->lock);
962-
hlist_del_init(&epb->node);
963-
write_unlock(&head->lock);
964-
}
965-
966-
/* Remove association from the hash table. Local BH-safe. */
967-
void sctp_unhash_established(struct sctp_association *asoc)
968-
{
969-
if (asoc->temp)
970-
return;
971-
972-
local_bh_disable();
973-
__sctp_unhash_established(asoc);
974-
local_bh_enable();
975-
}
976-
977916
/* Look up an association. */
978917
static struct sctp_association *__sctp_lookup_association(
979918
struct net *net,

net/sctp/protocol.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,24 +1416,6 @@ static __init int sctp_init(void)
14161416
for (order = 0; (1UL << order) < goal; order++)
14171417
;
14181418

1419-
do {
1420-
sctp_assoc_hashsize = (1UL << order) * PAGE_SIZE /
1421-
sizeof(struct sctp_hashbucket);
1422-
if ((sctp_assoc_hashsize > (64 * 1024)) && order > 0)
1423-
continue;
1424-
sctp_assoc_hashtable = (struct sctp_hashbucket *)
1425-
__get_free_pages(GFP_KERNEL | __GFP_NOWARN, order);
1426-
} while (!sctp_assoc_hashtable && --order > 0);
1427-
if (!sctp_assoc_hashtable) {
1428-
pr_err("Failed association hash alloc\n");
1429-
status = -ENOMEM;
1430-
goto err_ahash_alloc;
1431-
}
1432-
for (i = 0; i < sctp_assoc_hashsize; i++) {
1433-
rwlock_init(&sctp_assoc_hashtable[i].lock);
1434-
INIT_HLIST_HEAD(&sctp_assoc_hashtable[i].chain);
1435-
}
1436-
14371419
/* Allocate and initialize the endpoint hash table. */
14381420
sctp_ep_hashsize = 64;
14391421
sctp_ep_hashtable =
@@ -1470,8 +1452,7 @@ static __init int sctp_init(void)
14701452
if (sctp_transport_hashtable_init())
14711453
goto err_thash_alloc;
14721454

1473-
pr_info("Hash tables configured (established %d bind %d)\n",
1474-
sctp_assoc_hashsize, sctp_port_hashsize);
1455+
pr_info("Hash tables configured (bind %d)\n", sctp_port_hashsize);
14751456

14761457
sctp_sysctl_register();
14771458

@@ -1528,10 +1509,6 @@ static __init int sctp_init(void)
15281509
err_thash_alloc:
15291510
kfree(sctp_ep_hashtable);
15301511
err_ehash_alloc:
1531-
free_pages((unsigned long)sctp_assoc_hashtable,
1532-
get_order(sctp_assoc_hashsize *
1533-
sizeof(struct sctp_hashbucket)));
1534-
err_ahash_alloc:
15351512
percpu_counter_destroy(&sctp_sockets_allocated);
15361513
err_percpu_counter_init:
15371514
kmem_cache_destroy(sctp_chunk_cachep);
@@ -1565,13 +1542,10 @@ static __exit void sctp_exit(void)
15651542

15661543
sctp_sysctl_unregister();
15671544

1568-
free_pages((unsigned long)sctp_assoc_hashtable,
1569-
get_order(sctp_assoc_hashsize *
1570-
sizeof(struct sctp_hashbucket)));
1571-
kfree(sctp_ep_hashtable);
15721545
free_pages((unsigned long)sctp_port_hashtable,
15731546
get_order(sctp_port_hashsize *
15741547
sizeof(struct sctp_bind_hashbucket)));
1548+
kfree(sctp_ep_hashtable);
15751549
sctp_transport_hashtable_destroy();
15761550

15771551
percpu_counter_destroy(&sctp_sockets_allocated);

net/sctp/sm_sideeffect.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,6 @@ static void sctp_cmd_delete_tcb(sctp_cmd_seq_t *cmds,
866866
(!asoc->temp) && (sk->sk_shutdown != SHUTDOWN_MASK))
867867
return;
868868

869-
sctp_unhash_established(asoc);
870869
sctp_association_free(asoc);
871870
}
872871

@@ -1269,7 +1268,6 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
12691268
asoc = cmd->obj.asoc;
12701269
BUG_ON(asoc->peer.primary_path == NULL);
12711270
sctp_endpoint_add_asoc(ep, asoc);
1272-
sctp_hash_established(asoc);
12731271
break;
12741272

12751273
case SCTP_CMD_UPDATE_ASSOC:

net/sctp/socket.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,6 @@ static int __sctp_connect(struct sock *sk,
12281228
* To the hash table, try to unhash it, just in case, its a noop
12291229
* if it wasn't hashed so we're safe
12301230
*/
1231-
sctp_unhash_established(asoc);
12321231
sctp_association_free(asoc);
12331232
}
12341233
return err;
@@ -1504,7 +1503,6 @@ static void sctp_close(struct sock *sk, long timeout)
15041503
* ABORT or SHUTDOWN based on the linger options.
15051504
*/
15061505
if (sctp_state(asoc, CLOSED)) {
1507-
sctp_unhash_established(asoc);
15081506
sctp_association_free(asoc);
15091507
continue;
15101508
}
@@ -1986,10 +1984,8 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
19861984
goto out_unlock;
19871985

19881986
out_free:
1989-
if (new_asoc) {
1990-
sctp_unhash_established(asoc);
1987+
if (new_asoc)
19911988
sctp_association_free(asoc);
1992-
}
19931989
out_unlock:
19941990
release_sock(sk);
19951991

0 commit comments

Comments
 (0)