forked from Mirror/frr
Fix most compiler warnings in default GCC build.
Fix lots of warnings. Some const and type-pun breaks strict-aliasing warnings left but much reduced. * bgp_advertise.h: (struct bgp_advertise_fifo) is functionally identical to (struct fifo), so just use that. Makes it clearer the beginning of (struct bgp_advertise) is compatible with with (struct fifo), which seems to be enough for gcc. Add a BGP_ADV_FIFO_HEAD macro to contain the right cast to try shut up type-punning breaks strict aliasing warnings. * bgp_packet.c: Use BGP_ADV_FIFO_HEAD. (bgp_route_refresh_receive) fix an interesting logic error in (!ok || (ret != BLAH)) where ret is only well-defined if ok. * bgp_vty.c: Peer commands should use bgp_vty_return to set their return. * jhash.{c,h}: Can take const on * args without adding issues & fix warnings. * libospf.h: LSA sequence numbers use the unsigned range of values, and constants need to be set to unsigned, or it causes warnings in ospf6d. * md5.h: signedness of caddr_t is implementation specific, change to an explicit (uint_8 *), fix sign/unsigned comparison warnings. * vty.c: (vty_log_fixed) const on level is well-intentioned, but not going to fly given iov_base. * workqueue.c: ALL_LIST_ELEMENTS_RO tests for null pointer, which is always true for address of static variable. Correct but pointless warning in this case, but use a 2nd pointer to shut it up. * ospf6_route.h: Add a comment about the use of (struct prefix) to stuff 2 different 32 bit IDs into in (struct ospf6_route), and the resulting type-pun strict-alias breakage warnings this causes. Need to use 2 different fields to fix that warning? general: * remove unused variables, other than a few cases where they serve a sufficiently useful documentary purpose (e.g. for code that needs fixing), or they're required dummies. In those cases, try mark them as unused. * Remove dead code that can't be reached. * Quite a few 'no ...' forms of vty commands take arguments, but do not check the argument matches the command being negated. E.g., should 'distance X <prefix>' succeed if previously 'distance Y <prefix>' was set? Or should it be required that the distance match the previously configured distance for the prefix? Ultimately, probably better to be strict about this. However, changing from slack to strict might expose problems in command aliases and tools. * Fix uninitialised use of variables. * Fix sign/unsigned comparison warnings by making signedness of types consistent. * Mark functions as static where their use is restricted to the same compilation unit. * Add required headers * Move constants defined in headers into code. * remove dead, unused functions that have no debug purpose. (cherry picked from commit 7aa9dcef80b2ce50ecaa77653d87c8b84e009c49) Conflicts: bgpd/bgp_advertise.h bgpd/bgp_mplsvpn.c bgpd/bgp_nexthop.c bgpd/bgp_packet.c bgpd/bgp_route.c bgpd/bgp_routemap.c bgpd/bgp_vty.c lib/command.c lib/if.c lib/jhash.c lib/workqueue.c ospf6d/ospf6_lsa.c ospf6d/ospf6_neighbor.h ospf6d/ospf6_spf.c ospf6d/ospf6_top.c ospfd/ospf_api.c zebra/router-id.c zebra/rt_netlink.c zebra/rt_netlink.h
This commit is contained in:
parent
64fdba2ace
commit
1f9a9fffc1
|
@ -130,6 +130,15 @@ bgp_nlri_parse_vpnv4 (struct peer *peer, struct attr *attr,
|
|||
pnt += BGP_ADDPATH_ID_LEN;
|
||||
}
|
||||
|
||||
if (prefixlen < 88)
|
||||
{
|
||||
zlog_err ("prefix length is less than 88: %d", prefixlen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* XXX: Not doing anything with the label */
|
||||
decode_label (pnt);
|
||||
|
||||
/* Fetch prefix length. */
|
||||
prefixlen = *pnt++;
|
||||
p.family = afi2family (packet->afi);
|
||||
|
|
|
@ -1862,8 +1862,8 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
|
|||
if (orf_type == ORF_TYPE_PREFIX
|
||||
|| orf_type == ORF_TYPE_PREFIX_OLD)
|
||||
{
|
||||
u_char *p_pnt = stream_pnt (s);
|
||||
u_char *p_end = stream_pnt (s) + orf_len;
|
||||
uint8_t *p_pnt = stream_pnt (s);
|
||||
uint8_t *p_end = stream_pnt (s) + orf_len;
|
||||
struct orf_prefix orfp;
|
||||
u_char common = 0;
|
||||
u_int32_t seq;
|
||||
|
@ -1956,7 +1956,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
|
|||
(common & ORF_COMMON_PART_DENY ? 0 : 1 ),
|
||||
(common & ORF_COMMON_PART_REMOVE ? 0 : 1));
|
||||
|
||||
if (!ok || (ret != CMD_SUCCESS))
|
||||
if (!ok || (ok && ret != CMD_SUCCESS))
|
||||
{
|
||||
zlog_info ("%s Received misformatted prefixlist ORF."
|
||||
" Remove All pfxlist", peer->host);
|
||||
|
|
|
@ -13399,6 +13399,7 @@ bgp_distance_unset (struct vty *vty, const char *distance_str,
|
|||
const char *ip_str, const char *access_list_str)
|
||||
{
|
||||
int ret;
|
||||
int distance;
|
||||
struct prefix_ipv4 p;
|
||||
struct bgp_node *rn;
|
||||
struct bgp_distance *bdistance;
|
||||
|
@ -13418,6 +13419,13 @@ bgp_distance_unset (struct vty *vty, const char *distance_str,
|
|||
}
|
||||
|
||||
bdistance = rn->info;
|
||||
distance = atoi(distance_str);
|
||||
|
||||
if (bdistance->distance != distance)
|
||||
{
|
||||
vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (bdistance->access_list)
|
||||
XFREE(MTYPE_AS_LIST, bdistance->access_list);
|
||||
|
|
|
@ -2100,6 +2100,7 @@ static route_map_result_t
|
|||
route_match_ipv6_next_hop (void *rule, struct prefix *prefix,
|
||||
route_map_object_t type, void *object)
|
||||
{
|
||||
struct in6_addr *addr = rule;
|
||||
struct bgp_info *bgp_info;
|
||||
|
||||
if (type == RMAP_BGP)
|
||||
|
@ -2109,7 +2110,7 @@ route_match_ipv6_next_hop (void *rule, struct prefix *prefix,
|
|||
if (!bgp_info->attr->extra)
|
||||
return RMAP_NOMATCH;
|
||||
|
||||
if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, rule))
|
||||
if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, addr))
|
||||
return RMAP_MATCH;
|
||||
|
||||
if (bgp_info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL &&
|
||||
|
|
|
@ -4662,6 +4662,7 @@ static int
|
|||
peer_weight_set_vty (struct vty *vty, const char *ip_str,
|
||||
const char *weight_str)
|
||||
{
|
||||
int ret;
|
||||
struct peer *peer;
|
||||
unsigned long weight;
|
||||
|
||||
|
@ -4671,23 +4672,22 @@ peer_weight_set_vty (struct vty *vty, const char *ip_str,
|
|||
|
||||
VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
|
||||
|
||||
peer_weight_set (peer, weight);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
ret = peer_weight_set (peer, weight);
|
||||
return bgp_vty_return (vty, ret);
|
||||
}
|
||||
|
||||
static int
|
||||
peer_weight_unset_vty (struct vty *vty, const char *ip_str)
|
||||
{
|
||||
int ret;
|
||||
struct peer *peer;
|
||||
|
||||
peer = peer_and_group_lookup_vty (vty, ip_str);
|
||||
if (! peer)
|
||||
return CMD_WARNING;
|
||||
|
||||
peer_weight_unset (peer);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
ret = peer_weight_unset (peer);
|
||||
return bgp_vty_return (vty, ret);
|
||||
}
|
||||
|
||||
DEFUN (neighbor_weight,
|
||||
|
|
11
bgpd/bgpd.c
11
bgpd/bgpd.c
|
@ -4421,7 +4421,7 @@ peer_port_unset (struct peer *peer)
|
|||
}
|
||||
|
||||
/* neighbor weight. */
|
||||
void
|
||||
int
|
||||
peer_weight_set (struct peer *peer, u_int16_t weight)
|
||||
{
|
||||
struct peer_group *group;
|
||||
|
@ -4431,7 +4431,7 @@ peer_weight_set (struct peer *peer, u_int16_t weight)
|
|||
peer->weight = weight;
|
||||
|
||||
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
|
||||
return;
|
||||
return 0;
|
||||
|
||||
/* peer-group member updates. */
|
||||
group = peer->group;
|
||||
|
@ -4439,9 +4439,10 @@ peer_weight_set (struct peer *peer, u_int16_t weight)
|
|||
{
|
||||
peer->weight = group->conf->weight;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
peer_weight_unset (struct peer *peer)
|
||||
{
|
||||
struct peer_group *group;
|
||||
|
@ -4456,7 +4457,7 @@ peer_weight_unset (struct peer *peer)
|
|||
UNSET_FLAG (peer->config, PEER_CONFIG_WEIGHT);
|
||||
|
||||
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
|
||||
return;
|
||||
return 0;
|
||||
|
||||
/* peer-group member updates. */
|
||||
group = peer->group;
|
||||
|
@ -4464,7 +4465,7 @@ peer_weight_unset (struct peer *peer)
|
|||
{
|
||||
peer->weight = 0;
|
||||
}
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -1268,8 +1268,8 @@ extern int peer_default_originate_unset (struct peer *, afi_t, safi_t);
|
|||
extern int peer_port_set (struct peer *, u_int16_t);
|
||||
extern int peer_port_unset (struct peer *);
|
||||
|
||||
extern void peer_weight_set (struct peer *, u_int16_t);
|
||||
extern void peer_weight_unset (struct peer *);
|
||||
extern int peer_weight_set (struct peer *, u_int16_t);
|
||||
extern int peer_weight_unset (struct peer *);
|
||||
|
||||
extern int peer_timers_set (struct peer *, u_int32_t, u_int32_t);
|
||||
extern int peer_timers_unset (struct peer *);
|
||||
|
|
14
lib/if.c
14
lib/if.c
|
@ -638,16 +638,14 @@ if_flag_dump (unsigned long flag)
|
|||
static void
|
||||
if_dump (const struct interface *ifp)
|
||||
{
|
||||
struct listnode *node;
|
||||
struct connected *c __attribute__((unused));
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, c))
|
||||
zlog_info ("Interface %s vrf %u index %d metric %d mtu %d "
|
||||
#ifdef HAVE_IPV6
|
||||
"mtu6 %d "
|
||||
#endif /* HAVE_IPV6 */
|
||||
"%s",
|
||||
"mtu6 %d %s",
|
||||
ifp->name, ifp->vrf_id, ifp->ifindex, ifp->metric, ifp->mtu,
|
||||
#ifdef HAVE_IPV6
|
||||
ifp->mtu6,
|
||||
#endif /* HAVE_IPV6 */
|
||||
if_flag_dump (ifp->flags));
|
||||
ifp->mtu6, if_flag_dump (ifp->flags));
|
||||
}
|
||||
|
||||
/* Interface printing for all interface. */
|
||||
|
|
|
@ -105,7 +105,7 @@ jhash (const void *key, u_int32_t length, u_int32_t initval)
|
|||
* The length parameter here is the number of u_int32_ts in the key.
|
||||
*/
|
||||
u_int32_t
|
||||
jhash2 (const u_int32_t * k, u_int32_t length, u_int32_t initval)
|
||||
jhash2 (const u_int32_t *k, u_int32_t length, u_int32_t initval)
|
||||
{
|
||||
u_int32_t a, b, c, len;
|
||||
|
||||
|
|
|
@ -2486,7 +2486,7 @@ vty_log_fixed (char *buf, size_t len)
|
|||
if (!vtyvec)
|
||||
return;
|
||||
|
||||
iov[0].iov_base = (void *)buf;
|
||||
iov[0].iov_base = buf;
|
||||
iov[0].iov_len = len;
|
||||
iov[1].iov_base = crlf;
|
||||
iov[1].iov_len = 2;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
/* master list of work_queues */
|
||||
static struct list _work_queues;
|
||||
/* pointer primarly to avid an otherwise harmless warning on
|
||||
/* pointer primarily to avoid an otherwise harmless warning on
|
||||
* ALL_LIST_ELEMENTS_RO
|
||||
*/
|
||||
static struct list *work_queues = &_work_queues;
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
/* for struct ospf6_route */
|
||||
#include "ospf6_route.h"
|
||||
/* for struct ospf6_prefix */
|
||||
#include "ospf6_proto.h"
|
||||
|
||||
/* Debug option */
|
||||
extern unsigned char conf_debug_ospf6_abr;
|
||||
|
|
|
@ -37,18 +37,8 @@ int ospf6_sock;
|
|||
struct in6_addr allspfrouters6;
|
||||
struct in6_addr alldrouters6;
|
||||
|
||||
/* setsockopt ReUseAddr to on */
|
||||
void
|
||||
ospf6_set_reuseaddr (void)
|
||||
{
|
||||
u_int on = 0;
|
||||
if (setsockopt (ospf6_sock, SOL_SOCKET, SO_REUSEADDR, &on,
|
||||
sizeof (u_int)) < 0)
|
||||
zlog_warn ("Network: set SO_REUSEADDR failed: %s", safe_strerror (errno));
|
||||
}
|
||||
|
||||
/* setsockopt MulticastLoop to off */
|
||||
void
|
||||
static void
|
||||
ospf6_reset_mcastloop (void)
|
||||
{
|
||||
u_int off = 0;
|
||||
|
@ -58,7 +48,7 @@ ospf6_reset_mcastloop (void)
|
|||
safe_strerror (errno));
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
ospf6_set_pktinfo (void)
|
||||
{
|
||||
setsockopt_ipv6_pktinfo (ospf6_sock, 1);
|
||||
|
@ -72,7 +62,7 @@ ospf6_set_transport_class (void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
ospf6_set_checksum (void)
|
||||
{
|
||||
int offset = 12;
|
||||
|
|
|
@ -28,12 +28,6 @@ extern int ospf6_sock;
|
|||
extern struct in6_addr allspfrouters6;
|
||||
extern struct in6_addr alldrouters6;
|
||||
|
||||
/* Function Prototypes */
|
||||
extern void ospf6_set_reuseaddr (void);
|
||||
extern void ospf6_reset_mcastloop (void);
|
||||
extern void ospf6_set_pktinfo (void);
|
||||
extern void ospf6_set_checksum (void);
|
||||
|
||||
extern int ospf6_serv_sock (void);
|
||||
extern int ospf6_sso (u_int ifindex, struct in6_addr *group, int option);
|
||||
|
||||
|
|
|
@ -130,6 +130,10 @@ struct ospf6_route
|
|||
/* Destination Type */
|
||||
u_char type;
|
||||
|
||||
/* XXX: It would likely be better to use separate struct in_addr's
|
||||
* for the advertising router-ID and prefix IDs, instead of stuffing them
|
||||
* into one. See also XXX below.
|
||||
*/
|
||||
/* Destination ID */
|
||||
struct prefix prefix;
|
||||
|
||||
|
@ -247,6 +251,7 @@ extern const char *ospf6_path_type_substr[OSPF6_PATH_TYPE_MAX];
|
|||
|
||||
#define ospf6_route_is_best(r) (CHECK_FLAG ((r)->flag, OSPF6_ROUTE_BEST))
|
||||
|
||||
/* XXX: This gives GCC heartburn aboutbreaking aliasing rules. */
|
||||
#define ospf6_linkstate_prefix_adv_router(x) \
|
||||
((x)->u.prefix4.s_addr)
|
||||
#define ospf6_linkstate_prefix_id(x) \
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "ospf6_intra.h"
|
||||
#include "ospf6_interface.h"
|
||||
#include "ospf6d.h"
|
||||
#include "ospf6_abr.h"
|
||||
|
||||
unsigned char conf_debug_ospf6_spf = 0;
|
||||
|
||||
|
|
|
@ -43,6 +43,9 @@
|
|||
#include "zebra/router-id.h"
|
||||
#include "zebra/redistribute.h"
|
||||
|
||||
/* master zebra server structure */
|
||||
extern struct zebra_t zebrad;
|
||||
|
||||
static struct connected *
|
||||
router_id_find_node (struct list *l, struct connected *ifc)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue