From: Jesper B. Christensen <[email protected]>

Avoid having to re-solicit hw. addresses when configuring a ip-address
the same subnet as the old ip-address. This will enable one to implement
fast ip-failover.


Signed-off-by: Jesper B. Christensen <[email protected]>
---
Changes v2:
 * Move code to selective deletion path
 * Split up assignment
 * missing rtdev_dereference
---

diff --git a/stack/ipv4/af_inet.c b/stack/ipv4/af_inet.c
index 8b394be..4464608 100644
--- a/stack/ipv4/af_inet.c
+++ b/stack/ipv4/af_inet.c
@@ -239,7 +239,21 @@ static void rt_ip_ifup(struct rtnet_device *rtdev,
     int                 i;
 
 
-    rt_ip_route_del_all(rtdev); /* cleanup routing table */
+   /* Only delete our own address if the new address is
+      on the same subnet */
+   if (rtdev->broadcast_ip == up_cmd->args.up.broadcast_ip) {
+        rt_ip_route_del_host(rtdev->local_ip, rtdev);
+
+        /* Delete our loopback route for the device */
+        tmp = rtdev_get_loopback();
+        if (tmp != NULL) {
+            rt_ip_route_del_host(rtdev->local_ip, tmp);
+            rtdev_dereference(tmp);
+        }
+   } else {
+        rt_ip_route_del_all(rtdev); /* cleanup routing table */
+   }
+
 
     if (up_cmd->args.up.ip_addr != 0xFFFFFFFF) {
         rtdev->local_ip     = up_cmd->args.up.ip_addr;

-- 
/Jesper



------------------------------------------------------------------------------
Cloud Computing - Latest Buzzword or a Glimpse of the Future?
This paper surveys cloud computing today: What are the benefits? 
Why are businesses embracing it? What are its payoffs and pitfalls?
http://www.accelacomm.com/jaw/sdnl/114/51425149/
_______________________________________________
RTnet-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rtnet-developers

Reply via email to