All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miha Marolt <miham@beyondsemi.com>
To: netdev@vger.kernel.org
Subject: [BUG] "$ ss -a" incorrectly displays raw sockets as udp sockets
Date: Thu, 09 Jul 2015 16:13:12 +0200	[thread overview]
Message-ID: <559E8178.9080808@beyondsemi.com> (raw)

Hi!

I hope this is the right place to reports bugs. I apologize if it isn't.

I have written a C program (see below for source code) that opens a raw 
socket on CentOS 7.1 Linux and binds it to some address (it doesn't use 
the port that I supplied, but that is not the point here). The "netstat" 
program correctly recognizes the socket as "raw", while "ss" program 
says it is "udp". Here are the relevant lines from the ss and netstat 
commands:

$ netstat -an
raw        0      0 127.0.0.1:6             0.0.0.0:* 7

$ ./ss -an
udp    UNCONN     21569  0      127.0.0.1:6 *:*

Here is the version information

$ netstat --version  # From CentOS 7.1.
net-tools 2.10-alpha

$ ./ss --version  # Built from git.
ss utility, iproute2-ss150626


C source follows. If you store it in "main.c", then compile it with "$ 
gcc main.c -o main" and then run it by executing "$ sudo ./main".

#include <arpa/inet.h>
#include <assert.h>
#include <sys/socket.h>
#include <stdio.h>
#include <unistd.h>


int main(void)
{
     // Create a raw socket.
     int sock = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
     if (sock == -1) { perror(NULL); goto exc_cleanup; }

     // Bind socket to an address.
     struct sockaddr_in addr;
     addr.sin_family = AF_INET;
     inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr);
     addr.sin_port = htons(27183);

     int rc = bind(sock, (struct sockaddr*)&addr, sizeof(addr));
     if (rc != 0) { perror(NULL); goto exc_cleanup; }

     // Wait until user presses <ENTER>.
     printf("\nPress <ENTER> to quit the program.\n");
     getchar();

exc_cleanup:
     assert(!close(sock));
}


Best regards,
Miha

             reply	other threads:[~2015-07-09 14:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09 14:13 Miha Marolt [this message]
2015-07-09 14:50 ` [BUG] "$ ss -a" incorrectly displays raw sockets as udp sockets Nikolay Aleksandrov
2015-07-09 14:55   ` Vadim Kochan
2015-07-09 14:57     ` Nikolay Aleksandrov
2015-07-09 15:09       ` Miha Marolt
2015-07-09 15:15         ` Vadim Kochan
2015-07-10  7:09           ` Miha Marolt
2015-07-10  7:16             ` Vadim Kochan
2015-07-15 12:10               ` Miha Marolt
2015-07-15 12:50                 ` [PATCH iproute2] ss: fix display of raw sockets Nikolay Aleksandrov
2015-07-20 21:58                   ` Stephen Hemminger
2015-07-09 15:14 ` [BUG] "$ ss -a" incorrectly displays raw sockets as udp sockets Eric Dumazet
2015-07-09 15:21   ` Eric Dumazet
2015-07-09 15:28     ` Vadim Kochan
2015-07-09 15:30       ` Nikolay Aleksandrov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=559E8178.9080808@beyondsemi.com \
    --to=miham@beyondsemi.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.