From 99a9a0c9e045732e5977b24192e971ade92b59aa Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 27 May 2008 12:36:54 -0700 Subject: Change how link-detect is configured in build Rather that looking for /proc/sys/net/ipv4/conf, use --enable-linkdetect flag to configure. --- configure.ac | 18 ++++++++++++------ debian/rules | 1 + zebra/interface.h | 3 +-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index e679632f..1d2b2a3a 100755 --- a/configure.ac +++ b/configure.ac @@ -208,6 +208,8 @@ AC_ARG_ENABLE(bgp-announce, [ --disable-bgp-announce, turn off BGP route announcement]) AC_ARG_ENABLE(netlink, [ --enable-netlink force to use Linux netlink interface]) +AC_ARG_ENABLE(linkdetect, +[ --enable-linkdetect use Linux link-detect configuration]) AC_ARG_ENABLE(broken-aliases, [ --enable-broken-aliases enable aliases as distinct interfaces for Linux 2.2.X]) AC_ARG_ENABLE(snmp, @@ -917,6 +919,16 @@ AC_CHECK_HEADER([net/if.h], QUAGGA_INCLUDES)], [], QUAGGA_INCLUDES ) + +dnl --------------------------------------------------------------- +dnl kernel link-detect enable via /proc/sys/net/ipv4/conf/ethX/link_detect +dnl --------------------------------------------------------------- +if test "${enable_linkdetect}" = "yes"; then + AC_DEFINE(HAVE_LINKDETECT,1,Enable Linux kernel linkdetect) + LINK_DETECT=if_linkdetect.o +fi +AC_SUBST(LINK_DETECT) + dnl ----------------------- dnl check proc file system. dnl ----------------------- @@ -931,12 +943,6 @@ if test -r /proc/net/if_inet6; then fi AC_SUBST(IF_PROC) -if test -r /proc/sys/net/ipv4/conf; then - AC_DEFINE(HAVE_PROC_NET_IPV4_CONF,,/proc/sys/net/ipv4/conf) - LINK_DETECT=if_linkdetect.o -fi -AC_SUBST(LINK_DETECT) - dnl ----------------------------- dnl check ipforward detect method dnl ----------------------------- diff --git a/debian/rules b/debian/rules index e89dc246..f5f7e932 100755 --- a/debian/rules +++ b/debian/rules @@ -61,6 +61,7 @@ configure += --enable-logfile-mask=0640 configure += --enable-rtadv configure += --enable-tcp-md5 configure += --enable-gcc-rdynamic +configure += --enable-linkdetect configure += $(xable_snmp) configure += --with-libpam configure += CFLAGS="$(CFLAGS)" diff --git a/zebra/interface.h b/zebra/interface.h index 6f356686..6ab25bf4 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -234,11 +234,10 @@ extern int interface_list_proc (void); extern int ifaddr_proc_ipv6 (void); #endif /* HAVE_PROC_NET_IF_INET6 */ -#ifdef HAVE_PROC_NET_IPV4_CONF +#ifdef HAVE_LINKDETECT extern int if_linkdetect_on (const char *); extern int if_linkdetect_off (const char *); #else -#error config #define if_linkdetect_on(name) #define if_linkdetect_off(name) #endif -- cgit v1.2.3 From 6e69833249b701330913d80bd9b3c7c991ee61d5 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 08:57:30 -0700 Subject: Add ipv6 link detect hooks Enable ipv6 link detect in kernel if needed. --- zebra/if_linkdetect.c | 22 ++++++++++++++++++---- zebra/interface.c | 6 ++++++ zebra/interface.h | 8 ++++++++ zebra/linkdetect_null.c | 12 ++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/zebra/if_linkdetect.c b/zebra/if_linkdetect.c index 9ae7c6a6..9d0457aa 100644 --- a/zebra/if_linkdetect.c +++ b/zebra/if_linkdetect.c @@ -32,14 +32,14 @@ extern struct zebra_privs_t zserv_privs; static int -linkdetect (const char *name, int onoff) +linkdetect (const char *name, const char *ver, int onoff) { FILE *fp; int save_errno; char proc_name[128]; snprintf(proc_name, sizeof(proc_name)-1, - "/proc/sys/net/ipv4/conf/%s/link_detect", name); + "/proc/sys/net/%s/conf/%s/link_detect", ver, name); if ( zserv_privs.change(ZPRIVS_RAISE) ) zlog_err ("Can't raise privileges, %s", safe_strerror (errno) ); @@ -71,11 +71,25 @@ linkdetect (const char *name, int onoff) int if_linkdetect_on (const char *name) { - return linkdetect (name, 1); + return linkdetect (name, "ipv4", 1); } int if_linkdetect_off (const char *name) { - return linkdetect (name, 1); + return linkdetect (name, "ipv4", 0); } + +#ifdef HAVE_IPV6 +int +if_linkdetect_ipv6_on (const char *name) +{ + return linkdetect (name, "ipv6", 1); +} + +int +if_linkdetect_ipv6_off (const char *name) +{ + return linkdetect (name, "ipv6", 0); +} +#endif diff --git a/zebra/interface.c b/zebra/interface.c index f6d2ff9b..1be55c31 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1032,6 +1032,9 @@ DEFUN (linkdetect, /* Enable FIB to remove kernel routes as well */ if_linkdetect_on(ifp->name); +#ifdef HAVE_IPV6 + if_linkdetect_ipv6_on(ifp->name); +#endif /* When linkdetection is enabled, if might come down */ if (!if_is_operative(ifp) && if_was_operative) if_down(ifp); @@ -1058,6 +1061,9 @@ DEFUN (no_linkdetect, /* Disable FIB update on link-detect */ if_linkdetect_off(ifp->name); +#ifdef HAVE_IPV6 + if_linkdetect_ipv6_off(ifp->name); +#endif /* Interface may come up after disabling link detection */ if (if_is_operative(ifp) && !if_was_operative) if_up(ifp); diff --git a/zebra/interface.h b/zebra/interface.h index 6ab25bf4..114270e7 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -237,9 +237,17 @@ extern int ifaddr_proc_ipv6 (void); #ifdef HAVE_LINKDETECT extern int if_linkdetect_on (const char *); extern int if_linkdetect_off (const char *); +# ifdef HAVE_IPV6 +extern int if_linkdetect_ipv6_on (const char *); +extern int if_linkdetect_ipv6_off (const char *); +# endif #else #define if_linkdetect_on(name) #define if_linkdetect_off(name) +# ifdef HAVE_IPV6 +#define if_linkdetect_ipv6_on(name) +#define if_linkdetect_ipv6_off(name) +# endif #endif diff --git a/zebra/linkdetect_null.c b/zebra/linkdetect_null.c index c33363e1..1f160c8e 100644 --- a/zebra/linkdetect_null.c +++ b/zebra/linkdetect_null.c @@ -14,3 +14,15 @@ if_linkdetect_off (const char *name) { return 0; } + +int +if_linkdetect_ipv6_on (const char *name) +{ + return 0; +} + +int +if_linkdetect_ipv6_off (const char *name) +{ + return 0; +} -- cgit v1.2.3 From 8583ab7c9aaff066a45e477c9c25d921a02ce923 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 09:14:07 -0700 Subject: Handle empty auth string properly Compiler warned about dubious code where test was: char auth_str[]; ... if (!auth_str) return 0; Looks like what was meant was testing for empty auth string. --- ripd/ripd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ripd/ripd.c b/ripd/ripd.c index c5e42705..62d8691c 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -926,7 +926,7 @@ rip_auth_md5 (struct rip_packet *packet, struct sockaddr_in *from, else if (ri->auth_str) strncpy (auth_str, ri->auth_str, RIP_AUTH_MD5_SIZE); - if (! auth_str) + if (auth_str[0] == 0) return 0; /* MD5 digest authentication. */ -- cgit v1.2.3 From 11a1fd54a7246ae4afc634445f3bde06cdc52892 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 09:48:05 -0700 Subject: get rid of compiler warnings Changes to eliminate warnings: * Use %td for pointer diff printf format * Use %zd for size_t printf format * Change asn buffers to use u_char * make some functions local * add some casts --- lib/smux.c | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/smux.c b/lib/smux.c index c5159dd9..8572df54 100644 --- a/lib/smux.c +++ b/lib/smux.c @@ -324,13 +324,13 @@ smux_getresp_send (oid objid[], size_t objid_len, long reqid, long errstat, asn_build_sequence(h1,&length,(u_char)SMUX_GETRSP,ptr-h1e); if (debug_smux) - zlog_debug ("SMUX getresp send: %ld", (ptr - buf)); + zlog_debug ("SMUX getresp send: %td", (ptr - buf)); ret = send (smux_sock, buf, (ptr - buf), 0); } -char * -smux_var (char *ptr, size_t len, oid objid[], size_t *objid_len, +static u_char * +smux_var (u_char *ptr, size_t len, oid objid[], size_t *objid_len, size_t *var_val_len, u_char *var_val_type, void **var_value) @@ -341,14 +341,14 @@ smux_var (char *ptr, size_t len, oid objid[], size_t *objid_len, u_char *val; if (debug_smux) - zlog_debug ("SMUX var parse: len %ld", len); + zlog_debug ("SMUX var parse: len %zd", len); /* Parse header. */ ptr = asn_parse_header (ptr, &len, &type); if (debug_smux) { - zlog_debug ("SMUX var parse: type %d len %ld", 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)); } @@ -650,8 +650,8 @@ smux_getnext (oid *reqid, size_t *reqid_len, int exact, } /* GET message header. */ -char * -smux_parse_get_header (char *ptr, size_t *len, long *reqid) +static u_char * +smux_parse_get_header (u_char *ptr, size_t *len, long *reqid) { u_char type; long errstat; @@ -667,19 +667,19 @@ smux_parse_get_header (char *ptr, size_t *len, long *reqid) ptr = asn_parse_int (ptr, len, &type, &errstat, sizeof (errstat)); if (debug_smux) - zlog_debug ("SMUX GET errstat %ld len: %ld", errstat, *len); + zlog_debug ("SMUX GET errstat %ld len: %zd", errstat, *len); /* Error index. */ ptr = asn_parse_int (ptr, len, &type, &errindex, sizeof (errindex)); if (debug_smux) - zlog_debug ("SMUX GET errindex %ld len: %ld", errindex, *len); + zlog_debug ("SMUX GET errindex %ld len: %zd", errindex, *len); return ptr; } -void -smux_parse_set (char *ptr, size_t len, int action) +static void +smux_parse_set (u_char *ptr, size_t len, int action) { long reqid; oid oid[MAX_OID_LEN]; @@ -690,7 +690,7 @@ smux_parse_set (char *ptr, size_t len, int action) int ret; if (debug_smux) - zlog_debug ("SMUX SET(%s) message parse: len %ld", + zlog_debug ("SMUX SET(%s) message parse: len %zd", (RESERVE1 == action) ? "RESERVE1" : ((FREE == action) ? "FREE" : "COMMIT"), len); @@ -709,8 +709,8 @@ smux_parse_set (char *ptr, size_t len, int action) smux_getresp_send (oid, oid_len, reqid, ret, 3, ASN_NULL, NULL, 0); } -void -smux_parse_get (char *ptr, size_t len, int exact) +static void +smux_parse_get (u_char *ptr, size_t len, int exact) { long reqid; oid oid[MAX_OID_LEN]; @@ -721,7 +721,7 @@ smux_parse_get (char *ptr, size_t len, int exact) int ret; if (debug_smux) - zlog_debug ("SMUX GET message parse: len %ld", len); + zlog_debug ("SMUX GET message parse: len %zd", len); /* Parse GET message header. */ ptr = smux_parse_get_header (ptr, &len, &reqid); @@ -743,8 +743,8 @@ smux_parse_get (char *ptr, size_t len, int exact) } /* Parse SMUX_CLOSE message. */ -void -smux_parse_close (char *ptr, int len) +static void +smux_parse_close (u_char *ptr, int len) { long reason = 0; @@ -757,10 +757,10 @@ smux_parse_close (char *ptr, int len) } /* SMUX_RRSP message. */ -void -smux_parse_rrsp (char *ptr, size_t len) +static void +smux_parse_rrsp (u_char *ptr, size_t len) { - char val; + u_char val; long errstat; ptr = asn_parse_int (ptr, &len, &val, &errstat, sizeof (errstat)); @@ -770,8 +770,8 @@ smux_parse_rrsp (char *ptr, size_t len) } /* Parse SMUX message. */ -int -smux_parse (char *ptr, size_t len) +static int +smux_parse (u_char *ptr, size_t len) { /* This buffer we'll use for SOUT message. We could allocate it with malloc and save only static pointer/lenght, but IMHO static @@ -791,7 +791,7 @@ process_rest: /* see note below: YYY */ ptr = asn_parse_header (ptr, &len, &type); if (debug_smux) - zlog_debug ("SMUX message received type: %d rest len: %ld", type, len); + zlog_debug ("SMUX message received type: %d rest len: %zd", type, len); switch (type) { @@ -946,7 +946,7 @@ smux_open (int sock) u_char *ptr; size_t len; u_long version; - u_char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION; + char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION; if (debug_smux) { @@ -965,7 +965,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,13 +977,13 @@ 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, (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR), - smux_passwd, strlen (smux_passwd)); + (u_char *) smux_passwd, strlen (smux_passwd)); /* Fill in real SMUX header. We exclude ASN header size (2). */ len = BUFSIZ; @@ -1034,13 +1034,13 @@ smux_trap (oid *name, size_t namelen, val = SNMP_TRAP_ENTERPRISESPECIFIC; ptr = asn_build_int (ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), - &val, sizeof (val)); + (long *)&val, sizeof (val)); /* Specific trap integer. */ val = sptrap; ptr = asn_build_int (ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), - &val, sizeof (val)); + (long *)&val, sizeof (val)); /* Timeticks timestamp. */ val = 0; -- cgit v1.2.3 From 82e1d7bc0324c5b3afed465c0746d37f7fc1b13b Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 09:50:36 -0700 Subject: Fix compiler warnings To eliminate compiler warnings * comment out unused code * fix printf formats * remove always true expression * initialize variables --- zebra/interface.c | 2 ++ zebra/irdp_packet.c | 2 +- zebra/rtadv.c | 4 +++- zebra/zebra_rib.c | 11 ++++++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/zebra/interface.c b/zebra/interface.c index 1be55c31..916c58a6 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -833,6 +833,7 @@ if_dump_vty (struct vty *vty, struct interface *ifp) #endif /* HAVE_NET_RT_IFLIST */ } +#if 0 /* Check supported address family. */ static int if_supported_family (int family) @@ -845,6 +846,7 @@ if_supported_family (int family) #endif /* HAVE_IPV6 */ return 0; } +#endif /* Wrapper hook point for zebra daemon so that ifindex can be set * DEFUN macro not used as extract.pl HAS to ignore this diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c index 3c5f1559..ae121ea1 100644 --- a/zebra/irdp_packet.c +++ b/zebra/irdp_packet.c @@ -231,7 +231,7 @@ int irdp_read_raw(struct thread *r) struct zebra_if *zi; struct irdp_interface *irdp; char buf[IRDP_RX_BUF]; - int ret, ifindex; + int ret, ifindex = 0; int irdp_sock = THREAD_FD (r); t_irdp_raw = thread_add_read (zebrad.master, irdp_read_raw, NULL, irdp_sock); diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 4bdb83d5..0097e28f 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -90,11 +90,13 @@ rtadv_new (void) return new; } +#if 0 static void rtadv_free (struct rtadv *rtadv) { XFREE (MTYPE_TMP, rtadv); } +#endif static int rtadv_recv_packet (int sock, u_char *buf, int buflen, @@ -451,7 +453,7 @@ rtadv_read (struct thread *thread) int len; u_char buf[RTADV_MSG_SIZE]; struct sockaddr_in6 from; - unsigned int ifindex; + unsigned int ifindex = 0; int hoplimit = -1; sock = THREAD_FD (thread); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 5ae556bf..59b53fa1 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -93,6 +93,7 @@ vrf_alloc (const char *name) return vrf; } +#if 0 /* Free VRF. */ static void vrf_free (struct vrf *vrf) @@ -101,6 +102,7 @@ vrf_free (struct vrf *vrf) XFREE (MTYPE_VRF_NAME, vrf->name); XFREE (MTYPE_VRF, vrf); } +#endif /* Lookup VRF by identifier. */ struct vrf * @@ -109,6 +111,7 @@ vrf_lookup (u_int32_t id) return vector_lookup (vrf_vector, id); } +#if 0 /* Lookup VRF by name. */ static struct vrf * vrf_lookup_by_name (char *name) @@ -122,6 +125,7 @@ vrf_lookup_by_name (char *name) return vrf; return NULL; } +#endif /* Initialize VRF. */ static void @@ -911,8 +915,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, return CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); rmap = 0; - if (rib->type >= 0 && rib->type < ZEBRA_ROUTE_MAX && - proto_rm[family][rib->type]) + if (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]); @@ -1567,7 +1570,7 @@ void rib_dump (const char * func, const struct prefix_ipv4 * p, const struct rib zlog_debug ("%s: dumping RIB entry %p for %s/%d", func, rib, straddr1, p->prefixlen); zlog_debug ( - "%s: refcnt == %lu, uptime == %u, type == %u, table == %d", + "%s: refcnt == %lu, uptime == %lu, type == %u, table == %d", func, rib->refcnt, rib->uptime, @@ -2780,6 +2783,7 @@ rib_update (void) rib_queue_add (&zebrad, rn); } +#if 0 /* Interface goes up. */ static void rib_if_up (struct interface *ifp) @@ -2793,6 +2797,7 @@ rib_if_down (struct interface *ifp) { rib_update (); } +#endif /* Remove all routes which comes from non main table. */ static void -- cgit v1.2.3 From ce0f89b568b2170583ce53961b414b226cf96bbb Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 09:56:24 -0700 Subject: comment out unused code remove unused code, compiler flags this as unused --- ripd/ripd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ripd/ripd.c b/ripd/ripd.c index 62d8691c..af2e5d0e 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -2977,6 +2977,7 @@ DEFUN (no_rip_route, return CMD_SUCCESS; } +#if 0 static void rip_update_default_metric (void) { @@ -2988,6 +2989,7 @@ rip_update_default_metric (void) if (rinfo->type != ZEBRA_ROUTE_RIP && rinfo->type != ZEBRA_ROUTE_CONNECT) rinfo->metric = rip->default_metric; } +#endif DEFUN (rip_default_metric, rip_default_metric_cmd, -- cgit v1.2.3 From 86f447e58b2d673ac0776781558e956469054b6f Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 09:58:30 -0700 Subject: flag field printf formatting in debug strings Potential format incompatiablities because flags field in zebra is uint64_t but the printf format was only 32 bit. For safety, convert the flags field to unsigned long long. Since it is really a bit field print in hex. --- ripd/rip_interface.c | 22 ++++++++++++++-------- ripngd/ripng_interface.c | 14 ++++++++------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index b6d9240f..915cd911 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -253,6 +253,7 @@ 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) @@ -270,6 +271,7 @@ rip_request_neighbor_all (void) if (rp->info) rip_request_neighbor (rp->p.u.prefix4); } +#endif /* Multicast packet receive socket. */ static int @@ -403,8 +405,9 @@ rip_interface_down (int command, struct zclient *zclient, zebra_size_t length) rip_if_down(ifp); if (IS_RIP_DEBUG_ZEBRA) - zlog_debug ("interface %s index %d flags %ld metric %d mtu %d is down", - ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); + 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); return 0; } @@ -423,8 +426,9 @@ rip_interface_up (int command, struct zclient *zclient, zebra_size_t length) return 0; if (IS_RIP_DEBUG_ZEBRA) - zlog_debug ("interface %s index %d flags %ld metric %d mtu %d is up", - ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); + zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is up", + ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, + ifp->metric, ifp->mtu); /* Check if this interface is RIP enabled or not.*/ rip_enable_apply (ifp); @@ -447,8 +451,9 @@ rip_interface_add (int command, struct zclient *zclient, zebra_size_t length) ifp = zebra_interface_add_read (zclient->ibuf); if (IS_RIP_DEBUG_ZEBRA) - zlog_debug ("interface add %s index %d flags %ld metric %d mtu %d", - ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); + zlog_debug ("interface add %s index %d flags %#llx metric %d mtu %d", + ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, + ifp->metric, ifp->mtu); /* Check if this interface is RIP enabled or not.*/ rip_enable_apply (ifp); @@ -486,8 +491,9 @@ rip_interface_delete (int command, struct zclient *zclient, rip_if_down(ifp); } - zlog_info("interface delete %s index %d flags %ld metric %d mtu %d", - ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); + zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d", + ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, + ifp->metric, ifp->mtu); /* To support pseudo interface do not free interface structure. */ /* if_delete(ifp); */ diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index 140e3bef..c25677e7 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -243,8 +243,9 @@ ripng_interface_up (int command, struct zclient *zclient, zebra_size_t length) return 0; if (IS_RIPNG_DEBUG_ZEBRA) - zlog_debug ("interface up %s index %d flags %ld metric %d mtu %d", - ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6); + zlog_debug ("interface up %s index %d flags %#llx metric %d mtu %d", + ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, + ifp->metric, ifp->mtu6); /* Check if this interface is RIPng enabled or not. */ ripng_enable_apply (ifp); @@ -276,8 +277,9 @@ ripng_interface_down (int command, struct zclient *zclient, ripng_if_down (ifp); if (IS_RIPNG_DEBUG_ZEBRA) - zlog_debug ("interface down %s index %d flags %ld metric %d mtu %d", - ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6); + zlog_debug ("interface down %s index %d flags %#llx metric %d mtu %d", + ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, + ifp->metric, ifp->mtu6); return 0; } @@ -291,7 +293,7 @@ ripng_interface_add (int command, struct zclient *zclient, zebra_size_t length) ifp = zebra_interface_add_read (zclient->ibuf); if (IS_RIPNG_DEBUG_ZEBRA) - zlog_debug ("RIPng interface add %s index %d flags %ld metric %d mtu %d", + zlog_debug ("RIPng interface add %s index %d flags %#llx metric %d mtu %d", ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6); /* Check is this interface is RIP enabled or not.*/ @@ -324,7 +326,7 @@ ripng_interface_delete (int command, struct zclient *zclient, ripng_if_down(ifp); } - zlog_info("interface delete %s index %d flags %ld metric %d mtu %d", + zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d", ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6); /* To support pseudo interface do not free interface structure. */ -- cgit v1.2.3 From 31f4f59beb69270a3d39e96f527414880f49c846 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 09:59:21 -0700 Subject: ifdef out dead code Excise dead code to remove compiler warning --- lib/vty.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/vty.c b/lib/vty.c index ccf66406..0bfee7eb 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -1827,6 +1827,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) @@ -1891,6 +1892,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. */ -- cgit v1.2.3 From 23c6328dacc319630172356a063834c9773b1ada Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 10:01:09 -0700 Subject: fix warning from type mismatch size is size_t not int. --- bgpd/bgp_snmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index 3d26890e..a81f9b52 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -381,7 +381,7 @@ write_bgpPeerTable (int action, u_char *var_val, struct in_addr addr; struct peer *peer; long intval; - int bigsize = SNMP_MAX_LEN; + size_t bigsize = SNMP_MAX_LEN; if (var_val_type != ASN_INTEGER) { -- cgit v1.2.3 From 4421ea9c1df765b81cde6a9a4c2347e12151d230 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 10:01:58 -0700 Subject: ifdef out dead code ifdef out some unused functions to get rid of warnings. --- bgpd/bgp_packet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index e8f77f10..114cfb4f 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -923,6 +923,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) { @@ -946,6 +947,7 @@ safi2str (safi_t safi) else return "Unknown SAFI"; } +#endif /* Send route refresh message to the peer. */ void -- cgit v1.2.3 From 774b5b9ac303291dd153e79a6f6bab918a599025 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 10:03:14 -0700 Subject: get rid of compiler warnings in OSPF To get rid of warnings: * remove unused functions with ifdef * use correct printf formats --- ospf6d/ospf6_zebra.c | 5 +++-- ospfd/ospf_abr.c | 4 ++++ ospfd/ospf_api.c | 2 +- ospfd/ospf_ase.c | 2 ++ ospfd/ospf_lsa.c | 4 +++- ospfd/ospf_network.c | 10 ++++------ ospfd/ospf_route.c | 2 ++ ospfd/ospf_snmp.c | 2 ++ ospfd/ospf_spf.c | 2 ++ ospfd/ospf_vty.c | 2 ++ ospfd/ospf_zebra.c | 8 +++++--- ospfd/ospfd.c | 2 ++ 12 files changed, 32 insertions(+), 13 deletions(-) diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index c974005f..4440a67f 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -134,8 +134,9 @@ ospf6_zebra_if_state_update (int command, struct zclient *zclient, ifp = zebra_interface_state_read (zclient->ibuf); if (IS_OSPF6_DEBUG_ZEBRA (RECV)) zlog_debug ("Zebra Interface state change: " - "%s index %d flags %ld metric %d mtu %d", - ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6); + "%s index %d flags %#llx metric %d mtu %d", + ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, + ifp->metric, ifp->mtu6); ospf6_interface_state_update (ifp); return 0; diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index 88636f1a..d60ad120 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -614,6 +614,7 @@ set_metric (struct ospf_lsa *lsa, u_int32_t metric) memcpy(header->metric, mp, 3); } +#if 0 static int ospf_abr_check_nssa_range (struct prefix_ipv4 *p, u_int32_t cost, struct ospf_area *area) @@ -622,6 +623,7 @@ ospf_abr_check_nssa_range (struct prefix_ipv4 *p, u_int32_t cost, for lsa installation and flooding */ return 0; } +#endif /* ospf_abr_translate_nssa */ static int @@ -1580,6 +1582,7 @@ ospf_abr_send_nssa_aggregates (struct ospf *ospf) /* temporarily turned off */ zlog_debug ("ospf_abr_send_nssa_aggregates(): Stop"); } +#if 0 static void ospf_abr_announce_nssa_defaults (struct ospf *ospf) /* By ABR-Translator */ { @@ -1615,6 +1618,7 @@ ospf_abr_announce_nssa_defaults (struct ospf *ospf) /* By ABR-Translator */ } } } +#endif static void ospf_abr_announce_stub_defaults (struct ospf *ospf) diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c index 9c9997ba..179c97a7 100644 --- a/ospfd/ospf_api.c +++ b/ospfd/ospf_api.c @@ -220,7 +220,7 @@ msg_print (struct msg *msg) #else /* ORIGINAL_CODING */ /* API message common header part. */ zlog_debug - ("API-msg [%s]: type(%d),len(%d),seq(%lu),data(%p),size(%lu)", + ("API-msg [%s]: type(%d),len(%d),seq(%lu),data(%p),size(%z)", ospf_api_typename (msg->hdr.msgtype), msg->hdr.msgtype, ntohs (msg->hdr.msglen), (unsigned long) ntohl (msg->hdr.msgseq), STREAM_DATA (msg->s), STREAM_SIZE (msg->s)); diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index a4812345..47f8851f 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -156,6 +156,7 @@ ospf_ase_forward_address_check (struct ospf *ospf, struct in_addr fwd_addr) return 1; } +#if 0 /* Calculate ASBR route. */ static struct ospf_route * ospf_ase_calculate_asbr_route (struct ospf *ospf, @@ -236,6 +237,7 @@ ospf_ase_calculate_asbr_route (struct ospf *ospf, return asbr_route; } +#endif static struct ospf_route * ospf_ase_calculate_new_route (struct ospf_lsa *lsa, diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 243928f4..0d205ee3 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -526,7 +526,7 @@ link_info_set (struct stream *s, struct in_addr id, if (ret == OSPF_MAX_LSA_SIZE) { - zlog_warn ("%s: Out of space in LSA stream, left %ld, size %ld", + zlog_warn ("%s: Out of space in LSA stream, left %ld, size %z", __func__, STREAM_REMAIN (s), STREAM_SIZE (s)); return 0; } @@ -1895,6 +1895,7 @@ ospf_lsa_translated_nssa_new (struct ospf *ospf, return new; } +#if 0 /* compare type-5 to type-7 * -1: err, 0: same, 1: different */ @@ -1931,6 +1932,7 @@ ospf_lsa_translated_nssa_compare (struct ospf_lsa *t7, struct ospf_lsa *t5) return LSA_REFRESH_IF_CHANGED; } +#endif /* Originate Translated Type-5 for supplied Type-7 NSSA LSA */ struct ospf_lsa * diff --git a/ospfd/ospf_network.c b/ospfd/ospf_network.c index d5bf7493..1a91001f 100644 --- a/ospfd/ospf_network.c +++ b/ospfd/ospf_network.c @@ -165,11 +165,7 @@ int ospf_sock_init (void) { int ospf_sock; - /* - * XXX warning: unused variable `tos' - * tos should be ifdefed similarly to usage - */ - int ret, tos, hincl = 1; + int ret, hincl = 1; if ( ospfd_privs.change (ZPRIVS_RAISE) ) zlog_err ("ospf_sock_init: could not raise privs, %s", @@ -201,8 +197,9 @@ ospf_sock_init (void) #elif defined (IPTOS_PREC_INTERNETCONTROL) #warning "IP_HDRINCL not available on this system" #warning "using IPTOS_PREC_INTERNETCONTROL" + { /* Set precedence field. */ - tos = IPTOS_PREC_INTERNETCONTROL; + int tos = IPTOS_PREC_INTERNETCONTROL; ret = setsockopt (ospf_sock, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof (int)); if (ret < 0) @@ -216,6 +213,7 @@ ospf_sock_init (void) close (ospf_sock); /* Prevent sd leak. */ return ret; } + } #else /* !IPTOS_PREC_INTERNETCONTROL */ #warning "IP_HDRINCL not available, nor is IPTOS_PREC_INTERNETCONTROL" zlog_warn ("IP_HDRINCL option not available"); diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index 3a1fa999..fc372329 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -270,6 +270,7 @@ ospf_route_install (struct ospf *ospf, struct route_table *rt) } } +#if 0 static void ospf_intra_route_add (struct route_table *rt, struct vertex *v, struct ospf_area *area) @@ -324,6 +325,7 @@ ospf_intra_route_add (struct route_table *rt, struct vertex *v, rn->info = or; } +#endif /* RFC2328 16.1. (4). For "router". */ void diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 6e972605..e76b39b0 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -1561,6 +1561,7 @@ ospf_snmp_if_lookup_next (struct in_addr *ifaddr, unsigned int *ifindex, { /* Usual interface */ if (ifaddr->s_addr) + { /* The interface must have valid AF_INET connected address */ /* it must have lager IPv4 address value than the lookup entry */ if ((ospf_snmp_is_if_have_addr(osif->ifp)) && @@ -1574,6 +1575,7 @@ ospf_snmp_if_lookup_next (struct in_addr *ifaddr, unsigned int *ifindex, if (oi) return oi; } + } /* Unnumbered interface */ else /* The interface must NOT have valid AF_INET connected address */ diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index 23d45dd6..34d25ed5 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -1024,6 +1024,7 @@ ospf_rtrs_free (struct route_table *rtrs) route_table_finish (rtrs); } +#if 0 static void ospf_rtrs_print (struct route_table *rtrs) { @@ -1082,6 +1083,7 @@ ospf_rtrs_print (struct route_table *rtrs) zlog_debug ("ospf_rtrs_print() end"); } +#endif /* Calculating the shortest-path tree for an area. */ static void diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 5f9fa2cb..c96b88ab 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3766,6 +3766,7 @@ show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) return 0; } +#if 0 /* N.B. This function currently seems to be unused. */ static int show_as_external_lsa_stdvty (struct ospf_lsa *lsa) @@ -3790,6 +3791,7 @@ show_as_external_lsa_stdvty (struct ospf_lsa *lsa) return 0; } +#endif /* Show AS-NSSA-LSA detail information. */ static int diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index f302d28d..5405a782 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -92,8 +92,9 @@ ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length) ifp = zebra_interface_add_read (zclient->ibuf); if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) - zlog_debug ("Zebra: interface add %s index %d flags %ld metric %d mtu %d", - ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); + zlog_debug ("Zebra: interface add %s index %d flags %#llx metric %d mtu %d", + ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, + ifp->metric, ifp->mtu); assert (ifp->info); @@ -136,7 +137,8 @@ ospf_interface_delete (int command, struct zclient *zclient, if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) zlog_debug ("Zebra: interface delete %s index %d flags %ld metric %d mtu %d", - ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); + ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, + ifp->metric, ifp->mtu); #ifdef HAVE_SNMP ospf_snmp_if_delete (ifp); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index a4c4fac3..448f218e 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -1246,6 +1246,7 @@ ospf_area_nssa_translator_role_set (struct ospf *ospf, struct in_addr area_id, return 1; } +#if 0 /* XXX: unused? Leave for symmetry? */ static int ospf_area_nssa_translator_role_unset (struct ospf *ospf, @@ -1263,6 +1264,7 @@ ospf_area_nssa_translator_role_unset (struct ospf *ospf, return 1; } +#endif int ospf_area_export_list_set (struct ospf *ospf, -- cgit v1.2.3 From 078fe1a5228485101a19caba39dab70ea12179ae Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 10:20:21 -0700 Subject: only process some isisd files ISISD has several different methods and only one is valid on each system, so running the others through the preprocessor gives warnings for missing includes. Instead, only run the few isisd files that have VTY stuff through the extraction step. --- vtysh/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am index dbd1d3d2..a4be3413 100644 --- a/vtysh/Makefile.am +++ b/vtysh/Makefile.am @@ -18,7 +18,9 @@ dist_examples_DATA = vtysh.conf.sample EXTRA_DIST = extract.pl -vtysh_cmd_FILES = $(top_srcdir)/bgpd/*.c $(top_srcdir)/isisd/*.c \ +vtysh_cmd_FILES = $(top_srcdir)/bgpd/*.c \ + $(top_srcdir)/isisd/isisd.c $(top_srcdir)/isisd/isis_spf.c \ + $(top_srcdir)/isisd/isis_circuit.c \ $(top_srcdir)/ospfd/*.c $(top_srcdir)/ospf6d/*.c \ $(top_srcdir)/ripd/*.c $(top_srcdir)/ripngd/*.c \ $(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c \ -- cgit v1.2.3 From 489d3935b90bc6f1a0b866f321c4d1fc9f480d8b Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 10:21:51 -0700 Subject: fix compiler warnings Fix easy compiler warnings about unused code by marking them with #if 0 Add one missing printf argument. --- bgpd/bgp_clist.c | 2 ++ bgpd/bgp_damp.c | 4 ---- bgpd/bgp_packet.c | 2 +- bgpd/bgp_route.c | 2 ++ bgpd/bgp_zebra.c | 2 ++ 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index f75fc55b..a6ca1a46 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -836,6 +836,7 @@ community_list_init (void) return ch; } +#if 0 /* Terminate community-list. */ static void community_list_terminate (struct community_list_handler *ch) @@ -857,3 +858,4 @@ community_list_terminate (struct community_list_handler *ch) XFREE (MTYPE_COMMUNITY_LIST_HANDLER, ch); } +#endif diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 5a7c9aaa..a0a8557d 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -520,8 +520,6 @@ bgp_damp_disable (struct bgp *bgp, afi_t afi, safi_t safi) int bgp_config_write_damp (struct vty *vty) { - if (&bgp_damp_cfg) - { if (bgp_damp_cfg.half_life == DEFAULT_HALF_LIFE*60 && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS @@ -542,8 +540,6 @@ bgp_config_write_damp (struct vty *vty) bgp_damp_cfg.max_suppress_time/60, VTY_NEWLINE); return 1; - } - return 0; } #define BGP_UPTIME_LEN 25 diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 114cfb4f..f92a88ad 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1237,7 +1237,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size) zlog_debug ("%s [AS4] OPEN remote_as is AS_TRANS, but no AS4." " Odd, but proceeding.", peer->host); else if (as4 < BGP_AS_MAX && BGP_DEBUG (as4, AS4)) - zlog_debug ("%s [AS4] OPEN remote_as is AS_TRANS, but AS4 fits " + zlog_debug ("%s [AS4] OPEN remote_as is AS_TRANS, but AS4 %u fits " "in 2-bytes, very odd peer.", peer->host, as4); if (as4) remote_as = as4; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4fbc4bab..f8eb7f7f 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10959,6 +10959,7 @@ bgp_distance_unset (struct vty *vty, const char *distance_str, return CMD_SUCCESS; } +#if 0 static void bgp_distance_reset () { @@ -10975,6 +10976,7 @@ bgp_distance_reset () bgp_unlock_node (rn); } } +#endif /* Apply BGP information to distance method. */ u_char diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 0b6ab45a..ec1143af 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -639,6 +639,7 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, return ret; } +#if 0 #ifdef HAVE_IPV6 static unsigned int bgp_ifindex_by_nexthop (struct in6_addr *addr) @@ -671,6 +672,7 @@ bgp_ifindex_by_nexthop (struct in6_addr *addr) return 0; } #endif /* HAVE_IPV6 */ +#endif void bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp) -- cgit v1.2.3 From 2acdc2da15cd36573bdff5d5e7ee44a135fbf735 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 10:44:52 -0700 Subject: get rid of duplicate includes included same file twice --- zebra/if_linkdetect.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/zebra/if_linkdetect.c b/zebra/if_linkdetect.c index 9d0457aa..4f95c16e 100644 --- a/zebra/if_linkdetect.c +++ b/zebra/if_linkdetect.c @@ -20,9 +20,6 @@ */ #include -#include "log.h" -#include "privs.h" - #include "log.h" #include "privs.h" #include "prefix.h" -- cgit v1.2.3 From 97dd2bf9bb517c428cfa2778cac071ad845d03a1 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 May 2008 10:47:30 -0700 Subject: netlink interface minor stuff Add more prototypes and make some functions static --- zebra/if_netlink.c | 5 ++--- zebra/rt_netlink.c | 32 ++++++++++++++++---------------- zebra/rtread_netlink.c | 6 ++---- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index c9c14760..701c81b6 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -22,12 +22,11 @@ #include -/* Extern from rt_netlink.c */ -void interface_lookup_netlink (); +extern int interface_lookup_netlink (void); /* Interface information read by netlink. */ void -interface_list () +interface_list (void) { interface_lookup_netlink (); } diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 71d26a76..c6ec08c6 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 */ -struct message nlmsg_str[] = { +static struct message nlmsg_str[] = { {RTM_NEWROUTE, "RTM_NEWROUTE"}, {RTM_DELROUTE, "RTM_DELROUTE"}, {RTM_GETROUTE, "RTM_GETROUTE"}, @@ -66,7 +66,7 @@ struct message nlmsg_str[] = { {0, NULL} }; -const char *nexthop_types_desc[] = +static const char *nexthop_types_desc[] = { "none", "Directly connected", @@ -440,7 +440,7 @@ netlink_parse_rtattr (struct rtattr **tb, int max, struct rtattr *rta, /* Called from interface_lookup_netlink(). This function is only used during bootstrap. */ -int +static int netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h) { int len; @@ -517,7 +517,7 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h) } /* Lookup interface IPv4/IPv6 address. */ -int +static int netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) { int len; @@ -652,7 +652,7 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) } /* Looking up routing table by netlink interface. */ -int +static int netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) { int len; @@ -769,7 +769,7 @@ struct message rtproto_str[] = { }; /* Routing information change from the kernel. */ -int +static int netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h) { int len; @@ -910,7 +910,7 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h) return 0; } -int +static int netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h) { int len; @@ -1023,7 +1023,7 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h) return 0; } -int +static int netlink_information_fetch (struct sockaddr_nl *snl, struct nlmsghdr *h) { /* JF: Ignore messages that aren't from the kernel */ @@ -1125,7 +1125,7 @@ netlink_route_read (void) /* Utility function comes from iproute2. Authors: Alexey Kuznetsov, */ -int +static int addattr_l (struct nlmsghdr *n, int maxlen, int type, void *data, int alen) { int len; @@ -1145,7 +1145,7 @@ addattr_l (struct nlmsghdr *n, int maxlen, int type, void *data, int alen) return 0; } -int +static int rta_addattr_l (struct rtattr *rta, int maxlen, int type, void *data, int alen) { int len; @@ -1167,7 +1167,7 @@ rta_addattr_l (struct rtattr *rta, int maxlen, int type, void *data, int alen) /* Utility function comes from iproute2. Authors: Alexey Kuznetsov, */ -int +static int addattr32 (struct nlmsghdr *n, int maxlen, int type, int data) { int len; @@ -1195,7 +1195,7 @@ netlink_talk_filter (struct sockaddr_nl *snl, struct nlmsghdr *h) } /* sendmsg() to netlink socket then recvmsg(). */ -int +static int netlink_talk (struct nlmsghdr *n, struct nlsock *nl) { int status; @@ -1241,7 +1241,7 @@ netlink_talk (struct nlmsghdr *n, struct nlsock *nl) } /* Routing table change via netlink interface. */ -int +static int netlink_route (int cmd, int family, void *dest, int length, void *gate, int index, int zebra_flags, int table) { @@ -1316,7 +1316,7 @@ netlink_route (int cmd, int family, void *dest, int length, void *gate, } /* Routing table change via netlink interface. */ -int +static int netlink_route_multipath (int cmd, struct prefix *p, struct rib *rib, int family) { @@ -1779,7 +1779,7 @@ kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, #endif /* HAVE_IPV6 */ /* Interface address modification. */ -int +static int netlink_address (int cmd, int family, struct interface *ifp, struct connected *ifc) { @@ -1844,7 +1844,7 @@ kernel_address_delete_ipv4 (struct interface *ifp, struct connected *ifc) extern struct thread_master *master; /* Kernel route reflection. */ -int +static int kernel_read (struct thread *thread) { int ret; diff --git a/zebra/rtread_netlink.c b/zebra/rtread_netlink.c index 0b255a53..44715d94 100644 --- a/zebra/rtread_netlink.c +++ b/zebra/rtread_netlink.c @@ -21,11 +21,9 @@ */ #include +extern void netlink_route_read (void); -/* Extern from rt_netlink.c */ -void netlink_route_read (); - -void route_read () +void route_read (void) { netlink_route_read (); } -- cgit v1.2.3