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
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);
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;
(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);
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;
}
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);
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)
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 &&
peer_weight_set_vty (struct vty *vty, const char *ip_str,
const char *weight_str)
{
+ int ret;
struct peer *peer;
unsigned long weight;
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,
}
/* neighbor weight. */
-void
+int
peer_weight_set (struct peer *peer, u_int16_t weight)
{
struct peer_group *group;
peer->weight = weight;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
- return;
+ return 0;
/* peer-group member updates. */
group = peer->group;
{
peer->weight = group->conf->weight;
}
+ return 1;
}
-void
+int
peer_weight_unset (struct peer *peer)
{
struct peer_group *group;
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;
{
peer->weight = 0;
}
- return;
+ return 1;
}
int
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 *);
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. */
* 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;
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;
/* 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;
/* 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;
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;
safe_strerror (errno));
}
-void
+static void
ospf6_set_pktinfo (void)
{
setsockopt_ipv6_pktinfo (ospf6_sock, 1);
#endif
}
-void
+static void
ospf6_set_checksum (void)
{
int offset = 12;
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);
/* 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;
#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) \
#include "ospf6_intra.h"
#include "ospf6_interface.h"
#include "ospf6d.h"
+#include "ospf6_abr.h"
unsigned char conf_debug_ospf6_spf = 0;
#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)
{