LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-05-2011, 10:30 AM   #1
erbora00
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
raw IPv6 socket for SCTP stack


Hi,

I am trying to add IPv6 capability to an SCTP stack which runs on CentOS platforms. Currently it works using IPv4. But I am having some issues with IPv6.

Both IPv4 and IPv6 connectivity is via a RAW socket with IPPROTO_SCTP. Socket is opened as below for IPv4 and IPv6:
fd4 = socket(AF_INET, SOCK_RAW, IPPROTO_SCTP);
fd6 = socket(AF_INET6, SOCK_RAW, IPPROTO_SCTP);

After this I simply try to send a message by using sendto(fd, sctpMsg, msgSize, 0,(struct sockaddr*) toAddr, sizeof (struct sockaddr_in6));

The sendto call succeeds and I can see the packet outgoing from the interface via tcpdump. It even reaches the remote host. This is the SCTP INIT message I am trying to send.

But, the message goes out with a different destination port value than the one I had set in the message. I have debugged this and confirmed that right before the sendto call sctpMsg buffer has the correct values for source and destination port. But somehow the destination port of the SCTP INIT message goes out with a different value.

I am aware that this is a weird issue. But I would like to get any kind of pointers that might help. I could use any help in terms of how a transport layer protocol would be implemented using RAW sockets with IPV6.

I think I need to check the kernel source code of CentOS. Any ideas?

Thanks in advance.
 
Old 09-05-2011, 11:50 AM   #2
erbora00
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Wow, I found the reason for this.
For some reason, our legacy code has this:
int opt = 2;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_CHECKSUM, &opt, sizeof(opt)) < 0)

Basically, kernel calculates the checksum and overwrites the destination port value (which is at 2 bytes offset).

Hope this helps somebody else.
 
  


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
SCTP one to one socket programming deva199 Programming 1 06-27-2011 12:20 PM
Unable to close SCTP socket. isbicf Linux - Networking 2 06-19-2011 07:22 PM
kernel version for "sctp: make sctp over IPv6 work with IPsec" patch yhclqo Linux - Kernel 2 08-27-2010 01:00 AM
Raw SCTP socket cannot bind with port? JohnJLewis Linux - Networking 1 07-26-2010 02:14 PM
raw ipv6 socket example Steave Programming 0 06-27-2003 03:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:41 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