Bug 7432 - Using Link-local address, IPv6 udp Client and Server running on a same host won't communication
Using Link-local address, IPv6 udp Client and Server running on a same host w...
Status: CLOSED CODE_FIX
Product: Networking
Classification: Unclassified
Component: IPV6
i386 Linux
: P2 normal
Assigned To: Hideaki YOSHIFUJI
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-10-30 02:02 UTC by Weijia Song
Modified: 2008-02-18 04:05 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.18-1
Tree: Mainline
Regression: ---


Attachments
Fix address/interface handling in UDN and DCCP, according to the scoping architecture (1.81 KB, patch)
2006-11-20 08:27 UTC, Hideaki YOSHIFUJI
Details | Diff

Description Weijia Song 2006-10-30 02:02:47 UTC
/////////////////////////////////////////////////////
Most recent kernel where this bug did not occur:

//////////////////////////////////////////////////////////////
Distribution:suse 10.1, redhat 9, redhat AS4, 'uname -a' shows the followings:

Linux suse-linux 2.6.18.1-default #1 Mon Oct 30 10:23:04 EST 2006 i686 i686 
i386 GNU/Linux


///////////////////////////////////////////////////////////////
Hardware Environment:
sonic@suse-linux:~> cat /proc/cpuinfo 

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 8
model name      : Pentium III (Coppermine)
stepping        : 6
cpu MHz         : 864.481
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat 
pse36 mmx fxsr sse
bogomips        : 1730.50

sonic@suse-linux:~> cat /proc/meminfo
MemTotal:       191924 kB
...

sonic@suse-linux:~> ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:50:BA:4F:27:9F  
          inet addr:162.105.130.62  Bcast:162.105.130.255  Mask:255.255.255.0
          inet6 addr: fec0::6:250:baff:fe4f:279f/64 Scope:Site
          inet6 addr: 2001:da8:201:1130:250:baff:fe4f:279f/64 Scope:Global
          inet6 addr: fe80::250:baff:fe4f:279f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10540 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1175 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:868189 (847.8 Kb)  TX bytes:130119 (127.0 Kb)
          Interrupt:11 Base address:0xd800 
///////////////////////////////////////////////////
Software Environment:

sonic@suse-linux:~> gcc -v
Using built-in specs.
Target: i586-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-
local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --
libdir=/usr/lib --libexecdir=/usr/lib --enable-
languages=c,c++,objc,fortran,java,ada --enable-checking=release --with-gxx-
include-dir=/usr/include/c++/4.1.0 --enable-ssp --disable-libssp --enable-java-
awt=gtk --enable-gtk-cairo --disable-libjava-multilib --with-slibdir=/lib --
with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-
allocator=new --without-system-libunwind --with-cpu=generic --host=i586-suse-
linux
Thread model: posix
gcc version 4.1.0 (SUSE Linux)

/////////////////////////////////////////////
Problem Description:
As mentioned in the summary, if link-local address and UDP protocol is used, 
and IPv6 Client and Server run on a same host, they cannot communicating with 
each other.


//////////////////////////////////////
Steps to reproduce:


1) client source code:

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <string.h>
#include <arpa/inet.h>

#define SERVER_PORT (7782)
#define	BIND_IF	"eth0"

int main()
{
	printf("This is an IPv6 Client!\n");
	//open socket
	int csk = socket(PF_INET6,SOCK_DGRAM,0);
	if(csk==-1)
	{
		printf("socket() return error:%d\n",errno);
		printf(strerror(errno));
		return -1;
	}
	printf("socket()\n");
	//create server sockaddr
	struct sockaddr_in6 saddr;
	saddr.sin6_family = AF_INET6;
	saddr.sin6_port = htons(SERVER_PORT);
	//change the scope id to your interface index
	saddr.sin6_scope_id = 2; 
	//change the link-local address to yours.
	inet_pton(AF_INET6,"fe80::250:baff:fe4f:279f",&saddr.sin6_addr);
	char * msg = "Message from V6CUDP";
	int ret = sendto(csk,msg,strlen(msg),0,(struct sockaddr *)&saddr,sizeof
(saddr));
	if(ret==-1)
	{
		printf("send() return error:%d\n",errno);
		printf(strerror(errno));
		return -1;
	}
	
	//close connection
	close(csk);

	return 0;
}

2) server source code:

#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#include <arpa/inet.h>

#define	 SERVER_PORT (7782)

#define	BIND_IF	"eth0"

