From 770835713182ee2a7797e2147bb7f12813280b5a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 2 Jun 2019 15:21:01 -0400 Subject: [PATCH 1/7] lib: Move some log.c functions declarations to log.h We have some functions that are owned by log.c, so move their declarations from zebra.h to log.h Signed-off-by: Donald Sharp --- lib/log.h | 19 +++++++++++++++++++ lib/zebra.h | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/log.h b/lib/log.h index 9368bf9e82..608b8f3362 100644 --- a/lib/log.h +++ b/lib/log.h @@ -158,6 +158,25 @@ extern void zlog_hexdump(const void *mem, unsigned int len); extern const char *zlog_sanitize(char *buf, size_t bufsz, const void *in, size_t inlen); +/* Note: whenever a new route-type or zserv-command is added the + * corresponding {command,route}_types[] table in lib/log.c MUST be + * updated! */ + +/* Map a route type to a string. For example, ZEBRA_ROUTE_RIPNG -> "ripng". */ +extern const char *zebra_route_string(unsigned int route_type); +/* Map a route type to a char. For example, ZEBRA_ROUTE_RIPNG -> 'R'. */ +extern char zebra_route_char(unsigned int route_type); +/* Map a zserv command type to the same string, + * e.g. ZEBRA_INTERFACE_ADD -> "ZEBRA_INTERFACE_ADD" */ +/* Map a protocol name to its number. e.g. ZEBRA_ROUTE_BGP->9*/ +extern int proto_name2num(const char *s); +/* Map redistribute X argument to protocol number. + * unlike proto_name2num, this accepts shorthands and takes + * an AFI value to restrict input */ +extern int proto_redistnum(int afi, const char *s); + +extern const char *zserv_command_string(unsigned int command); + extern int vzlog_test(int priority); diff --git a/lib/zebra.h b/lib/zebra.h index 3e1eefdb2e..c19c5e0aae 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -358,25 +358,6 @@ struct in_pktinfo { /* Zebra route's types are defined in route_types.h */ #include "route_types.h" -/* Note: whenever a new route-type or zserv-command is added the - * corresponding {command,route}_types[] table in lib/log.c MUST be - * updated! */ - -/* Map a route type to a string. For example, ZEBRA_ROUTE_RIPNG -> "ripng". */ -extern const char *zebra_route_string(unsigned int route_type); -/* Map a route type to a char. For example, ZEBRA_ROUTE_RIPNG -> 'R'. */ -extern char zebra_route_char(unsigned int route_type); -/* Map a zserv command type to the same string, - * e.g. ZEBRA_INTERFACE_ADD -> "ZEBRA_INTERFACE_ADD" */ -/* Map a protocol name to its number. e.g. ZEBRA_ROUTE_BGP->9*/ -extern int proto_name2num(const char *s); -/* Map redistribute X argument to protocol number. - * unlike proto_name2num, this accepts shorthands and takes - * an AFI value to restrict input */ -extern int proto_redistnum(int afi, const char *s); - -extern const char *zserv_command_string(unsigned int command); - #define strmatch(a,b) (!strcmp((a), (b))) /* Zebra message flags */ From da01a37a1bdf54cc30e3bf64bc99f090a0241d02 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 2 Jun 2019 15:24:19 -0400 Subject: [PATCH 2/7] lib: Move zclient flags to zclient.h zebra.h had some defined flags that were being used as part of the route encode/decode functionality. These belong in the zclient.h code. Signed-off-by: Donald Sharp --- lib/zclient.h | 35 +++++++++++++++++++++++++++++++++++ lib/zebra.h | 38 -------------------------------------- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/lib/zclient.h b/lib/zclient.h index c61c8d4226..5f529dcb69 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -322,6 +322,41 @@ struct zapi_route { unsigned short instance; uint32_t flags; +/* + * Cause Zebra to consider this routes nexthops recursively + */ +#define ZEBRA_FLAG_ALLOW_RECURSION 0x01 +/* + * This is a route that is read in on startup that was left around + * from a previous run of FRR + */ +#define ZEBRA_FLAG_SELFROUTE 0x02 +/* + * This flag is used to tell Zebra that the BGP route being passed + * down is a IBGP route + */ +#define ZEBRA_FLAG_IBGP 0x04 +/* + * This is a route that has been selected for FIB installation. + * This flag is set in zebra and can be passed up to routing daemons + */ +#define ZEBRA_FLAG_SELECTED 0x08 +/* + * This is a route that we are telling Zebra that this route *must* + * win and will be installed even over ZEBRA_FLAG_SELECTED + */ +#define ZEBRA_FLAG_FIB_OVERRIDE 0x10 +/* + * This flag tells Zebra that the route is a EVPN route and should + * be treated specially + */ +#define ZEBRA_FLAG_EVPN_ROUTE 0x20 +/* + * This flag tells Zebra that it should treat the distance passed + * down as an additional discriminator for route selection of the + * route entry. This mainly is used for backup static routes. + */ +#define ZEBRA_FLAG_RR_USE_DISTANCE 0x40 uint8_t message; diff --git a/lib/zebra.h b/lib/zebra.h index c19c5e0aae..35d0cfbf5a 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -360,44 +360,6 @@ struct in_pktinfo { #define strmatch(a,b) (!strcmp((a), (b))) -/* Zebra message flags */ - -/* - * Cause Zebra to consider this routes nexthops recursively - */ -#define ZEBRA_FLAG_ALLOW_RECURSION 0x01 -/* - * This is a route that is read in on startup that was left around - * from a previous run of FRR - */ -#define ZEBRA_FLAG_SELFROUTE 0x02 -/* - * This flag is used to tell Zebra that the BGP route being passed - * down is a IBGP route - */ -#define ZEBRA_FLAG_IBGP 0x04 -/* - * This is a route that has been selected for FIB installation. - * This flag is set in zebra and can be passed up to routing daemons - */ -#define ZEBRA_FLAG_SELECTED 0x08 -/* - * This is a route that we are telling Zebra that this route *must* - * win and will be installed even over ZEBRA_FLAG_SELECTED - */ -#define ZEBRA_FLAG_FIB_OVERRIDE 0x10 -/* - * This flag tells Zebra that the route is a EVPN route and should - * be treated specially - */ -#define ZEBRA_FLAG_EVPN_ROUTE 0x20 -/* - * This flag tells Zebra that it should treat the distance passed - * down as an additional discriminator for route selection of the - * route entry. This mainly is used for backup static routes. - */ -#define ZEBRA_FLAG_RR_USE_DISTANCE 0x40 - #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */ #endif From 8ee06b2c462bdcc43605b632b9953aac397b7cda Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 2 Jun 2019 15:29:10 -0400 Subject: [PATCH 3/7] lib: Move ZEBRA_HEADER_MARKER to header it belongs in The ZEBRA_HEADER_MARKER is part of the zapi protocol Move it to the zclient.h header. Signed-off-by: Donald Sharp --- lib/zclient.h | 6 ++++++ lib/zebra.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/zclient.h b/lib/zclient.h index 5f529dcb69..c707f498c4 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -38,6 +38,12 @@ #include "mlag.h" +/* Marker value used in new Zserv, in the byte location corresponding + * the command value in the old zserv header. To allow old and new + * Zserv headers to be distinguished from each other. + */ +#define ZEBRA_HEADER_MARKER 254 + /* For input/output buffer to zebra. */ #define ZEBRA_MAX_PACKET_SIZ 16384U diff --git a/lib/zebra.h b/lib/zebra.h index 35d0cfbf5a..6adc9904e5 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -343,12 +343,6 @@ struct in_pktinfo { /* default zebra TCP port for zclient */ #define ZEBRA_PORT 2600 -/* Marker value used in new Zserv, in the byte location corresponding - * the command value in the old zserv header. To allow old and new - * Zserv headers to be distinguished from each other. - */ -#define ZEBRA_HEADER_MARKER 254 - /* * The compiler.h header is used for anyone using the CPP_NOTICE * since this is universally needed, let's add it to zebra.h From 26ee1525e6f5857a763a023a2fbe729c0d380767 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 2 Jun 2019 15:55:09 -0400 Subject: [PATCH 4/7] lib: Remove unused INT8_MAX and UINT8_MAX values We are not using these in the system, remove. Signed-off-by: Donald Sharp --- lib/zebra.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/zebra.h b/lib/zebra.h index 6adc9904e5..fe35e8c2ad 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -202,18 +202,12 @@ typedef unsigned char uint8_t; /* Some systems do not define UINT32_MAX, etc.. from inttypes.h * e.g. this makes life easier for FBSD 4.11 users. */ -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif From 0ce5349f98b56de288a2e2b9046cc26545ead57a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 2 Jun 2019 16:00:51 -0400 Subject: [PATCH 5/7] pimd: Cleanup mtracebis.c header inclusion a tiny bit The header inclusion in mtracebis.c should include zebra.h and not config.h. There are other issues that need to be worked through as well, but we can do this in the future. Signed-off-by: Donald Sharp --- pimd/mtracebis.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pimd/mtracebis.c b/pimd/mtracebis.c index 65c495eff0..dd95762754 100644 --- a/pimd/mtracebis.c +++ b/pimd/mtracebis.c @@ -17,9 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +#include #ifdef __linux__ From 64cbb7c5b75636bf429bb23675b8e334cc8f432d Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 2 Jun 2019 16:03:23 -0400 Subject: [PATCH 6/7] lib: Remove unused zebra_command_t type The zebra_command_t type was never being used, remove from the system. Signed-off-by: Donald Sharp --- lib/zebra.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/zebra.h b/lib/zebra.h index fe35e8c2ad..303b511bad 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -434,7 +434,6 @@ typedef enum { /* Zebra types. Used in Zserv message header. */ typedef uint16_t zebra_size_t; -typedef uint16_t zebra_command_t; /* VRF ID type. */ typedef uint32_t vrf_id_t; From 03edc41d517d8fcdb5d913a0b13d81798d555f52 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 2 Jun 2019 16:05:01 -0400 Subject: [PATCH 7/7] lib: Move zebra_size_t to zclient.h who should own it The zebra_size_t type needs to be owned by zclient.h since it is part of the zapi protocol. Move it to where the structure belongs. Signed-off-by: Donald Sharp --- lib/zclient.h | 3 +++ lib/zebra.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/zclient.h b/lib/zclient.h index c707f498c4..d651738687 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -38,6 +38,9 @@ #include "mlag.h" +/* Zebra types. Used in Zserv message header. */ +typedef uint16_t zebra_size_t; + /* Marker value used in new Zserv, in the byte location corresponding * the command value in the old zserv header. To allow old and new * Zserv headers to be distinguished from each other. diff --git a/lib/zebra.h b/lib/zebra.h index 303b511bad..2f9ada09be 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -432,9 +432,6 @@ typedef enum { #define RESET_FLAG_ATOMIC(PV) \ ((atomic_store_explicit(PV, 0, memory_order_seq_cst))) -/* Zebra types. Used in Zserv message header. */ -typedef uint16_t zebra_size_t; - /* VRF ID type. */ typedef uint32_t vrf_id_t;