netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* SIOCADDMULTI for unicast broken
@ 2003-01-03 21:46 jamal
  2003-01-04  0:07 ` Donald Becker
  2003-01-04  1:18 ` Jeff Garzik
  0 siblings, 2 replies; 21+ messages in thread
From: jamal @ 2003-01-03 21:46 UTC (permalink / raw)
  To: Jeff Garzik, Donald Becker; +Cc: netdev

[-- Attachment #1: Type: TEXT/PLAIN, Size: 441 bytes --]


Some programs require ability to accept packets destined to certain
MAC addresses (in addition to their own).
Example Jerome Ettienes vrrpd (http://w3.arobas.net/~jetienne/vrrpd/)

The trick is to add unicast addresses via SIOCADDMULTI and accept those
packets when they make their way up the stack.
I think this used to work, no? Donald, any history/comments behind
this?
Patch attahced, not very well tested but looks safe.

cheers,
jamal

[-- Attachment #2: Type: TEXT/PLAIN, Size: 1329 bytes --]

--- net/ethernet/eth.c	2003/01/03 18:20:49	1.1
+++ net/ethernet/eth.c	2003/01/03 18:22:05
@@ -148,6 +148,30 @@
 	return 0;
 }
 
+void check_mcast_list(struct sk_buff *skb, struct net_device *dev)
+{
+	struct dev_mc_list *dmi;
+	struct ethhdr *eth;
+			        
+	if (skb->pkt_type != PACKET_OTHERHOST)
+		return;
+
+	eth = skb->mac.ethernet;
+
+	/* may not be necessary to bh_lock - fix later - JHS */
+	spin_lock_bh(&dev->xmit_lock);
+
+	for (dmi = dev->mc_list; dmi != NULL; dmi = dmi->next) {
+		if (memcmp(dmi->dmi_addr, eth->h_dest, dev->addr_len) == 0
+		    && dmi->dmi_addrlen == dev->addr_len) { 
+			skb->pkt_type = PACKET_HOST;
+				break;
+		}
+	}
+
+	spin_unlock_bh(&dev->xmit_lock);
+}
+
 
 /*
  *	Determine the packet's protocol ID. The rule here is that we 
@@ -182,8 +206,14 @@
 	 
 	else if(1 /*dev->flags&IFF_PROMISC*/)
 	{
-		if(memcmp(eth->h_dest,dev->dev_addr, ETH_ALEN))
-			skb->pkt_type=PACKET_OTHERHOST;
+		if(memcmp(eth->h_dest,dev->dev_addr, ETH_ALEN)) {
+			skb->pkt_type = PACKET_OTHERHOST;
+			/* we override PACKET_OTHERHOST if MAC appears
+			 * in our mcast list allows to have several 
+			 * allowed MACs for receives added via 
+			 * SIOCADDMULTI on the device*/
+			check_mcast_list(skb,dev);
+		}
 	}
 	
 	if (ntohs(eth->h_proto) >= 1536)

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2003-01-06 17:23 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-03 21:46 SIOCADDMULTI for unicast broken jamal
2003-01-04  0:07 ` Donald Becker
2003-01-04  1:18 ` Jeff Garzik
2003-01-04  1:39   ` Donald Becker
2003-01-04  1:45     ` Ben Greear
2003-01-04  1:52       ` Jeff Garzik
2003-01-06 15:00         ` Krzysztof Halasa
2003-01-04  2:18       ` Donald Becker
2003-01-04  4:11         ` jamal
2003-01-04  6:33           ` Donald Becker
2003-01-04 17:41             ` jamal
2003-01-04 18:24               ` Donald Becker
2003-01-04 18:55                 ` jamal
2003-01-04 18:36               ` Julian Anastasov
2003-01-04 19:04                 ` jamal
2003-01-05 11:45                   ` Julian Anastasov
2003-01-06 13:44                     ` jamal
2003-01-06 15:00                       ` Julian Anastasov
2003-01-06 17:23                         ` jamal
2003-01-04  7:32           ` Jeff Garzik
2003-01-04 17:43             ` jamal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).