[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-16 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #18 from Cameron Sparr  ---
@Alfred, I guess on Linux there is no way to warn about that, users would have
to check the buffer size limits themselves.

In conclusion, should I change my patch to do what you originally suggested?
Which is to have kern.ipc.maxsockbuf represent that maximum amount of DATA that
the socket can handle?

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-16 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #19 from Alfred Perlstein  ---
For now it makes sense to implement the sysctls as described in comment #15. 
changing the behavior at this point seems a bad idea.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-13 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #17 from Alfred Perlstein  ---
That is interesting... how to applications warn "your system doesn't have
sufficient buffering enabled for performance" ?

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-12 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #16 from Cameron Sparr  ---
I forgot that it's actually spelled out pretty clearly in the comments of the
code:

/* Don't error on this BSD doesn't and if you think
 * about it this is right. Otherwise apps have to
 * play 'guess the biggest size' games. RCVBUF/SNDBUF
 * are treated in BSD as hints
 */
val = min_t(u32, val, sysctl_rmem_max);

So essentially they are just treating those buffer sizes as "hints". It makes
some sense, because they are correct about applications having no idea what
size they can actually set it to (without root access to the system).

So that would be another option, which is to just set the buffer to min(cc,
sb_max_adj)

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-12 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #15 from Alfred Perlstein  ---
> Re (1) do you mean that when kern.ipc.maxsockbuf gets set, scale the sb_max 
> value up by the inverse of sb_max_adj? ie, kern.ipc.maxsockbuf * 2304 / 2048. 
> In that case, setting kern.ipc.maxsockbuf to 100 bytes would actually set 
> sb_max to 1125000 (and sb_max_adj to 100), making it possible to set the 
> buffers to 100 bytes.

I think so.  However just to be clear, let's not have a sysctl that has the
following behavior:
% sysctl kern.ipc.maxsockbuf=100
% sysctl kern.ipc.maxsockbuf
kern.ipc.maxsockbuf=1125000
$

We probably want this:
% sysctl kern.ipc.maxsockbuf=100
% sysctl kern.ipc.maxsockbuf
kern.ipc.maxsockbuf=100
$ sysctl kern.ipc.maxsockbufmeta
kern.ipc.maxsockbufmeta=1125000



> Re (2), If kern.ipc.maxsockbufmeta were read/write, which of the settings 
> would have precedence? Would you have to set maxsockbufmeta first anytime you 
> wanted to set maxsockbuf? Or would setting maxsockbuf auto-set 
> maxsockbufmeta?'

I think having them auto-set each other would be the most user friendly option.

> Re Linux silent truncation: agreed, it's scary and gives the impression that 
> setsockopt() worked, when really it didn't do anything at all

Yes.  It would be a good idea to hop on a Linux kernel IRC channel/mailing list
and ask them.  Last time I did this I got some pretty useful information which
changed my world view.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-12 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

Alfred Perlstein  changed:

   What|Removed |Added

 CC||alf...@freebsd.org

--- Comment #13 from Alfred Perlstein  ---
I believe the reason for the adjustment is that "sb_max" is for "max kernel
memory taken by the socketbuffer INCLUDING MBUFS THEMSELVES"

So what is actually happening is that each MCLSIZE (size of cluster) of "data"
is having MSIZE (size of mbuf) added to it.

Why is it scaled up so?  Because in reality one needs MSIZE actual memory for
each cluster as metadata to point to it.

And why is this done?  So that you can actually trust "sb_max" to mean maximum
kernel memory taken to support N bytes per socket.

I didn't realize Linux silents truncates the requested amount, that's a little
scary, however I'm learning to trust more and more what Linux does.

What might make a bit more sense in the long run is actually to make:

1) kern.ipc.maxsockbuf == max number of bytes of DATA in each socketbuffer
2) kern.ipc.maxsockbufmeta = max number of bytes of DATA + METADATA required to
be allocated.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-12 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #14 from Cameron Sparr  ---
@Alfred, thanks for the background info

Re (1) do you mean that when kern.ipc.maxsockbuf gets set, scale the sb_max
value up by the inverse of sb_max_adj? ie, kern.ipc.maxsockbuf * 2304 / 2048.
In that case, setting kern.ipc.maxsockbuf to 100 bytes would actually set
sb_max to 1125000 (and sb_max_adj to 100), making it possible to set the
buffers to 100 bytes.

