From: jamal <hadi@cyberus.ca>
To: Jeff Garzik <jgarzik@pobox.com>, Donald Becker <becker@scyld.com>
Cc: netdev@oss.sgi.com
Subject: SIOCADDMULTI for unicast broken
Date: Fri, 3 Jan 2003 16:46:40 -0500 (EST) [thread overview]
Message-ID: <20030103164001.S48623@shell.cyberus.ca> (raw)
[-- 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)
next reply other threads:[~2003-01-03 21:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-03 21:46 jamal [this message]
2003-01-04 0:07 ` SIOCADDMULTI for unicast broken 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
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=20030103164001.S48623@shell.cyberus.ca \
--to=hadi@cyberus.ca \
--cc=becker@scyld.com \
--cc=jgarzik@pobox.com \
--cc=netdev@oss.sgi.com \
/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;
as well as URLs for NNTP newsgroup(s).