lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <47775C20.5010004@redhat.com>
Date:	Sun, 30 Dec 2007 03:51:44 -0500
From:	Hideo AOKI <haoki@...hat.com>
To:	David Miller <davem@...emloft.net>,
	Herbert Xu <herbert@...dor.apana.org.au>,
	vladislav.yasevich@...com, netdev <netdev@...r.kernel.org>
CC:	lksctp-developers@...ts.sourceforge.net,
	Takahiro Yasui <tyasui@...hat.com>,
	Masami Hiramatsu <mhiramat@...hat.com>,
	Satoshi Oshima <satoshi.oshima.fk@...achi.com>,
	billfink@...dspring.com, Andi Kleen <andi@...stfloor.org>,
	Evgeniy Polyakov <johnpol@....mipt.ru>,
	Stephen Hemminger <shemminger@...ux-foundation.org>,
	yoshfuji@...ux-ipv6.org,
	Yumiko Sugita <yumiko.sugita.yf@...achi.com>, haoki@...hat.com
Subject: [PATCH 2/4] [CORE]: adding memory accounting points

To consolidate memory accounting functions, this patch adds memory
accounting calls to network core functions. Moreover, present
memory accounting call is renamed to new accounting call.

Cc: Satoshi Oshima <satoshi.oshima.fk@...achi.com>
Cc: Masami Hiramatsu <mhiramat@...hat.com>
signed-off-by: Takahiro Yasui <tyasui@...hat.com>
signed-off-by: Hideo Aoki <haoki@...hat.com>
---

 include/net/sock.h  |    3 ++-
 net/core/datagram.c |    2 ++
 net/core/sock.c     |    7 +++++++
 net/core/stream.c   |    2 +-
 4 files changed, 12 insertions(+), 2 deletions(-)

diff -pruN net-2.6.25-t12t19m-p1/include/net/sock.h net-2.6.25-t12t19m-p2/include/net/sock.h
--- net-2.6.25-t12t19m-p1/include/net/sock.h	2007-12-29 20:16:31.000000000 -0500
+++ net-2.6.25-t12t19m-p2/include/net/sock.h	2007-12-29 20:28:15.000000000 -0500
@@ -1116,7 +1116,7 @@ static inline int skb_copy_to_page(struc
 	skb->data_len	     += copy;
 	skb->truesize	     += copy;
 	sk->sk_wmem_queued   += copy;
-	sk->sk_forward_alloc -= copy;
+	sk_mem_charge(sk, copy);
 	return 0;
 }

@@ -1142,6 +1142,7 @@ static inline void skb_set_owner_r(struc
 	skb->sk = sk;
 	skb->destructor = sock_rfree;
 	atomic_add(skb->truesize, &sk->sk_rmem_alloc);
+	sk_mem_charge(sk, skb->truesize);
 }

 extern void sk_reset_timer(struct sock *sk, struct timer_list* timer,
diff -pruN net-2.6.25-t12t19m-p1/net/core/datagram.c net-2.6.25-t12t19m-p2/net/core/datagram.c
--- net-2.6.25-t12t19m-p1/net/core/datagram.c	2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p2/net/core/datagram.c	2007-12-29 20:28:15.000000000 -0500
@@ -209,6 +209,7 @@ struct sk_buff *skb_recv_datagram(struct
 void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
 {
 	kfree_skb(skb);
+	sk_mem_reclaim(sk);
 }

 /**
@@ -248,6 +249,7 @@ int skb_kill_datagram(struct sock *sk, s
 	}

 	kfree_skb(skb);
+	sk_mem_reclaim(sk);
 	return err;
 }

diff -pruN net-2.6.25-t12t19m-p1/net/core/sock.c net-2.6.25-t12t19m-p2/net/core/sock.c
--- net-2.6.25-t12t19m-p1/net/core/sock.c	2007-12-29 20:16:31.000000000 -0500
+++ net-2.6.25-t12t19m-p2/net/core/sock.c	2007-12-29 20:28:15.000000000 -0500
@@ -282,6 +282,11 @@ int sock_queue_rcv_skb(struct sock *sk,
 	if (err)
 		goto out;

+	if (!sk_rmem_schedule(sk, skb->truesize)) {
+		err = -ENOBUFS;
+		goto out;
+	}
+
 	skb->dev = NULL;
 	skb_set_owner_r(skb, sk);

@@ -1107,7 +1112,9 @@ void sock_rfree(struct sk_buff *skb)
 {
 	struct sock *sk = skb->sk;

+	skb_truesize_check(skb);
 	atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
+	sk_mem_uncharge(skb->sk, skb->truesize);
 }


diff -pruN net-2.6.25-t12t19m-p1/net/core/stream.c net-2.6.25-t12t19m-p2/net/core/stream.c
--- net-2.6.25-t12t19m-p1/net/core/stream.c	2007-12-29 20:16:31.000000000 -0500
+++ net-2.6.25-t12t19m-p2/net/core/stream.c	2007-12-29 20:28:15.000000000 -0500
@@ -195,7 +195,7 @@ void sk_stream_kill_queues(struct sock *
 	BUG_TRAP(skb_queue_empty(&sk->sk_write_queue));

 	/* Account for returned memory. */
-	sk_stream_mem_reclaim(sk);
+	sk_mem_reclaim(sk);

 	BUG_TRAP(!sk->sk_wmem_queued);
 	BUG_TRAP(!sk->sk_forward_alloc);
-- 
Hitachi Computer Products (America) Inc.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