Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22137
b: refs/heads/master
c: 9b07ef5
h: refs/heads/master
i:
  22135: c8ce50f
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo authored and David S. Miller committed Mar 21, 2006
1 parent 90acd71 commit b10b8d0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fa23e2ecd30a584cdcb9b3de0149dbb5c073c20b
refs/heads/master: 9b07ef5ddaced1e822b1a1fb1da088eb15c45cb4
34 changes: 32 additions & 2 deletions trunk/net/dccp/ackvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
#include "dccp.h"

#include <linux/dccp.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
#include <linux/slab.h>

#include <net/sock.h>

static kmem_cache_t *dccp_ackvec_slab;

int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
{
struct dccp_sock *dp = dccp_sk(sk);
Expand Down Expand Up @@ -96,7 +102,7 @@ int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)

struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
{
struct dccp_ackvec *av = kmalloc(sizeof(*av), priority);
struct dccp_ackvec *av = kmem_cache_alloc(dccp_ackvec_slab, priority);

if (av != NULL) {
av->dccpav_buf_head =
Expand All @@ -115,7 +121,7 @@ struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)

void dccp_ackvec_free(struct dccp_ackvec *av)
{
kfree(av);
kmem_cache_free(dccp_ackvec_slab, av);
}

static inline u8 dccp_ackvec_state(const struct dccp_ackvec *av,
Expand Down Expand Up @@ -420,3 +426,27 @@ int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
len, value);
return 0;
}

static char dccp_ackvec_slab_msg[] __initdata =
KERN_CRIT "DCCP: Unable to create ack vectors slab cache\n";

int __init dccp_ackvec_init(void)
{
dccp_ackvec_slab = kmem_cache_create("dccp_ackvec",
sizeof(struct dccp_ackvec), 0,
SLAB_HWCACHE_ALIGN, NULL, NULL);
if (dccp_ackvec_slab == NULL) {
printk(dccp_ackvec_slab_msg);
return -ENOBUFS;
}

return 0;
}

void dccp_ackvec_exit(void)
{
if (dccp_ackvec_slab != NULL) {
kmem_cache_destroy(dccp_ackvec_slab);
dccp_ackvec_slab = NULL;
}
}
12 changes: 12 additions & 0 deletions trunk/net/dccp/ackvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ struct sock;
struct sk_buff;

#ifdef CONFIG_IP_DCCP_ACKVEC
extern int dccp_ackvec_init(void);
extern void dccp_ackvec_exit(void);

extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority);
extern void dccp_ackvec_free(struct dccp_ackvec *av);

Expand All @@ -89,6 +92,15 @@ static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
return av->dccpav_sent_len != av->dccpav_vec_len;
}
#else /* CONFIG_IP_DCCP_ACKVEC */
static inline int dccp_ackvec_init(void)
{
return 0;
}

static inline void dccp_ackvec_exit(void)
{
}

static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
{
return NULL;
Expand Down
9 changes: 8 additions & 1 deletion trunk/net/dccp/proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,11 +877,17 @@ static int __init dccp_init(void)

inet_register_protosw(&dccp_v4_protosw);

rc = dccp_ctl_sock_init();
rc = dccp_ackvec_init();
if (rc)
goto out_unregister_protosw;

rc = dccp_ctl_sock_init();
if (rc)
goto out_ackvec_exit;
out:
return rc;
out_ackvec_exit:
dccp_ackvec_exit();
out_unregister_protosw:
inet_unregister_protosw(&dccp_v4_protosw);
inet_del_protocol(&dccp_protocol, IPPROTO_DCCP);
Expand Down Expand Up @@ -923,6 +929,7 @@ static void __exit dccp_fini(void)
sizeof(struct inet_ehash_bucket)));
kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
proto_unregister(&dccp_prot);
dccp_ackvec_exit();
}

module_init(dccp_init);
Expand Down

0 comments on commit b10b8d0

Please sign in to comment.