diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 23 | ||||
-rw-r--r-- | lib/command.c | 12 | ||||
-rw-r--r-- | lib/distribute.c | 11 | ||||
-rw-r--r-- | lib/filter.c | 4 | ||||
-rw-r--r-- | lib/hash.c | 7 | ||||
-rw-r--r-- | lib/hash.h | 6 | ||||
-rw-r--r-- | lib/if_rmap.c | 11 | ||||
-rw-r--r-- | lib/keychain.c | 14 | ||||
-rw-r--r-- | lib/linklist.c | 12 | ||||
-rw-r--r-- | lib/log.c | 6 | ||||
-rw-r--r-- | lib/log.h | 49 | ||||
-rw-r--r-- | lib/md5.c | 2 | ||||
-rw-r--r-- | lib/md5.h | 2 | ||||
-rw-r--r-- | lib/memory.c | 2 | ||||
-rw-r--r-- | lib/memtypes.awk | 2 | ||||
-rw-r--r-- | lib/memtypes.c | 3 | ||||
-rw-r--r-- | lib/plist.c | 4 | ||||
-rw-r--r-- | lib/route_types.awk | 2 | ||||
-rw-r--r-- | lib/routemap.c | 2 | ||||
-rw-r--r-- | lib/smux.c | 2 | ||||
-rw-r--r-- | lib/sockopt.c | 85 | ||||
-rw-r--r-- | lib/sockopt.h | 30 | ||||
-rw-r--r-- | lib/sockunion.c | 11 | ||||
-rw-r--r-- | lib/str.h | 2 | ||||
-rw-r--r-- | lib/stream.c | 4 | ||||
-rw-r--r-- | lib/stream.h | 4 | ||||
-rw-r--r-- | lib/thread.c | 6 | ||||
-rw-r--r-- | lib/vty.h | 7 | ||||
-rw-r--r-- | lib/workqueue.c | 16 | ||||
-rw-r--r-- | lib/workqueue.h | 3 | ||||
-rw-r--r-- | lib/zassert.h | 16 | ||||
-rw-r--r-- | lib/zclient.c | 3 | ||||
-rw-r--r-- | lib/zebra.h | 1 |
33 files changed, 194 insertions, 170 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index da0fa8ca..688c44f7 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,26 @@ +2008-07-21 Paul Jakma <paul.jakma@sun.com> + + * sockunion.c: ifdef out various places that converted + v4mapped sockets to pure v4. Doesn't seem necessary at all, + presumably a workaround for now historical inet_ntop bugs (?) + +2008-07-21 Michael H. Warfield <mhw@wittsend.com> + YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> + + * sockopt.{c,h}: (sockopt_tcp_signature) Add TCP-MD5SIG support. + +2008-06-07 Paul Jakma <paul@jakma.org> + + * stream.{c,h}: (stream_{put,write}) add const qualifier to source + argument. Change u_char to void *. + +2008-06-02 Denis Ovsienko + + * workqueue.[ch]: completely drop WQ_AIM_HEAD flag and + work_queue_aim_head() function, they aren't needed any more + with the new meta queue structure; (work_queue_run) don't + increment the counter on work item requeueing + 2008-02-28 Paul Jakma <paul.jakma@sun.com> * log.c: (mes_lookup) Sowmini Varadhan diagnosed a problem where diff --git a/lib/command.c b/lib/command.c index f3d96ede..a9085eb7 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1,5 +1,5 @@ /* - $Id$ + $Id: command.c,v 1.55 2007/04/28 22:14:10 ajs Exp $ Command interpreter routine for virtual terminal [aka TeletYpe] Copyright (C) 1997, 98, 99 Kunihiro Ishiguro @@ -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. */ @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: log.c,v 1.34 2008/02/28 23:26:02 paul Exp $ * * Logging of zebra * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro @@ -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) @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: log.h,v 1.20 2008/02/28 23:26:02 paul Exp $ * * Zebra logging funcions. * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro @@ -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); @@ -1,6 +1,6 @@ /* $USAGI: md5.c,v 1.2 2000/11/02 11:59:24 yoshfuji Exp $ */ /* $KAME: md5.c,v 1.2 2000/05/27 07:07:48 jinmei Exp $ */ -/* $Id$ */ +/* $Id: md5.c,v 1.6 2006/01/17 23:39:04 vincent Exp $ */ /* * Copyright (C) 2004 6WIND @@ -1,6 +1,6 @@ /* $USAGI: md5.h,v 1.2 2000/11/02 11:59:25 yoshfuji Exp $ */ /* $KAME: md5.h,v 1.4 2000/03/27 04:36:22 sumikawa Exp $ */ -/* $Id$ */ +/* $Id: md5.h,v 1.3 2006/01/17 17:40:45 paul Exp $ */ /* * Copyright (C) 2004 6WIND 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/memtypes.awk b/lib/memtypes.awk index fbd5e251..5429f6e8 100644 --- a/lib/memtypes.awk +++ b/lib/memtypes.awk @@ -1,4 +1,4 @@ -# $Id$ +# $Id: memtypes.awk,v 1.4 2006/03/30 14:30:19 paul Exp $ # # Scan a file of memory definitions (see eg memtypes.c) and generate # a corresponding header file with an enum of the MTYPE's and declarations diff --git a/lib/memtypes.c b/lib/memtypes.c index f1b10e71..5c2c9034 100644 --- a/lib/memtypes.c +++ b/lib/memtypes.c @@ -6,7 +6,7 @@ * The script is sensitive to the format (though not whitespace), see * the top of memtypes.awk for more details. * - * $Id$ + * $Id: memtypes.c,v 1.13 2008/07/21 21:02:50 paul Exp $ */ #include "zebra.h" @@ -95,6 +95,7 @@ struct memory_list memory_list_bgp[] = { MTYPE_BGP_PEER_HOST, "BGP peer hostname" }, { MTYPE_PEER_GROUP, "Peer group" }, { MTYPE_PEER_DESC, "Peer description" }, + { MTYPE_PEER_PASSWORD, "Peer password string" }, { MTYPE_ATTR, "BGP attribute" }, { MTYPE_ATTR_EXTRA, "BGP extra attributes" }, { MTYPE_AS_PATH, "BGP aspath" }, 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/route_types.awk b/lib/route_types.awk index eb3d382a..6078406c 100644 --- a/lib/route_types.awk +++ b/lib/route_types.awk @@ -1,4 +1,4 @@ -# $Id$ +# $Id: route_types.awk,v 1.3 2006/06/27 10:42:18 paul Exp $ # # Scan a file of route-type definitions (see eg route_types.txt) and # generate a corresponding header file with: 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.c b/lib/sockopt.c index e0027e88..2f01199a 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -22,6 +22,7 @@ #include <zebra.h> #include "log.h" #include "sockopt.h" +#include "sockunion.h" int setsockopt_so_recvbuf (int sock, int size) @@ -494,35 +495,69 @@ sockopt_iphdrincl_swab_systoh (struct ip *iph) iph->ip_id = ntohs(iph->ip_id); } -#if defined(HAVE_TCP_MD5SIG) int -sockopt_tcp_signature (int sock, struct sockaddr_in *sin, const char *password) +sockopt_tcp_signature (int sock, union sockunion *su, const char *password) { - int keylen = password ? strlen(password) : 0; - -#if defined(GNU_LINUX) - - struct tcp_md5sig md5sig; - - bzero ((char *)&md5sig, sizeof(md5sig)); - memcpy (&md5sig.tcpm_addr, sin, sizeof(*sin)); - md5sig.tcpm_keylen = keylen; - if (keylen) - memcpy (md5sig.tcpm_key, password, keylen); - - return setsockopt (sock, IPPROTO_TCP, TCP_MD5SIG, &md5sig, sizeof md5sig); - -#else /* !GNU_LINUX */ - - int enable = keylen ? (TCP_SIG_SPI_BASE + sin->sin_port) : 0; - +#if HAVE_DECL_TCP_MD5SIG +#ifndef GNU_LINUX /* * XXX Need to do PF_KEY operation here to add/remove an SA entry, * and add/remove an SP entry for this peer's packet flows also. */ - return setsockopt (sock, IPPROTO_TCP, TCP_MD5SIG, &enable, - sizeof(enable)); - -#endif /* !GNU_LINUX */ -} + int md5sig = password && *password ? 1 : 0; +#else + int keylen = password ? strlen (password) : 0; + struct tcp_md5sig md5sig; + union sockunion *su2, *susock; + int ret; + + /* Figure out whether the socket and the sockunion are the same family.. + * adding AF_INET to AF_INET6 needs to be v4 mapped, you'd think.. + */ + if (!(susock = sockunion_getsockname (sock))) + return -1; + + if (susock->sa.sa_family == su->sa.sa_family) + su2 = su; + else + { + /* oops.. */ + su2 = susock; + + if (su2->sa.sa_family == AF_INET) + { + sockunion_free (susock); + return -1; + }; + + /* If this does not work, then all users of this sockopt will need to + * differentiate between IPv4 and IPv6, and keep seperate sockets for + * each. + * + * Sadly, it doesn't seem to work at present. It's unknown whether + * this is a bug or not. + */ + if (su2->sa.sa_family == AF_INET6 + && su->sa.sa_family == AF_INET) + { + su2->sin6.sin6_family = AF_INET6; + /* V4Map the address */ + memset (&su2->sin6.sin6_addr, 0, sizeof (struct in6_addr)); + su2->sin6.sin6_addr.s6_addr32[2] = htonl(0xffff); + memcpy (&su2->sin6.sin6_addr.s6_addr32[3], &su->sin.sin_addr, 4); + } + } + + memset (&md5sig, 0, sizeof (md5sig)); + memcpy (&md5sig.tcpm_addr, su2, sizeof (*su2)); + md5sig.tcpm_keylen = keylen; + if (keylen) + memcpy (md5sig.tcpm_key, password, keylen); +#endif /* GNU_LINUX */ + ret = setsockopt (sock, IPPROTO_TCP, TCP_MD5SIG, &md5sig, sizeof md5sig); + sockunion_free (susock); + return ret; +#else /* HAVE_TCP_MD5SIG */ + return -2; #endif /* HAVE_TCP_MD5SIG */ +} diff --git a/lib/sockopt.h b/lib/sockopt.h index df0de61c..cb05c6fb 100644 --- a/lib/sockopt.h +++ b/lib/sockopt.h @@ -22,6 +22,8 @@ #ifndef _ZEBRA_SOCKOPT_H #define _ZEBRA_SOCKOPT_H +#include "sockunion.h" + extern int setsockopt_so_recvbuf (int sock, int size); extern int setsockopt_so_sendbuf (const int sock, int size); extern int getsockopt_so_sendbuf (const int sock); @@ -99,32 +101,6 @@ extern int getsockopt_ifindex (int, struct msghdr *); extern void sockopt_iphdrincl_swab_htosys (struct ip *iph); extern void sockopt_iphdrincl_swab_systoh (struct ip *iph); -#if defined(HAVE_TCP_MD5SIG) - -#if defined(GNU_LINUX) && !defined(TCP_MD5SIG) - -/* XXX these will come from <linux/tcp.h> eventually */ - -#define TCP_MD5SIG 14 -#define TCP_MD5SIG_MAXKEYLEN 80 - -struct tcp_md5sig { - struct sockaddr_storage tcpm_addr; /* address associated */ - __u16 __tcpm_pad1; /* zero */ - __u16 tcpm_keylen; /* key length */ - __u32 __tcpm_pad2; /* zero */ - __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* key (binary) */ -}; - -#endif /* defined(GNU_LINUX) && !defined(TCP_MD5SIG) */ - -#if !defined(GNU_LINUX) && !defined(TCP_SIG_SPI_BASE) -#define TCP_SIG_SPI_BASE 1000 /* XXX this will go away */ -#endif - -extern int sockopt_tcp_signature(int sock, struct sockaddr_in *sin, +extern int sockopt_tcp_signature(int sock, union sockunion *su, const char *password); - -#endif /* HAVE_TCP_MD5SIG */ - #endif /*_ZEBRA_SOCKOPT_H */ diff --git a/lib/sockunion.c b/lib/sockunion.c index 7721666e..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. */ @@ -254,6 +253,7 @@ sockunion_accept (int sock, union sockunion *su) client_sock = accept (sock, (struct sockaddr *) su, &len); /* Convert IPv4 compatible IPv6 address to IPv4 address. */ +#if 0 #ifdef HAVE_IPV6 if (su->sa.sa_family == AF_INET6) { @@ -268,7 +268,7 @@ sockunion_accept (int sock, union sockunion *su) } } #endif /* HAVE_IPV6 */ - +#endif return client_sock; } @@ -592,6 +592,7 @@ sockunion_getsockname (int fd) su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); memcpy (su, &name, sizeof (struct sockaddr_in6)); +#if 0 if (IN6_IS_ADDR_V4MAPPED (&su->sin6.sin6_addr)) { struct sockaddr_in sin; @@ -601,6 +602,7 @@ sockunion_getsockname (int fd) sin.sin_port = su->sin6.sin6_port; memcpy (su, &sin, sizeof (struct sockaddr_in)); } +#endif return su; } #endif /* HAVE_IPV6 */ @@ -645,7 +647,7 @@ sockunion_getpeername (int fd) { su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); memcpy (su, &name, sizeof (struct sockaddr_in6)); - +#if 0 if (IN6_IS_ADDR_V4MAPPED (&su->sin6.sin6_addr)) { struct sockaddr_in sin; @@ -655,6 +657,7 @@ sockunion_getpeername (int fd) sin.sin_port = su->sin6.sin6_port; memcpy (su, &sin, sizeof (struct sockaddr_in)); } +#endif return su; } #endif /* HAVE_IPV6 */ @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: str.h,v 1.4 2005/09/19 09:53:21 hasso Exp $ */ #ifndef _ZEBRA_STR_H diff --git a/lib/stream.c b/lib/stream.c index 7034d904..983330ff 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -458,7 +458,7 @@ stream_get_ipv4 (struct stream *s) * stream_write() is saner */ void -stream_put (struct stream *s, void *src, size_t size) +stream_put (struct stream *s, const void *src, size_t size) { /* XXX: CHECK_SIZE has strange semantics. It should be deprecated */ @@ -833,7 +833,7 @@ stream_recvmsg (struct stream *s, int fd, struct msghdr *msgh, int flags, /* Write data to buffer. */ size_t -stream_write (struct stream *s, u_char *ptr, size_t size) +stream_write (struct stream *s, const void *ptr, size_t size) { CHECK_SIZE(s, size); diff --git a/lib/stream.h b/lib/stream.h index 715a083d..3e4ba7b4 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -150,7 +150,7 @@ extern void stream_forward_getp (struct stream *, size_t); extern void stream_forward_endp (struct stream *, size_t); /* steam_put: NULL source zeroes out size_t bytes of stream */ -extern void stream_put (struct stream *, void *, size_t); +extern void stream_put (struct stream *, const void *, size_t); extern int stream_putc (struct stream *, u_char); extern int stream_putc_at (struct stream *, size_t, u_char); extern int stream_putw (struct stream *, u_int16_t); @@ -200,7 +200,7 @@ extern ssize_t stream_recvmsg (struct stream *s, int fd, struct msghdr *, extern ssize_t stream_recvfrom (struct stream *s, int fd, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); -extern size_t stream_write (struct stream *, u_char *, size_t); +extern size_t stream_write (struct stream *, const void *, size_t); /* reset the stream. See Note above */ extern void stream_reset (struct stream *); 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/workqueue.c b/lib/workqueue.c index 8880b9e2..1d32d241 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -67,7 +67,6 @@ work_queue_new (struct thread_master *m, const char *queue_name) new->name = XSTRDUP (MTYPE_WORK_QUEUE_NAME, queue_name); new->master = m; SET_FLAG (new->flags, WQ_UNPLUGGED); - UNSET_FLAG (new->flags, WQ_AIM_HEAD); if ( (new->items = list_new ()) == NULL) { @@ -131,10 +130,7 @@ work_queue_add (struct work_queue *wq, void *data) } item->data = data; - if (CHECK_FLAG (wq->flags, WQ_AIM_HEAD)) - listnode_add_after (wq->items, NULL, item); - else - listnode_add (wq->items, item); + listnode_add (wq->items, item); work_queue_schedule (wq, wq->spec.hold); @@ -231,15 +227,6 @@ work_queue_unplug (struct work_queue *wq) work_queue_schedule (wq, wq->spec.hold); } -void -work_queue_aim_head (struct work_queue *wq, const unsigned aim_head) -{ - if (aim_head) - SET_FLAG (wq->flags, WQ_AIM_HEAD); - else - UNSET_FLAG (wq->flags, WQ_AIM_HEAD); -} - /* timer thread to process a work queue * will reschedule itself if required, * otherwise work_queue_item_add @@ -317,6 +304,7 @@ work_queue_run (struct thread *thread) } case WQ_REQUEUE: { + item->ran--; work_queue_item_requeue (wq, node); break; } diff --git a/lib/workqueue.h b/lib/workqueue.h index 3150c32e..f59499a0 100644 --- a/lib/workqueue.h +++ b/lib/workqueue.h @@ -48,7 +48,6 @@ struct work_queue_item }; #define WQ_UNPLUGGED (1 << 0) /* available for draining */ -#define WQ_AIM_HEAD (1 << 1) /* add new items before list head, not after tail */ struct work_queue { @@ -119,8 +118,6 @@ extern void work_queue_add (struct work_queue *, void *); extern void work_queue_plug (struct work_queue *wq); /* unplug the queue, allow it to be drained again */ extern void work_queue_unplug (struct work_queue *wq); -/* control the value for WQ_AIM_HEAD flag */ -extern void work_queue_aim_head (struct work_queue *wq, const unsigned); /* Helpers, exported for thread.c and command.c */ extern int work_queue_run (struct thread *); diff --git a/lib/zassert.h b/lib/zassert.h index 525d866c..123aee16 100644 --- a/lib/zassert.h +++ b/lib/zassert.h @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: zassert.h,v 1.2 2004/12/03 18:01:04 ajs Exp $ */ #ifndef _QUAGGA_ASSERT_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/lib/zebra.h b/lib/zebra.h index d4f68cf0..2716460f 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -163,6 +163,7 @@ typedef int socklen_t; #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <linux/filter.h> +#include <stddef.h> #else #define RT_TABLE_MAIN 0 #endif /* HAVE_NETLINK */ |