diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/command.c | 20 | ||||
-rw-r--r-- | lib/distribute.c | 7 | ||||
-rw-r--r-- | lib/filter.c | 4 | ||||
-rw-r--r-- | lib/hash.c | 3 | ||||
-rw-r--r-- | lib/if.c | 94 | ||||
-rw-r--r-- | lib/if.h | 63 | ||||
-rw-r--r-- | lib/keychain.c | 14 | ||||
-rw-r--r-- | lib/linklist.c | 12 | ||||
-rw-r--r-- | lib/log.c | 23 | ||||
-rw-r--r-- | lib/log.h | 20 | ||||
-rw-r--r-- | lib/plist.c | 4 | ||||
-rw-r--r-- | lib/routemap.c | 2 | ||||
-rw-r--r-- | lib/smux.c | 53 | ||||
-rw-r--r-- | lib/smux.h | 7 | ||||
-rw-r--r-- | lib/sockopt.c | 2 | ||||
-rw-r--r-- | lib/sockunion.c | 3 | ||||
-rw-r--r-- | lib/table.c | 18 | ||||
-rw-r--r-- | lib/table.h | 20 | ||||
-rw-r--r-- | lib/vty.c | 2 | ||||
-rw-r--r-- | lib/zclient.c | 3 |
20 files changed, 189 insertions, 185 deletions
diff --git a/lib/command.c b/lib/command.c index 4887f94f..c2e81217 100644 --- a/lib/command.c +++ b/lib/command.c @@ -41,37 +41,37 @@ 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 restricted_node = +static struct cmd_node restricted_node = { RESTRICTED_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)# ", @@ -199,8 +199,8 @@ install_node (struct cmd_node *node, static int cmp_node (const void *p, const void *q) { - const struct cmd_element *a = *(struct cmd_element **)p; - const struct cmd_element *b = *(struct cmd_element **)q; + const struct cmd_element *a = *(struct cmd_element *const *)p; + const struct cmd_element *b = *(struct cmd_element *const *)q; return strcmp (a->string, b->string); } @@ -208,8 +208,8 @@ cmp_node (const void *p, const void *q) static int cmp_desc (const void *p, const void *q) { - const struct desc *a = *(struct desc **)p; - const struct desc *b = *(struct desc **)q; + const struct desc *a = *(struct desc *const *)p; + const struct desc *b = *(struct desc *const *)q; return strcmp (a->cmd, b->cmd); } diff --git a/lib/distribute.c b/lib/distribute.c index 906e3f6d..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. */ diff --git a/lib/filter.c b/lib/filter.c index 7aeb8deb..af8d587f 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, "", @@ -32,9 +32,8 @@ hash_create_size (unsigned int size, unsigned int (*hash_key) (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; @@ -117,21 +117,25 @@ if_create (const char *name, int namelen) { struct interface *ifp; - ifp = XCALLOC (MTYPE_IF, sizeof (struct interface)); - ifp->ifindex = IFINDEX_INTERNAL; + ifp = if_lookup_by_name(name); + if (ifp) { + if (ifp->ifindex != IFINDEX_INTERNAL) + zlog_err("if_create(%s): corruption detected -- interface with this " + "name exists already!", ifp->name); + } else { + ifp = XCALLOC (MTYPE_IF, sizeof (struct interface)); + ifp->ifindex = IFINDEX_INTERNAL; - assert (name); - assert (namelen <= INTERFACE_NAMSIZ); /* Need space for '\0' at end. */ - strncpy (ifp->name, name, namelen); - ifp->name[namelen] = '\0'; - if (if_lookup_by_name(ifp->name) == NULL) + assert (namelen <= INTERFACE_NAMSIZ); /* Need space for '\0' at end. */ + strncpy (ifp->name, name, namelen); + ifp->name[namelen] = '\0'; + listnode_add_sort (iflist, ifp); - else - zlog_err("if_create(%s): corruption detected -- interface with this " - "name exists already!", ifp->name); + } + ifp->connected = list_new (); ifp->connected->del = (void (*) (void *)) connected_free; - + if (if_master.if_new_hook) (*if_master.if_new_hook) (ifp); @@ -146,7 +150,11 @@ if_delete_retain (struct interface *ifp) (*if_master.if_delete_hook) (ifp); /* Free connected address list */ - list_delete (ifp->connected); + if (ifp->connected) + { + list_delete (ifp->connected); + ifp->connected = NULL; + } } /* Delete and free interface structure. */ @@ -320,60 +328,6 @@ if_get_by_name_len(const char *name, size_t namelen) if_create(name, namelen); } -/* Does interface up ? */ -int -if_is_up (struct interface *ifp) -{ - return ifp->flags & IFF_UP; -} - -/* Is interface running? */ -int -if_is_running (struct interface *ifp) -{ - return ifp->flags & IFF_RUNNING; -} - -/* Is the interface operative, eg. either UP & RUNNING - or UP & !ZEBRA_INTERFACE_LINK_DETECTION */ -int -if_is_operative (struct interface *ifp) -{ - return ((ifp->flags & IFF_UP) && - (ifp->flags & IFF_RUNNING || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))); -} - -/* Is this loopback interface ? */ -int -if_is_loopback (struct interface *ifp) -{ - /* XXX: Do this better, eg what if IFF_WHATEVER means X on platform M - * but Y on platform N? - */ - return (ifp->flags & (IFF_LOOPBACK|IFF_NOXMIT|IFF_VIRTUAL)); -} - -/* Does this interface support broadcast ? */ -int -if_is_broadcast (struct interface *ifp) -{ - return ifp->flags & IFF_BROADCAST; -} - -/* Does this interface support broadcast ? */ -int -if_is_pointopoint (struct interface *ifp) -{ - return ifp->flags & IFF_POINTOPOINT; -} - -/* Does this interface support multicast ? */ -int -if_is_multicast (struct interface *ifp) -{ - return ifp->flags & IFF_MULTICAST; -} - /* Printout flag information into log */ const char * if_flag_dump (unsigned long flag) @@ -422,7 +376,7 @@ if_flag_dump (unsigned long flag) /* For debugging */ static void -if_dump (struct interface *ifp) +if_dump (const struct interface *ifp) { struct listnode *node; struct connected *c; @@ -444,7 +398,7 @@ if_dump (struct interface *ifp) /* Interface printing for all interface. */ void -if_dump_all () +if_dump_all (void) { struct listnode *node; void *p; @@ -620,9 +574,7 @@ DEFUN (show_address, struct connected * connected_new (void) { - struct connected *new = XMALLOC (MTYPE_CONNECTED, sizeof (struct connected)); - memset (new, 0, sizeof (struct connected)); - return new; + return XCALLOC (MTYPE_CONNECTED, sizeof (struct connected)); } /* Free connected structure. */ @@ -257,13 +257,62 @@ extern void if_delete_retain (struct interface *); deletes it from the interface list and frees the structure. */ extern void if_delete (struct interface *); -extern int if_is_up (struct interface *); -extern int if_is_running (struct interface *); -extern int if_is_operative (struct interface *); -extern int if_is_loopback (struct interface *); -extern int if_is_broadcast (struct interface *); -extern int if_is_pointopoint (struct interface *); -extern int if_is_multicast (struct interface *); +/* Does interface up ? */ +static inline int +if_is_up (const struct interface *ifp) +{ + return ifp->flags & IFF_UP; +} + +/* Is interface running? */ +static inline int +if_is_running (const struct interface *ifp) +{ + return ifp->flags & IFF_RUNNING; +} + +/* Is the interface operative, eg. either UP & RUNNING + or UP & !ZEBRA_INTERFACE_LINK_DETECTION */ +static inline int +if_is_operative (const struct interface *ifp) +{ + return ((ifp->flags & IFF_UP) && + ((ifp->flags & IFF_RUNNING) || + !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))); +} + +/* Is this loopback interface ? */ +static inline int +if_is_loopback (const struct interface *ifp) +{ + /* XXX: Do this better, eg what if IFF_WHATEVER means X on platform M + * but Y on platform N? + */ + return (ifp->flags & (IFF_LOOPBACK|IFF_NOXMIT|IFF_VIRTUAL)); +} + +/* Does this interface support broadcast ? */ +static inline int +if_is_broadcast (const struct interface *ifp) +{ + return ifp->flags & IFF_BROADCAST; +} + +/* Does this interface support broadcast ? */ +static inline int +if_is_pointopoint (const struct interface *ifp) +{ + return ifp->flags & IFF_POINTOPOINT; +} + +/* Does this interface support multicast ? */ +static inline int +if_is_multicast (const struct interface *ifp) +{ + return ifp->flags & IFF_MULTICAST; +} + + extern void if_add_hook (int, int (*)(struct interface *)); extern void if_init (void); extern void if_dump_all (void); 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. */ @@ -435,10 +435,10 @@ zlog_backtrace_sigsafe(int priority, void *program_counter) { #ifdef HAVE_STACK_TRACE static const char pclabel[] = "Program counter: "; - void *array[20]; + void *array[64]; int size; char buf[100]; - char *s; + char *s, **bt = NULL; #define LOC s,buf+sizeof(buf)-s #ifdef HAVE_GLIBC_BACKTRACE @@ -485,20 +485,29 @@ zlog_backtrace_sigsafe(int priority, void *program_counter) syslog_sigsafe(priority|zlog_default->facility,buf,s-buf); { int i; +#ifdef HAVE_GLIBC_BACKTRACE + bt = backtrace_symbols(array, size); +#endif /* Just print the function addresses. */ for (i = 0; i < size; i++) { s = buf; - s = str_append(LOC,"[bt "); - s = num_append(LOC,i); - s = str_append(LOC,"] 0x"); - s = hex_append(LOC,(u_long)(array[i])); + if (bt) + s = str_append(LOC, bt[i]); + else { + s = str_append(LOC,"[bt "); + s = num_append(LOC,i); + s = str_append(LOC,"] 0x"); + s = hex_append(LOC,(u_long)(array[i])); + } *s = '\0'; if (priority <= zlog_default->maxlvl[ZLOG_DEST_MONITOR]) vty_log_fixed(buf,s-buf); if (priority <= zlog_default->maxlvl[ZLOG_DEST_SYSLOG]) syslog_sigsafe(priority|zlog_default->facility,buf,s-buf); } + if (bt) + free(bt); } } #undef DUMP @@ -762,7 +771,7 @@ lookup (const struct message *mes, int key) * provided otherwise. */ const char * -mes_lookup (struct message *meslist, int max, int index, const char *none) +mes_lookup (const struct message *meslist, int max, int index, const char *none) { int pos = index - meslist[0].key; @@ -111,7 +111,8 @@ extern void closezlog (struct zlog *zl); #endif /* __GNUC__ */ /* 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); @@ -121,11 +122,16 @@ extern void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); extern void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); /* 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); +extern void plog_warn (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3); +extern void plog_info (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3); +extern void plog_notice (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3); +extern void plog_debug (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3); /* Set logging level for the given destination. If the log_level argument is ZLOG_DISABLED, then the destination is disabled. @@ -145,7 +151,7 @@ extern int zlog_rotate (struct zlog *); #define LOOKUP(x, y) mes_lookup(x, x ## _max, y, "(no item found)") extern const char *lookup (const struct message *, int); -extern const char *mes_lookup (struct message *meslist, +extern const char *mes_lookup (const struct message *meslist, int max, int index, const char *no_item); diff --git a/lib/plist.c b/lib/plist.c index 4b498c4d..0f802a83 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)# ", @@ -73,7 +73,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. */ @@ -83,7 +83,7 @@ struct cmd_node smux_node = static struct thread_master *master; void * -oid_copy (void *dest, void *src, size_t size) +oid_copy (void *dest, const void *src, size_t size) { return memcpy (dest, src, size * sizeof (oid)); } @@ -157,7 +157,7 @@ oid_compare_part (oid *o1, int o1_len, oid *o2, int o2_len) } static void -smux_oid_dump (const char *prefix, oid *oid, size_t oid_len) +smux_oid_dump (const char *prefix, const oid *oid, size_t oid_len) { unsigned int i; int first = 1; @@ -174,7 +174,7 @@ smux_oid_dump (const char *prefix, oid *oid, size_t oid_len) } static int -smux_socket () +smux_socket (void) { int ret; #ifdef HAVE_IPV6 @@ -228,7 +228,8 @@ smux_socket () } freeaddrinfo(res0); if (sock < 0) - zlog_warn ("Can't connect to SNMP agent with SMUX"); + if (debug_smux) + zlog_debug ("Can't connect to SNMP agent with SMUX"); #else sock = socket (AF_INET, SOCK_STREAM, 0); if (sock < 0) @@ -259,7 +260,8 @@ smux_socket () { close (sock); smux_sock = -1; - zlog_warn ("Can't connect to SNMP agent with SMUX"); + if (debug_smux) + zlog_debug ("Can't connect to SNMP agent with SMUX"); return -1; } #endif @@ -348,7 +350,7 @@ smux_var (u_char *ptr, size_t len, oid objid[], size_t *objid_len, if (debug_smux) { - zlog_debug ("SMUX var parse: type %d len %zd", type, len); + zlog_debug ("SMUX var parse: type %u len %zd", type, len); zlog_debug ("SMUX var parse: type must be %d", (ASN_SEQUENCE | ASN_CONSTRUCTOR)); } @@ -945,8 +947,8 @@ smux_open (int sock) u_char buf[BUFSIZ]; u_char *ptr; size_t len; - long version; - u_char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION; + u_long version; + char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION; if (debug_smux) { @@ -965,7 +967,7 @@ smux_open (int sock) version = 0; ptr = asn_build_int (ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), - &version, sizeof (version)); + (long *)&version, sizeof (version)); /* SMUX connection oid. */ ptr = asn_build_objid (ptr, &len, @@ -977,7 +979,7 @@ smux_open (int sock) ptr = asn_build_string (ptr, &len, (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR), - progname, strlen (progname)); + (u_char *) progname, strlen (progname)); /* SMUX connection password. */ ptr = asn_build_string (ptr, &len, @@ -993,9 +995,9 @@ smux_open (int sock) } int -smux_trap (oid *name, size_t namelen, - oid *iname, size_t inamelen, - struct trap_object *trapobj, size_t trapobjlen, +smux_trap (const oid *name, size_t namelen, + const oid *iname, size_t inamelen, + const struct trap_object *trapobj, size_t trapobjlen, unsigned int tick, u_char sptrap) { unsigned int i; @@ -1181,7 +1183,10 @@ smux_connect (struct thread *t) int ret; if (debug_smux) - zlog_debug ("SMUX connect try %d", fail + 1); + { + fail = fail + 1; + zlog_debug ("SMUX connect try %d", fail); + } /* Clear thread poner of myself. */ smux_connect_thread = NULL; @@ -1190,8 +1195,10 @@ smux_connect (struct thread *t) smux_sock = smux_socket (); if (smux_sock < 0) { - if (++fail < SMUX_MAX_FAILURE) - smux_event (SMUX_CONNECT, 0); + if (debug_smux) + zlog_debug ("SMUX socket/connection creation error"); + // if (++fail < SMUX_MAX_FAILURE) + smux_event (SMUX_CONNECT, 0); return 0; } @@ -1202,8 +1209,8 @@ smux_connect (struct thread *t) zlog_warn ("SMUX open message send failed: %s", safe_strerror (errno)); close (smux_sock); smux_sock = -1; - if (++fail < SMUX_MAX_FAILURE) - smux_event (SMUX_CONNECT, 0); + // if (++fail < SMUX_MAX_FAILURE) + smux_event (SMUX_CONNECT, 0); return -1; } @@ -1214,8 +1221,8 @@ smux_connect (struct thread *t) zlog_warn ("SMUX register message send failed: %s", safe_strerror (errno)); close (smux_sock); smux_sock = -1; - if (++fail < SMUX_MAX_FAILURE) - smux_event (SMUX_CONNECT, 0); + // if (++fail < SMUX_MAX_FAILURE) + smux_event (SMUX_CONNECT, 0); return -1; } @@ -1227,7 +1234,7 @@ smux_connect (struct thread *t) /* Clear all SMUX related resources. */ static void -smux_stop () +smux_stop (void) { if (smux_read_thread) { @@ -1388,7 +1395,7 @@ smux_header_generic (struct variable *v, oid *name, size_t *length, int exact, } static int -smux_peer_default () +smux_peer_default (void) { if (smux_oid) { @@ -39,7 +39,7 @@ #define SMUX_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 3) #define SMUX_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 4) -#define SMUX_MAX_FAILURE 3 +// #define SMUX_MAX_FAILURE 3 /* Structures here are mostly compatible with UCD SNMP 4.1.1 */ #define MATCH_FAILED (-1) @@ -150,11 +150,12 @@ extern void smux_register_mib(const char *, struct variable *, size_t, int, oid [], size_t); extern int smux_header_generic (struct variable *, oid [], size_t *, int, size_t *, WriteMethod **); -extern int smux_trap (oid *, size_t, oid *, size_t, struct trap_object *, +extern int smux_trap (const oid *, size_t, const oid *, size_t, + const struct trap_object *, size_t, unsigned int, u_char); extern int oid_compare (oid *, int, oid *, int); extern void oid2in_addr (oid [], int, struct in_addr *); -extern void *oid_copy (void *, void *, size_t); +extern void *oid_copy (void *, const void *, size_t); extern void oid_copy_addr (oid [], struct in_addr *, int); #endif /* _ZEBRA_SNMP_H */ diff --git a/lib/sockopt.c b/lib/sockopt.c index 4ba7e874..116ee498 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -530,6 +530,7 @@ sockopt_tcp_signature (int sock, union sockunion *su, const char *password) return -1; }; +#ifdef HAVE_IPV6 /* 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. @@ -546,6 +547,7 @@ sockopt_tcp_signature (int sock, union sockunion *su, const char *password) su2->sin6.sin6_addr.s6_addr32[2] = htonl(0xffff); memcpy (&su2->sin6.sin6_addr.s6_addr32[3], &su->sin.sin_addr, 4); } +#endif } memset (&md5sig, 0, sizeof (md5sig)); diff --git a/lib/sockunion.c b/lib/sockunion.c index 3750295c..75419b11 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/table.c b/lib/table.c index 2ade71b8..17f9607b 100644 --- a/lib/table.c +++ b/lib/table.c @@ -201,24 +201,6 @@ set_link (struct route_node *node, struct route_node *new) new->parent = node; } -/* Lock node. */ -struct route_node * -route_lock_node (struct route_node *node) -{ - node->lock++; - return node; -} - -/* Unlock node. */ -void -route_unlock_node (struct route_node *node) -{ - node->lock--; - - if (node->lock == 0) - route_node_delete (node); -} - /* Dump routing table. */ static void __attribute__ ((unused)) route_dump_node (struct route_table *t) diff --git a/lib/table.h b/lib/table.h index 45ec6067..0193e580 100644 --- a/lib/table.h +++ b/lib/table.h @@ -55,7 +55,6 @@ struct route_node /* Prototypes. */ extern struct route_table *route_table_init (void); extern void route_table_finish (struct route_table *); -extern void route_unlock_node (struct route_node *node); extern void route_node_delete (struct route_node *node); extern struct route_node *route_top (struct route_table *); extern struct route_node *route_next (struct route_node *); @@ -65,7 +64,6 @@ extern struct route_node *route_node_get (struct route_table *, struct prefix *); extern struct route_node *route_node_lookup (struct route_table *, struct prefix *); -extern struct route_node *route_lock_node (struct route_node *node); extern struct route_node *route_node_match (struct route_table *, struct prefix *); extern struct route_node *route_node_match_ipv4 (struct route_table *, @@ -75,4 +73,22 @@ extern struct route_node *route_node_match_ipv6 (struct route_table *, struct in6_addr *); #endif /* HAVE_IPV6 */ + + +/* Lock node. */ +static inline struct route_node * +route_lock_node (struct route_node *node) +{ + node->lock++; + return node; +} + +/* Unlock node. */ +static inline void +route_unlock_node (struct route_node *node) +{ + if (--node->lock == 0) + route_node_delete (node); +} + #endif /* _ZEBRA_TABLE_H */ @@ -1835,6 +1835,7 @@ vty_serv_sock_addrinfo (const char *hostname, unsigned short port) } #endif /* HAVE_IPV6 && ! NRL */ +#if 0 /* Make vty server socket. */ static void vty_serv_sock_family (const char* addr, unsigned short port, int family) @@ -1899,6 +1900,7 @@ vty_serv_sock_family (const char* addr, unsigned short port, int family) /* Add vty server event. */ vty_event (VTY_SERV, accept_sock, NULL); } +#endif #ifdef VTYSH /* For sockaddr_un. */ 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); |