title: Does Linux raw socket buffer size have upper limit of 256 K?
body: <p>I am using following code in Centos to change raw socket buffer size to 400 KB, however I got same result as I set buffer size to 256 KB. Anything wrong? or this is the limitation of socket layer? The kernel version is 2.6.34. Thanks!</p>
  
  <pre><code>int       rawsock;
  socklen_t socklen;
  int       optval;
  int       bufsize = 400 * 1024;
  
  rawsock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  if (rawsock &lt; 0) {
      my_log(LOG_ERR, "error creating raw socket");
      return rawsock;
  }
  
  optval = 0;
  socklen = 4;
  err = getsockopt(rawsock, SOL_SOCKET, SO_RCVBUF, &amp;optval, &amp;socklen);
  bail_error(err);
  my_log("socket RX original buffer size = %d", optval);
  
  optval = 0;
  socklen = 4;
  err = getsockopt(rawsock, SOL_SOCKET, SO_SNDBUF, &amp;optval, &amp;socklen);
  bail_error(err);
  my_log("socket TX original buffer size = %d", optval);
  
  err = setsockopt(rawsock, SOL_SOCKET, SO_RCVBUF, &amp;bufsize, sizeof(bufsize));
  bail_error(err);
  
  err = setsockopt(rawsock, SOL_SOCKET, SO_SNDBUF, &amp;bufsize, sizeof(bufsize));
  bail_error(err);
  
  optval = 0;
  socklen = 4;
  err = getsockopt(rawsock, SOL_SOCKET, SO_RCVBUF, &amp;optval, &amp;socklen);
  bail_error(err);
  my_log("socket RX new buffer size = %d", optval);
  
  optval = 0;
  socklen = 4;
  err = getsockopt(rawsock, SOL_SOCKET, SO_SNDBUF, &amp;optval, &amp;socklen);
  bail_error(err);
  my_log("socket TX new buffer size = %d", optval);
  </code></pre>
  
  <p>After running, the result is:</p>
  
  <pre><code>socket RX original buffer size = 110592
  socket TX original buffer size = 110592
  socket RX new buffer size = 524288
  socket TX new buffer size = 524288
  </code></pre>