summaryrefslogtreecommitdiffstats
path: root/zebra/rt_socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/rt_socket.c')
-rw-r--r--zebra/rt_socket.c74
1 files changed, 26 insertions, 48 deletions
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index a7ef4571..4d0a7db5 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -216,34 +216,6 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib, int family)
return 0; /*XXX*/
}
-int
-kernel_add_ipv4 (struct prefix *p, struct rib *rib)
-{
- int route;
-
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- route = kernel_rtm_ipv4 (RTM_ADD, p, rib, AF_INET);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
- return route;
-}
-
-int
-kernel_delete_ipv4 (struct prefix *p, struct rib *rib)
-{
- int route;
-
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- route = kernel_rtm_ipv4 (RTM_DELETE, p, rib, AF_INET);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
- return route;
-}
-
#ifdef HAVE_IPV6
#ifdef SIN6_LEN
@@ -273,8 +245,7 @@ sin6_masklen (struct in6_addr mask)
/* Interface between zebra message and rtm message. */
static int
-kernel_rtm_ipv6_multipath (int cmd, struct prefix *p, struct rib *rib,
- int family)
+kernel_rtm_ipv6 (int cmd, struct prefix *p, struct rib *rib, int family)
{
struct sockaddr_in6 *mask;
struct sockaddr_in6 sin_dest, sin_mask, sin_gate;
@@ -369,7 +340,7 @@ kernel_rtm_ipv6_multipath (int cmd, struct prefix *p, struct rib *rib,
#if 0
if (error)
{
- zlog_info ("kernel_rtm_ipv6_multipath(): nexthop %d add error=%d.",
+ zlog_info ("kernel_rtm_ipv6(): nexthop %d add error=%d.",
nexthop_num, error);
}
#else
@@ -383,38 +354,45 @@ kernel_rtm_ipv6_multipath (int cmd, struct prefix *p, struct rib *rib,
if (nexthop_num == 0)
{
if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug ("kernel_rtm_ipv6_multipath(): No useful nexthop.");
+ zlog_debug ("kernel_rtm_ipv6(): No useful nexthop.");
return 0;
}
return 0; /*XXX*/
}
+#endif
+
int
-kernel_add_ipv6 (struct prefix *p, struct rib *rib)
+kernel_route_rib (struct prefix *p, struct rib *old, struct rib *new)
{
- int route;
-
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- route = kernel_rtm_ipv6_multipath (RTM_ADD, p, rib, AF_INET6);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
+ struct rib *rib;
+ int route = 0, cmd;
- return route;
-}
+ if (!old && new)
+ cmd = RTM_ADD;
+ else if (old && !new)
+ cmd = RTM_DELETE;
+ else
+ cmd = RTM_CHANGE;
-int
-kernel_delete_ipv6 (struct prefix *p, struct rib *rib)
-{
- int route;
+ rib = new ? new : old;
if (zserv_privs.change(ZPRIVS_RAISE))
zlog (NULL, LOG_ERR, "Can't raise privileges");
- route = kernel_rtm_ipv6_multipath (RTM_DELETE, p, rib, AF_INET6);
+
+ switch (PREFIX_FAMILY(p))
+ {
+ case AF_INET:
+ route = kernel_rtm_ipv4 (cmd, p, rib, AF_INET);
+ break;
+ case AF_INET6:
+ route = kernel_rtm_ipv6 (cmd, p, rib, AF_INET6);
+ break;
+ }
+
if (zserv_privs.change(ZPRIVS_LOWER))
zlog (NULL, LOG_ERR, "Can't lower privileges");
return route;
}
-#endif /* HAVE_IPV6 */