SIOCADDMULTI for unicast broken
Subsystems (2)
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
ethernet/eth.c +32 -2
@@ -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 )
Quoted 10 lines · jamal
Subject: SIOCADDMULTI for unicast broken
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?
This is a very specialized requirement, so specialized that it should not be added as general-purpose requirement for drivers or the network stack.
This capability was supported as a special case for the Tulip driver, and then only for the real 21*4* chips that had the hardware CAM capable of matching up to 16 destination addresses.
A few other chips support matching unicast addresses with the multicast filter, but there is the general problem of false-accepts and chip-specific quirks that must be dealt with.
Once again: this is a very specialized thing. Of the few people that think they need the capability, most are wrong.
Signature · 4 lines
Donald Becker [email protected] Scyld Computing Corporation http://www.scyld.com 410 Severn Ave. Suite 210 Scyld Beowulf cluster system Annapolis MD 21403 410-990-9993
Quoted 8 lines · jamal
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?
Over and above Donald's comments, from an interface perspective I think this is a bit of a hack, don't you? :) Calling an "add-multi" ioctl should do precisely that... and only that :)
Quoted 5 lines · Jeff Garzik
Quoted 4 lines · jamal
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/)
Quoted 8 lines
Quoted 4 lines
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?Over and above Donald's comments, from an interface perspective I think this is a bit of a hack, don't you? :) Calling an "add-multi" ioctl should do precisely that... and only that :)
Yes, it is totally a hack, not an interface.
It was
"If you need this capability for a RESEARCH PROJECT, you can buy this specific board and thus not need to modify the kernel or device driver. "
You can also find a few people that want to receive specific corrupted packets, change the meaning of LEDs on a NIC, and do many other strange things. But we don't need a defined kernel interface for each one.
Improvement is what you can eliminate or simplify, not adding complexity.
Signature · 4 lines
Donald Becker [email protected] Scyld Computing Corporation http://www.scyld.com 410 Severn Ave. Suite 210 Scyld Beowulf cluster system Annapolis MD 21403 410-990-9993
Quoted 8 lines · Donald Becker
It was
"If you need this capability for a RESEARCH PROJECT, you can buy this specific board and thus not need to modify the kernel or device driver. "You can also find a few people that want to receive specific corrupted packets, change the meaning of LEDs on a NIC, and do many other strange things. But we don't need a defined kernel interface for each one.
Just out of curiosity, what is the suggested manner for adding such back-door hacks as this? Maybe in a proc file system that the driver implements? It would be neat to see various driver-specific features like this be implemented, and it would be even nicer if they followed at least some general guideline for how to interface with the rest of the world...
Quoted 2 lines
Improvement is what you can eliminate or simplify, not adding complexity.
Exposing new features can also be an improvement, though one does not imply the other ;)
Ben
Signature · 3 lines
Ben Greear <[email protected]> <Ben_Greear AT excite.com> President of Candela Technologies Inc http://www.candelatech.com ScryMUD: http://scry.wanfear.com http://scry.wanfear.com/~greear
Quoted 7 lines · Ben Greear
Quoted 5 lines · Donald Becker
It was
"If you need this capability for a RESEARCH PROJECT, you can buy this specific board and thus not need to modify the kernel or device driver. "
Quoted 7 lines
Quoted 3 lines
You can also find a few people that want to receive specific corrupted packets, change the meaning of LEDs on a NIC, and do many other strange things. But we don't need a defined kernel interface for each one.
Just out of curiosity, what is the suggested manner for adding such back-door hacks as this?
SIOCDEVPRIVATE is staying around
Quoted 2 lines
Maybe in a proc file system that the driver
implements?
No! procfs additions are discouraged. sysfs in 2.5.x if you _must_ do this, but SIOCDEVPRIVATE or just flat out maintaining a kernel patch against a stable kernel tree would be much preferred, I think.
Quoted 4 lines
It would be neat to see various driver-specific features like this be implemented, and it would be even nicer if they followed at least some general guideline for how to interface with the rest of the world...
Driver-specific features are by definition just that :) If you want a general guideline, you'll also want a header or helper lib quite often to eliminate duplication of code and standardize the interface.
Jeff
Quoted 11 lines · Ben Greear
Quoted 8 lines · Donald Becker
It was
"If you need this capability for a RESEARCH PROJECT, you can buy this specific board and thus not need to modify the kernel or device driver. "You can also find a few people that want to receive specific corrupted packets, change the meaning of LEDs on a NIC, and do many other strange things. But we don't need a defined kernel interface for each one.
Quoted 6 lines
Just out of curiosity, what is the suggested manner for adding such back-door hacks as this? Maybe in a proc file system that the driver implements? It would be neat to see various driver-specific features like this be implemented, and it would be even nicer if they followed at least some general guideline for how to interface with the rest of the world...
The problems are
- The extensions people (very few people) want are completely unpredictable.
- Unique features are, well, unique
You might think it's Really Very Important to change the LED meanings on your NIC. For instance, if one LED means all Rx traffic and another Rx accepted you can estimate how much traffic is for you. And most NICs provide a way to do this. But no two are the same, and there is no general way to describe the semantics. So it's a capability best ignored. (*)
Un
* You can access this and many other capabilities through the MII ioctl() interface to vendor specific register, but not as an abstracted, hardware-independent feature.
Why an ioctl() and not /proc? Exporting MII registers via /proc is problematic because of Sticky Bits and clear-on-read semantics.
Signature · 4 lines
Donald Becker [email protected] Scyld Computing Corporation http://www.scyld.com 410 Severn Ave. Suite 210 Scyld Beowulf cluster system Annapolis MD 21403 410-990-9993
Too many emails to respond to at once.
Q: Is this a hack?
A: Yes, indeed it is. wrong API is the main culprit.
Q: Is this a feature needed by only a few people?
A: No, Absolutely not. RFC2338 is one example that needs
such a feature for "aliasing" MAC addresses. RFC2338 is very popular these days for some reason. I would think any schemes that do HA takeover of another host would need such a feature.
How common are NICS such as the 21x4x that can be programmed to do perfect hashing and accept multiple MAC addresses in hardware? And if this was a commodity feature - what happens to PACKET_HOST setting? an netdevice can only have one unicast MAC address. SIOCDEVPRIVATE does not seem to be the right place to do this. You still wanna have ability to do proper RFC2338 and related protocols even when the h/ware is incapable.
And btw, i didnt even open up the whole can of worms - we also need to respond back with proper MAC addresses to ARPs and packets sourced with specific virtual router IPs. This is a seprate problem.
cheers,
jamal
PS: the hack credit (for using SIOCADDMULTI/DELMULTI) goes to Jerome Ettiene (this is a guy who never responds to email, probably too busy unicycling somewhere, so no point in ccing him) - Except it doesnt work without the patch i posted.
On takeover, he sets the original MAC address as a receiving MAC via SIOCADDMULTI and the allocated 00-00-5E-00-01-xx MAC to be the main MAC address.
The weakness is when you want to run multiple virtual routers; each one requires its own 00-00-5E-00-01-xx MAC.
Quoted 7 lines · jamal
Too many emails to respond to at once.
Q: Is this a hack?
A: Yes, indeed it is. wrong API is the main culprit.Q: Is this a feature needed by only a few people?
A: No, Absolutely not. RFC2338 is one example that needs
The common way of handling this is unsolicited ARP.
Quoted 2 lines
How common are NICS such as the 21x4x that can be programmed to do perfect hashing and accept multiple MAC addresses in hardware?
Not very common. I mentioned the 21*4* explicitly because few other common chips implement this feature.
The Digital design implemented it because of DECnet, which is long dead.
Quoted 8 lines
And if this was a commodity feature - what happens to
PACKET_HOSTsetting? an netdevice can only have one unicast MAC address. SIOCDEVPRIVATE does not seem to be the right place to do this. You still wanna have ability to do proper RFC2338 and related protocols even when the h/ware is incapable.
And btw, i didnt even open up the whole can of worms - we also need to respond back with proper MAC addresses to ARPs and packets sourced with specific virtual router IPs. This is a seprate problem.
Yup, a whole can of worms if you want it to be a general feature handled by the kernel...
Quoted 4 lines
PS: the hack credit (for using SIOCADDMULTI/DELMULTI) goes to Jerome Ettiene (this is a guy who never responds to email, probably too busy unicycling somewhere, so no point in ccing him) - Except it doesnt work without the patch i posted.
This has worked with the Tulip driver for many years. I've pointed it out to a number of people that requested this as a new feature.
Signature · 4 lines
Donald Becker [email protected] Scyld Computing Corporation http://www.scyld.com 410 Severn Ave. Suite 210 Scyld Beowulf cluster system Annapolis MD 21403 410-990-9993
I wonder if there are any good uses for more advanced RX filtering that is beginning to appear. I could certainly imagine an interface that was a more generic RX filtering interface, and [just by accident] happened to support existing unicast and multicast rx-mode-related controls.
As vendors stuff features onto cards and try to figure out where is the best dividing line between TCP stack acceleration and TCP stack offload, it seems to me that recent cards more often than not have nice RX filtering capabilities. If you look at the world through GigE-colored glasses, the RX filtering picture gets even better. There are some fun SMP implications with flexible enough RX filtering, for example.
Quoted 4 lines · Donald Becker
Quoted 2 lines · jamal
Too many emails to respond to at once.
Quoted 8 lines
Quoted 5 lines
Q: Is this a hack?
A: Yes, indeed it is. wrong API is the main culprit.Q: Is this a feature needed by only a few people?
A: No, Absolutely not. RFC2338 is one example that needsThe common way of handling this is unsolicited ARP.
unsolicited ARPs on failover are good. You send the arp with one of the allocated MAC addresses as the source. The hosts sending data use that MAC address as the dst MAC. Did i miss something or how do you see the packet making its way up the stack?
Quoted 7 lines
Quoted 2 lines
How common are NICS such as the 21x4x that can be programmed to do perfect hashing and accept multiple MAC addresses in hardware?
Not very common. I mentioned the 21*4* explicitly because few other common chips implement this feature.
The Digital design implemented it because of DECnet, which is long dead.
Side, unrelated question:
for h/ware multicast filtered multicast addresses: What is the common practise to handle the corner case where a hardware multicast address is filled up. Take an example of the tulip using perfect hashing when all the 16 entries are exhausted and the host still wants to subscribe to 100 other multicast groups... should we put the nic into promisc multicast?
Quoted 9 lines
Quoted 8 lines
And if this was a commodity feature - what happens to
PACKET_HOSTsetting? an netdevice can only have one unicast MAC address. SIOCDEVPRIVATE does not seem to be the right place to do this. You still wanna have ability to do proper RFC2338 and related protocols even when the h/ware is incapable.
And btw, i didnt even open up the whole can of worms - we also need to respond back with proper MAC addresses to ARPs and packets sourced with specific virtual router IPs. This is a seprate problem.
Quoted 3 lines
Yup, a whole can of worms if you want it to be a general feature handled by the kernel...
I think hacking the ARP code to do this would be horrible - one way to do it is write a tc module that mungles outgoing ARPs to substitute the src MAC address based on src IP.
Quoted 8 lines
Quoted 4 lines
PS: the hack credit (for using SIOCADDMULTI/DELMULTI) goes to Jerome Ettiene (this is a guy who never responds to email, probably too busy unicycling somewhere, so no point in ccing him) - Except it doesnt work without the patch i posted.
This has worked with the Tulip driver for many years. I've pointed it out to a number of people that requested this as a new feature.
didnt know that. I guess i was lucky not to have used the tulip when i got bitten by this. So, Donald, other than tulip what other NICs can do this?
cheers,
jamal
Quoted 5 lines · Jeff Garzik
I wonder if there are any good uses for more advanced RX filtering that is beginning to appear. I could certainly imagine an interface that was a more generic RX filtering interface, and [just by accident] happened to support existing unicast and multicast rx-mode-related controls.
Quoted 7 lines
As vendors stuff features onto cards and try to figure out where is the best dividing line between TCP stack acceleration and TCP stack offload, it seems to me that recent cards more often than not have nice RX filtering capabilities. If you look at the world through GigE-colored glasses, the RX filtering picture gets even better. There are some fun SMP implications with flexible enough RX filtering, for example.
Davem had some nifty ideas on this at least for TOE. I think we ought to start looking at that direction. Anyone who is working on this please involve me, i have some ideas (and it would avoid me stressing you when you output code).
cheers,
jamal
Quoted 4 lines · jamal
Quoted 3 lines · Donald Becker
Quoted 2 lines · jamal
Q: Is this a hack?
A: Yes, indeed it is. wrong API is the main culprit.
I disagree: it's a hack usable by the very few people that need it. Defining an API would add little-used complexity.
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
How common are NICS such as the 21x4x that can be programmed to do perfect hashing and accept multiple MAC addresses in hardware?
Not very common. I mentioned the 21*4* explicitly because few other common chips implement this feature.
The Digital design implemented it because of DECnet, which is long dead.Side, unrelated question:
for h/ware multicast filtered multicast addresses: What is the common practise to handle the corner case where a hardware multicast address is filled up.
This is good example of why an API is a bad idea: there is no general case. The Tulip has 16 filter addresses, but...
Oh, not all chips handled by the Tulip driver. Macronix does. Asix
doesn't. ADMtek doesn't. PNIC chips do.
You need one slot for the broadcast address on a few chip versions
with a bug. (I do this unconditionally.)
You cannot use the multicast hash filter.
"Only in the month after the full moon falls on a Tuesday."
Quoted 4 lines
Take an example of the tulip using perfect hashing when
all the 16 entries are exhausted and the host still wants to subscribe to 100 other multicast groups... should we put the nic into promisc multicast?
Yes. This is the DECnet case.
Quoted 3 lines
didnt know that. I guess i was lucky not to have used the tulip when i got bitten by this. So, Donald, other than tulip what other NICs can do this?
Mostly gigabit Ethernet chips. There are a few FE chips that allow setting the multicast hash address to also filter physical addresses, but imperfect filters result in the same extra cdoe as using promiscuous mode.
Signature · 4 lines
Donald Becker [email protected] Scyld Computing Corporation http://www.scyld.com 410 Severn Ave. Suite 210 Scyld Beowulf cluster system Annapolis MD 21403 410-990-9993
Hello,
Quoted 11 lines · jamal
Quoted 7 lines
Quoted 3 lines
And btw, i didnt even open up the whole can of worms - we also need to respond back with proper MAC addresses to ARPs and packets sourced with specific virtual router IPs. This is a seprate problem.
Yup, a whole can of worms if you want it to be a general feature handled by the kernel...
I think hacking the ARP code to do this would be horrible - one way to do it is write a tc module that mungles outgoing ARPs to substitute the src MAC address based on src IP.
You can do it with arptables (still not sure how) or with
arprules+iparp:
# send all our requests from VRIP with VMAC ip arp add table output from 1.2.3.4 llsrc 00:00:5E:00:01:10
But this is not enough for VRRP. For Linux we need a
way to bind VRIPs to source VMACs or sort of this. I'm cc-ing to Alexandre Cassen as he is working on VRRP (http://keepalived.sourceforge.net/).
I hope he can shed some light on the VRRP needs.
Quoted 2 lines
cheers,
jamal
Regards
--
Julian Anastasov <[email protected]>
Quoted 6 lines · Donald Becker
Quoted 3 lines
Quoted 3 lines · jamal
Quoted 2 lines
Q: Is this a hack?
A: Yes, indeed it is. wrong API is the main culprit.I disagree: it's a hack usable by the very few people that need it. Defining an API would add little-used complexity.
Somehow i (and people using VRRP or trying to write HSRP like apps) need to have multiple MAC addresses accepted by a single NIC. It is not really a science project reqnmt, rather needed by real-world apps which are becoming more common. The way i see it is:"
a) Introduce new API
b) reuse an API - considered a hack really
c) maintain it as a separate patch; needs to be cleaned a little for optimization (example not all NICS may need this extra per packet check).
Which one do you see as being reasonable?
You cant say none of the above because people need this feature ;-> You have to present an alternative at least.
Quoted 10 lines
Quoted 5 lines
Side, unrelated question:
for h/ware multicast filtered multicast addresses: What is the common practise to handle the corner case where a hardware multicast address is filled up.This is good example of why an API is a bad idea: there is no general case. The Tulip has 16 filter addresses, but...
Oh, not all chips handled by the Tulip driver. Macronix does. Asix
doesn't. ADMtek doesn't. PNIC chips do.
ok.
Quoted 2 lines
You need one slot for the broadcast address on a few chip versions
with a bug. (I do this unconditionally.)
Make sense.
Quoted 1 line
You cannot use the multicast hash filter.
Why not?
Quoted 9 lines
"Only in the month after the full moon falls on a Tuesday."
Quoted 4 lines
Take an example of the tulip using perfect hashing when
all the 16 entries are exhausted and the host still wants to subscribe to 100 other multicast groups... should we put the nic into promisc multicast?Yes. This is the DECnet case.
I dont think this is what we do today in general; does the tulip do this really?
Quoted 10 lines
Quoted 4 lines
didnt know that. I guess i was lucky not to have used the tulip when i got bitten by this. So, Donald, other than tulip what other NICs can do this?
Mostly gigabit Ethernet chips. There are a few FE chips that allow setting the multicast hash address to also filter physical addresses, but imperfect filters result in the same extra cdoe as using promiscuous mode.
OK, i guess this explains the imperfect filters; so since Giges are becoming such a commodity item, are you suggesting that since to do VRRP get yourself a Gige card or appropriate FE card?
cheers,
jamal
Quoted 11 lines · Julian Anastasov
Hello,
Quoted 4 lines · jamal
I think hacking the ARP code to do this would be horrible - one way to do it is write a tc module that mungles outgoing ARPs to substitute the src MAC address based on src IP.
You can do it with arptables (still not sure how) or with
I havent seen user-space arptables around.
Quoted 6 lines
arprules+iparp:
# send all our requests from VRIP with VMAC ip arp add table output from 1.2.3.4 llsrc 00:00:5E:00:01:10
I like this concept. This + the patch i posted should resolve the problem of getting multiple VRIDs on a single interface.
[Although you could do it in a lot less code, maybe 50%, using some of the tc filter extensions i am working on; also a lot less code than arptables]
Quoted 6 lines
But this is not enough for VRRP. For Linux we need a
way to bind VRIPs to source VMACs or sort of this. I'm cc-ing to Alexandre Cassen as he is working on VRRP (http://keepalived.sourceforge.net/).
I hope he can shed some light on the VRRP needs.
I guess there is more than one VRRP implementation on Linux; the one i played with is from some crazy Frenchman named Jerome Ettiene;-> With two conecpts being addressed i.e patch like that you have + the patch i posted i dont see any orther reason VRRP to be hindered.
cheers,
jamal
Hello,
Quoted 3 lines · jamal
Quoted 1 line
You can do it with arptables (still not sure how) or with
I havent seen user-space arptables around.
yes, that is what I mean
Quoted 7 lines
Quoted 1 line
I like this concept. This + the patch i posted should resolve the problem of getting multiple VRIDs on a single interface.
[Although you could do it in a lot less code, maybe 50%, using some of the tc filter extensions i am working on; also a lot less code than arptables]
I hope there will be support for altering any bit
in the skb->head - skb->end area, even by using negative offsets based on skb->nh.raw - this is needed for eth header manipulations. May be sort of: ... alter andmask 0xFF00 xormask 0x0023 at -4 ... i.e. syntax similar to ipchains TOS and u32 match.
As for VRRP I see it in this way. Note that I'm not a VRRP
fan, I prefer the ARP methods for takeover, Of course, sometimes they can not work due to the bad non-Linux ARP stack implementations. As Alexandre noted once, the gratuitous ARP should not be slower than VRRP talks. Only that there are bad ARP cache implementations.
1. if remote hosts asks for lladdr of VRIP tc should modify our ARP reply: the SMAC in the eth header (using negative offset) and the SMAC in the ARP header. This is analog to:
ip arp add to VRIP llsrc VMAC
2. if our IP stack sends packet with saddr=VRIP that leads to ARP probe sent from our host then we should modify the packet in the same way as (1). This is analog to:
ip arp add table output from VRIP llsrc VMAC
3. Replace the src MAC with proper VMAC for all IP packets with saddr=VRIP. This can be a neighbouring code job but difficult to implement there.
4. Not last: NIC should accept traffic for all VMACs (promisc when attached to switched hubs is enough?) and eth_type_trans to maintain list of MAC aliases. I'm not sure that such list/hashtable with MACs should be attached per device - may be VRRP needs to announce one MAC through different interfaces? Also think for the Bridging code which calls eth_type_trans too.
5. Enough from one who don't like VRRP :)
Quoted 2 lines
With two conecpts being addressed i.e patch like that you have + the patch i posted i dont see any orther reason VRRP to be hindered.
Not sure, may be the only remaining is (3).
Quoted 2 lines
cheers,
jamal
Regards
--
Julian Anastasov <[email protected]>
Quoted 19 lines · Julian Anastasov
Hello,
Quoted 3 lines · jamal
Quoted 1 line
You can do it with arptables (still not sure how) or with
I havent seen user-space arptables around.
yes, that is what I mean
Quoted 7 lines
Quoted 1 line
I like this concept. This + the patch i posted should resolve the problem of getting multiple VRIDs on a single interface.
[Although you could do it in a lot less code, maybe 50%, using some of the tc filter extensions i am working on; also a lot less code than arptables]
Quoted 5 lines
I hope there will be support for altering any bit
in theskb->head-skb->endarea, even by using negative offsets based onskb->nh.raw- this is needed for eth header manipulations. May be sort of: ... alter andmask0xFF00xormask0x0023at -4 ... i.e. syntax similar to ipchains TOS and u32 match.
I wanted to use u32 as the basis; which means u32 type matching is needed. then use vi/sed type substitution s/OL/V where:
O = offset (from skb->data, could be -ve),
L = length (cant go beyond head or end),
V is a static value configured (its size cant exceed L). V can also be computed off something example the data at offset O. I am trying to keep away from situations where L is larger or smaller than sizeof V so theres no mucking with any of the skb pointers ore reallocing etc. In the next iteration things could change. Note i havent written this but will in the near future (so anyone is welcome to hack on it)
I didnt understand your andmask and xormask idea...
Quoted 7 lines
As for VRRP I see it in this way. Note that I'm not a VRRP
fan, I prefer the ARP methods for takeover, Of course, sometimes they can not work due to the bad non-Linux ARP stack implementations. As Alexandre noted once, the gratuitous ARP should not be slower than VRRP talks. Only that there are bad ARP cache implementations.
yes, this is a big problem. But also in some complex multi-vlan switches grat arps are not sufficient.
Quoted 5 lines
1. if remote hosts asks for lladdr of VRIP tc should modify our ARP reply: the SMAC in the eth header (using negative offset) and the SMAC in the ARP header. This is analog to:
ip arp add to VRIP llsrc VMAC
I really like the brevity of the above;
equivalent for me would be (my longterm plan to move ingress to below IP has finaly found an excuse)
tc filter add <DEV x> parent x:y protocol arp prio 10 u32 flowid x:z \
match sip VRIP action edit s/smac/VMAC action edit s/SMAC/VMAC
u32 needs to be taught about ARP so it can understand different ARP header bits like sip (shouldnt be that difficult)
Quoted 6 lines
2. if our IP stack sends packet with saddr=VRIP that leads to ARP probe sent from our host then we should modify the packet in the same way as (1). This is analog to:
ip arp add table output from VRIP llsrc VMAC
Dont see the difference between 1) and 2)
Quoted 3 lines
3. Replace the src MAC with proper VMAC for all IP packets with saddr=VRIP. This can be a neighbouring code job but difficult to implement there.
tc filter add <DEV x> parent x:y protocol ip prio 10 u32 flowid x:z \
match ip src VRIP action edit s/smac/VMAC
Did i understand this correctly?
Quoted 7 lines
4. Not last: NIC should accept traffic for all VMACs (promisc when attached to switched hubs is enough?) and
eth_type_transto maintain list of MAC aliases. I'm not sure that such list/hashtable with MACs should be attached per device - may be VRRP needs to announce one MAC through different interfaces? Also think for the Bridging code which callseth_type_transtoo.
I plan to move ingress to below IP just before the bridging and tap code; experiments shows this works just fine.
So all the filters + edits going there should work fine. Thoughts?
cheers,
jamal
Hello,
Quoted 6 lines · jamal
Quoted 2 lines
May be sort of: ... alter andmask
0xFF00xormask0x0023at -4 ... i.e. syntax similar to ipchains TOS and u32 match.I wanted to use u32 as the basis; which means u32 type matching is needed. then use vi/sed type substitution s/OL/V where:
O = offset (fromskb->data, could be -ve),
IMO, using skb->nh.raw as basis is preferred. By this way
the filters can be used from different places in the net stack.
Quoted 5 lines
L = length (cant go beyond head or end),
V is a static value configured (its size cant exceed L). V can also be computed off something example the data at offset O. I am trying to keep away from situations where L is larger or smaller than sizeof V so theres no mucking with any of the skb pointers ore reallocing etc. In
Yes, changing skb len is problematic mostly for TCP. As
for L and V: I assume they are HEX digits or there will be a way to encode alphanumeric chars?
Quoted 3 lines
the next iteration things could change. Note i havent written this but will in the near future (so anyone is welcome to hack on it) I didnt understand your andmask and xormask idea...
The above example:
- goto word at offset -4
- AND the 2 bytes with FF00
- XOR the 2 bytes with 0023
AND+XOR allow any operations for bits:
1) preserving (AND 1 XOR 0)
2) inverting (AND 1 XOR 1)
3) setting (AND 0 XOR 1)
4) clearing (AND 0 XOR 0)
Quoted 7 lines
equivalent for me would be (my longterm plan to move ingress to below IP has finaly found an excuse)
tc filter add <DEV x> parent x:y protocol arp prio 10 u32 flowid x:z \
match sip VRIP action edit s/smac/VMAC action edit s/SMAC/VMACu32 needs to be taught about ARP so it can understand different ARP header bits like sip (shouldnt be that difficult)
Yes, we can teach u32 to know about ARP offsets,
ethhdr offsets...
Quoted 4 lines
Quoted 2 lines
ip arp add table output from VRIP llsrc VMAC
Dont see the difference between 1) and 2)
No difference for tc, only iparp has this difference because
it follows the routing
Quoted 8 lines
Quoted 3 lines
3. Replace the src MAC with proper VMAC for all IP packets with saddr=VRIP. This can be a neighbouring code job but difficult to implement there.
tc filter add <DEV x> parent x:y protocol ip prio 10 u32 flowid x:z \
match ip src VRIP action edit s/smac/VMACDid i understand this correctly?
Yes
Quoted 6 lines
Quoted 2 lines
MAC through different interfaces? Also think for the Bridging code which calls
eth_type_transtoo.I plan to move ingress to below IP just before the bridging and tap code; experiments shows this works just fine.
So all the filters + edits going there should work fine. Thoughts?
I assume just after skb->nh.raw = skb->data;
Also, before or after deliver to ptype_all?
I see one problem: egress is called after all csum calcs,
bad for IP (if tc is going to damage the payload), good for ethhdr, ARP.
Quoted 2 lines
cheers,
jamal
Regards
--
Julian Anastasov <[email protected]>
Quoted 3 lines · Jeff Garzik
No! procfs additions are discouraged. sysfs in 2.5.x if you _must_ do this, but SIOCDEVPRIVATE or just flat out maintaining a kernel patch against a stable kernel tree would be much preferred, I think.
Still, SIOCDEVPRIVATE should _not_, in my opinion, be used for anything but hacks.
For example, we should stop using it for configuring ethernet bridges:
net/bridge/br_device.c: if (cmd != SIOCDEVPRIVATE)
Signature · 2 lines
Krzysztof Halasa Network Administrator
Julian,
Quoted 8 lines · Julian Anastasov
Hello,
Quoted 3 lines · jamal
Quoted 2 lines
May be sort of: ... alter andmask
0xFF00xormask0x0023at -4 ... i.e. syntax similar to ipchains TOS and u32 match.
Quoted 6 lines
Quoted 3 lines
I wanted to use u32 as the basis; which means u32 type matching is needed. then use vi/sed type substitution s/OL/V where:
O = offset (fromskb->data, could be -ve),IMO, using skb->nh.raw as basis is preferred. By this waythe filters can be used from different places in the net stack.
Makes sense, let me think about it more and maybe experiment. "different places in the stack"? I was thinking only ingress or egress.
Quoted 11 lines
Quoted 6 lines
L = length (cant go beyond head or end),
V is a static value configured (its size cant exceed L). V can also be computed off something example the data at offset O. I am trying to keep away from situations where L is larger or smaller than sizeof V so theres no mucking with any of the skb pointers ore reallocing etc. InYes, changing skb len is problematic mostly for TCP. As
for L and V: I assume they are HEX digits or there will be a way to encode alphanumeric chars?
We leave that to user space. User space can translate from strings for example into hex. But yes, hex should be the default as is now.
Quoted 10 lines
Quoted 3 lines
the next iteration things could change. Note i havent written this but will in the near future (so anyone is welcome to hack on it) I didnt understand your andmask and xormask idea...
The above example:
- goto word at offset -4
- AND the 2 bytes with FF00
- XOR the 2 bytes with 0023
Quoted 7 lines
AND+XOR allow any operations for bits:
1) preserving (AND 1 XOR 0)
2) inverting (AND 1 XOR 1)
3) setting (AND 0 XOR 1)
4) clearing (AND 0 XOR 0)
Ok, makes sense and oughta be used.
Quoted 5 lines
Quoted 2 lines
u32 needs to be taught about ARP so it can understand different ARP header bits like sip (shouldnt be that difficult)
Yes, we can teach u32 to know about ARP offsets,
ethhdr offsets...
ethheaders are i think generic enough to be done first.
Quoted 7 lines
Quoted 4 lines
I plan to move ingress to below IP just before the bridging and tap code; experiments shows this works just fine.
So all the filters + edits going there should work fine. Thoughts?I assume just after skb->nh.raw = skb->data;Also, before or after deliver to
ptype_all?
yes before ptype_all i.e the first thing. But it could be a programmability thing where you at least allow ptype_all to see things.
Quoted 4 lines
I see one problem: egress is called after all csum calcs,
bad for IP (if tc is going to damage the payload), good for ethhdr, ARP.
well unless you pass options to recalculate csums or make csum an action by itself. I am thinking of "auxillary" actions which could be done by all actions - this could be one of them; logging is another; "change classid" is another.
Lets take this discussion offline, i think we have exceeded the topic that started it all and people are hitting "D"s.
cheers,
jamal