int main()
{
	printf("This is an IPv6 Server\n");
	//create socket
	int s = socket(PF_INET6,SOCK_DGRAM,0);
	if(s == -1)
	{
		printf("socket return error:%d",errno);
		printf(strerror(errno));
		return -1;
	}
	//create sockaddr
	struct sockaddr_in6 addr;
	addr.sin6_family = AF_INET6;
	addr.sin6_port = htons(SERVER_PORT);
	//change scope id to your interface index
	addr.sin6_scope_id = 2;
	//change link-local address to your interface index
	inet_pton(AF_INET6,"fe80::250:baff:fe4f:279f",&addr.sin6_addr);
	printf("inet_pton\n");
	//bind
	int ret = bind(s,(struct sockaddr*)&addr,sizeof(addr));
	if(ret==-1)
	{
		printf("bind() return error:%d\n",errno);
		printf(strerror(errno));
		return -1;
	}
	//recvfrom
	char buf[100];
	int len;
	while((len=recvfrom(s,buf,100,MSG_WAITALL,NULL,NULL))>=0)
	{
		buf[len]=0;
		printf("RECV:%s\n",buf);
	}
	close(s);
}

3) modify the scope id and link-local address to suite your configuration.
4) gcc -o v6sudp v6sudp.c;gcc -o v6cudp v6cudp.c
5) open a new terminal and issue './v6sudp'
6) open a new terminal and issue './v6cudp'
7) You will find v6cudp can send but v6sudp cannot recv:
sonic@suse-linux:~/workspace/ipv6> ./v6sudp
This is an IPv6 Server
inet_pton

sonic@suse-linux:~/workspace/ipv6> ./v6cudp
This is an IPv6 Client!
socket()
sonic@suse-linux:~/workspace/ipv6> 

8) If Client and server run on different hosts (NOTE:Change the scope-id and 
address before you start this expirement), server can get messages from client:

sonic@suse-linux:~/workspace/ipv6> ./v6sudp
This is an IPv6 Server
inet_pton
RECV:Message from V6CUDP
Comment 1 Joe Jin 2006-11-20 01:01:14 UTC
Do you have tried to lo device with ::1 ?
Comment 2 Weijia Song 2006-11-20 01:10:15 UTC
Yes, I've tested ::1, it works.
2006/11/20, bugme-daemon@bugzilla.kernel.org <
bugme-daemon@bugzilla.kernel.org>:
>
> http://bugzilla.kernel.org/show_bug.cgi?id=7432
>
>
>
>
>
> ------- Additional Comments From lkmaillist@gmail.com  2006-11-20 01:01
> -------
> Do you have tried to lo device with ::1 ?
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>



<br>Yes, I've tested ::1, it works.<br>
<div><span class="gmail_quote">2006/11/20, <a href="mailto:bugme-daemon@bugzilla.kernel.org">bugme-daemon@bugzilla.kernel.org</a> &lt;<a href="mailto:bugme-daemon@bugzilla.kernel.org">bugme-daemon@bugzilla.kernel.org</a>
&gt;:</span>
<blockquote class="gmail_quote" DEFANGED_style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><a href="http://bugzilla.kernel.org/show_bug.cgi?id=7432">http://bugzilla.kernel.org/show_bug.cgi?id=7432</a>
<br><br><br><br><br><br>------- Additional Comments From <a href="mailto:lkmaillist@gmail.com">lkmaillist@gmail.com</a>&nbsp;&nbsp;2006-11-20 01:01 -------<br>Do you have tried to lo device with ::1 ?<br><br>------- You are receiving this mail because: -------
<br>You reported the bug, or are watching the reporter.<br></blockquote></div><br><br clear="all"><br>-- <br>Song Weijia<br>CCNet, Peking Univ.<br>Beijing, P.R.China 
Comment 3 Hideaki YOSHIFUJI 2006-11-20 08:27:59 UTC
Created attachment 9574 [details]
Fix address/interface handling in UDN and DCCP, according to the scoping architecture

[IPV6]: Fix address/interface handling in UDN and DCCP, according to the
scoping architecture
    
With this patch, UDP and DCCP use incoming interface according to the scoping
architecture.
Comment 4 kamakshi 2008-02-18 03:50:12 UTC
(In reply to comment #3)
> Created an attachment (id=9574) [details]
> Fix address/interface handling in UDN and DCCP, according to the scoping
> architecture
> [IPV6]: Fix address/interface handling in UDN and DCCP, according to the
> scoping architecture
>     
> With this patch, UDP and DCCP use incoming interface according to the scoping
> architecture.


Hi,
 I have encountered exactly the same problem. The Kernel I am using is
Linux 2.6.9-54.ELsmp #1 SMP Thu Apr 5 20:37:11 EDT 2007 athlon GNU/Linux.

regards
Kamakshi
Comment 5 kamakshi 2008-02-18 04:05:28 UTC
Hi,
 I discovered that I was not too clear on the issue. I have encountered the same bug 7432 on my linux kernel,
Linux 2.6.9-54.ELsmp #1 SMP Thu Apr 5 20:37:11 EDT 2007 athlon GNU/Linux.
 Things work fine with the loopback address ::1. But with the link-local address, the client and server on the same machine are not able to communicate. Does the patch provided need to be applied on the kernel version I am using?

--Kamakshi

Note You need to log in before you can comment on or make changes to this bug.