From b51146856e660bcec723f535c17dc1c38b2f6efc Mon Sep 17 00:00:00 2001 From: Vyacheslav Trushkin Date: Fri, 25 Nov 2011 18:51:48 +0400 Subject: quagga: option "-z" ("--socket ") added All daemons modified to support custom path to zserv socket. lib: generalize a zclient connection zclient_socket_connect added. zclient_socket and zclient_socket_un were hidden under static expression. "zclient_serv_path_set" modified. --- lib/zclient.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 9 deletions(-) (limited to 'lib/zclient.c') diff --git a/lib/zclient.c b/lib/zclient.c index 52a3627d..3d5be918 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -41,6 +41,8 @@ static void zclient_event (enum event, struct zclient *); extern struct thread_master *master; +char *zclient_serv_path = NULL; + /* This file local debug flag. */ int zclient_debug = 0; @@ -143,8 +145,10 @@ zclient_reset (struct zclient *zclient) zclient_init (zclient, zclient->redist_default); } +#ifdef HAVE_TCP_ZEBRA + /* Make socket to zebra daemon. Return zebra socket. */ -int +static int zclient_socket(void) { int sock; @@ -175,10 +179,12 @@ zclient_socket(void) return sock; } +#endif /* HAVE_TCP_ZEBRA */ + /* For sockaddr_un. */ #include -int +static int zclient_socket_un (const char *path) { int ret; @@ -208,6 +214,24 @@ zclient_socket_un (const char *path) return sock; } +/** + * Connect to zebra daemon. + * @param zclient a pointer to zclient structure + * @return socket fd just to make sure that connection established + * @see zclient_init + * @see zclient_new + */ +int +zclient_socket_connect (struct zclient *zclient) +{ +#ifdef HAVE_TCP_ZEBRA + zclient->sock = zclient_socket (); +#else + zclient->sock = zclient_socket_un (zclient_serv_path ? zclient_serv_path : ZEBRA_SERV_PATH); +#endif + return zclient->sock; +} + static int zclient_failed(struct zclient *zclient) { @@ -313,13 +337,7 @@ zclient_start (struct zclient *zclient) if (zclient->t_connect) return 0; - /* Make socket. */ -#ifdef HAVE_TCP_ZEBRA - zclient->sock = zclient_socket (); -#else - zclient->sock = zclient_socket_un (ZEBRA_SERV_PATH); -#endif /* HAVE_TCP_ZEBRA */ - if (zclient->sock < 0) + if (zclient_socket_connect(zclient) < 0) { if (zclient_debug) zlog_debug ("zclient connection fail"); @@ -1018,3 +1036,29 @@ zclient_event (enum event event, struct zclient *zclient) break; } } + +void +zclient_serv_path_set (char *path) +{ + struct stat sb; + + /* reset */ + zclient_serv_path = NULL; + + /* test if `path' is socket. don't set it otherwise. */ + if (stat(path, &sb) == -1) + { + zlog_warn ("%s: zebra socket `%s' does not exist", __func__, path); + return; + } + + if ((sb.st_mode & S_IFMT) != S_IFSOCK) + { + zlog_warn ("%s: `%s' is not unix socket, sir", __func__, path); + return; + } + + /* it seems that path is unix socket */ + zclient_serv_path = path; +} + -- cgit v1.2.1 From 3414d03545205eda9fb47890e01b780485a613c6 Mon Sep 17 00:00:00 2001 From: Vyacheslav Trushkin Date: Wed, 30 Nov 2011 21:03:44 +0400 Subject: lib: clearing zclient.c for some cases of building lib/zclient.c: using of HAVE_TCP_ZEBRA in zclient_socket_* definitions extended by else clause. --- lib/zclient.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/zclient.c') diff --git a/lib/zclient.c b/lib/zclient.c index 3d5be918..a5d5b7ff 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -179,7 +179,7 @@ zclient_socket(void) return sock; } -#endif /* HAVE_TCP_ZEBRA */ +#else /* For sockaddr_un. */ #include @@ -214,6 +214,8 @@ zclient_socket_un (const char *path) return sock; } +#endif /* HAVE_TCP_ZEBRA */ + /** * Connect to zebra daemon. * @param zclient a pointer to zclient structure -- cgit v1.2.1 From 9206f9ecd5526778bf449bbb12f056d681d3b040 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Sun, 18 Dec 2011 19:43:40 +0400 Subject: fix set never used warnings (This patch was modified to leave calls to stream_getl() in place, they are necessary for the stream's internal pointer to advance to the correct position. -- Denis) Signed-off-by: Denis Ovsienko Fix gcc warnings about varables that are set but never used. * bgpd/bgp_attr.c * cluster_unintern(): ret * transit_unintern(): ret * bgp_attr_default_intern(): attre * bgp_mp_reach_parse(): rd_high, rd_low * bgpd/bgp_route.c * bgp_announce_check_rsclient(): bgp * bgpd/bgp_zebra.c * zebra_read_ipv4(): ifindex * zebra_read_ipv6(): ifindex * bgpd/bgpd.c * bgp_config_write_peer(): filter * lib/distribute.c * distribute_list_all(): dist * distribute_list(): dist * distribute_list_prefix_all(): dist * distribute_list_prefix(): dist * lib/if_rmap.c * if_rmap(): if_rmap * lib/vty.c * vty_accept(): vty * lib/zclient.c * zclient_read(): ret * zebra/irdp_interface.c * if_group(): zi * zebra/rt_netlink.c * kernel_read(): ret, sock --- lib/zclient.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'lib/zclient.c') diff --git a/lib/zclient.c b/lib/zclient.c index a5d5b7ff..5815eaa8 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -816,7 +816,6 @@ zebra_interface_address_read (int type, struct stream *s) static int zclient_read (struct thread *thread) { - int ret; size_t already; uint16_t length, command; uint8_t marker, version; @@ -911,47 +910,47 @@ zclient_read (struct thread *thread) { case ZEBRA_ROUTER_ID_UPDATE: if (zclient->router_id_update) - ret = (*zclient->router_id_update) (command, zclient, length); + (*zclient->router_id_update) (command, zclient, length); break; case ZEBRA_INTERFACE_ADD: if (zclient->interface_add) - ret = (*zclient->interface_add) (command, zclient, length); + (*zclient->interface_add) (command, zclient, length); break; case ZEBRA_INTERFACE_DELETE: if (zclient->interface_delete) - ret = (*zclient->interface_delete) (command, zclient, length); + (*zclient->interface_delete) (command, zclient, length); break; case ZEBRA_INTERFACE_ADDRESS_ADD: if (zclient->interface_address_add) - ret = (*zclient->interface_address_add) (command, zclient, length); + (*zclient->interface_address_add) (command, zclient, length); break; case ZEBRA_INTERFACE_ADDRESS_DELETE: if (zclient->interface_address_delete) - ret = (*zclient->interface_address_delete) (command, zclient, length); + (*zclient->interface_address_delete) (command, zclient, length); break; case ZEBRA_INTERFACE_UP: if (zclient->interface_up) - ret = (*zclient->interface_up) (command, zclient, length); + (*zclient->interface_up) (command, zclient, length); break; case ZEBRA_INTERFACE_DOWN: if (zclient->interface_down) - ret = (*zclient->interface_down) (command, zclient, length); + (*zclient->interface_down) (command, zclient, length); break; case ZEBRA_IPV4_ROUTE_ADD: if (zclient->ipv4_route_add) - ret = (*zclient->ipv4_route_add) (command, zclient, length); + (*zclient->ipv4_route_add) (command, zclient, length); break; case ZEBRA_IPV4_ROUTE_DELETE: if (zclient->ipv4_route_delete) - ret = (*zclient->ipv4_route_delete) (command, zclient, length); + (*zclient->ipv4_route_delete) (command, zclient, length); break; case ZEBRA_IPV6_ROUTE_ADD: if (zclient->ipv6_route_add) - ret = (*zclient->ipv6_route_add) (command, zclient, length); + (*zclient->ipv6_route_add) (command, zclient, length); break; case ZEBRA_IPV6_ROUTE_DELETE: if (zclient->ipv6_route_delete) - ret = (*zclient->ipv6_route_delete) (command, zclient, length); + (*zclient->ipv6_route_delete) (command, zclient, length); break; default: break; -- cgit v1.2.1 From 2ea1ab1c30c765cd4703794fcfaf044454fb533c Mon Sep 17 00:00:00 2001 From: Vyacheslav Trushkin Date: Sun, 11 Dec 2011 18:48:47 +0400 Subject: zebra: ZEBRA_HELLO and mopping up routes (BZ#448) ZEBRA_HELLO message is used by routing daemons to inform zebra what type of routes daemon will be announcing to zebra. Also zebra uses route_type_oaths array to track which daemon announces which protocol. Zebra mops up routes if daemon didn't for some reason. --- lib/zclient.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/zclient.c') diff --git a/lib/zclient.c b/lib/zclient.c index 5815eaa8..12d113e7 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -318,6 +318,25 @@ zebra_message_send (struct zclient *zclient, int command) return zclient_send_message(zclient); } +static int +zebra_hello_send (struct zclient *zclient) +{ + struct stream *s; + + if (zclient->redist_default) + { + s = zclient->obuf; + stream_reset (s); + + zclient_create_header (s, ZEBRA_HELLO); + stream_putc (s, zclient->redist_default); + stream_putw_at (s, 0, stream_get_endp (s)); + return zclient_send_message(zclient); + } + + return 0; +} + /* Make connection to zebra daemon. */ int zclient_start (struct zclient *zclient) @@ -359,6 +378,8 @@ zclient_start (struct zclient *zclient) /* Create read thread. */ zclient_event (ZCLIENT_READ, zclient); + zebra_hello_send (zclient); + /* We need router-id information. */ zebra_message_send (zclient, ZEBRA_ROUTER_ID_ADD); -- cgit v1.2.1 From 5a616c08ce089e25dc0e8da920727af4d11279bf Mon Sep 17 00:00:00 2001 From: "G.Balaji" Date: Sat, 26 Nov 2011 21:58:42 +0400 Subject: bgpd: IPv4 MP-BGP Routes addition and deletion This patch contains the following: 1. Addition of IPv4 SAFI_MULTICAST BGP routes into the BGP Multicast RIB. 2. Deletion of IPv4 SAFI_MULTICAST BGP routes from the BGP Multicast RIB. --- lib/zclient.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/zclient.c') diff --git a/lib/zclient.c b/lib/zclient.c index 12d113e7..0c3461e7 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -476,6 +476,7 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p, stream_putc (s, api->type); stream_putc (s, api->flags); stream_putc (s, api->message); + stream_putw (s, api->safi); /* Put prefix information. */ psize = PSIZE (p->prefixlen); -- cgit v1.2.1 From c7ec179a95c1ed4fcd3d3be3f981c8c20dce534a Mon Sep 17 00:00:00 2001 From: "G.Balaji" Date: Sat, 26 Nov 2011 22:04:05 +0400 Subject: bgpd: IPv6 MP-BGP Routes addition and deletion This patch contains the following: 1. Addition of IPv6 SAFI_MULTICAST BGP routes into the BGP Multicast RIB. 2. Deletion of IPv6 SAFI_MULTICAST BGP routes from the BGP Multicast RIB. --- lib/zclient.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/zclient.c') diff --git a/lib/zclient.c b/lib/zclient.c index 0c3461e7..3521d99e 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -538,6 +538,7 @@ zapi_ipv6_route (u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p, stream_putc (s, api->type); stream_putc (s, api->flags); stream_putc (s, api->message); + stream_putw (s, api->safi); /* Put prefix information. */ psize = PSIZE (p->prefixlen); -- cgit v1.2.1