LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 06-04-2016, 02:28 PM   #1
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Dragonboard (Debian) dropping TCP requests


I have a Dragonboard 410c running the Debian-based developer build, and I'm having some issues with TCP connections.

This is an example code which simply sets up a listening port, waits for a connection, prints when it gets one and exits, very simple.
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
  int fd = -1;
  int sock = socket(AF_INET, SOCK_STREAM, 0);

  if(sock<0){
    printf("could not open server socket");
    return -1;
  }
  struct sockaddr_in addr;
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_port = htons(3490);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);

  if(bind(sock, (struct sockaddr *) &addr, sizeof(addr))<0){
    printf("could not bind server socket");
    return -1;
  }

  if(listen(sock, 0)<0){
    printf("could not listen on server socket");
    return -1;
  }

  printf("waiting for a connection\n");

  fd = ::accept(sock, NULL, NULL);

  printf("accepted a connection: %d\n",fd);

  return 0;
}
On normal systems it works fine, the output looks like this:
server:
Code:
$ ./a.out
waiting for a connection
<wait until client connects>
accepted a connection: 4
client:
Code:
$ telnet 127.0.0.1 3490
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Connection closed by foreign host.
but on the Dragonboard I'm having an odd issue. The server code starts up fine, but as soon as any client tries to connect to it, the connection just times out, the server prints nothing (continues to wait) and I get this in /var/log/messages on the Dragonboard:
Code:
Jun 3 17:45:44 hostname kernel: [ 39.183685] TCP: request_sock_TCP: Possible SYN flooding on port 3490. Dropping request. Check SNMP counters.
Googling the error just comes back with people running servers with thousands of connections, and the solution is changing some sysctl settings to increase the limit, but none of that applies here.

Any idea what could be causing it?
 
Old 06-04-2016, 05:22 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Running your code on my system, I get a slightly different message:
Code:
Jun  4 16:49:46 debian kernel: [ 2718.964574] TCP: request_sock_TCP: Possible SYN flooding on port 3490. Sending cookies.  Check SNMP counters.
Two things to try:

Change the second parameter of listen to something other than 0:
Code:
if(listen(sock, 5)<0){
Check that sending SYN cookies is enabled (/etc/sysctrl.conf):
Code:
$ cat /proc/sys/net/ipv4/tcp_syncookies
1
HTH
 
1 members found this post helpful.
Old 06-04-2016, 07:05 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Original Poster
Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Interesting...thanks for the hint!

It looks like something must have changed since kernel version 3.10 (that's the desktop system I was testing on, and all of the systems I've used with this code were older than that) and 4.4 (what the Dragonboard is running). I just ran it again on the 3.10 system and again, no output at all in /var/log/messages, but then I ran it on my 4.6 OpenSUSE Tumbleweed system and the output looks like yours. I guess a backlog of "0" in the call to listen was reinterpreted to mean "no connection at all" instead of "no backlog after the first connection", and since the default kernel on the Dragonboard doesn't have syncookies (there is no /proc/sys/net/ipv4/tcp_syncookies), it was just dropping the connection.

I've upped it from 0 and it's now accepting connections, I'll see how this goes and possibly compile syncookies into the kernel if it comes to that.

Thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Samsung may still face EU sanctions after dropping Apple injunction requests LXer Syndicated Linux News 0 12-21-2012 02:40 PM
A note on tcp/ip programming and header requests eagle-bear Programming 2 01-16-2012 11:18 AM
TCP Crawler network not working after many TCP requests inftechpros Linux - Networking 1 06-12-2011 01:22 PM
With ubuntu dropping X and Debian releasing only every other year..... Chris_C Linux - Desktop 7 02-23-2011 11:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration