From b9df2d25fc8d06ca63fa792d162d97656361338b Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 9 May 2004 09:09:59 +0000 Subject: 2004-05-09 Paul Jakma * zserv.c: (zsend_route_multipath) Set the nexthop_num field correctly. Add NEXTHOP_TYPE_IPV6_IFNAME for v6. Conditionally set ZAPI_MESSAGE_METRIC flag - only for adds. (zsend_ipv4_add) cruft, deleted. (zsend_ipv4_delete) ditto. (zsend_ipv6_add) ditto. (zsend_ipv6_delete) ditto. 2004-05-09 Sowmini Varadhan * zserv.c: (zsend_ipv{4,6}_{add,delete}_multipath) collapsed into single zsend_route_multipath function. (zsend_interface_{up,down}) collapsed into zsend_interface_update. (zsend_interface_address_{add,delete}) collapsed into zsend_interface_address. (zsend_interface_add) send mtu6. (zsend_interface_delete) ditto. (zebra_write) remove unused function. (various) Apply static qualifier. Add comments. * zserv.h: Definitions changed as per above. * redistribute.c: Changes as per zserv.c. --- zebra/ChangeLog | 24 ++ zebra/redistribute.c | 32 +-- zebra/zserv.c | 696 +++++++++++++++------------------------------------ zebra/zserv.h | 65 +---- 4 files changed, 249 insertions(+), 568 deletions(-) diff --git a/zebra/ChangeLog b/zebra/ChangeLog index 981c85ce..a543da8e 100644 --- a/zebra/ChangeLog +++ b/zebra/ChangeLog @@ -1,3 +1,27 @@ +2004-05-09 Paul Jakma + + * zserv.c: (zsend_route_multipath) Set the nexthop_num + field correctly. Add NEXTHOP_TYPE_IPV6_IFNAME for v6. + Conditionally set ZAPI_MESSAGE_METRIC flag - only for adds. + (zsend_ipv4_add) cruft, deleted. + (zsend_ipv4_delete) ditto. + (zsend_ipv6_add) ditto. + (zsend_ipv6_delete) ditto. + +2004-05-09 Sowmini Varadhan + + * zserv.c: (zsend_ipv{4,6}_{add,delete}_multipath) collapsed + into single zsend_route_multipath function. + (zsend_interface_{up,down}) collapsed into zsend_interface_update. + (zsend_interface_address_{add,delete}) collapsed into + zsend_interface_address. + (zsend_interface_add) send mtu6. + (zsend_interface_delete) ditto. + (zebra_write) remove unused function. + (various) Apply static qualifier. Add comments. + * zserv.h: Definitions changed as per above. + * redistribute.c: Changes as per zserv.c. + 2004-04-06 Krzysztof Oledzki * rt_netlink.c: Do not ignore metric when reading kernel routing diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 2d30f790..ae61a448 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -107,7 +107,7 @@ zebra_redistribute_default (struct zserv *client) for (newrib = rn->info; newrib; newrib = newrib->next) if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED) && newrib->distance != DISTANCE_INFINITY) - zsend_ipv4_add_multipath (client, &rn->p, newrib); + zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, &rn->p, newrib); route_unlock_node (rn); } } @@ -127,7 +127,7 @@ zebra_redistribute_default (struct zserv *client) for (newrib = rn->info; newrib; newrib = newrib->next) if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED) && newrib->distance != DISTANCE_INFINITY) - zsend_ipv6_add_multipath (client, &rn->p, newrib); + zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, &rn->p, newrib); route_unlock_node (rn); } } @@ -150,7 +150,7 @@ zebra_redistribute (struct zserv *client, int type) && newrib->type == type && newrib->distance != DISTANCE_INFINITY && zebra_check_addr (&rn->p)) - zsend_ipv4_add_multipath (client, &rn->p, newrib); + zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, &rn->p, newrib); #ifdef HAVE_IPV6 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); @@ -161,7 +161,7 @@ zebra_redistribute (struct zserv *client, int type) && newrib->type == type && newrib->distance != DISTANCE_INFINITY && zebra_check_addr (&rn->p)) - zsend_ipv6_add_multipath (client, &rn->p, newrib); + zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, &rn->p, newrib); #endif /* HAVE_IPV6 */ } @@ -179,20 +179,20 @@ redistribute_add (struct prefix *p, struct rib *rib) if (client->redist_default || client->redist[rib->type]) { if (p->family == AF_INET) - zsend_ipv4_add_multipath (client, p, rib); + zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib); #ifdef HAVE_IPV6 if (p->family == AF_INET6) - zsend_ipv6_add_multipath (client, p, rib); + zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib); #endif /* HAVE_IPV6 */ } } else if (client->redist[rib->type]) { if (p->family == AF_INET) - zsend_ipv4_add_multipath (client, p, rib); + zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib); #ifdef HAVE_IPV6 if (p->family == AF_INET6) - zsend_ipv6_add_multipath (client, p, rib); + zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib); #endif /* HAVE_IPV6 */ } } @@ -216,20 +216,20 @@ redistribute_delete (struct prefix *p, struct rib *rib) if (client->redist_default || client->redist[rib->type]) { if (p->family == AF_INET) - zsend_ipv4_delete_multipath (client, p, rib); + zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib); #ifdef HAVE_IPV6 if (p->family == AF_INET6) - zsend_ipv6_delete_multipath (client, p, rib); + zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib); #endif /* HAVE_IPV6 */ } } else if (client->redist[rib->type]) { if (p->family == AF_INET) - zsend_ipv4_delete_multipath (client, p, rib); + zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib); #ifdef HAVE_IPV6 if (p->family == AF_INET6) - zsend_ipv6_delete_multipath (client, p, rib); + zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib); #endif /* HAVE_IPV6 */ } } @@ -313,7 +313,7 @@ zebra_interface_up_update (struct interface *ifp) for (node = listhead (zebrad.client_list); node; nextnode (node)) if ((client = getdata (node)) != NULL) - zsend_interface_up (client, ifp); + zsend_interface_update (ZEBRA_INTERFACE_UP, client, ifp); } /* Interface down information. */ @@ -328,7 +328,7 @@ zebra_interface_down_update (struct interface *ifp) for (node = listhead (zebrad.client_list); node; nextnode (node)) if ((client = getdata (node)) != NULL) - zsend_interface_down (client, ifp); + zsend_interface_update (ZEBRA_INTERFACE_DOWN, client, ifp); } /* Interface information update. */ @@ -383,7 +383,7 @@ zebra_interface_address_add_update (struct interface *ifp, for (node = listhead (zebrad.client_list); node; nextnode (node)) if ((client = getdata (node)) != NULL) if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) - zsend_interface_address_add (client, ifp, ifc); + zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client, ifp, ifc); } /* Interface address deletion. */ @@ -407,5 +407,5 @@ zebra_interface_address_delete_update (struct interface *ifp, for (node = listhead (zebrad.client_list); node; nextnode (node)) if ((client = getdata (node)) != NULL) if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) - zsend_interface_address_delete (client, ifp, ifc); + zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_DELETE, client, ifp, ifc); } diff --git a/zebra/zserv.c b/zebra/zserv.c index c623151e..3c582afb 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -45,12 +45,12 @@ enum event { ZEBRA_SERV, ZEBRA_READ, ZEBRA_WRITE }; extern struct zebra_t zebrad; -void zebra_event (enum event event, int sock, struct zserv *client); +static void zebra_event (enum event event, int sock, struct zserv *client); extern struct zebra_privs_t zserv_privs; /* For logging of zebra meesages. */ -char *zebra_command_str [] = +static char *zebra_command_str [] = { "NULL", "ZEBRA_INTERFACE_ADD", @@ -172,6 +172,16 @@ zebra_server_send_message (int sock, u_char *buf, unsigned long length) } /* Interface is added. Send ZEBRA_INTERFACE_ADD to client. */ +/* + * This function is called in the following situations: + * - in response to a 3-byte ZEBRA_INTERFACE_ADD request + * from the client. + * - at startup, when zebra figures out the available interfaces + * - when an interface is added (where support for + * RTM_IFANNOUNCE or AF_NETLINK sockets is available), or when + * an interface is marked IFF_UP (i.e., an RTM_IFINFO message is + * received) + */ int zsend_interface_add (struct zserv *client, struct interface *ifp) { @@ -197,6 +207,7 @@ zsend_interface_add (struct zserv *client, struct interface *ifp) stream_putl (s, ifp->flags); stream_putl (s, ifp->metric); stream_putl (s, ifp->mtu); + stream_putl (s, ifp->mtu6); stream_putl (s, ifp->bandwidth); #ifdef HAVE_SOCKADDR_DL stream_put (s, &ifp->sdl, sizeof (ifp->sdl)); @@ -215,6 +226,12 @@ zsend_interface_add (struct zserv *client, struct interface *ifp) } /* Interface deletion from zebra daemon. */ +/* + * This function is only called when support for + * RTM_IFANNOUNCE or AF_NETLINK sockets (RTM_DELLINK message) + * is available. It is not called on Solaris. + */ +#if (defined(RTM_IFANNOUNCE) || defined(HAVE_NETLINK)) int zsend_interface_delete (struct zserv *client, struct interface *ifp) { @@ -238,6 +255,7 @@ zsend_interface_delete (struct zserv *client, struct interface *ifp) stream_putl (s, ifp->flags); stream_putl (s, ifp->metric); stream_putl (s, ifp->mtu); + stream_putl (s, ifp->mtu6); stream_putl (s, ifp->bandwidth); /* Write packet length. */ @@ -247,12 +265,49 @@ zsend_interface_delete (struct zserv *client, struct interface *ifp) return 0; } +#endif /* (defined(RTM_IFANNOUNCE) || defined(HAVE_LINUX_RTNETLINK_H)) */ -/* Interface address is added. Send ZEBRA_INTERFACE_ADDRESS_ADD to the - client. */ +/* Interface address is added/deleted. Send ZEBRA_INTERFACE_ADDRESS_ADD or + * ZEBRA_INTERFACE_ADDRESS_DELETE to the client. + * + * A ZEBRA_INTERFACE_ADDRESS_ADD is sent in the following situations: + * - in response to a 3-byte ZEBRA_INTERFACE_ADD request + * from the client, after the ZEBRA_INTERFACE_ADD has been + * sent from zebra to the client + * - redistribute new address info to all clients in the following situations + * - at startup, when zebra figures out the available interfaces + * - when an interface is added (where support for + * RTM_IFANNOUNCE or AF_NETLINK sockets is available), or when + * an interface is marked IFF_UP (i.e., an RTM_IFINFO message is + * received) + * - for the vty commands "ip address A.B.C.D/M [|