netdev
[Top] [All Lists]

Re: [PATCH] allow 0 protocol for bind() of packet sockets

To: laudney@xxxxxxxx
Subject: Re: [PATCH] allow 0 protocol for bind() of packet sockets
From: Jason Lunz <j@xxxxxxxxxxxxxx>
Date: Wed, 20 Feb 2002 12:05:57 -0500
Cc: netdev@xxxxxxxxxxx
In-reply-to: <200202200604.g1K64s903784@xxxxxxxxxxx>
References: <200202200604.g1K64s903784@xxxxxxxxxxx>
Sender: owner-netdev@xxxxxxxxxxx
User-agent: Mutt/1.3.27i
laudney@xxxxxxxx said:
> After reading the patch, I found some problems.
> 1. The patch doesn't allow "protocol == 0" either, even exit the
> funtion at an earlier stage by shifting the place of
> "if (protocol == 0)
>   goto out_unlock;"
> forward.

That's the point. The patch allows one to remove a socket from the
ptype_all list (or ptype_base hash) after it's been added.

Userspace can make the socket active again by binding to an actual
protocol, like ETH_P_ALL.

> 2. all the bulk changes to the codes of
> if(dev) {
> ..
> }
> are simply an optimization. No content change at all!!

true. maybe I should remove that; I just thought it was just ugly having
the same block in two places when one would do.

> /* since protocol == 0, no hook should exist */
>       if (protocol == 0)
>               sk->protinfo.af_packet->running = 0;

this is wrong. af_packet->running indicates whether the socket is in the
ptype_all list or the ptype_base hash (read the rest of af_packet.c).
You break this here by setting running to 0 without actually removing
it.

-- 
Jason Lunz              Trellis Network Security
j@xxxxxxxxxxxxxx        http://www.trellisinc.com/

<Prev in Thread] Current Thread [Next in Thread>