On 2011-12-14 15:32, Jesper Christensen wrote: > From: Jesper B. Christensen <[email protected]> > > Avoid having to re-solicit hw. addresses when configuring a ip-address
'in' or 'for' > 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) { Sorry, missed some important things on first run: if up_cmd->args.up.ip_addr == 0 || rtdev->flags & IFF_LOOPBACK, all routes need to be removed as before. Also, better say "Delete only the loopback routes..." and move the comment into the corresponding block. That makes it clearer that the alternative is deleting all routes. > + rt_ip_route_del_host(rtdev->local_ip, rtdev); This should not be executed if local_ip was 0. > + > + /* 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); > + } Don't understand this anymore: Why do we need to remove the loopback route like this? The above should do the trick, doesn't it? > + } 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; > Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux ------------------------------------------------------------------------------ 10 Tips for Better Server Consolidation Server virtualization is being driven by many needs. But none more important than the need to reduce IT complexity while improving strategic productivity. Learn More! http://www.accelacomm.com/jaw/sdnl/114/51507609/ _______________________________________________ RTnet-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rtnet-developers

