[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <153de016-8274-5d62-83fe-ce7d8218f906@i-love.sakura.ne.jp>
Date: Tue, 7 Jan 2020 06:03:44 +0900
From: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>
To: David Ahern <dsahern@...il.com>
Cc: Casey Schaufler <casey@...aufler-ca.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: commit b9ef5513c99b breaks ping to ipv6 linklocal addresses on
debian buster
On 2020/01/07 1:41, David Ahern wrote:
>>> #ifdef SMACK_IPV6_SECMARK_LABELING
>>> rsp = smack_ipv6host_label(sip);
>>>
>>>
>>> ie., if the socket family is AF_INET6 the address length should be an
>>> IPv6 address. The family in the sockaddr is not as important.
>>>
>>
>> Commit b9ef5513c99b was wrong, but we need to also fix commit c673944347ed ?
>>
>
> not sure. I have not seen a problem related to it yet.
>
A sample program shown below is expected to return 0.
Casey, what does smack wants to do for IPv4 address on IPv6 socket case?
----------
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <arpa/inet.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
const int fd1 = socket(PF_INET6, SOCK_DGRAM, 0);
const int fd2 = socket(PF_INET, SOCK_DGRAM, 0);
struct sockaddr_in addr1 = {
.sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_LOOPBACK),
.sin_port = htons(10000)
};
struct sockaddr_in addr2 = { };
char c = 0;
struct iovec iov1 = { "", 1 };
struct iovec iov2 = { &c, 1 };
const struct msghdr msg1 = {
.msg_iov = &iov1,
.msg_iovlen = 1,
.msg_name = &addr1,
.msg_namelen = sizeof(addr1)
};
struct msghdr msg2 = {
.msg_iov = &iov2,
.msg_iovlen = 1,
.msg_name = &addr2,
.msg_namelen = sizeof(addr2)
};
if (bind(fd2, (struct sockaddr *) &addr1, sizeof(addr1)))
return 1;
if (sendmsg(fd1, &msg1, 0) != 1 || recvmsg(fd2, &msg2, 0) != 1)
return 1;
if (connect(fd1, (struct sockaddr *) &addr1, sizeof(addr1)))
return 1;
if (send(fd1, "", 1, 0) != 1 || recv(fd2, &c, 1, 0) != 1)
return 1;
return 0;
}
----------
Powered by blists - more mailing lists