[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dccp] [PATCH] Remerge - stage 2 of history refactoring



Arnaldo,

This is stage 2 of history refactoring. Found this a little trickier to
remerge due to inet_hashinfo change. Thought about altering style of
this but leaving slabs in proto.c. Feel free to alter if you disagree.

Also some tidyup of copyrights/owners.

Signed-off-by: Ian McDonald <iam4 at cs.waikato.ac.nz>
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -2,12 +2,12 @@
  *  net/dccp/ccids/ccid3.c
  *
  *  Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
+ *  Copyright (c) 2005 Ian Mcdonald <imcdnzl at gmail.com>
  *
  *  An implementation of the DCCP protocol
  *
  *  This code has been developed by the University of Waikato WAND
  *  research group. For further information please see http://www.wand.net.nz/
- *  or e-mail Ian McDonald - iam4 at cs.waikato.ac.nz
  *
  *  This code also uses code from Lulea University, rereleased as GPL by its
  *  authors:
@@ -82,61 +82,8 @@ enum ccid3_options {
 
 static int ccid3_debug;
 
-static kmem_cache_t *dccp_tx_hist_slab;
-static kmem_cache_t *dccp_rx_hist_slab;
 static kmem_cache_t *ccid3_loss_interval_hist_slab;
 
-static inline struct dccp_tx_hist_entry *dccp_tx_hist_entry_new(int prio)
-{
-	struct dccp_tx_hist_entry *entry = kmem_cache_alloc(dccp_tx_hist_slab, prio);
-
-	if (entry != NULL)
-		entry->tx_hist_sent = 0;
-
-	return entry;
-}
-
-static inline void dccp_tx_hist_entry_delete(struct dccp_tx_hist_entry *entry)
-{
-	if (entry != NULL)
-		kmem_cache_free(dccp_tx_hist_slab, entry);
-}
-
-static inline struct dccp_rx_hist_entry *dccp_rx_hist_entry_new(struct sock *sk,
-								  struct sk_buff *skb,
-								  int prio)
-{
-	struct dccp_rx_hist_entry *entry = kmem_cache_alloc(dccp_rx_hist_slab, prio);
-
-	if (entry != NULL) {
-		const struct dccp_hdr *dh = dccp_hdr(skb);
-
-		entry->rx_hist_seqno	  = DCCP_SKB_CB(skb)->dccpd_seq;
-		entry->rx_hist_ccval = dh->dccph_ccval;
-		entry->rx_hist_type	  = dh->dccph_type;
-		entry->rx_hist_ndp 	  = dccp_sk(sk)->dccps_options_received.dccpor_ndp;
-		do_gettimeofday(&(entry->rx_hist_rxtime));
-	}
-
-	return entry;
-}
-
-static inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist_entry *entry)
-{
-	if (entry != NULL)
-		kmem_cache_free(dccp_rx_hist_slab, entry);
-}
-
-static void ccid3_rx_history_delete(struct list_head *hist)
-{
-	struct dccp_rx_hist_entry *entry, *next;
-
-	list_for_each_entry_safe(entry, next, hist, rx_hist_node) {
-		list_del_init(&entry->rx_hist_node);
-		kmem_cache_free(dccp_rx_hist_slab, entry);
-	}
-}
-
 static inline struct ccid3_loss_interval_hist_entry *ccid3_loss_interval_hist_entry_new(int prio)
 {
 	return kmem_cache_alloc(ccid3_loss_interval_hist_slab, prio);
@@ -2059,7 +2006,7 @@ static void ccid3_hc_rx_exit(struct sock
 	ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM);
 
 	/* Empty packet history */
-	ccid3_rx_history_delete(&dp->dccps_rx_history);
+	dccp_rx_history_delete(&dp->dccps_rx_history);
 
 	/* Empty loss interval history */
 	ccid3_loss_interval_history_delete(&hcrx->ccid3hcrx_loss_interval_hist);
@@ -2094,23 +2041,11 @@ static __init int ccid3_module_init(void
 {
 	int rc = -ENOMEM;
 
-	dccp_tx_hist_slab = kmem_cache_create("dccp_tx_history",
-					       sizeof(struct dccp_tx_hist_entry), 0,
-					       SLAB_HWCACHE_ALIGN, NULL, NULL);
-	if (dccp_tx_hist_slab == NULL)
-		goto out;
-
-	dccp_rx_hist_slab = kmem_cache_create("dccp_rx_history",
-					       sizeof(struct dccp_rx_hist_entry), 0,
-					       SLAB_HWCACHE_ALIGN, NULL, NULL);
-	if (dccp_rx_hist_slab == NULL)
-		goto out_free_tx_history;
-
 	ccid3_loss_interval_hist_slab = kmem_cache_create("dccp_ccid3_loss_interval_history",
 							  sizeof(struct ccid3_loss_interval_hist_entry), 0,
 							  SLAB_HWCACHE_ALIGN, NULL, NULL);
 	if (ccid3_loss_interval_hist_slab == NULL)
-		goto out_free_rx_history;
+		goto out;
 
 	rc = ccid_register(&ccid3);
 	if (rc != 0) 
@@ -2121,12 +2056,6 @@ out:
 out_free_loss_interval_history:
 	kmem_cache_destroy(ccid3_loss_interval_hist_slab);
 	ccid3_loss_interval_hist_slab = NULL;
-out_free_rx_history:
-	kmem_cache_destroy(dccp_rx_hist_slab);
-	dccp_rx_hist_slab = NULL;
-out_free_tx_history:
-	kmem_cache_destroy(dccp_tx_hist_slab);
-	dccp_tx_hist_slab = NULL;
 	goto out;
 }
 module_init(ccid3_module_init);
@@ -2135,14 +2064,6 @@ static __exit void ccid3_module_exit(voi
 {
 	ccid_unregister(&ccid3);
 
-	if (dccp_tx_hist_slab != NULL) {
-		kmem_cache_destroy(dccp_tx_hist_slab);
-		dccp_tx_hist_slab = NULL;
-	}
-	if (dccp_rx_hist_slab != NULL) {
-		kmem_cache_destroy(dccp_rx_hist_slab);
-		dccp_rx_hist_slab = NULL;
-	}
 	if (ccid3_loss_interval_hist_slab != NULL) {
 		kmem_cache_destroy(ccid3_loss_interval_hist_slab);
 		ccid3_loss_interval_hist_slab = NULL;
@@ -2150,7 +2071,7 @@ static __exit void ccid3_module_exit(voi
 }
 module_exit(ccid3_module_exit);
 
-MODULE_AUTHOR("Ian McDonald <iam4 at cs.waikato.ac.nz> & Arnaldo Carvalho de Melo <acme at ghostprotocols.net>");
+MODULE_AUTHOR("Ian McDonald <imcdnzl at gmail.com> & Arnaldo Carvalho de Melo <acme at ghostprotocols.net>");
 MODULE_DESCRIPTION("DCCP TFRC CCID3 CCID");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("net-dccp-ccid-3");
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -4,7 +4,8 @@
  *  net/dccp/dccp.h
  *
  *  An implementation of the DCCP protocol
- *  Arnaldo Carvalho de Melo <acme at conectiva.com.br>
+ *  Copyright (c) 2005 Arnaldo Carvalho de Melo <acme at conectiva.com.br>
+ *  Copyright (c) 2005 Ian McDonald <imcdnzl at gmail.com>
  *
  *	This program is free software; you can redistribute it and/or
  *	modify it under the terms of the GNU General Public License
@@ -434,4 +435,11 @@ static inline void dccp_ackvector_print(
 static inline void dccp_ackpkts_print(const struct dccp_ackpkts *ap) { }
 #endif
 
+inline struct dccp_tx_hist_entry *dccp_tx_hist_entry_new(int prio);
+inline void dccp_tx_hist_entry_delete(struct dccp_tx_hist_entry *entry);
+inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist_entry *entry);
+inline struct dccp_rx_hist_entry *dccp_rx_hist_entry_new(struct sock *sk,
+	struct sk_buff *skb, int prio);
+void dccp_rx_history_delete(struct list_head *hist);
+
 #endif /* _DCCP_H */
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -2,7 +2,8 @@
  *  net/dccp/proto.c
  *
  *  An implementation of the DCCP protocol
- *  Arnaldo Carvalho de Melo <acme at conectiva.com.br>
+ *  Copyright (c) 2005 Arnaldo Carvalho de Melo <acme at conectiva.com.br>
+ *  Copyright (c) 2005 Ian McDonald <imcdnzl at gmail.com>
  *
  *	This program is free software; you can redistribute it and/or modify it
  *	under the terms of the GNU General Public License version 2 as
@@ -39,7 +40,8 @@
 #include "ccid.h"
 #include "dccp.h"
 
-DEFINE_SNMP_STAT(struct dccp_mib, dccp_statistics);
+static kmem_cache_t *dccp_tx_hist_slab;
+static kmem_cache_t *dccp_rx_hist_slab;DEFINE_SNMP_STAT(struct dccp_mib, dccp_statistics);
 
 atomic_t dccp_orphan_count = ATOMIC_INIT(0);
 
@@ -168,6 +170,67 @@ int dccp_getsockopt(struct sock *sk, int
 	return -EOPNOTSUPP;
 }
 
+inline void dccp_tx_hist_entry_delete(struct dccp_tx_hist_entry *entry)
+{
+	if (entry != NULL)
+		kmem_cache_free(dccp_tx_hist_slab, entry);
+}
+
+EXPORT_SYMBOL_GPL(dccp_tx_hist_entry_delete);
+
+inline struct dccp_rx_hist_entry *dccp_rx_hist_entry_new(struct sock *sk,
+								  struct sk_buff *skb,
+								  int prio)
+{
+	struct dccp_rx_hist_entry *entry = kmem_cache_alloc(dccp_rx_hist_slab, prio);
+
+	if (entry != NULL) {
+		const struct dccp_hdr *dh = dccp_hdr(skb);
+
+		entry->rx_hist_seqno	= DCCP_SKB_CB(skb)->dccpd_seq;
+		entry->rx_hist_ccval 	= dh->dccph_ccval;
+		entry->rx_hist_type	= dh->dccph_type;
+		entry->rx_hist_ndp	= dccp_sk(sk)->dccps_options_received.dccpor_ndp;
+		do_gettimeofday(&(entry->rx_hist_rxtime));
+	}
+
+	return entry;
+}
+
+EXPORT_SYMBOL_GPL(dccp_rx_hist_entry_new);
+
+inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist_entry *entry)
+{
+	if (entry != NULL)
+		kmem_cache_free(dccp_rx_hist_slab, entry);
+}
+
+EXPORT_SYMBOL_GPL(dccp_rx_hist_entry_delete);
+
+void dccp_rx_history_delete(struct list_head *hist)
+{
+	struct dccp_rx_hist_entry *entry, *next;
+
+	list_for_each_entry_safe(entry, next, hist, rx_hist_node) {
+		list_del_init(&entry->rx_hist_node);
+		kmem_cache_free(dccp_rx_hist_slab, entry);
+	}
+}
+
+EXPORT_SYMBOL_GPL(dccp_rx_history_delete);
+
+inline struct dccp_tx_hist_entry *dccp_tx_hist_entry_new(int prio)
+{
+	struct dccp_tx_hist_entry *entry = kmem_cache_alloc(dccp_tx_hist_slab, prio);
+
+	if (entry != NULL)
+		entry->tx_hist_sent = 0;
+
+	return entry;
+}
+
+EXPORT_SYMBOL_GPL(dccp_tx_hist_entry_new);
+
 int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 		 size_t len)
 {
@@ -650,6 +713,21 @@ static int __init dccp_init(void)
 	if (!dccp_hashinfo.bind_bucket_cachep)
 		goto out_proto_unregister;
 
+	dccp_tx_hist_slab = kmem_cache_create("dccp_tx_history",
+					       sizeof(struct dccp_tx_hist_entry),
+					       0, SLAB_HWCACHE_ALIGN,
+					       NULL, NULL);
+	if (!dccp_tx_hist_slab)
+		goto out_free_bind_bucket_cachep;
+
+	dccp_rx_hist_slab = kmem_cache_create("dccp_rx_history",
+					       sizeof(struct dccp_rx_hist_entry),
+					       0, SLAB_HWCACHE_ALIGN,
+					       NULL, NULL);
+	if (!dccp_rx_hist_slab)
+		goto out_free_tx_history;
+
+
 	/*
 	 * Size and allocate the main established and bind bucket
 	 * hash tables.
@@ -680,7 +758,7 @@ static int __init dccp_init(void)
 	if (!dccp_hashinfo.ehash) {
 		printk(KERN_CRIT "Failed to allocate DCCP "
 				 "established hash table\n");
-		goto out_free_bind_bucket_cachep;
+		goto out_free_rx_history;
 	}
 
 	for (i = 0; i < (dccp_hashinfo.ehash_size << 1); i++) {
@@ -736,6 +814,12 @@ out_free_dccp_bhash:
 out_free_dccp_ehash:
 	free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order);
 	dccp_hashinfo.ehash = NULL;
+out_free_rx_history:
+	kmem_cache_destroy(dccp_rx_hist_slab);
+	dccp_rx_hist_slab = NULL;
+out_free_tx_history:
+	kmem_cache_destroy(dccp_tx_hist_slab);
+	dccp_tx_hist_slab = NULL;
 out_free_bind_bucket_cachep:
 	kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
 	dccp_hashinfo.bind_bucket_cachep = NULL;
@@ -762,6 +846,8 @@ static void __exit dccp_fini(void)
 	proto_unregister(&dccp_v4_prot);
 
 	kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
+	kmem_cache_destroy(dccp_tx_hist_slab);
+	kmem_cache_destroy(dccp_rx_hist_slab);
 }
 
 module_init(dccp_init);
@@ -775,5 +861,5 @@ module_exit(dccp_fini);
 MODULE_ALIAS("net-proto-" __stringify(PF_INET) "-33-6");
 MODULE_ALIAS("net-proto-" __stringify(PF_INET) "-0-6");
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme at conectiva.com.br>");
+MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme at conectiva.com.br> & Ian McDonald <imcdnzl at gmail.com>");
 MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol");