patch-2.4.26 linux-2.4.26/net/sctp/ssnmap.c
Next file: linux-2.4.26/net/sctp/sysctl.c
Previous file: linux-2.4.26/net/sctp/socket.c
Back to the patch index
Back to the overall index
- Lines: 52
- Date:
2004-04-14 06:05:41.000000000 -0700
- Orig file:
linux-2.4.25/net/sctp/ssnmap.c
- Orig date:
2003-11-28 10:26:21.000000000 -0800
diff -urN linux-2.4.25/net/sctp/ssnmap.c linux-2.4.26/net/sctp/ssnmap.c
@@ -40,6 +40,7 @@
#include <net/sctp/sctp.h>
#include <net/sctp/sm.h>
+#define MAX_KMALLOC_SIZE 131072
/* Storage size needed for map includes 2 headers and then the
* specific needs of in or out streams.
@@ -56,9 +57,14 @@
struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, int gfp)
{
struct sctp_ssnmap *retval;
+ int size;
- retval = kmalloc(sctp_ssnmap_size(in, out), gfp);
-
+ size = sctp_ssnmap_size(in, out);
+ if (size <= MAX_KMALLOC_SIZE)
+ retval = kmalloc(size, gfp);
+ else
+ retval = (struct sctp_ssnmap *)
+ __get_free_pages(gfp, get_order(size));
if (!retval)
goto fail;
@@ -71,7 +77,10 @@
return retval;
fail_map:
- kfree(retval);
+ if (size <= MAX_KMALLOC_SIZE)
+ kfree(retval);
+ else
+ free_pages((unsigned long)retval, get_order(size));
fail:
return NULL;
}
@@ -107,7 +116,13 @@
void sctp_ssnmap_free(struct sctp_ssnmap *map)
{
if (map && map->malloced) {
- kfree(map);
+ int size;
+
+ size = sctp_ssnmap_size(map->in.len, map->out.len);
+ if (size <= MAX_KMALLOC_SIZE)
+ kfree(map);
+ else
+ free_pages((unsigned long)map, get_order(size));
SCTP_DBG_OBJCNT_DEC(ssnmap);
}
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)