From: Andi Kleen <ak@suse.de>
To: Joris van Rantwijk <joris@deadlock.et.tudelft.nl>
Cc: Andi Kleen <ak@suse.de>,
linux-kernel@vger.kernel.org,
"A.N.Kuznetsov" <kuznet@ms2.inr.ac.ru>,
"David S. Miller" <davem@redhat.com>
Subject: Re: Bind to protocol with AF_PACKET doesn't work for outgoing packets
Date: Thu, 1 Nov 2001 17:46:56 +0100 [thread overview]
Message-ID: <20011101174656.A8627@wotan.suse.de> (raw)
In-Reply-To: <p733d3yr2b1.fsf@amdsim2.suse.de> <Pine.LNX.4.21.0111011603040.25072-100000@deadlock.et.tudelft.nl>
In-Reply-To: <Pine.LNX.4.21.0111011603040.25072-100000@deadlock.et.tudelft.nl>; from joris@deadlock.et.tudelft.nl on Thu, Nov 01, 2001 at 04:18:27PM +0100
On Thu, Nov 01, 2001 at 04:18:27PM +0100, Joris van Rantwijk wrote:
> Ah, right. I suspected there was a good reason not to do it, or it
> would have been done ages ago.
> But it's still a bit weird isn't it ?
> You sure won't find this in man packet(7).
>
I would more consider it a bug. I didn't know about it while writing
packet(7)
Here is a patch.
-Andi
--- linux-2.4.13-work/net/packet/af_packet.c-PACKET Tue Aug 7 17:30:50 2001
+++ linux-2.4.13-work/net/packet/af_packet.c Thu Nov 1 17:38:12 2001
@@ -250,6 +250,9 @@
if (skb->pkt_type == PACKET_LOOPBACK)
goto out;
+ if (sk->num != htons(ETH_P_ALL) && skb->protocol != sk->num)
+ goto out;
+
if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
goto oom;
@@ -413,6 +416,10 @@
goto drop;
sk = (struct sock *) pt->data;
+
+ if (sk->num != htons(ETH_P_ALL) && skb->protocol != sk->num)
+ goto drop;
+
po = sk->protinfo.af_packet;
skb->dev = dev;
@@ -824,7 +831,8 @@
}
sk->num = protocol;
- sk->protinfo.af_packet->prot_hook.type = protocol;
+ /* XXX Always bind to ETH_P_ALL to catch outgoing packets. */
+ sk->protinfo.af_packet->prot_hook.type = htons(ETH_P_ALL);
sk->protinfo.af_packet->prot_hook.dev = dev;
sk->protinfo.af_packet->ifindex = dev ? dev->ifindex : 0;
@@ -973,7 +981,7 @@
sk->protinfo.af_packet->prot_hook.data = (void *)sk;
if (protocol) {
- sk->protinfo.af_packet->prot_hook.type = protocol;
+ sk->protinfo.af_packet->prot_hook.type = htons(ETH_P_ALL);
dev_add_pack(&sk->protinfo.af_packet->prot_hook);
sock_hold(sk);
sk->protinfo.af_packet->running = 1;
next prev parent reply other threads:[~2001-11-01 16:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.21.0111010944050.16656-100000@deadlock.et.tudelft.nl.suse.lists.linux.kernel>
2001-11-01 14:30 ` Bind to protocol with AF_PACKET doesn't work for outgoing packets Andi Kleen
2001-11-01 15:18 ` Joris van Rantwijk
2001-11-01 16:46 ` Andi Kleen [this message]
2001-11-01 17:33 ` kuznet
2001-11-01 17:45 ` Andi Kleen
2001-11-01 18:09 ` kuznet
2001-11-01 18:21 ` Andi Kleen
2001-11-01 18:56 ` kuznet
2001-11-01 19:28 ` Andi Kleen
2001-11-01 19:48 ` kuznet
2001-11-01 9:11 Joris van Rantwijk
2001-11-02 2:26 ` Edgar Toernig
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=20011101174656.A8627@wotan.suse.de \
--to=ak@suse.de \
--cc=davem@redhat.com \
--cc=joris@deadlock.et.tudelft.nl \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@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