diff options
author | Rick Balocca <rbalocca@vyatta.com> | 2008-10-16 17:39:55 -0700 |
---|---|---|
committer | Rick Balocca <rbalocca@vyatta.com> | 2008-10-16 17:39:55 -0700 |
commit | 04c7298b3684ddda4e6669f14374e2377deb04ea (patch) | |
tree | b3c11943294ffc282863dbca418d408a7869f86f | |
parent | 1581cf27e9e187a12f25221cc42123a056469adb (diff) | |
parent | fa3e86a1a7559808ba5e32374e35d387472567c8 (diff) | |
download | quagga-04c7298b3684ddda4e6669f14374e2377deb04ea.tar.bz2 quagga-04c7298b3684ddda4e6669f14374e2377deb04ea.tar.xz |
Merge branch 'islavista'
Conflicts:
debian/changelog
109 files changed, 674 insertions, 775 deletions
@@ -17,13 +17,12 @@ config.status config.sub configure debian/build-stamp +debian/quagga debian/vyatta-quagga -debian/vyatta-quagga.substvars +debian/*.substvars debian/files -debian/vyatta-quagga.postinst.debhelper -debian/vyatta-quagga.postrm.debhelper -debian/vyatta-quagga.prerm.debhelper -debian/vyatta-quagga.debhelper.log +debian/*.debhelper +debian/*.log depcomp doc/defines.texi doc/mdate-sh diff --git a/Makefile.am b/Makefile.am index a9a48ae1..96da94fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in. SUBDIRS = lib @ZEBRA@ @BGPD@ @RIPD@ @RIPNGD@ @OSPFD@ @OSPF6D@ \ - @ISISD@ @WATCHQUAGGA@ @WATCHLINK@ @VTYSH@ @OSPFCLIENT@ doc m4 @pkgsrcdir@ \ + @ISISD@ @WATCHQUAGGA@ @VTYSH@ @OSPFCLIENT@ doc m4 @pkgsrcdir@ \ redhat @SOLARIS@ DIST_SUBDIRS = lib zebra bgpd ripd ripngd ospfd ospf6d \ diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c index 870aab13..b9f4a85b 100644 --- a/bgpd/bgp_advertise.c +++ b/bgpd/bgp_advertise.c @@ -72,10 +72,10 @@ baa_hash_key (void *p) } static int -baa_hash_cmp (void *p1, void *p2) +baa_hash_cmp (const void *p1, const void *p2) { - struct bgp_advertise_attr * baa1 = (struct bgp_advertise_attr *) p1; - struct bgp_advertise_attr * baa2 = (struct bgp_advertise_attr *) p2; + const struct bgp_advertise_attr * baa1 = p1; + const struct bgp_advertise_attr * baa2 = p2; return attrhash_cmp (baa1->attr, baa2->attr); } diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index 38c9caa6..242bd8ee 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -322,11 +322,7 @@ assegment_normalise (struct assegment *head) static struct aspath * aspath_new (void) { - struct aspath *aspath; - - aspath = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath)); - memset (aspath, 0, sizeof (struct aspath)); - return aspath; + return XCALLOC (MTYPE_AS_PATH, sizeof (struct aspath)); } /* Free AS path structure. */ @@ -1347,10 +1343,10 @@ aspath_add_seq (struct aspath *aspath, as_t asno) /* Compare leftmost AS value for MED check. If as1's leftmost AS and as2's leftmost AS is same return 1. */ int -aspath_cmp_left (struct aspath *aspath1, struct aspath *aspath2) +aspath_cmp_left (const struct aspath *aspath1, const struct aspath *aspath2) { - struct assegment *seg1 = NULL; - struct assegment *seg2 = NULL; + const struct assegment *seg1 = NULL; + const struct assegment *seg2 = NULL; if (!(aspath1 && aspath2)) return 0; @@ -1484,7 +1480,7 @@ aspath_reconcile_as4 ( struct aspath *aspath, struct aspath *as4path) as2's leftmost AS is same return 1. (confederation as-path only). */ int -aspath_cmp_left_confed (struct aspath *aspath1, struct aspath *aspath2) +aspath_cmp_left_confed (const struct aspath *aspath1, const struct aspath *aspath2) { if (! (aspath1 && aspath2) ) return 0; @@ -1769,10 +1765,10 @@ aspath_key_make (void *p) /* If two aspath have same value then return 1 else return 0 */ static int -aspath_cmp (void *arg1, void *arg2) +aspath_cmp (const void *arg1, const void *arg2) { - struct assegment *seg1 = ((struct aspath *)arg1)->segments; - struct assegment *seg2 = ((struct aspath *)arg2)->segments; + const struct assegment *seg1 = ((struct aspath *)arg1)->segments; + const struct assegment *seg2 = ((struct aspath *)arg2)->segments; while (seg1 || seg2) { diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h index d8b41fa9..2b4625c8 100644 --- a/bgpd/bgp_aspath.h +++ b/bgpd/bgp_aspath.h @@ -72,8 +72,8 @@ extern struct aspath *aspath_prepend (struct aspath *, struct aspath *); extern struct aspath *aspath_filter_exclude (struct aspath *, struct aspath *); extern struct aspath *aspath_add_seq (struct aspath *, as_t); extern struct aspath *aspath_add_confed_seq (struct aspath *, as_t); -extern int aspath_cmp_left (struct aspath *, struct aspath *); -extern int aspath_cmp_left_confed (struct aspath *, struct aspath *); +extern int aspath_cmp_left (const struct aspath *, const struct aspath *); +extern int aspath_cmp_left_confed (const struct aspath *, const struct aspath *); extern struct aspath *aspath_delete_confed_seq (struct aspath *); extern struct aspath *aspath_empty (void); extern struct aspath *aspath_empty_get (void); diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index b20386e5..c52c776e 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -131,15 +131,13 @@ cluster_hash_key_make (void *p) } static int -cluster_hash_cmp (void *p1, void *p2) +cluster_hash_cmp (const void *p1, const void *p2) { - struct cluster_list * cluster1 = (struct cluster_list *) p1; - struct cluster_list * cluster2 = (struct cluster_list *) p2; + const struct cluster_list * cluster1 = p1; + const struct cluster_list * cluster2 = p2; - if (cluster1->length == cluster2->length && - memcmp (cluster1->list, cluster2->list, cluster1->length) == 0) - return 1; - return 0; + return (cluster1->length == cluster2->length && + memcmp (cluster1->list, cluster2->list, cluster1->length) == 0); } static void @@ -150,13 +148,13 @@ cluster_free (struct cluster_list *cluster) XFREE (MTYPE_CLUSTER, cluster); } +#if 0 static struct cluster_list * cluster_dup (struct cluster_list *cluster) { struct cluster_list *new; - new = XMALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list)); - memset (new, 0, sizeof (struct cluster_list)); + new = XCALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list)); new->length = cluster->length; if (cluster->length) @@ -169,6 +167,7 @@ cluster_dup (struct cluster_list *cluster) return new; } +#endif static struct cluster_list * cluster_intern (struct cluster_list *cluster) @@ -267,15 +266,13 @@ transit_hash_key_make (void *p) } static int -transit_hash_cmp (void *p1, void *p2) +transit_hash_cmp (const void *p1, const void *p2) { - struct transit * transit1 = (struct transit *) p1; - struct transit * transit2 = (struct transit *) p2; + const struct transit * transit1 = p1; + const struct transit * transit2 = p2; - if (transit1->length == transit2->length && - memcmp (transit1->val, transit2->val, transit1->length) == 0) - return 1; - return 0; + return (transit1->length == transit2->length && + memcmp (transit1->val, transit2->val, transit1->length) == 0); } static void @@ -393,10 +390,10 @@ attrhash_key_make (void *p) } int -attrhash_cmp (void *p1, void *p2) +attrhash_cmp (const void *p1, const void *p2) { - struct attr * attr1 = (struct attr *) p1; - struct attr * attr2 = (struct attr *) p2; + const struct attr * attr1 = p1; + const struct attr * attr2 = p2; if (attr1->flag == attr2->flag && attr1->origin == attr2->origin @@ -408,8 +405,8 @@ attrhash_cmp (void *p1, void *p2) && attr1->pathlimit.ttl == attr2->pathlimit.ttl && attr1->pathlimit.as == attr2->pathlimit.as) { - struct attr_extra *ae1 = attr1->extra; - struct attr_extra *ae2 = attr2->extra; + const struct attr_extra *ae1 = attr1->extra; + const struct attr_extra *ae2 = attr2->extra; if (ae1 && ae2 && ae1->aggregator_as == ae2->aggregator_as @@ -435,7 +432,7 @@ attrhash_cmp (void *p1, void *p2) } static void -attrhash_init () +attrhash_init (void) { attrhash = hash_create (attrhash_key_make, attrhash_cmp); } @@ -1573,7 +1570,7 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size, zlog (peer->log, LOG_WARNING, "%s Extended length set, but just %lu bytes of attr header", peer->host, - endp - STREAM_PNT (BGP_INPUT (peer))); + (unsigned long) (endp - STREAM_PNT (BGP_INPUT (peer)))); bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index 9647ccf8..12149a17 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -163,7 +163,7 @@ extern bgp_size_t bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix_rd *, u_char *); extern void bgp_dump_routes_attr (struct stream *, struct attr *, struct prefix *); -extern int attrhash_cmp (void *, void *); +extern int attrhash_cmp (const void *, const void *); extern unsigned int attrhash_key_make (void *); extern void attr_show_all (struct vty *); extern unsigned long int attr_count (void); diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index a6ca1a46..6bf3b64a 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -51,11 +51,7 @@ community_list_master_lookup (struct community_list_handler *ch, int master) static struct community_entry * community_entry_new () { - struct community_entry *new; - - new = XMALLOC (MTYPE_COMMUNITY_LIST_ENTRY, sizeof (struct community_entry)); - memset (new, 0, sizeof (struct community_entry)); - return new; + return XCALLOC (MTYPE_COMMUNITY_LIST_ENTRY, sizeof (struct community_entry)); } /* Free community list entry. */ @@ -92,11 +88,7 @@ community_entry_free (struct community_entry *entry) static struct community_list * community_list_new () { - struct community_list *new; - - new = XMALLOC (MTYPE_COMMUNITY_LIST, sizeof (struct community_list)); - memset (new, 0, sizeof (struct community_list)); - return new; + return XCALLOC (MTYPE_COMMUNITY_LIST, sizeof (struct community_list)); } /* Free community-list. */ diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c index 592b810d..1cafdb3e 100644 --- a/bgpd/bgp_community.c +++ b/bgpd/bgp_community.c @@ -633,5 +633,6 @@ community_hash (void) void community_init (void) { - comhash = hash_create (community_hash_make, community_cmp); + comhash = hash_create ((unsigned int (*) (void *))community_hash_make, + (int (*) (const void *, const void *))community_cmp); } diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index a0a8557d..ba25f4d1 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -517,29 +517,28 @@ bgp_damp_disable (struct bgp *bgp, afi_t afi, safi_t safi) return 0; } -int +void bgp_config_write_damp (struct vty *vty) { - if (bgp_damp_cfg.half_life == DEFAULT_HALF_LIFE*60 - && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE - && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS - && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) - vty_out (vty, " bgp dampening%s", VTY_NEWLINE); - else if (bgp_damp_cfg.half_life != DEFAULT_HALF_LIFE*60 - && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE - && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS - && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) - vty_out (vty, " bgp dampening %ld%s", - bgp_damp_cfg.half_life/60, - VTY_NEWLINE); - else - vty_out (vty, " bgp dampening %ld %d %d %ld%s", - bgp_damp_cfg.half_life/60, - bgp_damp_cfg.reuse_limit, - bgp_damp_cfg.suppress_value, - bgp_damp_cfg.max_suppress_time/60, - VTY_NEWLINE); - return 1; + if (bgp_damp_cfg.half_life == DEFAULT_HALF_LIFE*60 + && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE + && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS + && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) + vty_out (vty, " bgp dampening%s", VTY_NEWLINE); + else if (bgp_damp_cfg.half_life != DEFAULT_HALF_LIFE*60 + && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE + && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS + && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) + vty_out (vty, " bgp dampening %ld%s", + bgp_damp_cfg.half_life/60, + VTY_NEWLINE); + else + vty_out (vty, " bgp dampening %ld %d %d %ld%s", + bgp_damp_cfg.half_life/60, + bgp_damp_cfg.reuse_limit, + bgp_damp_cfg.suppress_value, + bgp_damp_cfg.max_suppress_time/60, + VTY_NEWLINE); } #define BGP_UPTIME_LEN 25 diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h index 37ed90bc..17c31cb9 100644 --- a/bgpd/bgp_damp.h +++ b/bgpd/bgp_damp.h @@ -140,7 +140,7 @@ extern void bgp_damp_info_free (struct bgp_damp_info *, int); extern void bgp_damp_info_clean (void); extern char * bgp_get_reuse_time (unsigned int, char*, size_t); extern int bgp_damp_decay (time_t, int); -extern int bgp_config_write_damp (struct vty *); +extern void bgp_config_write_damp (struct vty *); extern void bgp_damp_info_vty (struct vty *, struct bgp_info *); extern char * bgp_damp_reuse_time_vty (struct vty *, struct bgp_info *); diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 757b9cf8..b7280d93 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -856,7 +856,7 @@ bgp_config_write_debug (struct vty *vty) return write; } -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index e815ea3c..53dea805 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -773,7 +773,7 @@ DEFUN (no_dump_bgp_routes, } /* BGP node structure. */ -struct cmd_node bgp_dump_node = +static struct cmd_node bgp_dump_node = { DUMP_NODE, "", diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 9e7ae1b3..c08673ce 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -247,15 +247,13 @@ ecommunity_hash_make (void *arg) /* Compare two Extended Communities Attribute structure. */ int -ecommunity_cmp (void *arg1, void *arg2) +ecommunity_cmp (const void *arg1, const void *arg2) { const struct ecommunity *ecom1 = arg1; const struct ecommunity *ecom2 = arg2; - if (ecom1->size == ecom2->size - && memcmp (ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE) == 0) - return 1; - return 0; + return (ecom1->size == ecom2->size + && memcmp (ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE) == 0); } /* Initialize Extended Comminities related hash. */ diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h index 69014237..278721c8 100644 --- a/bgpd/bgp_ecommunity.h +++ b/bgpd/bgp_ecommunity.h @@ -72,7 +72,7 @@ extern struct ecommunity *ecommunity_parse (u_int8_t *, u_short); extern struct ecommunity *ecommunity_dup (struct ecommunity *); extern struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *); extern struct ecommunity *ecommunity_intern (struct ecommunity *); -extern int ecommunity_cmp (void *, void *); +extern int ecommunity_cmp (const void *, const void *); extern void ecommunity_unintern (struct ecommunity *); extern unsigned int ecommunity_hash_make (void *); extern struct ecommunity *ecommunity_str2com (const char *, int, int); diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index ab7f0703..e4cf91af 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -99,11 +99,7 @@ static struct as_list_master as_list_master = static struct as_filter * as_filter_new () { - struct as_filter *new; - - new = XMALLOC (MTYPE_AS_FILTER, sizeof (struct as_filter)); - memset (new, 0, sizeof (struct as_filter)); - return new; + return XCALLOC (MTYPE_AS_FILTER, sizeof (struct as_filter)); } /* Free allocated AS filter. */ @@ -179,11 +175,7 @@ as_list_lookup (const char *name) static struct as_list * as_list_new () { - struct as_list *new; - - new = XMALLOC (MTYPE_AS_LIST, sizeof (struct as_list)); - memset (new, 0, sizeof (struct as_list)); - return new; + return XCALLOC (MTYPE_AS_LIST, sizeof (struct as_list)); } static void @@ -679,7 +671,7 @@ config_write_as_list (struct vty *vty) return write; } -struct cmd_node as_list_node = +static struct cmd_node as_list_node = { AS_LIST_NODE, "", diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 71f3ec7d..87f7f7b6 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -92,12 +92,6 @@ bgp_md5_set (struct peer *peer) struct listnode *node; int fret = 0, ret; int *socket; - - if ( bgpd_privs.change (ZPRIVS_RAISE) ) - { - zlog_err ("%s: could not raise privs", __func__); - return -1; - } /* Just set the password on the listen socket(s). Outbound connections * are taken care of in bgp_connect() below. @@ -108,9 +102,6 @@ bgp_md5_set (struct peer *peer) if (ret < 0) fret = ret; } - if (bgpd_privs.change (ZPRIVS_LOWER) ) - zlog_err ("%s: could not lower privs", __func__); - return fret; } @@ -314,6 +305,11 @@ bgp_connect (struct peer *peer) sockopt_reuseaddr (peer->fd); sockopt_reuseport (peer->fd); +#ifdef IPTOS_PREC_INTERNETCONTROL + if (sockunion_family (&peer->su) == AF_INET) + setsockopt_ipv4_tos (peer->fd, IPTOS_PREC_INTERNETCONTROL); +#endif + if (peer->password) bgp_md5_set_connect (peer->fd, &peer->su, peer->password); @@ -402,6 +398,20 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address) sockopt_reuseaddr (sock); sockopt_reuseport (sock); +#ifdef IPTOS_PREC_INTERNETCONTROL + if (ainfo->ai_family == AF_INET) + setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL); +#endif + +#ifdef IPV6_V6ONLY + /* Want only IPV6 on ipv6 socket (not mapped addresses) */ + if (ainfo->ai_family == AF_INET6) { + int on = 1; + setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, + (void *) &on, sizeof (on)); + } +#endif + if (bgpd_privs.change (ZPRIVS_RAISE) ) zlog_err ("bgp_socket: could not raise privs"); @@ -454,6 +464,10 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address) sockopt_reuseaddr (sock); sockopt_reuseport (sock); +#ifdef IPTOS_PREC_INTERNETCONTROL + setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL); +#endif + memset (&sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 4dd5d946..a184dd4a 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -98,11 +98,7 @@ bnc_nexthop_free (struct bgp_nexthop_cache *bnc) static struct bgp_nexthop_cache * bnc_new () { - struct bgp_nexthop_cache *new; - - new = XMALLOC (MTYPE_BGP_NEXTHOP_CACHE, sizeof (struct bgp_nexthop_cache)); - memset (new, 0, sizeof (struct bgp_nexthop_cache)); - return new; + return XCALLOC (MTYPE_BGP_NEXTHOP_CACHE, sizeof (struct bgp_nexthop_cache)); } static void diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 4d7f32de..19375ef9 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -920,6 +920,7 @@ bgp_notify_send (struct peer *peer, u_char code, u_char sub_code) bgp_notify_send_with_data (peer, code, sub_code, NULL, 0); } +#if 0 static const char * afi2str (afi_t afi) { @@ -943,6 +944,7 @@ safi2str (safi_t safi) else return "Unknown SAFI"; } +#endif /* Send route refresh message to the peer. */ void diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index e8b3b70d..db8e36d5 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -129,12 +129,7 @@ bgp_info_extra_get (struct bgp_info *ri) static struct bgp_info * bgp_info_new () { - struct bgp_info *new; - - new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); - memset (new, 0, sizeof (struct bgp_info)); - - return new; + return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); } /* Free bgp route information. */ @@ -3088,10 +3083,7 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, static struct bgp_static * bgp_static_new () { - struct bgp_static *new; - new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); - memset (new, 0, sizeof (struct bgp_static)); - return new; + return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); } static void @@ -4476,10 +4468,7 @@ struct bgp_aggregate static struct bgp_aggregate * bgp_aggregate_new () { - struct bgp_aggregate *new; - new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); - memset (new, 0, sizeof (struct bgp_aggregate)); - return new; + return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); } static void @@ -10826,10 +10815,7 @@ struct bgp_distance static struct bgp_distance * bgp_distance_new () { - struct bgp_distance *new; - new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); - memset (new, 0, sizeof (struct bgp_distance)); - return new; + return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); } static void diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c index 50cf8e8f..15630a24 100644 --- a/bgpd/bgp_table.c +++ b/bgpd/bgp_table.c @@ -36,8 +36,7 @@ bgp_table_init (afi_t afi, safi_t safi) { struct bgp_table *rt; - rt = XMALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table)); - memset (rt, 0, sizeof (struct bgp_table)); + rt = XCALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table)); rt->type = BGP_TABLE_MAIN; rt->afi = afi; @@ -56,11 +55,7 @@ bgp_table_finish (struct bgp_table **rt) static struct bgp_node * bgp_node_create () { - struct bgp_node *rn; - - rn = (struct bgp_node *) XMALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node)); - memset (rn, 0, sizeof (struct bgp_node)); - return rn; + return XCALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node)); } /* Allocate new route node with prefix set. */ diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 54f11701..fc560d17 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -8749,42 +8749,42 @@ bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, } /* BGP node structure. */ -struct cmd_node bgp_node = +static struct cmd_node bgp_node = { BGP_NODE, "%s(config-router)# ", 1, }; -struct cmd_node bgp_ipv4_unicast_node = +static struct cmd_node bgp_ipv4_unicast_node = { BGP_IPV4_NODE, "%s(config-router-af)# ", 1, }; -struct cmd_node bgp_ipv4_multicast_node = +static struct cmd_node bgp_ipv4_multicast_node = { BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, }; -struct cmd_node bgp_ipv6_unicast_node = +static struct cmd_node bgp_ipv6_unicast_node = { BGP_IPV6_NODE, "%s(config-router-af)# ", 1, }; -struct cmd_node bgp_ipv6_multicast_node = +static struct cmd_node bgp_ipv6_multicast_node = { BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, }; -struct cmd_node bgp_vpnv4_node = +static struct cmd_node bgp_vpnv4_node = { BGP_VPNV4_NODE, "%s(config-router-af)# ", @@ -10673,7 +10673,7 @@ community_list_config_write (struct vty *vty) return write; } -struct cmd_node community_list_node = +static struct cmd_node community_list_node = { COMMUNITY_LIST_NODE, "", diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index ec1143af..943b1777 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -640,7 +640,6 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, } #if 0 -#ifdef HAVE_IPV6 static unsigned int bgp_ifindex_by_nexthop (struct in6_addr *addr) { @@ -671,7 +670,6 @@ bgp_ifindex_by_nexthop (struct in6_addr *addr) } return 0; } -#endif /* HAVE_IPV6 */ #endif void diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index cd9e6396..7f6ca168 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -114,46 +114,6 @@ bgp_option_check (int flag) return CHECK_FLAG (bm->options, flag); } -/* BGP flag manipulation. */ -int -bgp_flag_set (struct bgp *bgp, int flag) -{ - SET_FLAG (bgp->flags, flag); - return 0; -} - -int -bgp_flag_unset (struct bgp *bgp, int flag) -{ - UNSET_FLAG (bgp->flags, flag); - return 0; -} - -int -bgp_flag_check (struct bgp *bgp, int flag) -{ - return CHECK_FLAG (bgp->flags, flag); -} - -/* Internal function to set BGP structure configureation flag. */ -static void -bgp_config_set (struct bgp *bgp, int config) -{ - SET_FLAG (bgp->config, config); -} - -static void -bgp_config_unset (struct bgp *bgp, int config) -{ - UNSET_FLAG (bgp->config, config); -} - -static int -bgp_config_check (struct bgp *bgp, int config) -{ - return CHECK_FLAG (bgp->config, config); -} - /* Set BGP router identifier. */ int bgp_router_id_set (struct bgp *bgp, struct in_addr *id) diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 85341fe4..f699dc35 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -59,11 +59,6 @@ struct bgp_master #define BGP_OPT_NO_FIB (1 << 0) #define BGP_OPT_MULTIPLE_INSTANCE (1 << 1) #define BGP_OPT_CONFIG_CISCO (1 << 2) - -#ifdef HAVE_TCP_MD5SIG - /* bgp receive socket */ - int sock; -#endif /* HAVE_TCP_MD5SIG */ }; /* BGP instance structure. */ @@ -72,13 +67,6 @@ struct bgp /* AS number of this BGP instance. */ as_t as; - /* reference count, primarily to allow bgp_process'ing of route_node's - * to be done after a struct peer is deleted. - * - * named 'lock' for hysterical reasons within Quagga. - */ - int lock; - /* Name of this BGP instance. */ char *name; @@ -373,7 +361,6 @@ struct peer /* NSF mode (graceful restart) */ u_char nsf[AFI_MAX][SAFI_MAX]; -#define PEER_FLAG_PASSWORD (1 << 9) /* password */ /* Per AF configuration flags. */ u_int32_t af_flags[AFI_MAX][SAFI_MAX]; @@ -872,26 +859,43 @@ extern int bgp_get (struct bgp **, as_t *, const char *); extern void bgp_delete (struct bgp *); extern void bgp_free (struct bgp *); -static inline struct bgp * -bgp_lock (struct bgp *bgp) +/* BGP flag manipulation. */ +static inline void +bgp_flag_set (struct bgp *bgp, int flag) { - assert (bgp && (bgp->lock >= 0)); - bgp->lock++; - return bgp; + SET_FLAG (bgp->flags, flag); } static inline void -bgp_unlock (struct bgp *bgp) +bgp_flag_unset (struct bgp *bgp, int flag) { - assert (bgp && (bgp->lock > 0)); - if (--bgp->lock == 0) - bgp_free (bgp); + UNSET_FLAG (bgp->flags, flag); } +static inline int +bgp_flag_check (const struct bgp *bgp, int flag) +{ + return CHECK_FLAG (bgp->flags, flag); +} -extern int bgp_flag_set (struct bgp *, int); -extern int bgp_flag_unset (struct bgp *, int); -extern int bgp_flag_check (struct bgp *, int); +/* Internal function to set BGP structure configureation flag. */ +static inline void +bgp_config_set (struct bgp *bgp, int config) +{ + SET_FLAG (bgp->config, config); +} + +static inline void +bgp_config_unset (struct bgp *bgp, int config) +{ + UNSET_FLAG (bgp->config, config); +} + +static inline int +bgp_config_check (const struct bgp *bgp, int config) +{ + return CHECK_FLAG (bgp->config, config); +} extern int bgp_router_id_set (struct bgp *, struct in_addr *); diff --git a/configure.ac b/configure.ac index a94dac54..0224785c 100755 --- a/configure.ac +++ b/configure.ac @@ -216,8 +216,6 @@ AC_ARG_WITH(libpam, [ --with-libpam use libpam for PAM support in vtysh]) AC_ARG_ENABLE(tcp-zebra, [ --enable-tcp-zebra enable TCP/IP socket connection between zebra and protocol daemon]) -AC_ARG_ENABLE(tcp-md5, -[ --enable-tcp-md5 enable TCP/IP md5 in BGPd]) AC_ARG_ENABLE(opaque-lsa, [ --enable-opaque-lsa enable OSPF Opaque-LSA with OSPFAPI support (RFC2370)]) AC_ARG_ENABLE(ospfapi, @@ -288,10 +286,6 @@ if test "${enable_tcp_zebra}" = "yes"; then AC_DEFINE(HAVE_TCP_ZEBRA,,Use TCP for zebra communication) fi -if test "${enable_tcp_md5}" = "yes"; then - AC_DEFINE(HAVE_TCP_MD5SIG,1,Enable TCP MD5 Signatures) -fi - if test "${enable_opaque_lsa}" = "yes"; then AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA) fi @@ -1231,7 +1225,6 @@ AC_SUBST(RIPNGD) AC_SUBST(OSPFD) AC_SUBST(OSPF6D) AC_SUBST(WATCHQUAGGA) -AC_SUBST(WATCHLINK) AC_SUBST(ISISD) AC_SUBST(SOLARIS) AC_SUBST(VTYSH) diff --git a/debian/README b/debian/README index ee91c1f1..cd10e951 100644 --- a/debian/README +++ b/debian/README @@ -1,4 +1,4 @@ -The Debian Package quagga +The Debian Package vyatta-quagga ---------------------------- This package is the Vyatta build of the Quagga routing protocol @@ -19,7 +19,8 @@ To build from the source package, first add the following to deb-src http://archive1.vyatta.com/vyatta community testing Then: - apt-get source quagga + apt-get source vyatta-quagga + cd vyatta-quagga-VERSION debuild -nc -b -uc -us -- Tom Grennan <tgrennan@vyatta.com> Wed, 19 DEC 2007 diff --git a/debian/changelog b/debian/changelog index 09274092..27a97490 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,18 @@ -quagga (0.99.10-vyatta1) unstable; urgency=low +vyatta-quagga (0.99.10-1) unstable; urgency=low + + 3.1.4 + [ Mark O'Brien ] + + + [ Paul Jakma ] + * [bgpd] bug #419: partial aspath-limit incorrectly causes session + reset + + [ Mark O'Brien ] + + -- Mark O'Brien <mobrien@firebolt.vyatta.com> Tue, 14 Oct 2008 17:30:19 -0700 + +vyatta-quagga (0.99.9-13) unstable; urgency=low 3.1.3 [ Mark O'Brien ] @@ -20,8 +34,6 @@ vyatta-quagga (0.99.9-12) unstable; urgency=low * Merge in upstream version 0.99.10 * Rename package from vyatta-quagga to quagga 3.1.2 - [ Mark O'Brien ] - [ Stephen Hemminger ] * Remove routes from FIB. diff --git a/debian/control b/debian/control index 9e0b264f..12718e01 100644 --- a/debian/control +++ b/debian/control @@ -1,4 +1,4 @@ -Source: quagga +Source: vyatta-quagga Section: contrib/net Priority: extra Maintainer: Stephen Hemminger <shemminger@vyatta.com> @@ -17,12 +17,12 @@ Build-Depends: debhelper (>= 5), Standards-Version: 3.7.2 Vcs-Git: http://suva.vyatta.com/git/vyatta-quagga.git -Package: quagga +Package: vyatta-quagga Architecture: any Depends: ${shlibs:Depends}, logrotate (>= 3.2-11), iproute, ${misc:Depends} Pre-Depends: adduser -Conflicts: zebra, zebra-pj, vyatta-quagga -Replaces: zebra, zebra-pj, vyatta-quagga +Conflicts: zebra, zebra-pj, quagga +Replaces: zebra, zebra-pj, quagga Suggests: snmpd Description: BGP/OSPF/RIP routing daemon GNU Quagga is free software which manages TCP/IP based routing protocols. diff --git a/debian/lintian b/debian/lintian index 58019e16..08d952e9 100644 --- a/debian/lintian +++ b/debian/lintian @@ -1,2 +1,2 @@ -quagga: binary-without-manpage usr/sbin/vyatta-ospfclient -quagga: binary-without-manpage usr/sbin/vyatta-watchquagga +vyatta-quagga: binary-without-manpage usr/sbin/vyatta-ospfclient +vyatta-quagga: binary-without-manpage usr/sbin/vyatta-watchquagga diff --git a/debian/rules b/debian/rules index 6dd5b36f..67ee890b 100755 --- a/debian/rules +++ b/debian/rules @@ -14,17 +14,13 @@ # from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) -PACKAGE=quagga +PACKAGE=vyatta-quagga PKGDIR=$(CURDIR)/debian/$(PACKAGE) BUILD_STAMP=debian/build-stamp CFLAGS = -Wall -g WANT_SNMP=1 -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif +CFLAGS += -Os ifeq ($(WANT_SNMP),1) xable_snmp = --enable-snmp @@ -59,7 +55,6 @@ configure += --enable-vty-group=quaggavty configure += --enable-configfile-mask=0640 configure += --enable-logfile-mask=0640 configure += --enable-rtadv -configure += --enable-tcp-md5 configure += --enable-gcc-rdynamic configure += $(xable_snmp) configure += --with-libpam diff --git a/debian/quagga.dirs b/debian/vyatta-quagga.dirs index 8f5c59a8..8f5c59a8 100644 --- a/debian/quagga.dirs +++ b/debian/vyatta-quagga.dirs diff --git a/debian/quagga.files b/debian/vyatta-quagga.files index 3ed35a43..38b1ab33 100644 --- a/debian/quagga.files +++ b/debian/vyatta-quagga.files @@ -1,6 +1,6 @@ -etc/vyatta/quagga/ +etc/quagga/ opt/vyatta/ -usr/lib/quagga/ +usr/lib/vyatta-quagga/ usr/share/lintian/overrides/ usr/share/man/man1/vtysh.1 usr/share/man/man8 diff --git a/debian/quagga.init.d b/debian/vyatta-quagga.init.d index 69f5752e..fcf3e51a 100644 --- a/debian/quagga.init.d +++ b/debian/vyatta-quagga.init.d @@ -1,7 +1,7 @@ #!/bin/bash # ### BEGIN INIT INFO -# Provides: quagga +# Provides: vyatta-quagga # Required-Start: $local_fs $network $remote_fs $syslog # Required-Stop: $local_fs $network $remote_fs $syslog # Default-Start: 2 3 4 5 @@ -32,7 +32,7 @@ for dir in $pid_dir $log_dir ; do done declare -a common_args=( -d -P 0 ) -declare -a zebra_args=( ${common_args[@]} -l -s 1048576 -i $pid_dir/zebra.pid ) +declare -a zebra_args=( ${common_args[@]} -l -S -s 1048576 -i $pid_dir/zebra.pid ) declare -a ripd_args=( ${common_args[@]} -i $pid_dir/ripd.pid ) declare -a ripngd_args=( ${common_args[@]} -i $pid_dir/ripngd.pid ) declare -a ospfd_args=( ${common_args[@]} -i $pid_dir/ospfd.pid ) diff --git a/debian/quagga.logrotate b/debian/vyatta-quagga.logrotate index 020eb83e..020eb83e 100644 --- a/debian/quagga.logrotate +++ b/debian/vyatta-quagga.logrotate diff --git a/debian/quagga.manpages b/debian/vyatta-quagga.manpages index 24556b2d..24556b2d 100644 --- a/debian/quagga.manpages +++ b/debian/vyatta-quagga.manpages diff --git a/debian/quagga.postinst b/debian/vyatta-quagga.postinst index 366f8299..366f8299 100644 --- a/debian/quagga.postinst +++ b/debian/vyatta-quagga.postinst diff --git a/debian/quagga.postrm b/debian/vyatta-quagga.postrm index dac97986..dac97986 100644 --- a/debian/quagga.postrm +++ b/debian/vyatta-quagga.postrm diff --git a/debian/quagga.preinst b/debian/vyatta-quagga.preinst index 29c18b2b..29c18b2b 100644 --- a/debian/quagga.preinst +++ b/debian/vyatta-quagga.preinst diff --git a/debian/quagga.prerm b/debian/vyatta-quagga.prerm index 69792d27..69792d27 100644 --- a/debian/quagga.prerm +++ b/debian/vyatta-quagga.prerm diff --git a/debian/quagga.quagga.pam b/debian/vyatta-quagga.quagga.pam index 6dd5d474..6dd5d474 100644 --- a/debian/quagga.quagga.pam +++ b/debian/vyatta-quagga.quagga.pam diff --git a/doc/main.texi b/doc/main.texi index 9966b356..49a1db4d 100644 --- a/doc/main.texi +++ b/doc/main.texi @@ -31,6 +31,10 @@ immediately. @itemx --keep_kernel When zebra starts up, don't delete old self inserted routes. +@item -S +@itemx --rib_system +Causes zebra to manage system routes (those not created by zebra) on link events. + @item -r @itemx --retain When program terminates, retain routes added by zebra. diff --git a/doc/zebra.8 b/doc/zebra.8 index 558e27be..8b15b98c 100644 --- a/doc/zebra.8 +++ b/doc/zebra.8 @@ -60,6 +60,10 @@ restart zebra. The likely default is \fB\fI/var/run/zebra.pid\fR. \fB\-k\fR, \fB\-\-keep_kernel\fR On startup, don't delete self inserted routes. .TP +\fB\-S\fR, \fB\-\-rib_system\fR +Manage all routes, on link transistion events, including those not generated by +zebra. +.TP \fB\-l\fR, \fB\-\-log_mode\fR Turn verbose logging on. .TP diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index af24988e..d2923b57 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -2028,7 +2028,7 @@ DEFUN (no_ipv6_router_isis, } #endif /* HAVE_IPV6 */ -struct cmd_node interface_node = { +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", 1, diff --git a/isisd/isisd.c b/isisd/isisd.c index 7c669fcb..1e84a1ce 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -2076,7 +2076,7 @@ isis_config_write (struct vty *vty) return write; } -struct cmd_node isis_node = { +static struct cmd_node isis_node = { ISIS_NODE, "%s(config-router)# ", 1 diff --git a/lib/command.c b/lib/command.c index 270bf0d3..a9085eb7 100644 --- a/lib/command.c +++ b/lib/command.c @@ -41,31 +41,31 @@ vector cmdvec = NULL; struct host host; /* Standard command node structures. */ -struct cmd_node auth_node = +static struct cmd_node auth_node = { AUTH_NODE, "Password: ", }; -struct cmd_node view_node = +static struct cmd_node view_node = { VIEW_NODE, "%s> ", }; -struct cmd_node auth_enable_node = +static struct cmd_node auth_enable_node = { AUTH_ENABLE_NODE, "Password: ", }; -struct cmd_node enable_node = +static struct cmd_node enable_node = { ENABLE_NODE, "%s# ", }; -struct cmd_node config_node = +static struct cmd_node config_node = { CONFIG_NODE, "%s(config)# ", diff --git a/lib/distribute.c b/lib/distribute.c index 3d616211..242a225c 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -38,12 +38,7 @@ void (*distribute_delete_hook) (struct distribute *); static struct distribute * distribute_new (void) { - struct distribute *new; - - new = XMALLOC (MTYPE_DISTRIBUTE, sizeof (struct distribute)); - memset (new, 0, sizeof (struct distribute)); - - return new; + return XCALLOC (MTYPE_DISTRIBUTE, sizeof (struct distribute)); } /* Free distribute object. */ @@ -134,7 +129,7 @@ distribute_hash_make (struct distribute *dist) /* If two distribute-list have same value then return 1 else return 0. This function is used by hash package. */ static int -distribute_cmp (struct distribute *dist1, struct distribute *dist2) +distribute_cmp (const struct distribute *dist1, const struct distribute *dist2) { if (dist1->ifname && dist2->ifname) if (strcmp (dist1->ifname, dist2->ifname) == 0) @@ -769,7 +764,7 @@ void distribute_list_init (int node) { disthash = hash_create ((unsigned int (*) (void *)) distribute_hash_make, - (int (*) (void *, void *)) distribute_cmp); + (int (*) (const void *, const void *)) distribute_cmp); if(node==RIP_NODE) { install_element (RIP_NODE, &distribute_list_all_cmd); diff --git a/lib/filter.c b/lib/filter.c index 069919bb..1509cc31 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -1857,7 +1857,7 @@ config_write_access (struct vty *vty, afi_t afi) } /* Access-list node. */ -struct cmd_node access_node = +static struct cmd_node access_node = { ACCESS_NODE, "", /* Access list has no interface. */ @@ -1953,7 +1953,7 @@ access_list_init_ipv4 (void) } #ifdef HAVE_IPV6 -struct cmd_node access_ipv6_node = +static struct cmd_node access_ipv6_node = { ACCESS_IPV6_NODE, "", @@ -27,14 +27,13 @@ /* Allocate a new hash. */ struct hash * hash_create_size (unsigned int size, unsigned int (*hash_key) (void *), - int (*hash_cmp) (void *, void *)) + int (*hash_cmp) (const void *, const void *)) { struct hash *hash; hash = XMALLOC (MTYPE_HASH, sizeof (struct hash)); - hash->index = XMALLOC (MTYPE_HASH_INDEX, + hash->index = XCALLOC (MTYPE_HASH_INDEX, sizeof (struct hash_backet *) * size); - memset (hash->index, 0, sizeof (struct hash_backet *) * size); hash->size = size; hash->hash_key = hash_key; hash->hash_cmp = hash_cmp; @@ -46,7 +45,7 @@ hash_create_size (unsigned int size, unsigned int (*hash_key) (void *), /* Allocate a new hash with default hash size. */ struct hash * hash_create (unsigned int (*hash_key) (void *), - int (*hash_cmp) (void *, void *)) + int (*hash_cmp) (const void *, const void *)) { return hash_create_size (HASHTABSIZE, hash_key, hash_cmp); } @@ -48,16 +48,16 @@ struct hash unsigned int (*hash_key) (void *); /* Data compare function. */ - int (*hash_cmp) (void *, void *); + int (*hash_cmp) (const void *, const void *); /* Backet alloc. */ unsigned long count; }; extern struct hash *hash_create (unsigned int (*) (void *), - int (*) (void *, void *)); + int (*) (const void *, const void *)); extern struct hash *hash_create_size (unsigned int, unsigned int (*) (void *), - int (*) (void *, void *)); + int (*) (const void *, const void *)); extern void *hash_get (struct hash *, void *, void * (*) (void *)); extern void *hash_alloc_intern (void *); diff --git a/lib/if_rmap.c b/lib/if_rmap.c index e6f753c2..ddc62fd5 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -120,13 +120,12 @@ if_rmap_hash_make (void *data) } static int -if_rmap_hash_cmp (void *arg1, void* arg2) +if_rmap_hash_cmp (const void *arg1, const void* arg2) { - struct if_rmap *if_rmap1 = arg1; - struct if_rmap *if_rmap2 = arg2; - if (strcmp (if_rmap1->ifname, if_rmap2->ifname) == 0) - return 1; - return 0; + const struct if_rmap *if_rmap1 = arg1; + const struct if_rmap *if_rmap2 = arg2; + + return strcmp (if_rmap1->ifname, if_rmap2->ifname) == 0; } static struct if_rmap * diff --git a/lib/keychain.c b/lib/keychain.c index 10928b11..6719cebf 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -31,10 +31,7 @@ struct list *keychain_list; static struct keychain * keychain_new (void) { - struct keychain *new; - new = XMALLOC (MTYPE_KEYCHAIN, sizeof (struct keychain)); - memset (new, 0, sizeof (struct keychain)); - return new; + return XCALLOC (MTYPE_KEYCHAIN, sizeof (struct keychain)); } static void @@ -46,10 +43,7 @@ keychain_free (struct keychain *keychain) static struct key * key_new (void) { - struct key *new; - new = XMALLOC (MTYPE_KEY, sizeof (struct key)); - memset (new, 0, sizeof (struct key)); - return new; + return XCALLOC (MTYPE_KEY, sizeof (struct key)); } static void @@ -854,14 +848,14 @@ DEFUN (send_lifetime_duration_month_day, argv[3], argv[4]); } -struct cmd_node keychain_node = +static struct cmd_node keychain_node = { KEYCHAIN_NODE, "%s(config-keychain)# ", 1 }; -struct cmd_node keychain_key_node = +static struct cmd_node keychain_key_node = { KEYCHAIN_KEY_NODE, "%s(config-keychain-key)# ", diff --git a/lib/linklist.c b/lib/linklist.c index a16e9e18..485a80be 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -28,11 +28,7 @@ struct list * list_new (void) { - struct list *new; - - new = XMALLOC (MTYPE_LINK_LIST, sizeof (struct list)); - memset (new, 0, sizeof (struct list)); - return new; + return XCALLOC (MTYPE_LINK_LIST, sizeof (struct list)); } /* Free list. */ @@ -46,11 +42,7 @@ list_free (struct list *l) static struct listnode * listnode_new (void) { - struct listnode *node; - - node = XMALLOC (MTYPE_LINK_NODE, sizeof (struct listnode)); - memset (node, 0, sizeof (struct listnode)); - return node; + return XCALLOC (MTYPE_LINK_NODE, sizeof (struct listnode)); } /* Free listnode. */ @@ -740,9 +740,9 @@ zlog_rotate (struct zlog *zl) /* Message lookup function. */ const char * -lookup (struct message *mes, int key) +lookup (const struct message *mes, int key) { - struct message *pnt; + const struct message *pnt; for (pnt = mes; pnt->key != 0; pnt++) if (pnt->key == key) @@ -105,27 +105,48 @@ extern void closezlog (struct zlog *zl); /* GCC have printf type attribute check. */ #ifdef __GNUC__ -#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b))) +#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((format (printf, a, b))) #else #define PRINTF_ATTRIBUTE(a,b) #endif /* __GNUC__ */ +#if !(__GNUC__ == 4) +/* Mark functions as cold. gcc will assume any path leading to a call + to them will be unlikely. This means a lot of paths leading up + to log messages are easily marked as not likely. +*/ +#define COLD_ATTRIBUTE __attribute__((__cold__)) +#else +#define COLD_ATTRIBUTE +#endif + /* Generic function for zlog. */ -extern void zlog (struct zlog *zl, int priority, const char *format, ...) PRINTF_ATTRIBUTE(3, 4); +extern void zlog (struct zlog *zl, int priority, const char *format, ...) + PRINTF_ATTRIBUTE(3, 4); /* Handy zlog functions. */ -extern void zlog_err (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -extern void zlog_warn (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -extern void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -extern void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -extern void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); +extern void zlog_err (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; +extern void zlog_warn (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; +extern void zlog_info (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; +extern void zlog_notice (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; +extern void zlog_debug (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; /* For bgpd's peer oriented log. */ -extern void plog_err (struct zlog *, const char *format, ...); -extern void plog_warn (struct zlog *, const char *format, ...); -extern void plog_info (struct zlog *, const char *format, ...); -extern void plog_notice (struct zlog *, const char *format, ...); -extern void plog_debug (struct zlog *, const char *format, ...); +extern void plog_err (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; +extern void plog_warn (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; +extern void plog_info (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; +extern void plog_notice (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; +extern void plog_debug (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; /* Set logging level for the given destination. If the log_level argument is ZLOG_DISABLED, then the destination is disabled. @@ -144,7 +165,7 @@ extern int zlog_rotate (struct zlog *); /* For hackey massage lookup and check */ #define LOOKUP(x, y) mes_lookup(x, x ## _max, y, "(no item found)") -extern const char *lookup (struct message *, int); +extern const char *lookup (const struct message *, int); extern const char *mes_lookup (struct message *meslist, int max, int index, const char *no_item); diff --git a/lib/memory.c b/lib/memory.c index 9ed5e100..28b3d896 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -33,7 +33,7 @@ static void alloc_inc (int); static void alloc_dec (int); static void log_memstats(int log_priority); -static struct message mstr [] = +static const struct message mstr [] = { { MTYPE_THREAD, "thread" }, { MTYPE_THREAD_MASTER, "thread_master" }, diff --git a/lib/plist.c b/lib/plist.c index 6caece0e..e46dae0b 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -2623,7 +2623,7 @@ prefix_list_reset_orf (void) /* Prefix-list node. */ -struct cmd_node prefix_node = +static struct cmd_node prefix_node = { PREFIX_NODE, "", /* Prefix list has no interface. */ @@ -2732,7 +2732,7 @@ prefix_list_init_ipv4 (void) #ifdef HAVE_IPV6 /* Prefix-list node. */ -struct cmd_node prefix_ipv6_node = +static struct cmd_node prefix_ipv6_node = { PREFIX_IPV6_NODE, "", /* Prefix list has no interface. */ diff --git a/lib/routemap.c b/lib/routemap.c index 58ed09a7..5f7a3182 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -1280,7 +1280,7 @@ route_map_config_write (struct vty *vty) } /* Route map node structure. */ -struct cmd_node rmap_node = +static struct cmd_node rmap_node = { RMAP_NODE, "%s(config-route-map)# ", @@ -71,7 +71,7 @@ int debug_smux = 0; int fail = 0; /* SMUX node. */ -struct cmd_node smux_node = +static struct cmd_node smux_node = { SMUX_NODE, "" /* SMUX has no interface. */ diff --git a/lib/sockopt.h b/lib/sockopt.h index 95382792..cb05c6fb 100644 --- a/lib/sockopt.h +++ b/lib/sockopt.h @@ -89,6 +89,7 @@ extern int setsockopt_multicast_ipv4(int sock, int optname, unsigned int ifindex /* optional: if non-zero, may be used instead of if_addr */); +extern int setsockopt_ipv4_tos(int sock, int tos); /* Ask for, and get, ifindex, by whatever method is supported. */ extern int setsockopt_ifindex (int, int, int); diff --git a/lib/sockunion.c b/lib/sockunion.c index cfd3bf9a..1ae092bd 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -180,8 +180,7 @@ sockunion_str2su (const char *str) int ret; union sockunion *su; - su = XMALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); - memset (su, 0, sizeof (union sockunion)); + su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); ret = inet_pton (AF_INET, str, &su->sin.sin_addr); if (ret > 0) /* Valid IPv4 address format. */ diff --git a/lib/thread.c b/lib/thread.c index 095dff4e..260e8c8e 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -223,8 +223,8 @@ cpu_record_hash_key (struct cpu_thread_history *a) } static int -cpu_record_hash_cmp (struct cpu_thread_history *a, - struct cpu_thread_history *b) +cpu_record_hash_cmp (const struct cpu_thread_history *a, + const struct cpu_thread_history *b) { return a->func == b->func; } @@ -410,7 +410,7 @@ thread_master_create () if (cpu_record == NULL) cpu_record = hash_create_size (1011, (unsigned int (*) (void *))cpu_record_hash_key, - (int (*) (void *, void *))cpu_record_hash_cmp); + (int (*) (const void *, const void *))cpu_record_hash_cmp); return (struct thread_master *) XCALLOC (MTYPE_THREAD_MASTER, sizeof (struct thread_master)); @@ -141,13 +141,6 @@ struct vty #define IS_DIRECTORY_SEP(c) ((c) == DIRECTORY_SEP) #endif -/* GCC have printf type attribute check. */ -#ifdef __GNUC__ -#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b))) -#else -#define PRINTF_ATTRIBUTE(a,b) -#endif /* __GNUC__ */ - /* Utility macros to convert VTY argument to unsigned long or integer. */ #define VTY_GET_LONG(NAME,V,STR) \ do { \ diff --git a/lib/zassert.h b/lib/zassert.h index 79126760..123aee16 100644 --- a/lib/zassert.h +++ b/lib/zassert.h @@ -17,9 +17,17 @@ extern void _zlog_assert_failed (const char *assertion, const char *file, #define __ASSERT_FUNCTION NULL #endif -#define zassert(EX) ((void)((EX) ? 0 : \ - (_zlog_assert_failed(#EX, __FILE__, __LINE__, \ - __ASSERT_FUNCTION), 0))) +#ifdef __GNUC__ +#define UNLIKELY(EX) __builtin_expect(!!(EX), 0) +#define LIKELY(EX) __builtin_expect(!!(EX), 1) +#else +#define UNLIKELY(EX) (EX) +#define LIKELY(EX) (EX) +#endif + +#define zassert(EX) ((void)(UNLIKELY(EX) ? 0 : \ + (_zlog_assert_failed(#EX, __FILE__, __LINE__, \ + __ASSERT_FUNCTION), 0))) #undef assert #define assert(EX) zassert(EX) diff --git a/lib/zclient.c b/lib/zclient.c index 10e6b5fd..4a716a66 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -49,8 +49,7 @@ struct zclient * zclient_new () { struct zclient *zclient; - zclient = XMALLOC (MTYPE_ZCLIENT, sizeof (struct zclient)); - memset (zclient, 0, sizeof (struct zclient)); + zclient = XCALLOC (MTYPE_ZCLIENT, sizeof (struct zclient)); zclient->ibuf = stream_new (ZEBRA_MAX_PACKET_SIZ); zclient->obuf = stream_new (ZEBRA_MAX_PACKET_SIZ); diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 95464b63..ab8c4519 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -1511,7 +1511,7 @@ config_write_ospf6_interface (struct vty *vty) return 0; } -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index a5efcb8d..deaa7ff5 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -114,8 +114,7 @@ ospf6_create () { struct ospf6 *o; - o = XMALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6)); - memset (o, 0, sizeof (struct ospf6)); + o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6)); /* initialize */ gettimeofday (&o->starttime, (struct timezone *) NULL); @@ -651,7 +650,7 @@ config_write_ospf6 (struct vty *vty) } /* OSPF6 node structure. */ -struct cmd_node ospf6_node = +static struct cmd_node ospf6_node = { OSPF6_NODE, "%s(config-ospf6)# ", diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 4440a67f..7b3d2438 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -336,7 +336,7 @@ config_write_ospf6_zebra (struct vty *vty) } /* Zebra node structure. */ -struct cmd_node zebra_node = +static struct cmd_node zebra_node = { ZEBRA_NODE, "%s(config-zebra)# ", diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 3c84fe65..86836fc5 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -97,7 +97,7 @@ DEFUN (show_version_ospf6, return CMD_SUCCESS; } -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c index b6c8bc90..fc3b51dd 100644 --- a/ospfd/ospf_api.c +++ b/ospfd/ospf_api.c @@ -99,8 +99,7 @@ msg_new (u_char msgtype, void *msgbody, u_int32_t seqnum, u_int16_t msglen) { struct msg *new; - new = XMALLOC (MTYPE_OSPF_API_MSG, sizeof (struct msg)); - memset (new, 0, sizeof (struct msg)); + new = XCALLOC (MTYPE_OSPF_API_MSG, sizeof (struct msg)); new->hdr.version = OSPF_API_VERSION; new->hdr.msgtype = msgtype; @@ -271,12 +270,7 @@ msg_get_seq (struct msg *msg) struct msg_fifo * msg_fifo_new () { - struct msg_fifo *new; - - new = XMALLOC (MTYPE_OSPF_API_FIFO, sizeof (struct msg_fifo)); - memset (new, 0, sizeof (struct msg_fifo)); - - return new; + return XCALLOC (MTYPE_OSPF_API_FIFO, sizeof (struct msg_fifo)); } /* Add new message to fifo. */ diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index dac4c93f..15fd2e5f 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -937,8 +937,7 @@ ospf_apiserver_register_opaque_type (struct ospf_apiserver *apiserv, type. */ regtype = - XMALLOC (MTYPE_OSPF_APISERVER, sizeof (struct registered_opaque_type)); - memset (regtype, 0, sizeof (struct registered_opaque_type)); + XCALLOC (MTYPE_OSPF_APISERVER, sizeof (struct registered_opaque_type)); regtype->lsa_type = lsa_type; regtype->opaque_type = opaque_type; diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index a4826237..6f1b0b06 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -104,8 +104,7 @@ ospf_external_info_new (u_char type) struct external_info *new; new = (struct external_info *) - XMALLOC (MTYPE_OSPF_EXTERNAL_INFO, sizeof (struct external_info)); - memset (new, 0, sizeof (struct external_info)); + XCALLOC (MTYPE_OSPF_EXTERNAL_INFO, sizeof (struct external_info)); new->type = type; ospf_reset_route_map_set_values (&new->route_map_set); diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 2fcbfe64..de9ef055 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -1509,7 +1509,7 @@ DEFUN (show_debugging_ospf, } /* Debug node. */ -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 63681429..5d4f415f 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -638,8 +638,7 @@ ospf_if_new_hook (struct interface *ifp) { int rc = 0; - ifp->info = XMALLOC (MTYPE_OSPF_IF_INFO, sizeof (struct ospf_if_info)); - memset (ifp->info, 0, sizeof (struct ospf_if_info)); + ifp->info = XCALLOC (MTYPE_OSPF_IF_INFO, sizeof (struct ospf_if_info)); IF_OIFS (ifp) = route_table_init (); IF_OIFS_PARAMS (ifp) = route_table_init (); @@ -814,8 +813,7 @@ ospf_vl_data_new (struct ospf_area *area, struct in_addr vl_peer) { struct ospf_vl_data *vl_data; - vl_data = XMALLOC (MTYPE_OSPF_VL_DATA, sizeof (struct ospf_vl_data)); - memset (vl_data, 0, sizeof (struct ospf_vl_data)); + vl_data = XCALLOC (MTYPE_OSPF_VL_DATA, sizeof (struct ospf_vl_data)); vl_data->vl_peer.s_addr = vl_peer.s_addr; vl_data->vl_area_id = area->area_id; @@ -1180,12 +1178,7 @@ ospf_vls_in_area (struct ospf_area *area) struct crypt_key * ospf_crypt_key_new () { - struct crypt_key *ck; - - ck = XMALLOC (MTYPE_OSPF_CRYPT_KEY, sizeof (struct crypt_key)); - memset (ck, 0, sizeof (struct crypt_key)); - - return ck; + return XCALLOC (MTYPE_OSPF_CRYPT_KEY, sizeof (struct crypt_key)); } void diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index fccae82f..aff395af 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -326,12 +326,7 @@ ospf_lsa_discard (struct ospf_lsa *lsa) struct lsa_header * ospf_lsa_data_new (size_t size) { - struct lsa_header *new; - - new = (struct lsa_header *) XMALLOC (MTYPE_OSPF_LSA_DATA, size); - memset (new, 0, size); - - return new; + return XCALLOC (MTYPE_OSPF_LSA_DATA, size); } /* Duplicate LSA data. */ diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c index 843e93f6..967ca15d 100644 --- a/ospfd/ospf_neighbor.c +++ b/ospfd/ospf_neighbor.c @@ -69,8 +69,7 @@ ospf_nbr_new (struct ospf_interface *oi) struct ospf_neighbor *nbr; /* Allcate new neighbor. */ - nbr = XMALLOC (MTYPE_OSPF_NEIGHBOR, sizeof (struct ospf_neighbor)); - memset (nbr, 0, sizeof (struct ospf_neighbor)); + nbr = XCALLOC (MTYPE_OSPF_NEIGHBOR, sizeof (struct ospf_neighbor)); /* Relate neighbor to the interface. */ nbr->oi = oi; diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index e76b39b0..a16da41b 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -1389,11 +1389,7 @@ struct ospf_snmp_if struct ospf_snmp_if * ospf_snmp_if_new () { - struct ospf_snmp_if *osif; - - osif = XMALLOC (0, sizeof (struct ospf_snmp_if)); - memset (osif, 0, sizeof (struct ospf_snmp_if)); - return osif; + return XCALLOC (0, sizeof (struct ospf_snmp_if)); } void diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index a3ebe62e..c5ec0ad8 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -561,13 +561,13 @@ ospf_mpls_te_new_if (struct interface *ifp) goto out; } - if ((new = XMALLOC (MTYPE_OSPF_MPLS_TE_LINKPARAMS, - sizeof (struct mpls_te_link))) == NULL) + new = XCALLOC (MTYPE_OSPF_MPLS_TE_LINKPARAMS, + sizeof (struct mpls_te_link)); + if (new == NULL) { zlog_warn ("ospf_mpls_te_new_if: XMALLOC: %s", safe_strerror (errno)); goto out; } - memset (new, 0, sizeof (struct mpls_te_link)); new->area = NULL; new->flags = 0; diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c96b88ab..bfd90466 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -8056,7 +8056,7 @@ ospf_vty_show_init (void) /* ospfd's interface node. */ -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", @@ -8165,13 +8165,6 @@ ospf_vty_if_init (void) install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); } -/* Zebra node structure. */ -struct cmd_node zebra_node = -{ - ZEBRA_NODE, - "%s(config-router)#", -}; - static void ospf_vty_zebra_init (void) { @@ -8264,7 +8257,7 @@ ospf_vty_zebra_init (void) #endif /* 0 */ } -struct cmd_node ospf_node = +static struct cmd_node ospf_node = { OSPF_NODE, "%s(config-router)# ", diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index c627afb2..3afbcbb7 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -1126,10 +1126,7 @@ ospf_prefix_list_update (struct prefix_list *plist) static struct ospf_distance * ospf_distance_new (void) { - struct ospf_distance *new; - new = XMALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance)); - memset (new, 0, sizeof (struct ospf_distance)); - return new; + return XCALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance)); } static void diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 448f218e..d352a056 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -1385,9 +1385,8 @@ ospf_nbr_nbma_new (void) { struct ospf_nbr_nbma *nbr_nbma; - nbr_nbma = XMALLOC (MTYPE_OSPF_NEIGHBOR_STATIC, + nbr_nbma = XCALLOC (MTYPE_OSPF_NEIGHBOR_STATIC, sizeof (struct ospf_nbr_nbma)); - memset (nbr_nbma, 0, sizeof (struct ospf_nbr_nbma)); nbr_nbma->priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; nbr_nbma->v_poll = OSPF_POLL_INTERVAL_DEFAULT; diff --git a/ripd/rip_debug.c b/ripd/rip_debug.c index d788ea7e..64dc27c0 100644 --- a/ripd/rip_debug.c +++ b/ripd/rip_debug.c @@ -203,7 +203,7 @@ DEFUN (no_debug_rip_zebra, } /* Debug node. */ -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", /* Debug node has no interface. */ diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 915cd911..131898c2 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -50,11 +50,12 @@ static int rip_enable_if_lookup (const char *ifname); static int rip_enable_network_lookup2 (struct connected *connected); static void rip_enable_apply_all (void); -struct message ri_version_msg[] = +const struct message ri_version_msg[] = { {RI_RIP_VERSION_1, "1"}, {RI_RIP_VERSION_2, "2"}, {RI_RIP_VERSION_1_AND_2, "1 2"}, + {0, NULL} }; extern struct zebra_privs_t ripd_privs; @@ -118,8 +119,7 @@ rip_interface_new (void) { struct rip_interface *ri; - ri = XMALLOC (MTYPE_RIP_INTERFACE, sizeof (struct rip_interface)); - memset (ri, 0, sizeof (struct rip_interface)); + ri = XCALLOC (MTYPE_RIP_INTERFACE, sizeof (struct rip_interface)); /* Default authentication type is simple password for Cisco compatibility. */ @@ -240,6 +240,7 @@ rip_request_interface (struct interface *ifp) } } +#if 0 /* Send RIP request to the neighbor. */ static void rip_request_neighbor (struct in_addr addr) @@ -253,7 +254,6 @@ rip_request_neighbor (struct in_addr addr) rip_request_send (&to, NULL, rip->version_send, NULL); } -#if 0 /* Request routes at all interfaces. */ static void rip_request_neighbor_all (void) @@ -406,8 +406,8 @@ rip_interface_down (int command, struct zclient *zclient, zebra_size_t length) if (IS_RIP_DEBUG_ZEBRA) zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is down", - ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, - ifp->metric, ifp->mtu); + ifp->name, ifp->ifindex, + (unsigned long long) ifp->flags, ifp->metric, ifp->mtu); return 0; } @@ -427,7 +427,7 @@ rip_interface_up (int command, struct zclient *zclient, zebra_size_t length) if (IS_RIP_DEBUG_ZEBRA) zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is up", - ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, + ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, ifp->metric, ifp->mtu); /* Check if this interface is RIP enabled or not.*/ @@ -492,7 +492,7 @@ rip_interface_delete (int command, struct zclient *zclient, } zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d", - ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, + ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, ifp->metric, ifp->mtu); /* To support pseudo interface do not free interface structure. */ @@ -2058,7 +2058,7 @@ config_write_rip_network (struct vty *vty, int config_mode) return 0; } -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", diff --git a/ripd/rip_offset.c b/ripd/rip_offset.c index e7d71f6c..0155f90e 100644 --- a/ripd/rip_offset.c +++ b/ripd/rip_offset.c @@ -63,11 +63,7 @@ strcmp_safe (const char *s1, const char *s2) static struct rip_offset_list * rip_offset_list_new (void) { - struct rip_offset_list *new; - - new = XMALLOC (MTYPE_RIP_OFFSET_LIST, sizeof (struct rip_offset_list)); - memset (new, 0, sizeof (struct rip_offset_list)); - return new; + return XCALLOC (MTYPE_RIP_OFFSET_LIST, sizeof (struct rip_offset_list)); } static void diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c index e0617890..fd912eba 100644 --- a/ripd/rip_peer.c +++ b/ripd/rip_peer.c @@ -36,11 +36,7 @@ struct list *peer_list; static struct rip_peer * rip_peer_new (void) { - struct rip_peer *new; - - new = XMALLOC (MTYPE_RIP_PEER, sizeof (struct rip_peer)); - memset (new, 0, sizeof (struct rip_peer)); - return new; + return XCALLOC (MTYPE_RIP_PEER, sizeof (struct rip_peer)); } static void diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index b924199f..c476d8f4 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -233,6 +233,7 @@ DEFUN (no_router_zebra, return CMD_SUCCESS; } +#if 0 static int rip_redistribute_set (int type) { @@ -246,6 +247,7 @@ rip_redistribute_set (int type) return CMD_SUCCESS; } +#endif static int rip_redistribute_unset (int type) @@ -651,7 +653,7 @@ config_write_rip_redistribute (struct vty *vty, int config_mode) } /* Zebra node structure. */ -struct cmd_node zebra_node = +static struct cmd_node zebra_node = { ZEBRA_NODE, "%s(config-router)# ", diff --git a/ripd/ripd.c b/ripd/ripd.c index af2e5d0e..fc8ce1b8 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -76,7 +76,7 @@ enum }; /* RIP command strings. */ -struct message rip_msg[] = +static const struct message rip_msg[] = { {RIP_REQUEST, "REQUEST"}, {RIP_RESPONSE, "RESPONSE"}, @@ -84,6 +84,7 @@ struct message rip_msg[] = {RIP_TRACEOFF, "TRACEOFF"}, {RIP_POLL, "POLL"}, {RIP_POLL_ENTRY, "POLL ENTRY"}, + {0, NULL}, }; /* Utility function to set boradcast option to the socket. */ @@ -111,11 +112,7 @@ rip_route_rte (struct rip_info *rinfo) static struct rip_info * rip_info_new () { - struct rip_info *new; - - new = XMALLOC (MTYPE_RIP_INFO, sizeof (struct rip_info)); - memset (new, 0, sizeof (struct rip_info)); - return new; + return XCALLOC (MTYPE_RIP_INFO, sizeof (struct rip_info)); } void @@ -2696,8 +2693,7 @@ rip_redistribute_withdraw (int type) static int rip_create (void) { - rip = XMALLOC (MTYPE_RIP, sizeof (struct rip)); - memset (rip, 0, sizeof (struct rip)); + rip = XCALLOC (MTYPE_RIP, sizeof (struct rip)); /* Set initial value. */ rip->version_send = RI_RIP_VERSION_2; @@ -3118,10 +3114,7 @@ struct rip_distance static struct rip_distance * rip_distance_new (void) { - struct rip_distance *new; - new = XMALLOC (MTYPE_RIP_DISTANCE, sizeof (struct rip_distance)); - memset (new, 0, sizeof (struct rip_distance)); - return new; + return XCALLOC (MTYPE_RIP_DISTANCE, sizeof (struct rip_distance)); } static void @@ -3510,7 +3503,7 @@ DEFUN (show_ip_rip_status, struct listnode *node; struct interface *ifp; struct rip_interface *ri; - extern struct message ri_version_msg[]; + extern const struct message ri_version_msg[]; const char *send_version; const char *receive_version; @@ -3689,7 +3682,7 @@ config_write_rip (struct vty *vty) } /* RIP node structure. */ -struct cmd_node rip_node = +static struct cmd_node rip_node = { RIP_NODE, "%s(config-router)# ", diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index 7841fe21..aac254d4 100644 --- a/ripngd/ripng_debug.c +++ b/ripngd/ripng_debug.c @@ -204,7 +204,7 @@ DEFUN (no_debug_ripng_zebra, } /* Debug node. */ -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", /* Debug node has no interface. */ diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index cad6240b..06df6a10 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -1205,7 +1205,7 @@ interface_config_write (struct vty *vty) } /* ripngd's interface node. */ -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c index 34f5ac6c..0438b4bf 100644 --- a/ripngd/ripng_peer.c +++ b/ripngd/ripng_peer.c @@ -42,11 +42,7 @@ struct list *peer_list; struct ripng_peer * ripng_peer_new () { - struct ripng_peer *new; - - new = XMALLOC (MTYPE_RIPNG_PEER, sizeof (struct ripng_peer)); - memset (new, 0, sizeof (struct ripng_peer)); - return new; + return XCALLOC (MTYPE_RIPNG_PEER, sizeof (struct ripng_peer)); } void diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index 1f9bee0c..c624454e 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -538,7 +538,7 @@ zebra_config_write (struct vty *vty) } /* Zebra node structure. */ -struct cmd_node zebra_node = +static struct cmd_node zebra_node = { ZEBRA_NODE, "%s(config-router)# ", diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index a8277fe2..9bf40dff 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -1820,8 +1820,7 @@ ripng_create () assert (ripng == NULL); /* Allocaste RIPng instance. */ - ripng = XMALLOC (MTYPE_RIPNG, sizeof (struct ripng)); - memset (ripng, 0, sizeof (struct ripng)); + ripng = XCALLOC (MTYPE_RIPNG, sizeof (struct ripng)); /* Default version and timer values. */ ripng->version = RIPNG_V1; @@ -2685,7 +2684,7 @@ ripng_config_write (struct vty *vty) } /* RIPng node structure. */ -struct cmd_node cmd_ripng_node = +static struct cmd_node cmd_ripng_node = { RIPNG_NODE, "%s(config-router)# ", diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index e2ac9ab7..bff06323 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -713,97 +713,97 @@ vtysh_completion (char *text, int start, int end) #endif /* Vty node structures. */ -struct cmd_node bgp_node = +static struct cmd_node bgp_node = { BGP_NODE, "%s(config-router)# ", }; -struct cmd_node rip_node = +static struct cmd_node rip_node = { RIP_NODE, "%s(config-router)# ", }; -struct cmd_node isis_node = +static struct cmd_node isis_node = { ISIS_NODE, "%s(config-router)# ", }; -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", }; -struct cmd_node rmap_node = +static struct cmd_node rmap_node = { RMAP_NODE, "%s(config-route-map)# " }; -struct cmd_node zebra_node = +static struct cmd_node zebra_node = { ZEBRA_NODE, "%s(config-router)# " }; -struct cmd_node bgp_vpnv4_node = +static struct cmd_node bgp_vpnv4_node = { BGP_VPNV4_NODE, "%s(config-router-af)# " }; -struct cmd_node bgp_ipv4_node = +static struct cmd_node bgp_ipv4_node = { BGP_IPV4_NODE, "%s(config-router-af)# " }; -struct cmd_node bgp_ipv4m_node = +static struct cmd_node bgp_ipv4m_node = { BGP_IPV4M_NODE, "%s(config-router-af)# " }; -struct cmd_node bgp_ipv6_node = +static struct cmd_node bgp_ipv6_node = { BGP_IPV6_NODE, "%s(config-router-af)# " }; -struct cmd_node bgp_ipv6m_node = +static struct cmd_node bgp_ipv6m_node = { BGP_IPV6M_NODE, "%s(config-router-af)# " }; -struct cmd_node ospf_node = +static struct cmd_node ospf_node = { OSPF_NODE, "%s(config-router)# " }; -struct cmd_node ripng_node = +static struct cmd_node ripng_node = { RIPNG_NODE, "%s(config-router)# " }; -struct cmd_node ospf6_node = +static struct cmd_node ospf6_node = { OSPF6_NODE, "%s(config-ospf6)# " }; -struct cmd_node keychain_node = +static struct cmd_node keychain_node = { KEYCHAIN_NODE, "%s(config-keychain)# " }; -struct cmd_node keychain_key_node = +static struct cmd_node keychain_key_node = { KEYCHAIN_KEY_NODE, "%s(config-keychain-key)# " diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c index e3015056..58676c10 100644 --- a/vtysh/vtysh_user.c +++ b/vtysh/vtysh_user.c @@ -101,10 +101,7 @@ struct list *userlist; struct vtysh_user * user_new () { - struct vtysh_user *user; - user = XMALLOC (0, sizeof (struct vtysh_user)); - memset (user, 0, sizeof (struct vtysh_user)); - return user; + return XCALLOC (0, sizeof (struct vtysh_user)); } void diff --git a/zebra/connected.c b/zebra/connected.c index f3e5396c..b235d8c0 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -36,6 +36,7 @@ #include "zebra/interface.h" #include "zebra/connected.h" extern struct zebra_t zebrad; + /* withdraw a connected address */ static void @@ -174,6 +175,7 @@ void connected_up_ipv4 (struct interface *ifp, struct connected *ifc) { struct prefix_ipv4 p; + struct in_addr src = ((struct prefix_ipv4 *) ifc->address)->prefix; if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) return; @@ -188,14 +190,14 @@ connected_up_ipv4 (struct interface *ifp, struct connected *ifc) if (prefix_ipv4_any (&p)) return; - rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex, - RT_TABLE_MAIN, ifp->metric, 0); + rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, &src, + ifp->ifindex, RT_TABLE_MAIN, ifp->metric, 0, RT_SCOPE_LINK); rib_update (); } /* Add connected IPv4 route to the interface. */ -void +struct connected * connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, u_char prefixlen, struct in_addr *broad, const char *label) @@ -270,10 +272,10 @@ connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); /* nothing to do? */ - if ((ifc = connected_implicit_withdraw (ifp, ifc)) == NULL) - return; - + ifc = connected_implicit_withdraw (ifp, ifc); connected_announce (ifp, ifc); + + return ifc; } void @@ -347,7 +349,7 @@ connected_up_ipv6 (struct interface *ifp, struct connected *ifc) } /* Add connected IPv6 route to the interface. */ -void +struct connected * connected_add_ipv6 (struct interface *ifp, int flags, struct in6_addr *addr, u_char prefixlen, struct in6_addr *broad, const char *label) @@ -394,10 +396,10 @@ connected_add_ipv6 (struct interface *ifp, int flags, struct in6_addr *addr, if (label) ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); - if ((ifc = connected_implicit_withdraw (ifp, ifc)) == NULL) - return; - + ifc = connected_implicit_withdraw (ifp, ifc); connected_announce (ifp, ifc); + + return ifc; } void diff --git a/zebra/connected.h b/zebra/connected.h index 9595ddb1..8bfe4118 100644 --- a/zebra/connected.h +++ b/zebra/connected.h @@ -26,7 +26,7 @@ extern struct connected * connected_check (struct interface *ifp, struct prefix *p); -extern void +extern struct connected * connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, u_char prefixlen, struct in_addr *broad, const char *label); @@ -39,7 +39,7 @@ extern void connected_up_ipv4 (struct interface *, struct connected *); extern void connected_down_ipv4 (struct interface *, struct connected *); #ifdef HAVE_IPV6 -extern void +extern struct connected * connected_add_ipv6 (struct interface *ifp, int flags, struct in6_addr *address, u_char prefixlen, struct in6_addr *broad, const char *label); diff --git a/zebra/interface.c b/zebra/interface.c index ce506056..74c977a9 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -48,8 +48,7 @@ if_zebra_new_hook (struct interface *ifp) { struct zebra_if *zebra_if; - zebra_if = XMALLOC (MTYPE_TMP, sizeof (struct zebra_if)); - memset (zebra_if, 0, sizeof (struct zebra_if)); + zebra_if = XCALLOC (MTYPE_TMP, sizeof (struct zebra_if)); zebra_if->multicast = IF_ZEBRA_MULTICAST_UNSPEC; zebra_if->shutdown = IF_ZEBRA_SHUTDOWN_UNSPEC; diff --git a/zebra/kernel_null.c b/zebra/kernel_null.c index 94b7b3c7..c72bbd09 100644 --- a/zebra/kernel_null.c +++ b/zebra/kernel_null.c @@ -12,9 +12,9 @@ int kernel_add_ipv4 (struct prefix *a, struct rib *b) { return 0; } #pragma weak kernel_delete_ipv4 = kernel_add_ipv4 int kernel_add_ipv6 (struct prefix *a, struct rib *b) { return 0; } #pragma weak kernel_delete_ipv6 = kernel_add_ipv6 -int kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, - unsigned int index, int flags, int table) -{ return 0; } +void kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, + unsigned int index, int table) +{ } int kernel_add_route (struct prefix_ipv4 *a, struct in_addr *b, int c, int d) { return 0; } diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 2e04b031..e77b9b78 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -126,7 +126,7 @@ extern struct zebra_t zebrad; (LEN) = 0; \ } /* Routing socket message types. */ -struct message rtm_type_str[] = +const struct message rtm_type_str[] = { {RTM_ADD, "RTM_ADD"}, {RTM_DELETE, "RTM_DELETE"}, diff --git a/zebra/main.c b/zebra/main.c index 61750f1d..ac0637b6 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -63,12 +63,16 @@ int keep_kernel_mode = 0; u_int32_t nl_rcvbufsize = 0; #endif /* HAVE_NETLINK */ +/* Manage system routes. */ +extern int rib_system_routes; + /* Command line options. */ struct option longopts[] = { { "batch", no_argument, NULL, 'b'}, { "daemon", no_argument, NULL, 'd'}, { "keep_kernel", no_argument, NULL, 'k'}, + { "rib_system", no_argument, NULL, 'S'}, { "log_mode", no_argument, NULL, 'l'}, { "config_file", required_argument, NULL, 'f'}, { "pid_file", required_argument, NULL, 'i'}, @@ -131,6 +135,7 @@ usage (char *progname, int status) "-i, --pid_file Set process identifier file name\n"\ "-k, --keep_kernel Don't delete old routes which installed by "\ "zebra.\n"\ + "-S, --system Manage all routes on link transistions\n" "-l, --log_mode Set verbose log mode flag\n"\ "-C, --dryrun Check configuration for validity and exit\n"\ "-A, --vty_addr Set vty's bind address\n"\ @@ -231,9 +236,9 @@ main (int argc, char **argv) int opt; #ifdef HAVE_NETLINK - opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:C", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:CS", longopts, 0); #else - opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vC", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vCS", longopts, 0); #endif /* HAVE_NETLINK */ if (opt == EOF) @@ -251,6 +256,9 @@ main (int argc, char **argv) case 'k': keep_kernel_mode = 1; break; + case 'S': + rib_system_routes = 1; + break; case 'C': dryrun = 1; break; diff --git a/zebra/rib.h b/zebra/rib.h index d5613d8a..c39afa73 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -60,6 +60,9 @@ struct rib /* Type for this route. < ZEBRA_ROUTE_MAX */ u_int8_t type; + /* Scope for this route. */ + u_int8_t scope; + /* Status Flags for the *route_node*, but kept in the head RIB.. */ u_char rn_status; #define RIB_ROUTE_QUEUED(x) (1 << (x)) @@ -76,6 +79,7 @@ struct rib /* RIB internal status */ u_char status; #define RIB_ENTRY_REMOVED (1 << 0) +#define RIB_ENTRY_PRESERVE (2 << 0) /* Nexthop information. */ u_char nexthop_num; @@ -221,7 +225,8 @@ struct vrf struct route_table *stable[AFI_MAX][SAFI_MAX]; }; -extern struct nexthop *nexthop_ifindex_add (struct rib *, unsigned int); +extern struct nexthop *nexthop_ifindex_add (struct rib *, unsigned int, + struct in_addr *); extern struct nexthop *nexthop_ifname_add (struct rib *, char *); extern struct nexthop *nexthop_blackhole_add (struct rib *); extern struct nexthop *nexthop_ipv4_add (struct rib *, struct in_addr *, @@ -250,7 +255,7 @@ extern struct route_table *vrf_static_table (afi_t afi, safi_t safi, u_int32_t i extern int rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, struct in_addr *gate, struct in_addr *src, unsigned int ifindex, u_int32_t vrf_id, - u_int32_t, u_char); + u_int32_t metric, u_int8_t distance, u_int8_t scope); extern int rib_add_ipv4_multipath (struct prefix_ipv4 *, struct rib *); @@ -36,8 +36,8 @@ 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_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); +extern void kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, + unsigned int index, int table); #endif /* HAVE_IPV6 */ diff --git a/zebra/rt_ioctl.c b/zebra/rt_ioctl.c index a5d588c7..d39ec4df 100644 --- a/zebra/rt_ioctl.c +++ b/zebra/rt_ioctl.c @@ -553,8 +553,8 @@ kernel_delete_ipv6 (struct prefix *p, struct rib *rib) /* Delete IPv6 route from the kernel. */ int kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, - unsigned int index, int flags, int table) + unsigned int index, int table) { - return kernel_ioctl_ipv6 (SIOCDELRT, dest, gate, index, flags); + return kernel_ioctl_ipv6 (SIOCDELRT, dest, gate, index, 0; } #endif /* HAVE_IPV6 */ diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 3e8048ba..f9f90224 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -53,7 +53,7 @@ struct nlsock } netlink = { -1, 0, {0}, "netlink-listen"}, /* kernel messages */ netlink_cmd = { -1, 0, {0}, "netlink-cmd"}; /* command channel */ -static struct message nlmsg_str[] = { +static const struct message nlmsg_str[] = { {RTM_NEWROUTE, "RTM_NEWROUTE"}, {RTM_DELROUTE, "RTM_DELROUTE"}, {RTM_GETROUTE, "RTM_GETROUTE"}, @@ -87,6 +87,12 @@ extern struct zebra_privs_t zserv_privs; extern u_int32_t nl_rcvbufsize; +extern int rib_system_routes; + +static void +netlink_delroute (int family, void *dest, int length, void *gate, + int index, int table, int proto); + static int netlink_recvbuf (struct nlsock *nl, uint32_t newsize) { @@ -289,6 +295,13 @@ netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *), return -1; } + /* JF: Ignore messages that aren't from the kernel */ + if ( snl.nl_pid != 0 ) + { + zlog_debug ("Ignoring message from pid %u", snl.nl_pid ); + continue; + } + for (h = (struct nlmsghdr *) buf; NLMSG_OK (h, (unsigned int) status); h = NLMSG_NEXT (h, status)) { @@ -461,7 +474,7 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h) } strncpy(ifp->name, name, INTERFACE_NAMSIZ); ifp->flags = ifi->ifi_flags & 0x0000fffff; - ifp->mtu6 = ifp->mtu = *(int *) RTA_DATA (tb[IFLA_MTU]); + ifp->mtu6 = ifp->mtu = *(uint32_t *) RTA_DATA (tb[IFLA_MTU]); ifp->metric = 1; /* Hardware type and address. */ @@ -515,7 +528,7 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) #ifdef HAVE_IPV6 && ifa->ifa_family != AF_INET6 #endif /* HAVE_IPV6 */ - ) + ) return 0; if (h->nlmsg_type != RTM_NEWADDR && h->nlmsg_type != RTM_DELADDR) @@ -540,7 +553,7 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) { char buf[BUFSIZ]; zlog_debug ("netlink_interface_addr %s %s:", - lookup (nlmsg_str, h->nlmsg_type), ifp->name); + lookup (nlmsg_str, h->nlmsg_type), ifp->name); if (tb[IFA_LOCAL]) zlog_debug (" IFA_LOCAL %s/%d", inet_ntop (ifa->ifa_family, RTA_DATA (tb[IFA_LOCAL]), @@ -606,9 +619,25 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) if (ifa->ifa_family == AF_INET) { if (h->nlmsg_type == RTM_NEWADDR) - connected_add_ipv4 (ifp, flags, - (struct in_addr *) addr, ifa->ifa_prefixlen, - (struct in_addr *) broad, label); + { + struct connected *ifc; + ifc = connected_add_ipv4 (ifp, flags, + (struct in_addr *) addr, ifa->ifa_prefixlen, + (struct in_addr *) broad, label); + + /* If address added, but interface is down, + then remove the FIB entry from kernel. + */ + if (rib_system_routes && ifc && !if_is_operative (ifp)) + { + struct prefix_ipv4 p; + PREFIX_COPY_IPV4(&p, CONNECTED_PREFIX(ifc)); + apply_mask_ipv4 (&p); + + netlink_delroute (p.family, &p.prefix, p.prefixlen, NULL, + ifp->ifindex, RT_TABLE_MAIN, RTPROT_KERNEL); + } + } else connected_delete_ipv4 (ifp, flags, (struct in_addr *) addr, ifa->ifa_prefixlen, @@ -618,9 +647,9 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) if (ifa->ifa_family == AF_INET6) { if (h->nlmsg_type == RTM_NEWADDR) - connected_add_ipv6 (ifp, flags, - (struct in6_addr *) addr, ifa->ifa_prefixlen, - (struct in6_addr *) broad, label); + connected_add_ipv6 (ifp, flags, + (struct in6_addr *) addr, ifa->ifa_prefixlen, + (struct in6_addr *) broad, label); else connected_delete_ipv6 (ifp, (struct in6_addr *) addr, ifa->ifa_prefixlen, @@ -691,7 +720,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) src = NULL; if (tb[RTA_OIF]) - index = *(int *) RTA_DATA (tb[RTA_OIF]); + index = *(uint32_t *) RTA_DATA (tb[RTA_OIF]); if (tb[RTA_DST]) dest = RTA_DATA (tb[RTA_DST]); @@ -706,7 +735,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) gate = RTA_DATA (tb[RTA_GATEWAY]); if (tb[RTA_PRIORITY]) - metric = *(int *) RTA_DATA(tb[RTA_PRIORITY]); + metric = *(uint32_t *) RTA_DATA(tb[RTA_PRIORITY]); if (rtm->rtm_family == AF_INET) { @@ -715,7 +744,8 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) memcpy (&p.prefix, dest, 4); p.prefixlen = rtm->rtm_dst_len; - rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, src, index, table, metric, 0); + rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, src, index, + table, metric, 0, rtm->rtm_scope); } #ifdef HAVE_IPV6 if (rtm->rtm_family == AF_INET6) @@ -733,7 +763,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) return 0; } -struct message rtproto_str[] = { +static const struct message rtproto_str[] = { {RTPROT_REDIRECT, "redirect"}, {RTPROT_KERNEL, "kernel"}, {RTPROT_BOOT, "boot"}, @@ -822,7 +852,7 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h) src = NULL; if (tb[RTA_OIF]) - index = *(int *) RTA_DATA (tb[RTA_OIF]); + index = *(uint32_t *) RTA_DATA (tb[RTA_OIF]); if (tb[RTA_DST]) dest = RTA_DATA (tb[RTA_DST]); @@ -853,7 +883,8 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h) } if (h->nlmsg_type == RTM_NEWROUTE) - rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, src, index, table, 0, 0); + rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, src, index, table, 0, + 0, rtm->rtm_scope); else rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table); } @@ -938,72 +969,84 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h) if (h->nlmsg_type == RTM_NEWLINK) { unsigned long new_flags = ifi->ifi_flags & 0x0000fffff; + unsigned int mtu = *(uint32_t *) RTA_DATA (tb[IFLA_MTU]); ifp = if_lookup_by_index (ifi->ifi_index); - if (ifp && strcmp(ifp->name, name) != 0) - { - zlog_info("interface index %d was renamed from %s to %s", - ifi->ifi_index, ifp->name, name); - - strncpy(ifp->name, name, INTERFACE_NAMSIZ); - } - + /* New interface */ if (ifp == NULL || !CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) { if (ifp == NULL) { - ifp = if_create(name, strlen(name)); - ifp->ifindex = ifi->ifi_index; + ifp = if_create(name, strlen(name)); + ifp->ifindex = ifi->ifi_index; + ifp->metric = 1; + } + else if (strcmp(ifp->name, name) != 0) + { + strncpy(ifp->name, name, INTERFACE_NAMSIZ); } zlog_info ("interface %s index %d %s added.", name, ifi->ifi_index, if_flag_dump(new_flags)); ifp->flags = new_flags; - ifp->mtu6 = ifp->mtu = *(int *) RTA_DATA (tb[IFLA_MTU]); - ifp->metric = 1; + ifp->mtu6 = ifp->mtu = mtu; - /* If new link is added. */ - if_add_update (ifp); + /* If new link is added. */ + if_add_update (ifp); } - else - { - /* Interface status change. */ - ifp->mtu6 = ifp->mtu = *(int *) RTA_DATA (tb[IFLA_MTU]); - ifp->metric = 1; + /* Interface status change. */ + else if (new_flags != ifp->flags) + { + ifp->mtu6 = ifp->mtu = mtu; - if (new_flags != ifp->flags) - { - zlog_info ("interface %s index %d changed %s.", - name, ifi->ifi_index, if_flag_dump(new_flags)); + zlog_info ("interface %s index %d changed %s.", + name, ifi->ifi_index, if_flag_dump(new_flags)); - if (if_is_operative (ifp)) - { - ifp->flags = new_flags; - if (!if_is_operative (ifp)) - if_down (ifp); - else - /* Must notify client daemons of new interface status. */ - zebra_interface_up_update (ifp); - } + if (if_is_operative (ifp)) + { + ifp->flags = new_flags; + if (!if_is_operative (ifp)) + if_down (ifp); else - { - ifp->flags = new_flags; - if (if_is_operative (ifp)) - if_up (ifp); - } + /* Must notify client daemons of new interface status. */ + zebra_interface_up_update (ifp); } - } + else + { + ifp->flags = new_flags; + if (if_is_operative (ifp)) + if_up (ifp); + } + } + /* Interface name change */ + else if (strcmp(ifp->name, name) != 0) + { + ifp->mtu = ifp->mtu6 = mtu; + zlog_info("interface index %d was renamed from %s to %s", + ifi->ifi_index, ifp->name, name); + + strncpy(ifp->name, name, INTERFACE_NAMSIZ); + rib_update(); + } + /* Interface mtu change */ + else if (mtu != ifp->mtu) + { + zlog_info("interface index %d mtu changed from %u to %u", + ifp->mtu, mtu); + ifp->mtu = ifp->mtu6 = mtu; + if (if_is_operative (ifp)) + zebra_interface_up_update (ifp); + } } else { // RTM_DELLINK. - ifp = if_lookup_by_name (name); - + ifp = if_lookup_by_index (ifi->ifi_index); if (ifp == NULL) { - zlog (NULL, LOG_WARNING, "interface %s is deleted but can't find", - name); + zlog (NULL, LOG_WARNING, "interface %s index %d is deleted but can't find", + name, ifi->ifi_index); return 0; } else @@ -1011,6 +1054,7 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h) name, ifi->ifi_index); if_delete_update (ifp); + if_delete (ifp); } return 0; } @@ -1204,11 +1248,6 @@ netlink_talk (struct nlmsghdr *n, struct nlsock *nl) /* Request an acknowledgement by setting NLM_F_ACK */ n->nlmsg_flags |= NLM_F_ACK; - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug ("netlink_talk: %s type %s(%u), seq=%u", nl->name, - lookup (nlmsg_str, n->nlmsg_type), n->nlmsg_type, - n->nlmsg_seq); - /* Send message to netlink interface. */ if (zserv_privs.change (ZPRIVS_RAISE)) zlog (NULL, LOG_ERR, "Can't raise privileges"); @@ -1233,15 +1272,11 @@ netlink_talk (struct nlmsghdr *n, struct nlsock *nl) } /* Routing table change via netlink interface. */ -static int -netlink_route (int cmd, int family, void *dest, int length, void *gate, - int index, int zebra_flags, int table) +static void +netlink_delroute (int family, void *dest, int length, void *gate, + int index, int table, int proto) { - int ret; - int bytelen; - struct sockaddr_nl snl; - int discard; - + int bytelen = (family == AF_INET ? 4 : 16); struct { struct nlmsghdr n; @@ -1251,60 +1286,25 @@ netlink_route (int cmd, int family, void *dest, int length, void *gate, memset (&req, 0, sizeof req); - bytelen = (family == AF_INET ? 4 : 16); - req.n.nlmsg_len = NLMSG_LENGTH (sizeof (struct rtmsg)); - req.n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST; - req.n.nlmsg_type = cmd; + req.n.nlmsg_flags = NLM_F_REQUEST; + req.n.nlmsg_type = RTM_DELROUTE; req.r.rtm_family = family; + req.r.rtm_scope = RT_SCOPE_NOWHERE; req.r.rtm_table = table; req.r.rtm_dst_len = length; - if ((zebra_flags & ZEBRA_FLAG_BLACKHOLE) - || (zebra_flags & ZEBRA_FLAG_REJECT)) - discard = 1; - else - discard = 0; - - if (cmd == RTM_NEWROUTE) - { - req.r.rtm_protocol = RTPROT_ZEBRA; - req.r.rtm_scope = RT_SCOPE_UNIVERSE; - - if (discard) - { - if (zebra_flags & ZEBRA_FLAG_BLACKHOLE) - req.r.rtm_type = RTN_BLACKHOLE; - else if (zebra_flags & ZEBRA_FLAG_REJECT) - req.r.rtm_type = RTN_UNREACHABLE; - else - assert (RTN_BLACKHOLE != RTN_UNREACHABLE); /* false */ - } - else - req.r.rtm_type = RTN_UNICAST; - } - if (dest) addattr_l (&req.n, sizeof req, RTA_DST, dest, bytelen); - if (!discard) - { - if (gate) - addattr_l (&req.n, sizeof req, RTA_GATEWAY, gate, bytelen); - if (index > 0) - addattr32 (&req.n, sizeof req, RTA_OIF, index); - } + if (gate) + addattr_l (&req.n, sizeof req, RTA_GATEWAY, gate, bytelen); - /* Destination netlink address. */ - memset (&snl, 0, sizeof snl); - snl.nl_family = AF_NETLINK; + if (index > 0) + addattr32 (&req.n, sizeof req, RTA_OIF, index); /* Talk to netlink socket. */ - ret = netlink_talk (&req.n, &netlink_cmd); - if (ret < 0) - return -1; - - return 0; + netlink_talk (&req.n, &netlink_cmd); } /* Routing table change via netlink interface. */ @@ -1341,11 +1341,22 @@ netlink_route_multipath (int cmd, struct prefix *p, struct rib *rib, else discard = 0; + switch (rib->type) { + case ZEBRA_ROUTE_KERNEL: + /* FIXME: should remember original protocol from RTM_NEWLINK */ + req.r.rtm_protocol = RTPROT_BOOT; + break; + case ZEBRA_ROUTE_CONNECT: + req.r.rtm_protocol = RTPROT_KERNEL; + break; + default: + req.r.rtm_protocol = RTPROT_ZEBRA; + } + + req.r.rtm_scope = rib->scope; + if (cmd == RTM_NEWROUTE) { - req.r.rtm_protocol = RTPROT_ZEBRA; - req.r.rtm_scope = RT_SCOPE_UNIVERSE; - if (discard) { if (rib->flags & ZEBRA_FLAG_BLACKHOLE) @@ -1361,8 +1372,8 @@ netlink_route_multipath (int cmd, struct prefix *p, struct rib *rib, addattr_l (&req.n, sizeof req, RTA_DST, &p->u.prefix, bytelen); - /* Metric. */ - addattr32 (&req.n, sizeof req, RTA_PRIORITY, rib->metric); + if (rib->type != ZEBRA_ROUTE_CONNECT) + addattr32 (&req.n, sizeof req, RTA_PRIORITY, rib->metric); if (discard) { @@ -1761,12 +1772,12 @@ kernel_delete_ipv6 (struct prefix *p, struct rib *rib) } /* Delete IPv6 route from the kernel. */ -int +void kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, - unsigned int index, int flags, int table) + unsigned int index, int table) { - return netlink_route (RTM_DELROUTE, AF_INET6, &dest->prefix, - dest->prefixlen, gate, index, flags, table); + netlink_delroute (AF_INET6, &dest->prefix, + dest->prefixlen, gate, index, table, RTPROT_ZEBRA); } #endif /* HAVE_IPV6 */ @@ -1855,19 +1866,13 @@ kernel_read (struct thread *thread) static void netlink_install_filter (int sock, __u32 pid) { struct sock_filter filter[] = { - /* 0: ldh [4] */ - BPF_STMT(BPF_LD|BPF_ABS|BPF_H, offsetof(struct nlmsghdr, nlmsg_type)), - /* 1: jeq 0x18 jt 3 jf 6 */ - BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_NEWROUTE), 1, 0), - /* 2: jeq 0x19 jt 3 jf 6 */ - BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_DELROUTE), 0, 3), - /* 3: ldw [12] */ + /* 0: ldw [12] */ BPF_STMT(BPF_LD|BPF_ABS|BPF_W, offsetof(struct nlmsghdr, nlmsg_pid)), - /* 4: jeq XX jt 5 jf 6 */ + /* 1: jeq XX jt 2 jf 3 */ BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htonl(pid), 0, 1), - /* 5: ret 0 (skip) */ + /* 2: ret 0 (skip) */ BPF_STMT(BPF_RET|BPF_K, 0), - /* 6: ret 0xffff (keep) */ + /* 3: ret 0xffff (keep) */ BPF_STMT(BPF_RET|BPF_K, 0xffff), }; diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 1b8ded7e..9bbecb95 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -509,13 +509,13 @@ kernel_delete_ipv6 (struct prefix *p, struct rib *rib) /* Delete IPv6 route from the kernel. */ int kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, - unsigned int index, int flags, int table) + unsigned int index, int table) { int route; if (zserv_privs.change(ZPRIVS_RAISE)) zlog (NULL, LOG_ERR, "Can't raise privileges"); - route = kernel_rtm_ipv6 (RTM_DELETE, dest, gate, index, flags); + route = kernel_rtm_ipv6 (RTM_DELETE, dest, gate, index); if (zserv_privs.change(ZPRIVS_LOWER)) zlog (NULL, LOG_ERR, "Can't lower privileges"); diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 0097e28f..86956ed7 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -84,10 +84,7 @@ struct rtadv *rtadv = NULL; static struct rtadv * rtadv_new (void) { - struct rtadv *new; - new = XMALLOC (MTYPE_TMP, sizeof (struct rtadv)); - memset (new, 0, sizeof (struct rtadv)); - return new; + return XCALLOC (MTYPE_TMP, sizeof (struct rtadv)); } #if 0 @@ -531,12 +528,7 @@ rtadv_make_socket (void) static struct rtadv_prefix * rtadv_prefix_new () { - struct rtadv_prefix *new; - - new = XMALLOC (MTYPE_RTADV_PREFIX, sizeof (struct rtadv_prefix)); - memset (new, 0, sizeof (struct rtadv_prefix)); - - return new; + return XCALLOC (MTYPE_RTADV_PREFIX, sizeof (struct rtadv_prefix)); } static void diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 545481d1..69249779 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -44,6 +44,9 @@ /* Default rtm_table for all clients */ extern struct zebra_t zebrad; +/* Should kernel routes be removed on link down? */ +int rib_system_routes = 0; + /* Hold time for RIB process, should be very minimal. * it is useful to able to set it otherwise for testing, hence exported * as global here for test-rig code. @@ -209,14 +212,16 @@ nexthop_free (struct nexthop *nexthop) } struct nexthop * -nexthop_ifindex_add (struct rib *rib, unsigned int ifindex) +nexthop_ifindex_add (struct rib *rib, unsigned int ifindex, + struct in_addr *src) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IFINDEX; nexthop->ifindex = ifindex; + if (src) + nexthop->src.ipv4 = *src; nexthop_add (rib, nexthop); @@ -228,8 +233,7 @@ nexthop_ifname_add (struct rib *rib, char *ifname) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IFNAME; nexthop->ifname = XSTRDUP (0, ifname); @@ -243,8 +247,7 @@ nexthop_ipv4_add (struct rib *rib, struct in_addr *ipv4, struct in_addr *src) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV4; nexthop->gate.ipv4 = *ipv4; if (src) @@ -261,8 +264,7 @@ nexthop_ipv4_ifindex_add (struct rib *rib, struct in_addr *ipv4, { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV4_IFINDEX; nexthop->gate.ipv4 = *ipv4; if (src) @@ -280,8 +282,7 @@ nexthop_ipv6_add (struct rib *rib, struct in6_addr *ipv6) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV6; nexthop->gate.ipv6 = *ipv6; @@ -296,8 +297,7 @@ nexthop_ipv6_ifname_add (struct rib *rib, struct in6_addr *ipv6, { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV6_IFNAME; nexthop->gate.ipv6 = *ipv6; nexthop->ifname = XSTRDUP (0, ifname); @@ -313,8 +313,7 @@ nexthop_ipv6_ifindex_add (struct rib *rib, struct in6_addr *ipv6, { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV6_IFINDEX; nexthop->gate.ipv6 = *ipv6; nexthop->ifindex = ifindex; @@ -330,8 +329,7 @@ nexthop_blackhole_add (struct rib *rib) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_BLACKHOLE; SET_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE); @@ -444,7 +442,7 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, if (nexthop->type == NEXTHOP_TYPE_IPV4) nexthop->ifindex = newhop->ifindex; } - else + else { if (nexthop->ifindex != newhop->ifindex || CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) @@ -453,8 +451,8 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, return 1; } } - else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL) || - match->type == ZEBRA_ROUTE_STATIC) + else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL) + || match->type == ZEBRA_ROUTE_STATIC) { for (newhop = match->nexthop; newhop; newhop = newhop->next) if (CHECK_FLAG (newhop->flags, NEXTHOP_FLAG_FIB) @@ -479,8 +477,6 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, || newhop->ifindex != nexthop->ifindex || nexthop->gate.ipv4.s_addr != newhop->gate.ipv4.s_addr) SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED); - - return 1; } return 0; @@ -573,7 +569,7 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, if (nexthop->type == NEXTHOP_TYPE_IPV6) nexthop->ifindex = newhop->ifindex; } - else + else { if (nexthop->ifindex != newhop->ifindex || CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) @@ -582,7 +578,8 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, return 1; } } - else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL)) + else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL) || + match->type == ZEBRA_ROUTE_STATIC) { for (newhop = match->nexthop; newhop; newhop = newhop->next) if (CHECK_FLAG (newhop->flags, NEXTHOP_FLAG_FIB) @@ -607,8 +604,8 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, } else if (! CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE) || newhop->ifindex != nexthop->ifindex - || !IPV6_ADDR_SAME(&nexthop->gate.ipv6, - &newhop->gate.ipv4)) + || !IPV6_ADDR_SAME(&nexthop->gate.ipv6, + &newhop->gate.ipv6)) SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED); return 1; @@ -654,12 +651,11 @@ rib_match_ipv4 (struct in_addr addr) for (match = rn->info; match; match = match->next) { if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) - continue; + continue; if (CHECK_FLAG (match->flags, ZEBRA_FLAG_SELECTED)) break; } - /* If there is no selected route or matched route is EGP, go up tree. */ if (! match @@ -710,7 +706,6 @@ rib_lookup_ipv4 (struct prefix_ipv4 *p) /* Unlock node. */ route_unlock_node (rn); - /* Pick up selected route. */ for (match = rn->info; match; match = match->next) { if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) @@ -786,24 +781,24 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate) /* Ok, we have a cood candidate, let's check it's nexthop list... */ for (nexthop = match->nexthop; nexthop; nexthop = nexthop->next) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) - { - /* We are happy with either direct or recursive hexthop */ - if (nexthop->gate.ipv4.s_addr == qgate->sin.sin_addr.s_addr || - nexthop->rgate.ipv4.s_addr == qgate->sin.sin_addr.s_addr) - return ZEBRA_RIB_FOUND_EXACT; - else { - if (IS_ZEBRA_DEBUG_RIB) - { - char gate_buf[INET_ADDRSTRLEN], rgate_buf[INET_ADDRSTRLEN], qgate_buf[INET_ADDRSTRLEN]; - inet_ntop (AF_INET, &nexthop->gate.ipv4.s_addr, gate_buf, INET_ADDRSTRLEN); - inet_ntop (AF_INET, &nexthop->rgate.ipv4.s_addr, rgate_buf, INET_ADDRSTRLEN); - inet_ntop (AF_INET, &qgate->sin.sin_addr.s_addr, qgate_buf, INET_ADDRSTRLEN); - zlog_debug ("%s: qgate == %s, gate == %s, rgate == %s", __func__, qgate_buf, gate_buf, rgate_buf); - } - return ZEBRA_RIB_FOUND_NOGATE; + /* We are happy with either direct or recursive hexthop */ + if (nexthop->gate.ipv4.s_addr == qgate->sin.sin_addr.s_addr || + nexthop->rgate.ipv4.s_addr == qgate->sin.sin_addr.s_addr) + return ZEBRA_RIB_FOUND_EXACT; + else + { + if (IS_ZEBRA_DEBUG_RIB) + { + char gate_buf[INET_ADDRSTRLEN], rgate_buf[INET_ADDRSTRLEN], qgate_buf[INET_ADDRSTRLEN]; + inet_ntop (AF_INET, &nexthop->gate.ipv4.s_addr, gate_buf, INET_ADDRSTRLEN); + inet_ntop (AF_INET, &nexthop->rgate.ipv4.s_addr, rgate_buf, INET_ADDRSTRLEN); + inet_ntop (AF_INET, &qgate->sin.sin_addr.s_addr, qgate_buf, INET_ADDRSTRLEN); + zlog_debug ("%s: qgate == %s, gate == %s, rgate == %s", __func__, qgate_buf, gate_buf, rgate_buf); + } + return ZEBRA_RIB_FOUND_NOGATE; + } } - } return ZEBRA_RIB_NOTFOUND; } @@ -838,7 +833,7 @@ rib_match_ipv6 (struct in6_addr *addr) for (match = rn->info; match; match = match->next) { if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) - continue; + continue; if (CHECK_FLAG (match->flags, ZEBRA_FLAG_SELECTED)) break; } @@ -872,8 +867,10 @@ rib_match_ipv6 (struct in6_addr *addr) } #endif /* HAVE_IPV6 */ -#define RIB_SYSTEM_ROUTE(R) \ +#define RIB_SYSTEM_ROUTE(R) \ ((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT) +#define RIB_SHOULD_UPDATE(R) \ + (! CHECK_FLAG((R)->status, RIB_ENTRY_PRESERVE) ) /* This function verifies reachability of one given nexthop, which can be * numbered or unnumbered, IPv4 or IPv6. The result is unconditionally stored @@ -884,7 +881,6 @@ rib_match_ipv6 (struct in6_addr *addr) * * The return value is the final value of 'ACTIVE' flag. */ - static int nexthop_active_check (struct route_node *rn, struct rib *rib, struct nexthop *nexthop, int set) @@ -900,7 +896,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, { case NEXTHOP_TYPE_IFINDEX: ifp = if_lookup_by_index (nexthop->ifindex); - if (ifp && if_is_operative (ifp)) + if (ifp && if_is_operative(ifp)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); else UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); @@ -909,7 +905,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, family = AFI_IP6; case NEXTHOP_TYPE_IFNAME: ifp = if_lookup_by_name (nexthop->ifname); - if (ifp && if_is_operative (ifp)) + if (ifp && if_is_operative(ifp)) { if (set) nexthop->ifindex = ifp->ifindex; @@ -943,7 +939,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, if (IN6_IS_ADDR_LINKLOCAL (&nexthop->gate.ipv6)) { ifp = if_lookup_by_index (nexthop->ifindex); - if (ifp && if_is_operative (ifp)) + if (ifp && if_is_operative(ifp)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); else UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); @@ -972,7 +968,8 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, return CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); rmap = 0; - if (rib->type < ZEBRA_ROUTE_MAX && proto_rm[family][rib->type]) + if (rib->type >= 0 && rib->type < ZEBRA_ROUTE_MAX && + proto_rm[family][rib->type]) rmap = route_map_lookup_by_name (proto_rm[family][rib->type]); if (!rmap && proto_rm[family][ZEBRA_ROUTE_MAX]) rmap = route_map_lookup_by_name (proto_rm[family][ZEBRA_ROUTE_MAX]); @@ -1056,8 +1053,6 @@ rib_uninstall_kernel (struct route_node *rn, struct rib *rib) break; #ifdef HAVE_IPV6 case AF_INET6: - if (IS_ZEBRA_DEBUG_RIB) - zlog_debug ("%s: calling kernel_delete_ipv4 (%p, %p)", __func__, rn, rib); ret = kernel_delete_ipv6 (&rn->p, rib); break; #endif /* HAVE_IPV6 */ @@ -1076,7 +1071,7 @@ rib_uninstall (struct route_node *rn, struct rib *rib) if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) { redistribute_delete (&rn->p, rib); - if (! RIB_SYSTEM_ROUTE (rib)) + if (RIB_SHOULD_UPDATE (rib)) rib_uninstall_kernel (rn, rib); UNSET_FLAG (rib->flags, ZEBRA_FLAG_SELECTED); } @@ -1201,17 +1196,17 @@ rib_process (struct route_node *rn) if (CHECK_FLAG (select->flags, ZEBRA_FLAG_CHANGED)) { redistribute_delete (&rn->p, select); - if (! RIB_SYSTEM_ROUTE (select)) + if (RIB_SHOULD_UPDATE (select)) rib_uninstall_kernel (rn, select); /* Set real nexthop. */ nexthop_active_update (rn, select, 1); - if (! RIB_SYSTEM_ROUTE (select)) + if (RIB_SHOULD_UPDATE (select)) rib_install_kernel (rn, select); redistribute_add (&rn->p, select); } - else if (! RIB_SYSTEM_ROUTE (select)) + else if (RIB_SHOULD_UPDATE (select)) { /* Housekeeping code to deal with race conditions in kernel with linux @@ -1242,7 +1237,7 @@ rib_process (struct route_node *rn) zlog_debug ("%s: %s/%d: Removing existing route, fib %p", __func__, buf, rn->p.prefixlen, fib); redistribute_delete (&rn->p, fib); - if (! RIB_SYSTEM_ROUTE (fib)) + if (RIB_SHOULD_UPDATE (fib)) rib_uninstall_kernel (rn, fib); UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED); @@ -1262,7 +1257,7 @@ rib_process (struct route_node *rn) /* Set real nexthop. */ nexthop_active_update (rn, select, 1); - if (! RIB_SYSTEM_ROUTE (select)) + if (RIB_SHOULD_UPDATE (select)) rib_install_kernel (rn, select); SET_FLAG (select->flags, ZEBRA_FLAG_SELECTED); redistribute_add (&rn->p, select); @@ -1282,21 +1277,25 @@ end: zlog_debug ("%s: %s/%d: rn %p dequeued", __func__, buf, rn->p.prefixlen, rn); } -/* Take a list of route_node structs and return 1, if there was a record picked from - * it and processed by rib_process(). Don't process more, than one RN record; operate - * only in the specified sub-queue. +/* Take a list of route_node structs and return 1, if there was a record + * picked from it and processed by rib_process(). Don't process more, + * than one RN record; operate only in the specified sub-queue. */ -unsigned int +static unsigned int process_subq (struct list * subq, u_char qindex) { - struct listnode *lnode; + struct listnode *lnode = listhead (subq); struct route_node *rnode; - if (!(lnode = listhead (subq))) + + if (!lnode) return 0; + rnode = listgetdata (lnode); rib_process (rnode); + if (rnode->info) /* The first RIB record is holding the flags bitmask. */ UNSET_FLAG (((struct rib *)rnode->info)->rn_status, RIB_ROUTE_QUEUED(qindex)); + route_unlock_node (rnode); list_delete_node (subq, lnode); return 1; @@ -1310,65 +1309,66 @@ static wq_item_status meta_queue_process (struct work_queue *dummy, void *data) { struct meta_queue * mq = data; - u_char i; + unsigned i; + for (i = 0; i < MQ_SIZE; i++) if (process_subq (mq->subq[i], i)) - { - mq->size--; - break; - } + { + mq->size--; + break; + } return mq->size ? WQ_REQUEUE : WQ_SUCCESS; } -/* Look into the RN and queue it into one or more priority queues, increasing the size - * for each data push done. +/* Map from rib types to queue type (priority) in meta queue */ +static const u_char meta_queue_map[ZEBRA_ROUTE_MAX] = { + [ZEBRA_ROUTE_SYSTEM] = 4, + [ZEBRA_ROUTE_KERNEL] = 0, + [ZEBRA_ROUTE_CONNECT] = 0, + [ZEBRA_ROUTE_STATIC] = 1, + [ZEBRA_ROUTE_RIP] = 2, + [ZEBRA_ROUTE_RIPNG] = 2, + [ZEBRA_ROUTE_OSPF] = 2, + [ZEBRA_ROUTE_OSPF6] = 2, + [ZEBRA_ROUTE_ISIS] = 2, + [ZEBRA_ROUTE_BGP] = 3, + [ZEBRA_ROUTE_HSLS] = 4, +}; + +/* Look into the RN and queue it into one or more priority queues, + * increasing the size for each data push done. */ -void rib_meta_queue_add (struct meta_queue *mq, struct route_node *rn) +static void +rib_meta_queue_add (struct meta_queue *mq, struct route_node *rn) { - u_char qindex; struct rib *rib; char buf[INET6_ADDRSTRLEN]; + if (IS_ZEBRA_DEBUG_RIB_Q) inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN); + for (rib = rn->info; rib; rib = rib->next) - { - switch (rib->type) - { - case ZEBRA_ROUTE_KERNEL: - case ZEBRA_ROUTE_CONNECT: - qindex = 0; - break; - case ZEBRA_ROUTE_STATIC: - qindex = 1; - break; - case ZEBRA_ROUTE_RIP: - case ZEBRA_ROUTE_RIPNG: - case ZEBRA_ROUTE_OSPF: - case ZEBRA_ROUTE_OSPF6: - case ZEBRA_ROUTE_ISIS: - qindex = 2; - break; - case ZEBRA_ROUTE_BGP: - qindex = 3; - break; - default: - qindex = 4; - break; - } - /* Invariant: at this point we always have rn->info set. */ - if (CHECK_FLAG (((struct rib *)rn->info)->rn_status, RIB_ROUTE_QUEUED(qindex))) { + u_char qindex = meta_queue_map[rib->type]; + + /* Invariant: at this point we always have rn->info set. */ + if (CHECK_FLAG (((struct rib *)rn->info)->rn_status, RIB_ROUTE_QUEUED(qindex))) + { + if (IS_ZEBRA_DEBUG_RIB_Q) + zlog_debug ("%s: %s/%d: rn %p is already queued in sub-queue %u", + __func__, buf, rn->p.prefixlen, rn, qindex); + continue; + } + + SET_FLAG (((struct rib *)rn->info)->rn_status, RIB_ROUTE_QUEUED(qindex)); + listnode_add (mq->subq[qindex], rn); + route_lock_node (rn); + mq->size++; + if (IS_ZEBRA_DEBUG_RIB_Q) - zlog_debug ("%s: %s/%d: rn %p is already queued in sub-queue %u", __func__, buf, rn->p.prefixlen, rn, qindex); - continue; - } - SET_FLAG (((struct rib *)rn->info)->rn_status, RIB_ROUTE_QUEUED(qindex)); - listnode_add (mq->subq[qindex], rn); - route_lock_node (rn); - mq->size++; - if (IS_ZEBRA_DEBUG_RIB_Q) - zlog_debug ("%s: %s/%d: queued rn %p into sub-queue %u", __func__, buf, rn->p.prefixlen, rn, qindex); - } + zlog_debug ("%s: %s/%d: queued rn %p into sub-queue %u", + __func__, buf, rn->p.prefixlen, rn, qindex); + } } /* Add route_node to work queue and schedule processing */ @@ -1420,27 +1420,24 @@ rib_queue_add (struct zebra_t *zebra, struct route_node *rn) return; } -/* Create new meta queue. A destructor function doesn't seem to be necessary here. */ -struct meta_queue * -meta_queue_new () +/* Create new meta queue. + A destructor function doesn't seem to be necessary here. + */ +static struct meta_queue * +meta_queue_new (void) { struct meta_queue *new; - unsigned i, failed = 0; + unsigned i; + + new = XCALLOC (MTYPE_WORK_QUEUE, sizeof (struct meta_queue)); + assert(new); - if ((new = XCALLOC (MTYPE_WORK_QUEUE, sizeof (struct meta_queue))) == NULL) - return NULL; for (i = 0; i < MQ_SIZE; i++) - if ((new->subq[i] = list_new ()) == NULL) - failed = 1; - if (failed) - { - for (i = 0; i < MQ_SIZE; i++) - if (new->subq[i]) - list_delete (new->subq[i]); - XFREE (MTYPE_WORK_QUEUE, new); - return NULL; - } - new->size = 0; + { + new->subq[i] = list_new (); + assert(new->subq[i]); + } + return new; } @@ -1626,7 +1623,7 @@ int rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, struct in_addr *gate, struct in_addr *src, unsigned int ifindex, u_int32_t vrf_id, - u_int32_t metric, u_char distance) + u_int32_t metric, u_int8_t distance, u_int8_t scope) { struct rib *rib; struct rib *same = NULL; @@ -1634,6 +1631,7 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, struct route_node *rn; struct nexthop *nexthop; + /* Lookup table. */ table = vrf_table (AFI_IP, SAFI_UNICAST, 0); if (! table) @@ -1689,6 +1687,7 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, rib->table = vrf_id; rib->nexthop_num = 0; rib->uptime = time (NULL); + rib->scope = scope; /* Nexthop settings. */ if (gate) @@ -1699,12 +1698,18 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, nexthop_ipv4_add (rib, gate, src); } else - nexthop_ifindex_add (rib, ifindex); + nexthop_ifindex_add (rib, ifindex, src); /* If this route is kernel route, set FIB flag to the route. */ - if (type == ZEBRA_ROUTE_KERNEL || type == ZEBRA_ROUTE_CONNECT) - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) - SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); + if (RIB_SYSTEM_ROUTE (rib)) + { + /* Mark system routes with the don't touch me flag */ + if (! rib_system_routes) + SET_FLAG(rib->status, RIB_ENTRY_PRESERVE); + + for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); + } /* Link new rib to node.*/ if (IS_ZEBRA_DEBUG_RIB) @@ -1740,7 +1745,7 @@ void rib_dump (const char * func, const struct prefix_ipv4 * p, const struct rib "%s: refcnt == %lu, uptime == %lu, type == %u, table == %d", func, rib->refcnt, - rib->uptime, + (unsigned long) rib->uptime, rib->type, rib->table ); @@ -1862,8 +1867,7 @@ void rib_lookup_and_pushup (struct prefix_ipv4 * p) */ for (rib = rn->info; rib; rib = rib->next) { - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) && - ! RIB_SYSTEM_ROUTE (rib)) + if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) && RIB_SHOULD_UPDATE (rib)) { changed = 1; if (IS_ZEBRA_DEBUG_RIB) @@ -2281,8 +2285,7 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, static_delete_ipv4 (p, gate, ifname, update->distance, vrf_id); /* Make new static route structure. */ - si = XMALLOC (MTYPE_STATIC_IPV4, sizeof (struct static_ipv4)); - memset (si, 0, sizeof (struct static_ipv4)); + si = XCALLOC (MTYPE_STATIC_IPV4, sizeof (struct static_ipv4)); si->type = type; si->distance = distance; @@ -2413,7 +2416,7 @@ rib_bogus_ipv6 (int type, struct prefix_ipv6 *p, if (type == ZEBRA_ROUTE_KERNEL && IN6_IS_ADDR_UNSPECIFIED (&p->prefix) && p->prefixlen == 96 && gate && IN6_IS_ADDR_UNSPECIFIED (gate)) { - kernel_delete_ipv6_old (p, gate, ifindex, 0, table); + kernel_delete_ipv6_old (p, gate, ifindex, table); return 1; } return 0; @@ -2495,12 +2498,18 @@ rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p, nexthop_ipv6_add (rib, gate); } else - nexthop_ifindex_add (rib, ifindex); + nexthop_ifindex_add (rib, ifindex, NULL); /* If this route is kernel route, set FIB flag to the route. */ if (type == ZEBRA_ROUTE_KERNEL || type == ZEBRA_ROUTE_CONNECT) - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) - SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); + { + /* Mark system routes with the don't touch me flag */ + if (! rib_system_routes) + SET_FLAG(rib->status, RIB_ENTRY_PRESERVE); + + for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); + } /* Link new rib to node.*/ rib_addnode (rn, rib); @@ -2831,8 +2840,7 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, } /* Make new static route structure. */ - si = XMALLOC (MTYPE_STATIC_IPV6, sizeof (struct static_ipv6)); - memset (si, 0, sizeof (struct static_ipv6)); + si = XCALLOC (MTYPE_STATIC_IPV6, sizeof (struct static_ipv6)); si->type = type; si->distance = distance; @@ -3049,7 +3057,7 @@ rib_close_table (struct route_table *table) for (rn = route_top (table); rn; rn = route_next (rn)) for (rib = rn->info; rib; rib = rib->next) { - if (! RIB_SYSTEM_ROUTE (rib) + if (RIB_SHOULD_UPDATE (rib) && CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) rib_uninstall_kernel (rn, rib); } diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 0c313921..f50ab05e 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2030,10 +2030,10 @@ static int config_write_protocol(struct vty *vty) } /* table node for protocol filtering */ -struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 }; +static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 }; /* IP node for static routes. */ -struct cmd_node ip_node = { IP_NODE, "", 1 }; +static struct cmd_node ip_node = { IP_NODE, "", 1 }; /* Route VTY. */ void diff --git a/zebra/zserv.c b/zebra/zserv.c index ef79eaad..76e74088 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -773,7 +773,7 @@ zread_ipv4_add (struct zserv *client, u_short length) { case ZEBRA_NEXTHOP_IFINDEX: ifindex = stream_getl (s); - nexthop_ifindex_add (rib, ifindex); + nexthop_ifindex_add (rib, ifindex, NULL); break; case ZEBRA_NEXTHOP_IFNAME: ifname_len = stream_getc (s); @@ -1569,7 +1569,7 @@ config_write_table (struct vty *vty) } /* table node for routing tables. */ -struct cmd_node table_node = +static struct cmd_node table_node = { TABLE_NODE, "", /* This node has no interface. */ @@ -1689,7 +1689,7 @@ config_write_forwarding (struct vty *vty) } /* table node for routing tables. */ -struct cmd_node forwarding_node = +static struct cmd_node forwarding_node = { FORWARDING_NODE, "", /* This node has no interface. */ |