From: Stas Sergeev <stsp@aknet.ru>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-kernel@vger.kernel.org, linux-net@vger.kernel.org
Subject: Re: [patch] allow write() on SOCK_PACKET sockets
Date: Thu, 14 Oct 2004 07:45:08 +0400 [thread overview]
Message-ID: <416DF644.2070906@aknet.ru> (raw)
In-Reply-To: <E1CHv6u-0001EU-00@gondolin.me.apana.org.au>
Hi.
Herbert Xu wrote:
Stas Sergeev <stsp@aknet.ru> wrote:
>> I claim that SOCK_RAW allows write() after bind()
>> because a few days ago I changed dosemu code
>> to use SOCK_RAW instead of SOCK_PACKET and write()
> Well I just checked net/ipv4/raw.c and it's pretty clear that it does
I think you are looking at a wrong place.
You are looking into IP raw sockets code.
Packet sockets are really the different
layer. Please have a look into
net/packet/af_packet.c instead.
> So you need to connect before you can write.
Packet sockets, actually, do not even have
connect:
.connect = sock_no_connect
> I'm intrigued that
> you can write before connecting on a raw socket.
Not an IP raw socket, but the raw packet
socket. So yes, I can. And that looks very
natural to me, not a hack or something.
> Could you please
> write up a minimal program that I can play with?
I can but I am a bit surprised that dosemu
is not a sufficient test-case for *you* :)
But I don't seem to be able to send any
mail to you:
<herbert@gondor.apana.org.au>: host arnor.apana.org.au[203.14.152.115] said:
550 mail from 217.67.122.194 rejected: administrative prohibition (in reply
to RCPT TO command)
> Well read() is different.
Yes, not a good argument on my side, sorry.
> OTOH, write() and send() needs to know where the message is going
> to.
That's exactly where the packet sockets are
different. Here's the whole point. Have a
look into a "struct sockaddr_pkt":
struct sockaddr_pkt
{
unsigned short spkt_family;
unsigned char spkt_device[14];
unsigned short spkt_protocol;
};
Not too much about a destination here.
For the packet sockets you only need to
know via which eth device you want to send
it, and nothing more. And this is what I
specify to bind() anyway, so I dont want
to duplicate that info all the time.
You say it is counter-intuitive.
I'll agree with this only if you point me
another convinient way to bind to the
particular eth device and send/receive via
that device without always specifying its
name/number. That's what SOCK_RAW allows,
but not SOCK_PACKET.
My patch is probably dead anyway though.
SOCK_PACKET is mentioned to be deprecated
in man, so perhaps noone will apply any
patches on it... Just wanted to point out
that there is a bug/inconsistency in it.
next prev parent reply other threads:[~2004-10-14 3:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-11 17:18 [patch] allow write() on SOCK_PACKET sockets Stas Sergeev
2004-10-11 21:34 ` Herbert Xu
2004-10-12 3:33 ` Stas Sergeev
2004-10-14 2:12 ` Herbert Xu
2004-10-14 3:45 ` Stas Sergeev [this message]
2004-10-14 8:26 ` Herbert Xu
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=416DF644.2070906@aknet.ru \
--to=stsp@aknet.ru \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net@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