From: Stas Sergeev <stsp@aknet.ru>
To: Linux kernel <linux-kernel@vger.kernel.org>
Cc: linux-net@vger.kernel.org
Subject: [patch] allow write() on SOCK_PACKET sockets
Date: Mon, 11 Oct 2004 21:18:00 +0400 [thread overview]
Message-ID: <416AC048.6040805@aknet.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 428 bytes --]
Hello.
Unless I am really missing something, there
seem to be no reason why the SOCK_PACKET code
does not allow to use write() or send() when
the socket was bound, and insists on using
sendto(). SOCK_RAW code, in comparison, allows
write() after bind().
Attached patch allows write() for the SOCK_PACKET
sockets when they are bound.
Can this be applied, or am I missing the point?
Signed-off-by: Stas Sergeev <stsp@aknet.ru>
[-- Attachment #2: pkt_send.diff --]
[-- Type: text/x-patch, Size: 916 bytes --]
--- linux/net/packet/af_packet.c 2004-06-26 15:20:54.000000000 +0400
+++ linux/net/packet/af_packet.c 2004-10-10 02:25:41.000000000 +0400
@@ -322,16 +322,23 @@
return(-EINVAL);
if (msg->msg_namelen==sizeof(struct sockaddr_pkt))
proto=saddr->spkt_protocol;
+ /*
+ * Find the device first to size check it
+ */
+
+ saddr->spkt_device[13] = 0;
+ dev = dev_get_by_name(saddr->spkt_device);
}
else
- return(-ENOTCONN); /* SOCK_PACKET must be sent giving an address */
-
- /*
- * Find the device first to size check it
- */
+ {
+ struct packet_opt *po = pkt_sk(sk);
+ if (!po->running || !po->prot_hook.dev)
+ return -ENOTCONN; /* SOCK_PACKET must be sent giving an address */
+ proto = po->prot_hook.type;
+ dev = po->prot_hook.dev;
+ dev_hold(dev);
+ }
- saddr->spkt_device[13] = 0;
- dev = dev_get_by_name(saddr->spkt_device);
err = -ENODEV;
if (dev == NULL)
goto out_unlock;
next reply other threads:[~2004-10-11 18:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-11 17:18 Stas Sergeev [this message]
2004-10-11 21:34 ` [patch] allow write() on SOCK_PACKET sockets Herbert Xu
2004-10-12 3:33 ` Stas Sergeev
2004-10-14 2:12 ` Herbert Xu
2004-10-14 3:45 ` Stas Sergeev
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=416AC048.6040805@aknet.ru \
--to=stsp@aknet.ru \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.