af_packet: Teach to listen for multiple unicast addresses.
authorEric W. Biederman <ebiederm@xmission.com>
Tue, 19 May 2009 18:27:17 +0000 (18:27 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 May 2009 22:13:39 +0000 (15:13 -0700)
The the PACKET_ADD_MEMBERSHIP and the PACKET_DROP_MEMBERSHIP setsockopt
calls for af_packet already has all of the infrastructure needed to subscribe
to multiple mac addresses.  All that is missing is a flag to say that
the address we want to listen on is a unicast address.

So introduce PACKET_MR_UNICAST and wire it up to dev_unicast_add and
dev_unicast_delete.

Additionally I noticed that errors from dev_mc_add were not propagated
from packet_dev_mc so fix that.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/if_packet.h
net/packet/af_packet.c

index 5b2badeb9497189247eafbbefdc316c57911b0b7..dea7d6b7cf982fcb2d78266faddc7ba43a1db3a2 100644 (file)
@@ -145,5 +145,6 @@ struct packet_mreq
 #define PACKET_MR_MULTICAST    0
 #define PACKET_MR_PROMISC      1
 #define PACKET_MR_ALLMULTI     2
+#define PACKET_MR_UNICAST      3
 
 #endif
index 766e6b41f7cad432b9eb2a4ec499cedf1dc76a2a..c7c5d524967e9e889431cf05842d6fd1cb1c9ad3 100644 (file)
@@ -1570,9 +1570,9 @@ static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i,
        switch (i->type) {
        case PACKET_MR_MULTICAST:
                if (what > 0)
-                       dev_mc_add(dev, i->addr, i->alen, 0);
+                       return dev_mc_add(dev, i->addr, i->alen, 0);
                else
-                       dev_mc_delete(dev, i->addr, i->alen, 0);
+                       return dev_mc_delete(dev, i->addr, i->alen, 0);
                break;
        case PACKET_MR_PROMISC:
                return dev_set_promiscuity(dev, what);
@@ -1580,6 +1580,12 @@ static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i,
        case PACKET_MR_ALLMULTI:
                return dev_set_allmulti(dev, what);
                break;
+       case PACKET_MR_UNICAST:
+               if (what > 0)
+                       return dev_unicast_add(dev, i->addr, i->alen);
+               else
+                       return dev_unicast_delete(dev, i->addr, i->alen);
+               break;
        default:;
        }
        return 0;