From: Brian Haley <brian.haley@hp.com>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: IPV6 raw socket denies bind(2)
Date: Wed, 27 Oct 2010 19:54:54 -0400 [thread overview]
Message-ID: <4CC8BBCE.70609@hp.com> (raw)
In-Reply-To: <alpine.LNX.2.01.1010280000260.7820@obet.zrqbmnf.qr>
On 10/27/2010 06:01 PM, Jan Engelhardt wrote:
> int main(void)
> {
> struct sockaddr_in6 src = {};
> int sk;
>
> sk = socket(AF_INET6, SOCK_RAW, IPPROTO_UDP);
> memset(&src, 0, sizeof(src));
> inet_pton(AF_INET6, "::1", &src);
> src.sin6_family = AF_INET6;
>
> if (bind(sk, (void *)&src, sizeof(src)) < 0) {
> perror("bind");
> abort();
> }
> return 0;
> }
You're trashing the sockaddr, try this patch:
< inet_pton(AF_INET6, "::1", &src);
---
> inet_pton(AF_INET6, "::1", &src.sin6_addr);
-Brian
next prev parent reply other threads:[~2010-10-27 23:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-27 22:01 IPV6 raw socket denies bind(2) Jan Engelhardt
2010-10-27 23:54 ` Brian Haley [this message]
2010-10-28 8:25 ` Rémi Denis-Courmont
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=4CC8BBCE.70609@hp.com \
--to=brian.haley@hp.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jengelh@medozas.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).