summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/log.c2
-rw-r--r--zebra/interface.c20
-rw-r--r--zebra/interface.h17
-rw-r--r--zebra/kernel_null.c1
-rw-r--r--zebra/main.c6
-rw-r--r--zebra/rib.h17
-rw-r--r--zebra/rt.h1
-rw-r--r--zebra/rt_ioctl.c7
-rw-r--r--zebra/rt_netlink.c6
-rw-r--r--zebra/rt_socket.c7
-rw-r--r--zebra/rtadv.c4
-rw-r--r--zebra/rtadv.h4
-rw-r--r--zebra/zebra_rib.c123
13 files changed, 98 insertions, 117 deletions
diff --git a/lib/log.c b/lib/log.c
index 3fd62d59cf..13fbc00317 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -1021,7 +1021,7 @@ zlog_hexdump (void *mem, unsigned int len) {
if (j >= len) /* end of block, not really printing */
s += sprintf(s, " ");
- else if(isprint(((char*)mem)[j])) /* printable char */
+ else if(isprint((int)((char*)mem)[j])) /* printable char */
s += sprintf(s, "%c", 0xFF & ((char*)mem)[j]);
else /* other char */
diff --git a/zebra/interface.c b/zebra/interface.c
index a2d1c95b56..cdd825461c 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -48,11 +48,11 @@
#define ZEBRA_PTM_SUPPORT
-#ifdef RTADV
+#if defined (HAVE_RTADV)
/* Order is intentional. Matches RFC4191. This array is also used for
command matching, so only modify with care. */
const char *rtadv_pref_strs[] = { "medium", "high", "INVALID", "low", 0 };
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
/* Called when new interface is added. */
static int
@@ -66,7 +66,7 @@ if_zebra_new_hook (struct interface *ifp)
zebra_if->shutdown = IF_ZEBRA_SHUTDOWN_OFF;
ifp->ptm_enable = zebra_ptm_get_enable_state();
-#ifdef RTADV
+#if defined (HAVE_RTADV)
{
/* Set default router advertise values. */
struct rtadvconf *rtadv;
@@ -92,7 +92,7 @@ if_zebra_new_hook (struct interface *ifp)
rtadv->AdvPrefixList = list_new ();
}
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
/* Initialize installed address chains tree. */
zebra_if->ipv4_subnets = route_table_init ();
@@ -752,7 +752,7 @@ nbr_connected_dump_vty (struct vty *vty, struct nbr_connected *connected)
vty_out (vty, "%s", VTY_NEWLINE);
}
-#ifdef RTADV
+#if defined (HAVE_RTADV)
/* Dump interface ND information to vty. */
static void
nd_dump_vty (struct vty *vty, struct interface *ifp)
@@ -813,7 +813,7 @@ nd_dump_vty (struct vty *vty, struct interface *ifp)
VTY_NEWLINE);
}
}
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
/* Interface's information print out to vty interface. */
static void
@@ -923,9 +923,9 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
connected_dump_vty (vty, connected);
}
-#ifdef RTADV
+#if defined (HAVE_RTADV)
nd_dump_vty (vty, ifp);
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
if (listhead(ifp->nbr_connected))
vty_out (vty, " Neighbor address(s):%s", VTY_NEWLINE);
for (ALL_LIST_ELEMENTS_RO (ifp->nbr_connected, node, nbr_connected))
@@ -1911,9 +1911,9 @@ if_config_write (struct vty *vty)
VTY_NEWLINE);
}
-#ifdef RTADV
+#if defined (HAVE_RTADV)
rtadv_config_write (vty, ifp);
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
#ifdef HAVE_IRDP
irdp_config_write (vty, ifp);
diff --git a/zebra/interface.h b/zebra/interface.h
index ba76d3e845..650b62a458 100644
--- a/zebra/interface.h
+++ b/zebra/interface.h
@@ -37,16 +37,7 @@
#define IF_ZEBRA_SHUTDOWN_OFF 0
#define IF_ZEBRA_SHUTDOWN_ON 1
-/* Router advertisement feature. */
-#ifndef RTADV
-#if (defined(LINUX_IPV6) && (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1)) || defined(KAME)
- #ifdef HAVE_RTADV
- #define RTADV
- #endif
-#endif
-#endif
-
-#ifdef RTADV
+#if defined (HAVE_RTADV)
/* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
struct rtadvconf
{
@@ -180,7 +171,7 @@ struct rtadvconf
#define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
};
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
/* `zebra' daemon local interface structure. */
struct zebra_if
@@ -197,9 +188,9 @@ struct zebra_if
/* Installed addresses chains tree. */
struct route_table *ipv4_subnets;
-#ifdef RTADV
+#if defined(HAVE_RTADV)
struct rtadvconf rtadv;
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
#ifdef HAVE_IRDP
struct irdp_interface irdp;
diff --git a/zebra/kernel_null.c b/zebra/kernel_null.c
index 08fef9b309..64d854a069 100644
--- a/zebra/kernel_null.c
+++ b/zebra/kernel_null.c
@@ -19,6 +19,7 @@ int kernel_delete_ipv4 (struct prefix *a, struct rib *b) { return 0; }
#endif
int kernel_add_ipv6 (struct prefix *a, struct rib *b) { return 0; }
+int kernel_update_ipv6 (struct prefix *a, struct rib *b) { return 0; }
#ifdef HAVE_SYS_WEAK_ALIAS_PRAGMA
#pragma weak kernel_delete_ipv6 = kernel_add_ipv6
#else
diff --git a/zebra/main.c b/zebra/main.c
index 4b2a89856e..8048eba71e 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -238,7 +238,7 @@ zebra_vrf_enable (vrf_id_t vrf_id, void **info)
assert (zvrf);
-#ifdef RTADV
+#if defined (HAVE_RTADV)
rtadv_init (zvrf);
#endif
kernel_init (zvrf);
@@ -269,7 +269,7 @@ zebra_vrf_disable (vrf_id_t vrf_id, void **info)
if_down (ifp);
}
-#ifdef RTADV
+#if defined (HAVE_RTADV)
rtadv_terminate (zvrf);
#endif
kernel_terminate (zvrf);
@@ -417,7 +417,7 @@ main (int argc, char **argv)
zebra_vty_init ();
access_list_init ();
prefix_list_init ();
-#ifdef RTADV
+#if defined (HAVE_RTADV)
rtadv_cmd_init ();
#endif
#ifdef HAVE_IRDP
diff --git a/zebra/rib.h b/zebra/rib.h
index 3656646c9b..1f045310a5 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -259,16 +259,7 @@ struct static_route
: ((tnexthop) = (nexthop)->next)) \
: (((recursing) = 0),((tnexthop) = (tnexthop)->next)))
-/* Router advertisement feature. */
-#ifndef RTADV
-#if (defined(LINUX_IPV6) && (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1)) || defined(KAME)
- #ifdef HAVE_RTADV
- #define RTADV
- #endif
-#endif
-#endif
-
-#if defined (RTADV)
+#if defined (HAVE_RTADV)
/* Structure which hold status of router advertisement. */
struct rtadv
{
@@ -280,7 +271,7 @@ struct rtadv
struct thread *ra_read;
struct thread *ra_timer;
};
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
#ifdef HAVE_NETLINK
/* Socket interface to kernel */
@@ -338,9 +329,9 @@ struct zebra_vrf
struct list *rid_lo_sorted_list;
struct prefix rid_user_assigned;
-#if defined (RTADV)
+#if defined (HAVE_RTADV)
struct rtadv rtadv;
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
};
/*
diff --git a/zebra/rt.h b/zebra/rt.h
index 6d98f57ca3..8e31bb6c56 100644
--- a/zebra/rt.h
+++ b/zebra/rt.h
@@ -36,6 +36,7 @@ extern int kernel_address_delete_ipv4 (struct interface *, struct connected *);
#ifdef HAVE_IPV6
extern int kernel_add_ipv6 (struct prefix *, struct rib *);
+extern int kernel_update_ipv6 (struct prefix *, struct rib *);
extern int kernel_delete_ipv6 (struct prefix *, struct rib *);
extern int kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate,
unsigned int index, int flags, int table);
diff --git a/zebra/rt_ioctl.c b/zebra/rt_ioctl.c
index 34e2a60feb..5a386e97c9 100644
--- a/zebra/rt_ioctl.c
+++ b/zebra/rt_ioctl.c
@@ -520,6 +520,13 @@ kernel_add_ipv6 (struct prefix *p, struct rib *rib)
}
int
+kernel_update_ipv6 (struct prefix *p, struct rib *rib)
+{
+ kernel_ioctl_ipv6_multipath (SIOCDELRT, p, rib, AF_INET6);
+ return kernel_ioctl_ipv6_multipath(SIOCADDRT, p, rib, AF_INET6);
+}
+
+int
kernel_delete_ipv6 (struct prefix *p, struct rib *rib)
{
return kernel_ioctl_ipv6_multipath (SIOCDELRT, p, rib, AF_INET6);
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index a4da7f079d..183dc6e057 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -2113,6 +2113,12 @@ kernel_add_ipv6 (struct prefix *p, struct rib *rib)
}
int
+kernel_update_ipv6 (struct prefix *p, struct rib *rib)
+{
+ return netlink_route_multipath (RTM_NEWROUTE, p, rib, AF_INET6, 1);
+}
+
+int
kernel_delete_ipv6 (struct prefix *p, struct rib *rib)
{
{
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index c366775105..9af2d61dbb 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -474,6 +474,13 @@ kernel_add_ipv6 (struct prefix *p, struct rib *rib)
}
int
+kernel_update_ipv6 (struct prefix *p, struct rib *rib)
+{
+ kernel_delete_ipv6 (p, rib);
+ return kernel_add_ipv6 (p, rib);
+}
+
+int
kernel_delete_ipv6 (struct prefix *p, struct rib *rib)
{
int route;
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index d48f804f77..29a29c4044 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -41,7 +41,7 @@
extern struct zebra_privs_t zserv_privs;
-#if defined (HAVE_IPV6) && defined (RTADV)
+#if defined (HAVE_IPV6) && defined (HAVE_RTADV)
#ifdef OPEN_BSD
#include <netinet/icmp6.h>
@@ -1863,4 +1863,4 @@ rtadv_cmd_init (void)
{
/* Empty.*/;
}
-#endif /* RTADV && HAVE_IPV6 */
+#endif /* HAVE_RTADV && HAVE_IPV6 */
diff --git a/zebra/rtadv.h b/zebra/rtadv.h
index 76f98cf2c8..160814b209 100644
--- a/zebra/rtadv.h
+++ b/zebra/rtadv.h
@@ -27,7 +27,7 @@
#include "zebra/interface.h"
/* NB: RTADV is defined in zebra/interface.h above */
-#ifdef RTADV
+#if defined (HAVE_RTADV)
/* Router advertisement prefix. */
struct rtadv_prefix
@@ -98,7 +98,7 @@ struct nd_opt_homeagent_info { /* Home Agent info */
extern const char *rtadv_pref_strs[];
-#endif /* RTADV */
+#endif /* HAVE_RTADV */
extern void rtadv_init (struct zebra_vrf *);
extern void rtadv_terminate (struct zebra_vrf *);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 0fa9a79c31..300c2143cb 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1292,7 +1292,10 @@ rib_install_kernel (struct route_node *rn, struct rib *rib, int update)
ret = kernel_add_ipv4 (&rn->p, rib);
break;
case AF_INET6:
- ret = kernel_add_ipv6 (&rn->p, rib);
+ if (update)
+ ret = kernel_update_ipv6 (&rn->p, rib);
+ else
+ ret = kernel_add_ipv6 (&rn->p, rib);
break;
}
@@ -1427,7 +1430,6 @@ rib_process (struct route_node *rn)
struct nexthop *nexthop = NULL, *tnexthop;
int recursing;
char buf[INET6_ADDRSTRLEN];
- int update_ok = 0;
assert (rn);
@@ -1560,30 +1562,21 @@ rib_process (struct route_node *rn)
{
zfpm_trigger_update (rn, "updating existing route");
- if (! RIB_SYSTEM_ROUTE (select))
- {
- /* For v4, use the replace semantics of netlink. */
- if (PREFIX_FAMILY (&rn->p) == AF_INET)
- update_ok = 1;
- else
- rib_uninstall_kernel (rn, select);
- }
-
-
/* Set real nexthop. */
/* Need to check if any NHs are active to clear the
* the selected flag
*/
if (nexthop_active_update (rn, select, 1))
{
- /* Clear FIB flag for IPv4, install will set it */
- if (update_ok)
+ if (! RIB_SYSTEM_ROUTE (select))
{
+ /* Clear FIB flag if performing a replace, will get set again
+ * as part of install.
+ */
for (nexthop = select->nexthop; nexthop; nexthop = nexthop->next)
UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
+ rib_install_kernel (rn, select, 1);
}
- if (! RIB_SYSTEM_ROUTE (select))
- rib_install_kernel (rn, select, update_ok);
/* assuming that the receiver knows how to dedup */
redistribute_update (&rn->p, select, NULL);
@@ -1593,8 +1586,8 @@ rib_process (struct route_node *rn)
/* Withdraw unreachable redistribute route */
redistribute_delete(&rn->p, select);
- /* For IPv4, do the uninstall here. */
- if (update_ok)
+ /* Do the uninstall here, if not done earlier. */
+ if (! RIB_SYSTEM_ROUTE (select))
rib_uninstall_kernel (rn, select);
UNSET_FLAG (select->flags, ZEBRA_FLAG_SELECTED);
}
@@ -1633,25 +1626,16 @@ rib_process (struct route_node *rn)
zfpm_trigger_update (rn, "removing existing route");
- /* If there's no route to replace this with, withdraw redistribute */
+ /* If there's no route to replace this with, withdraw redistribute and
+ * uninstall from kernel.
+ */
if (!select)
- redistribute_delete(&rn->p, fib);
-
- if (! RIB_SYSTEM_ROUTE (fib))
{
- /* For v4, use the replace semantics of netlink -- only if there is
- * another route to replace this with.
- */
- if (PREFIX_FAMILY (&rn->p) == AF_INET)
- {
- if (!select)
- rib_uninstall_kernel (rn, fib);
- else
- update_ok = 1;
- }
- else
- rib_uninstall_kernel (rn, fib);
+ redistribute_delete(&rn->p, fib);
+ if (! RIB_SYSTEM_ROUTE (fib))
+ rib_uninstall_kernel (rn, fib);
}
+
UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);
/* Set real nexthop. */
@@ -1674,15 +1658,25 @@ rib_process (struct route_node *rn)
/* Set real nexthop. */
if (nexthop_active_update (rn, select, 1))
{
- /* Clear FIB flag for IPv4 for previous installed route. */
- if (update_ok)
+ if (! RIB_SYSTEM_ROUTE (select))
+ {
+ /* Clear FIB flag if performing a replace, will get set again
+ * as part of install.
+ */
+ if (fib)
+ {
+ for (nexthop = fib->nexthop; nexthop; nexthop = nexthop->next)
+ UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
+ }
+ rib_install_kernel (rn, select, fib? 1 : 0);
+ }
+ else
{
- assert (fib);
- for (nexthop = fib->nexthop; nexthop; nexthop = nexthop->next)
- UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
+ /* Uninstall prior route here, if needed. */
+ if (fib && !RIB_SYSTEM_ROUTE (fib))
+ rib_uninstall_kernel (rn, fib);
}
- if (! RIB_SYSTEM_ROUTE (select))
- rib_install_kernel (rn, select, update_ok);
+
SET_FLAG (select->flags, ZEBRA_FLAG_SELECTED);
/* Unconditionally announce, this part is exercised by new routes */
/* If we cannot add, for example route added is learnt by the */
@@ -1692,12 +1686,9 @@ rib_process (struct route_node *rn)
}
else
{
- /* For IPv4, uninstall prior route here, if any. */
- if (update_ok)
- {
- assert (fib);
- rib_uninstall_kernel (rn, fib);
- }
+ /* Uninstall prior route here, if needed. */
+ if (fib && !RIB_SYSTEM_ROUTE (fib))
+ rib_uninstall_kernel (rn, fib);
/* if "select", the earlier redist delete wouldn't have happened */
if (fib)
redistribute_delete(&rn->p, fib);
@@ -2864,31 +2855,17 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, struct static_
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
{
- if (afi == AFI_IP)
- {
- /* If there are other active nexthops, do an update. */
- if (rib->nexthop_active_num > 1)
- {
- rib_install_kernel (rn, rib, 1);
- redistribute_update (&rn->p, rib, NULL);
- }
- else
- {
- redistribute_delete (&rn->p, rib);
- rib_uninstall_kernel (rn, rib);
- }
- }
- else
- {
- redistribute_delete (&rn->p, rib);
- rib_uninstall_kernel (rn, rib);
- /* Are there other active nexthops? */
- if (rib->nexthop_active_num > 1)
- {
- rib_install_kernel (rn, rib, 0);
- redistribute_update (&rn->p, rib, NULL);
- }
- }
+ /* If there are other active nexthops, do an update. */
+ if (rib->nexthop_active_num > 1)
+ {
+ rib_install_kernel (rn, rib, 1);
+ redistribute_update (&rn->p, rib, NULL);
+ }
+ else
+ {
+ redistribute_delete (&rn->p, rib);
+ rib_uninstall_kernel (rn, rib);
+ }
}
if (afi == AFI_IP)
@@ -3885,7 +3862,7 @@ rib_tables_iter_next (rib_tables_iter_t *iter)
{
case RIB_TABLES_ITER_S_INIT:
- iter->vrf_id = 0;
+ iter->vrf_id = VRF_DEFAULT;
iter->afi_safi_ix = -1;
/* Fall through */