Re (2), If kern.ipc.maxsockbufmeta were read/write, which of the settings would
have precedence? Would you have to set maxsockbufmeta first anytime you wanted
to set maxsockbuf? Or would setting maxsockbuf auto-set maxsockbufmeta?'

Re Linux silent truncation: agreed, it's scary and gives the impression that
setsockopt() worked, when really it didn't do anything at all

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

Kubilay Kocak  changed:

   What|Removed |Added

  Flags||mfc-stable9?, mfc-stable10?
 CC||ko...@freebsd.org
   Keywords||needs-patch, needs-qa
URL||https://github.com/sparrc/f
   ||reebsd/commit/157f90c55d1d5
   ||4d33f41c6f7517de1a9c5f5e229

--- Comment #5 from Kubilay Kocak  ---
@Cameron, if you could get a changeset up on reviews. that would be great. Feel
free to replace the URL field value in this issue with the review URL once it's
up.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

Kubilay Kocak  changed:

   What|Removed |Added

   Keywords|needs-patch |patch

--- Comment #11 from Kubilay Kocak  ---
That's perfectly fine Cameron, thank you

Once a committer 'takes' /assigns this issue, they can put it up on reviews if
necessary.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #12 from Kubilay Kocak  ---
Looks like I missed the review creation, ignore my last comment, except for the
'needs a committer/assignee' bit ;D

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Differential] [Updated, 12 lines] D4129: Bug 204438 - setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread cameronsparr_gmail.com (Cameron Sparr)
cameronsparr_gmail.com removed rS FreeBSD src repository as the repository for 
this revision.
cameronsparr_gmail.com updated this revision to Diff 10121.
cameronsparr_gmail.com added a comment.


  spaces to tabs

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D4129?vs=10120=10121

REVISION DETAIL
  https://reviews.freebsd.org/D4129

AFFECTED FILES
  sys/kern/uipc_sockbuf.c

CHANGE DETAILS
  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
  @@ -397,7 +397,7 @@
sb_max_adj = (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES);
return (0);
   }
  - 
  +
   /*
* Allot mbufs to a sockbuf.  Attempt to scale mbmax so that mbcnt doesn't
* become limiting if buffering efficiency is near the normal case.
  @@ -417,8 +417,12 @@
 * appropriate thread resource limits are available.  In that case,
 * we don't apply a process limit.
 */
  - if (cc > sb_max_adj)
  + if (cc > sb_max)
return (0);
  +
  + if (cc > sb_max_adj)
  + cc = sb_max_adj;
  +
if (td != NULL) {
sbsize_limit = lim_cur(td, RLIMIT_SBSIZE);
} else
  @@ -433,7 +437,7 @@
   }
   
   int
  -sbreserve(struct sockbuf *sb, u_long cc, struct socket *so, 
  +sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
   struct thread *td)
   {
int error;
  @@ -1297,7 +1301,7 @@
xsb->sb_cc = sb->sb_ccc;
xsb->sb_hiwat = sb->sb_hiwat;
xsb->sb_mbcnt = sb->sb_mbcnt;
  - xsb->sb_mcnt = sb->sb_mcnt; 
  + xsb->sb_mcnt = sb->sb_mcnt;
xsb->sb_ccnt = sb->sb_ccnt;
xsb->sb_mbmax = sb->sb_mbmax;
xsb->sb_lowat = sb->sb_lowat;

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: cameronsparr_gmail.com, Contributor Reviewers, network
Cc: freebsd-net-list, imp
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
@@ -397,7 +397,7 @@
 	sb_max_adj = (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES);
 	return (0);
 }
-	
+
 /*
  * Allot mbufs to a sockbuf.  Attempt to scale mbmax so that mbcnt doesn't
  * become limiting if buffering efficiency is near the normal case.
@@ -417,8 +417,12 @@
 	 * appropriate thread resource limits are available.  In that case,
 	 * we don't apply a process limit.
 	 */
-	if (cc > sb_max_adj)
+	if (cc > sb_max)
 		return (0);
+
+	if (cc > sb_max_adj)
+		cc = sb_max_adj;
+
 	if (td != NULL) {
 		sbsize_limit = lim_cur(td, RLIMIT_SBSIZE);
 	} else
@@ -433,7 +437,7 @@
 }
 
 int
-sbreserve(struct sockbuf *sb, u_long cc, struct socket *so, 
+sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
 struct thread *td)
 {
 	int error;
@@ -1297,7 +1301,7 @@
 	xsb->sb_cc = sb->sb_ccc;
 	xsb->sb_hiwat = sb->sb_hiwat;
 	xsb->sb_mbcnt = sb->sb_mbcnt;
-	xsb->sb_mcnt = sb->sb_mcnt;	
+	xsb->sb_mcnt = sb->sb_mcnt;
 	xsb->sb_ccnt = sb->sb_ccnt;
 	xsb->sb_mbmax = sb->sb_mbmax;
 	xsb->sb_lowat = sb->sb_lowat;

___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

[Differential] [Updated] D4129: Bug 204438 - setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread cameronsparr_gmail.com (Cameron Sparr)
cameronsparr_gmail.com updated the summary for this revision.

REVISION DETAIL
  https://reviews.freebsd.org/D4129

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: cameronsparr_gmail.com, Contributor Reviewers, network
Cc: freebsd-net-list, imp
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #6 from Cameron Sparr  ---
Created attachment 163023
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=163023=edit
Patch of the diff in the URL section. Changes behavior of setsockopt

This change makes it so that the setsockopt() function does not error
when a user passes a value for SO_RCVBUF equal or under the maximim
(kern.ipc.maxsockbuf).

Currently the behavior is to error if the value is greater than the
_adjusted_ max, which on amd64 turns out to be something like
kern.ipc.maxsockbuf * 0.889

This is confusing for users, and this change will set the value passed
to the adjusted max if the value is greater than the adjusted and less
than the actual max.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #8 from Allan Jude  ---
There is a command line tool for Phabricator called 'arcanist'
(devel/php5-arcanist) that simplifies posting patches to PHabriactor. It works
with svn and git.

Or, via the Phabricator web interface, you can post a .patch file (helps if you
set it to 99 lines of context)

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #9 from NGie Cooper  ---
This wiki page describes how our current code review process works:
https://wiki.freebsd.org/CodeReview

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #7 from Cameron Sparr  ---
@Kubilay I realized that I actually have no idea how to use svn/phabricator, so
I'm just going to attach a patch to this case. Let me know how it looks, thank
you.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

Cameron Sparr  changed:

   What|Removed |Added

URL|https://github.com/sparrc/f |https://reviews.freebsd.org
   |reebsd/commit/157f90c55d1d5 |/D4129
   |4d33f41c6f7517de1a9c5f5e229 |

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Differential] [Updated] D4129: Bug 204438 - setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread cameronsparr_gmail.com (Cameron Sparr)
cameronsparr_gmail.com added a reviewer: network.
cameronsparr_gmail.com added a subscriber: freebsd-net-list.

REPOSITORY
  rS FreeBSD src repository

REVISION DETAIL
  https://reviews.freebsd.org/D4129

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: cameronsparr_gmail.com, Contributor Reviewers, network
Cc: freebsd-net-list, imp
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

--- Comment #10 from Cameron Sparr  ---
Got it, thanks for the link, I put up a review on phabricator. May I suggest
you put a link to the wiki (https://wiki.freebsd.org/CodeReview) on the
homepage of the phabricator site? Looks like you can edit it using the
"dashboard" app but I don't have permissions, obviously:
https://reviews.freebsd.org/dashboard/manage/2/

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-10 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

NGie Cooper  changed:

   What|Removed |Added

   Assignee|freebsd-b...@freebsd.org|freebsd-net@FreeBSD.org
 CC||n...@freebsd.org

--- Comment #3 from NGie Cooper  ---
Reassigning to -net@

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 204438] setsockopt() handling of kern.ipc.maxsockbuf limit

2015-11-10 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204438

Hiren Panchasara  changed:

   What|Removed |Added

 CC||gleb...@freebsd.org,
   ||rwat...@freebsd.org

--- Comment #4 from Hiren Panchasara  ---
I am not sure about the linux way but the first part looks okay to me. I am no
expert here so adding Robert and Gleb for their inputs.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"