+2005-09-12 Paul Jakma <paul.jakma@sun.com>
+
+ * (general) RTM_CHANGE and implicit withdraw on RTM_NEWADDR
+ support.
+ * connected.c: (connected_withdraw) new function. withdraw a
+ connected subnet address set from zebra, and pass information
+ along to clients.
+ (connected_announce) similar, but to announce a new connected
+ subnet address set.
+ (connected_check_ipv4) renamed to connected_check, as its
+ AFI independent.
+ (connected_add_ipv{4,6}) Remove the connected address announce
+ stuff, use connected_announce instead.
+ If connected_check indicates address is already present,
+ treat it as an implicit withdraw of the existing address, ie
+ remove the old address details and replace with the new
+ details.
+ (connected_delete_ipv{4,6}) Use connected_withdraw.
+ (connected_check_ipv6) deleted in favour of connected_check.
+ * connected.h: Rename connected_check_ipv4 to connected_check.
+ delete connected_check_ipv6.
+ * interface.c: Use connected_check rather than the AFI specific
+ symbols.
+ * kernel_socket.c: (rtm_read) RTM_CHANGE support. Create a
+ rib delete event for the existing route, before adding route
+ again.
+ (kernel_read) we can handle RTM_CHANGE now.
+
2005-08-27 Hasso Tepper <hasso at quagga.net>
* zebra_rib.c, rib.h: Add distance and metric arguments to the
#include "zebra/interface.h"
#include "zebra/connected.h"
\f
+/* withdraw a connected address */
+static void
+connected_withdraw (struct connected *ifc)
+{
+ if (! ifc)
+ return;
+
+ /* Update interface address information to protocol daemon. */
+ if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
+ {
+ zebra_interface_address_delete_update (ifc->ifp, ifc);
+
+ if_subnet_delete (ifc->ifp, ifc);
+
+ if (ifc->address->family == AF_INET)
+ connected_down_ipv4 (ifc->ifp, ifc);
+ else
+ connected_down_ipv6 (ifc->ifp, ifc);
+
+ UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL);
+ }
+
+ listnode_delete (ifc->ifp->connected, ifc);
+ connected_free (ifc);
+}
+
+static void
+connected_announce (struct interface *ifp, struct connected *ifc)
+{
+ if (!ifc)
+ return;
+
+ listnode_add (ifp->connected, ifc);
+
+ /* Update interface address information to protocol daemon. */
+ if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
+ {
+ if (ifc->address->family == AF_INET)
+ if_subnet_add (ifp, ifc);
+
+ SET_FLAG (ifc->conf, ZEBRA_IFC_REAL);
+
+ zebra_interface_address_add_update (ifp, ifc);
+
+ if (if_is_up(ifp))
+ {
+ if (ifc->address->family == AF_INET)
+ connected_up_ipv4 (ifp, ifc);
+ else
+ connected_up_ipv6 (ifp, ifc);
+ }
+ }
+}
+\f
/* If same interface address is already exist... */
struct connected *
-connected_check_ipv4 (struct interface *ifp, struct prefix *p)
+connected_check (struct interface *ifp, struct prefix *p)
{
struct connected *ifc;
struct listnode *node;
p->prefix = *addr;
p->prefixlen = prefixlen;
ifc->address = (struct prefix *) p;
-
+
/* If there is broadcast or pointopoint address. */
if (broad)
{
ifc->label = strdup (label);
/* Check same connected route. */
- current = connected_check_ipv4 (ifp, (struct prefix *) ifc->address);
- if (current)
- {
- connected_free (ifc);
- ifc = current;
- }
- else
- {
- listnode_add (ifp->connected, ifc);
- }
-
- /* Update interface address information to protocol daemon. */
- if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- {
- if_subnet_add (ifp, ifc);
-
- SET_FLAG (ifc->conf, ZEBRA_IFC_REAL);
-
- zebra_interface_address_add_update (ifp, ifc);
-
- if (if_is_up(ifp))
- connected_up_ipv4 (ifp, ifc);
- }
+ if ((current = connected_check (ifp, (struct prefix *) ifc->address)))
+ connected_withdraw (current); /* implicit withdraw - freebsd does this */
+
+ connected_announce (ifp, ifc);
}
void
p.prefix = *addr;
p.prefixlen = prefixlen;
- ifc = connected_check_ipv4 (ifp, (struct prefix *) &p);
+ ifc = connected_check (ifp, (struct prefix *) &p);
if (! ifc)
return;
-
- /* Update interface address information to protocol daemon. */
- if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- {
- zebra_interface_address_delete_update (ifp, ifc);
-
- if_subnet_delete (ifp, ifc);
-
- connected_down_ipv4 (ifp, ifc);
-
- UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL);
- }
-
- listnode_delete (ifp->connected, ifc);
- connected_free (ifc);
+
+ connected_withdraw (ifc);
}
#ifdef HAVE_IPV6
-/* If same interface address is already exist... */
-struct connected *
-connected_check_ipv6 (struct interface *ifp, struct prefix *p)
-{
- struct connected *ifc;
- struct listnode *node;
-
- for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
- if (prefix_same (ifc->address, p))
- return ifc;
-
- return 0;
-}
-
void
connected_up_ipv6 (struct interface *ifp, struct connected *ifc)
{
ifc->destination = (struct prefix *) p;
}
- current = connected_check_ipv6 (ifp, (struct prefix *) ifc->address);
- if (current)
- {
- connected_free (ifc);
- ifc = current;
- }
- else
- {
- listnode_add (ifp->connected, ifc);
- }
-
- /* Update interface address information to protocol daemon. */
- if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- {
- SET_FLAG (ifc->conf, ZEBRA_IFC_REAL);
-
- zebra_interface_address_add_update (ifp, ifc);
-
- if (if_is_up(ifp))
- connected_up_ipv6 (ifp, ifc);
- }
+ if ((current = connected_check (ifp, (struct prefix *) ifc->address)))
+ connected_withdraw (current); /* implicit update of existing address */
+
+ connected_announce (ifp, ifc);
}
void
memcpy (&p.prefix, address, sizeof (struct in6_addr));
p.prefixlen = prefixlen;
- ifc = connected_check_ipv6 (ifp, (struct prefix *) &p);
+ ifc = connected_check (ifp, (struct prefix *) &p);
if (! ifc)
return;
- /* Update interface address information to protocol daemon. */
- if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- {
- zebra_interface_address_delete_update (ifp, ifc);
-
- connected_down_ipv6 (ifp, ifc);
-
- UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL);
- }
-
- listnode_delete (ifp->connected, ifc);
- connected_free (ifc);
+ connected_withdraw (ifc);
}
#endif /* HAVE_IPV6 */
p.prefixlen = IPV4_MAX_PREFIXLEN;
else
p.prefixlen = ip_masklen (mask.sin.sin_addr);
-
- if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD)
+
+ /* Change, delete the old prefix, we have no further information
+ * to specify the route really
+ */
+ if (rtm->rtm_type == RTM_CHANGE)
+ rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p,
+ NULL, 0, 0);
+
+ if (rtm->rtm_type == RTM_GET
+ || rtm->rtm_type == RTM_ADD
+ || rtm->rtm_type == RTM_CHANGE)
rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags,
&p, &gate.sin.sin_addr, 0, 0, 0, 0);
else
}
#endif /* KAME */
- if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD)
+ /* CHANGE: delete the old prefix, we have no further information
+ * to specify the route really
+ */
+ if (rtm->rtm_type == RTM_CHANGE)
+ rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p,
+ NULL, 0, 0);
+
+ if (rtm->rtm_type == RTM_GET
+ || rtm->rtm_type == RTM_ADD
+ || rtm->rtm_type == RTM_CHANGE)
rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, zebra_flags,
&p, &gate.sin6.sin6_addr, ifindex, 0, 0, 0);
else
{
case RTM_ADD:
case RTM_DELETE:
+ case RTM_CHANGE:
rtm_read (rtm);
break;
case RTM_IFINFO: