Re: [PATCH net-2.6][NEIGH] Updating affected neighbours when about MAC address change
Hello, First, it indeed can be handled by user space. (even though it should be done twice, once for ifconig of net-tools and once for ip of iproute2) / However, we have already methods which deal with bringing down an interface - neigh_ifdown(), and changing MAC address of an interface (neigh_changeaddr). So why not do it from the kernel ? DS On Dec 23, 2007 4:02 PM, Herbert Xu [EMAIL PROTECTED] wrote: David Shwatrz [EMAIL PROTECTED] wrote: Hi, Oop, I am TWICE sorry ! I wrongly attached a wrong, empty file. Attached here is the patch. Regarding your answer; I accept it and I will soon send a revised version of this patch (making changes to arp_netdev_event() and ndisc_netdev_event().) I had IPv4 in mind, there is no reason that it will no be also in IPv6. Hmm, why can't you do this from user-space? Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmVHI~} [EMAIL PROTECTED] Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-2.6][NEIGH] Updating affected neighbours about MAC address change
Hello, We know that changes in MAC addresses are not frequent but we are working on a special, highly advanced networking Linux based project in our LABs, where we do change MAC addresses of an interface quite frequently. (We do not go totally wild; the MAC addresses we are changing into are from a set of given MAC addresses). Normally, when we change a MAC address of some interface, the relevant neighbours in the LAN which have entries with the previous MAC address are not sent any update notification; instead, it is there regular timers mechanisms which update the MAC address to the new one in their ARP tables. I had written a small patch to neigh_changeaddr() in net/core/neighbour.c against the 2.6 git net tree, which sends a gratuitous ARP to update the list of all the involved neighbours with the change of MAC address. The patch is for neigh_changeaddr() only. This patch was tested and it does work in my LAB; if such a patch is not needed, I wonder why ? It seems to me that it could not cause any troubles. BTW, I had noticed that in irlan driver, there is such a mechanism of sending a gratuitous ARP to update all the neighbours when a MAC address is changed. Signed-off-by: David Shwatrz [EMAIL PROTECTED] -- To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-2.6][NEIGH] Updating affected neighbours when about MAC address change
Hello, Attached here is the patch - please read the following text here below: We know that changes in MAC addresses are not frequent but we are working on a special, highly advanced networking Linux based project in our LABs, where we do change MAC addresses of an interface quite frequently. (We do not go totally wild; the MAC addresses we are changing into are from a set of given MAC addresses). Normally, when we change a MAC address of some interface, the relevant neighbours in the LAN which have entries with the previous MAC address are not sent any update notification; instead, it is there regular timers mechanisms which update the MAC address to the new one in their ARP tables. I had written a small patch to neigh_changeaddr() in net/core/neighbour.c against the 2.6 git net tree, which sends a gratuitous ARP to update the list of all the involved neighbours with the change of MAC address. The patch is for neigh_changeaddr() only. This patch was tested and it does work in my LAB; if such a patch is not needed, I wonder why ? It seems to me that it could not cause any troubles. BTW, I had noticed that in irlan driver, there is such a mechanism of sending a gratuitous ARP to update all the neighbours when a MAC address is changed. Signed-off-by: David Shwatrz [EMAIL PROTECTED] -- To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-2.6][NEIGH] Updating affected neighbours when about MAC address change
Hi, Oop, I am TWICE sorry ! I wrongly attached a wrong, empty file. Attached here is the patch. Regarding your answer; I accept it and I will soon send a revised version of this patch (making changes to arp_netdev_event() and ndisc_netdev_event().) I had IPv4 in mind, there is no reason that it will no be also in IPv6. Regads, David Shwatrz On Dec 23, 2007 2:11 PM, YOSHIFUJI Hideaki / 吉藤英明 [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED] (at Sun, 23 Dec 2007 13:41:36 +0200), David Shwatrz [EMAIL PROTECTED] says: I had written a small patch to neigh_changeaddr() in net/core/neighbour.c against the 2.6 git net tree, which sends a gratuitous ARP to update the list of all the involved neighbours with the change of MAC address. The patch is for neigh_changeaddr() only. Though I can see no patch, but I disagree. ;-) I do think you should change arp_netdev_event() and ndisc_netdev_event(). --yoshfuji diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 29b8ee4..ddeae82 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -36,6 +36,9 @@ #include linux/string.h #include linux/log2.h +#include linux/inetdevice.h +#include net/arp.h + #define NEIGH_DEBUG 1 #define NEIGH_PRINTK(x...) printk(x) @@ -228,9 +231,26 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev) void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev) { + struct in_device *in_dev; write_lock_bh(tbl-lock); neigh_flush_dev(tbl, dev); write_unlock_bh(tbl-lock); + + /* Send a gratuitous ARP to the neighbours to update their arp tables */ + + rcu_read_lock(); + in_dev = __in_dev_get_rcu(dev); + if (in_dev == NULL) + goto out; + if (in_dev-ifa_list) + + arp_send(ARPOP_REQUEST, ETH_P_ARP, +in_dev-ifa_list-ifa_address, +dev, +in_dev-ifa_list-ifa_address, +NULL, dev-dev_addr, NULL); +out: + rcu_read_unlock(); } int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
Re: [PATCH net-2.6][NEIGH] Updating affected neighbours when about MAC address change
Hello, You should iterate all of ifa_list (for IPv4) / addr_list (for IPv6). For IPv6, we also have anycast (maintained by ac_list) as well. I am not sure that we need to iterate all of ifa_list in IPv4. The reason is that we end with arp_send, and it initiates a broadcast. So all neighbours will receive it and update their arp tables accordingly. The dest hw in the arp_send is NULL according to this patch ; this means that we will assign dev-broadcast to dest_hw in apr_create(). It seems to me there's no reason to send more than one broadcast. In IPv6, I need to check, since it is multicast. Thoughts ? Regards, DS On Dec 23, 2007 2:38 PM, YOSHIFUJI Hideaki / 吉藤英明 [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED] (at Sun, 23 Dec 2007 14:24:00 +0200), David Shwatrz [EMAIL PROTECTED] says: Regarding your answer; I accept it and I will soon send a revised version of this patch (making changes to arp_netdev_event() and ndisc_netdev_event().) I had IPv4 in mind, there is no reason that it will no be also in IPv6. You should iterate all of ifa_list (for IPv4) / addr_list (for IPv6). For IPv6, we also have anycast (maintained by ac_list) as well. --yoshfuji -- To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-2.6][NEIGH] Updating affected neighbours when about MAC address change
Yoshfuji, Thanks, you are right ! soon I will send the patches. Thanks ! DS On Dec 23, 2007 3:13 PM, YOSHIFUJI Hideaki / 吉藤英明 [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED] (at Sun, 23 Dec 2007 15:04:37 +0200), David Shwatrz [EMAIL PROTECTED] says: Hello, You should iterate all of ifa_list (for IPv4) / addr_list (for IPv6). For IPv6, we also have anycast (maintained by ac_list) as well. I am not sure that we need to iterate all of ifa_list in IPv4. The reason is that we end with arp_send, and it initiates a broadcast. So all neighbours will receive it and update their arp tables accordingly. The dest hw in the arp_send is NULL according to this patch ; this means that we will assign dev-broadcast to dest_hw in apr_create(). It seems to me there's no reason to send more than one broadcast. Urgh? what is happend if you have multiple IPv4 addresses on the device? In IPv6, I need to check, since it is multicast. Please read RFC2461 Section 7.2.6. In short we should send a few unsolicited NA, but I think you can start from sending once per an address. --yoshfuji -- To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-2.6] [NEIGH] [resend] Updating affected neighbours when about MAC address change in arp_netdev_event()
Hello, This is a resend of the patch according to Yoshifuji comment. I will send a patch for IPv6 later. We know that changes in MAC addresses are not frequent but we are working on a special, highly advanced networking Linux based project in our LABs, where we do change MAC addresses of an interface quite frequently. (We do not go totally wild; the MAC addresses we are changing into are from a set of given MAC addresses). Normally, when we change a MAC address of some interface, the relevant neighbours in the LAN which have entries with the previous MAC address are not sent any update notification; instead, it is there regular timers mechanisms which update the MAC address to the new one in their ARP tables. I had written a small patch to neigh_changeaddr() in net/ipv4/arp.c against the 2.6 git net tree, which sends a gratuitous ARP to update the list of all the involved neighbours with the change of MAC address. The patch is for arp_netdev_event() only. This patch was tested and it does work in my LAB; if such a patch is not needed, I wonder why ? It seems to me that it could not cause any troubles. BTW, I had noticed that in irlan driver, there is such a mechanism of sending a gratuitous ARP to update all the neighbours when a MAC address is changed. Signed-off-by: David Shwartz [EMAIL PROTECTED] diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 08174a2..7b1162b 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1185,6 +1185,8 @@ out: static int arp_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) { + struct in_device *in_dev; + struct in_ifaddr *ifa; struct net_device *dev = ptr; if (dev-nd_net != init_net) @@ -1194,6 +1196,22 @@ static int arp_netdev_event(struct notifier_block *this, unsigned long event, vo case NETDEV_CHANGEADDR: neigh_changeaddr(arp_tbl, dev); rt_cache_flush(0); + + /* Send gratuitous ARP to the neighbours to update their arp tables */ + + rcu_read_lock(); + in_dev = __in_dev_get_rcu(dev); + if (in_dev == NULL) + goto out; + for (ifa = in_dev-ifa_list; ifa; ifa = ifa-ifa_next) + arp_send(ARPOP_REQUEST, ETH_P_ARP, + ifa-ifa_address, + dev, + ifa-ifa_address, + NULL, dev-dev_addr, NULL); +out: + rcu_read_unlock(); + break; default: break;
A short question about net git tree and patches
Hello, I have a short question regarding the net git tree and patches: I want to write and send patches against the most recent and bleeding edge kernel networking code. I see in: http://kernel.org/pub/scm/linux/kernel/git/davem/?C=M;O=A that there are 3 git trees which can be candidates for git-clone and making patches against; these are: netdev-2.6.git, net-2.6.25.git and net-2.6.git. It seems to me that net-2.6.git is the most suitable one to work against; am I right ? what is the difference, in short, between the three repositories? Regards, DS -- To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html