Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F159653773
D36747.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D36747.id.diff
View Options
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -66,9 +66,10 @@
* Primitive routines for operating on socket buffers
*/
+#define BUF_MAX_ADJ(_sz) (((u_quad_t)(_sz)) * MCLBYTES / (MSIZE + MCLBYTES))
+
u_long sb_max = SB_MAX;
-u_long sb_max_adj =
- (quad_t)SB_MAX * MCLBYTES / (MSIZE + MCLBYTES); /* adjusted sb_max */
+u_long sb_max_adj = BUF_MAX_ADJ(SB_MAX);
static u_long sb_efficiency = 8; /* parameter for sbreserve() */
@@ -611,7 +612,7 @@
if (tmp_sb_max < MSIZE + MCLBYTES)
return (EINVAL);
sb_max = tmp_sb_max;
- sb_max_adj = (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES);
+ sb_max_adj = BUF_MAX_ADJ(sb_max);
return (0);
}
@@ -620,8 +621,8 @@
* become limiting if buffering efficiency is near the normal case.
*/
bool
-sbreserve_locked(struct socket *so, sb_which which, u_long cc,
- struct thread *td)
+sbreserve_locked_limit(struct socket *so, sb_which which, u_long cc,
+ u_long buf_max, struct thread *td)
{
struct sockbuf *sb = sobuf(so, which);
rlim_t sbsize_limit;
@@ -635,7 +636,7 @@
* appropriate thread resource limits are available. In that case,
* we don't apply a process limit.
*/
- if (cc > sb_max_adj)
+ if (cc > BUF_MAX_ADJ(buf_max))
return (false);
if (td != NULL) {
sbsize_limit = lim_cur(td, RLIMIT_SBSIZE);
@@ -644,12 +645,19 @@
if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc,
sbsize_limit))
return (false);
- sb->sb_mbmax = min(cc * sb_efficiency, sb_max);
+ sb->sb_mbmax = min(cc * sb_efficiency, buf_max);
if (sb->sb_lowat > sb->sb_hiwat)
sb->sb_lowat = sb->sb_hiwat;
return (true);
}
+bool
+sbreserve_locked(struct socket *so, sb_which which, u_long cc,
+ struct thread *td)
+{
+ return (sbreserve_locked_limit(so, which, cc, sb_max, td));
+}
+
int
sbsetopt(struct socket *so, struct sockopt *sopt)
{
diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h
--- a/sys/sys/sockbuf.h
+++ b/sys/sys/sockbuf.h
@@ -231,6 +231,8 @@
int sbsetopt(struct socket *so, struct sockopt *);
bool sbreserve_locked(struct socket *so, sb_which which, u_long cc,
struct thread *td);
+bool sbreserve_locked_limit(struct socket *so, sb_which which, u_long cc,
+ u_long buf_max, struct thread *td);
void sbsndptr_adv(struct sockbuf *sb, struct mbuf *mb, u_int len);
struct mbuf *
sbsndptr_noadv(struct sockbuf *sb, u_int off, u_int *moff);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jun 17, 4:36 PM (7 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33991562
Default Alt Text
D36747.id.diff (2 KB)
Attached To
Mode
D36747: sockbufs: add sbreserve_locked_limit() with custom maxsockbuf limit.
Attached
Detach File
Event Timeline
Log In to Comment