From 0cefb3ad30d54bf4b74855c7eba4d0328098e3f0 Mon Sep 17 00:00:00 2001 From: renato Date: Wed, 21 Oct 2015 03:48:09 +0000 Subject: [PATCH] Minor fixes and code cleanup. --- usr.sbin/eigrpd/eigrpd.h | 54 ++++++++++++++++++------------------- usr.sbin/eigrpd/interface.c | 8 +++--- usr.sbin/eigrpd/kroute.c | 3 +-- usr.sbin/eigrpd/rde.c | 4 +-- usr.sbin/eigrpd/rde.h | 6 ++--- usr.sbin/eigrpd/rde_dual.c | 21 ++------------- usr.sbin/eigrpd/rtp.c | 13 +++++---- usr.sbin/eigrpd/tlv.c | 4 +-- 8 files changed, 45 insertions(+), 68 deletions(-) diff --git a/usr.sbin/eigrpd/eigrpd.h b/usr.sbin/eigrpd/eigrpd.h index bfe89a26bad..e9b52ab44bb 100644 --- a/usr.sbin/eigrpd/eigrpd.h +++ b/usr.sbin/eigrpd/eigrpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpd.h,v 1.3 2015/10/04 22:54:38 renato Exp $ */ +/* $OpenBSD: eigrpd.h,v 1.4 2015/10/21 03:48:09 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -157,18 +157,18 @@ enum route_type { /* routing information advertised by update/query/reply messages */ struct rinfo { - int af; - enum route_type type; - union eigrpd_addr prefix; - uint8_t prefixlen; - union eigrpd_addr nexthop; - struct classic_metric metric; - struct classic_emetric emetric; + int af; + enum route_type type; + union eigrpd_addr prefix; + uint8_t prefixlen; + union eigrpd_addr nexthop; + struct classic_metric metric; + struct classic_emetric emetric; }; struct rinfo_entry { - TAILQ_ENTRY(rinfo_entry) entry; - struct rinfo rinfo; + TAILQ_ENTRY(rinfo_entry) entry; + struct rinfo rinfo; }; TAILQ_HEAD(rinfo_head, rinfo_entry); @@ -202,9 +202,9 @@ struct eigrp_iface { #define IN6ADDRSZ 16 struct seq_addr_entry { - TAILQ_ENTRY(seq_addr_entry) entry; - int af; - union eigrpd_addr addr; + TAILQ_ENTRY(seq_addr_entry) entry; + int af; + union eigrpd_addr addr; }; TAILQ_HEAD(seq_addr_head, seq_addr_entry); @@ -223,24 +223,24 @@ RB_HEAD(rt_tree, rt_node); #define REDIST_NO 0x40 struct redist_metric { - uint32_t bandwidth; - uint32_t delay; - uint8_t reliability; - uint8_t load; - uint16_t mtu; + uint32_t bandwidth; + uint32_t delay; + uint8_t reliability; + uint8_t load; + uint16_t mtu; }; struct redistribute { - SIMPLEQ_ENTRY(redistribute) entry; - uint8_t type; - int af; - union eigrpd_addr addr; - uint8_t prefixlen; - struct redist_metric *metric; + SIMPLEQ_ENTRY(redistribute) entry; + uint8_t type; + int af; + union eigrpd_addr addr; + uint8_t prefixlen; + struct redist_metric *metric; struct { - uint32_t as; - uint32_t metric; - uint32_t tag; + uint32_t as; + uint32_t metric; + uint32_t tag; } emetric; }; SIMPLEQ_HEAD(redist_list, redistribute); diff --git a/usr.sbin/eigrpd/interface.c b/usr.sbin/eigrpd/interface.c index 0b5fec75b57..824d96c8f6c 100644 --- a/usr.sbin/eigrpd/interface.c +++ b/usr.sbin/eigrpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.6 2015/10/10 05:09:19 renato Exp $ */ +/* $OpenBSD: interface.c,v 1.7 2015/10/21 03:48:09 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -93,14 +93,10 @@ if_new(struct eigrpd_conf *xconf, struct kif *kif) void if_del(struct iface *iface) { - struct eigrp_iface *ei; struct if_addr *if_addr; log_debug("%s: interface %s", __func__, iface->name); - while ((ei = TAILQ_FIRST(&iface->ei_list)) != NULL) - eigrp_if_del(ei); - while ((if_addr = TAILQ_FIRST(&iface->addr_list)) != NULL) { TAILQ_REMOVE(&iface->addr_list, if_addr, entry); free(if_addr); @@ -316,6 +312,8 @@ eigrp_if_del(struct eigrp_iface *ei) RB_REMOVE(iface_id_head, &ifaces_by_id, ei); TAILQ_REMOVE(&ei->eigrp->ei_list, ei, e_entry); TAILQ_REMOVE(&ei->iface->ei_list, ei, i_entry); + message_list_clr(&ei->query_list); + message_list_clr(&ei->update_list); if (ei->state == IF_STA_ACTIVE) eigrp_if_reset(ei); diff --git a/usr.sbin/eigrpd/kroute.c b/usr.sbin/eigrpd/kroute.c index 7d0c081b1eb..e1b879d595d 100644 --- a/usr.sbin/eigrpd/kroute.c +++ b/usr.sbin/eigrpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.1 2015/10/02 04:26:47 renato Exp $ */ +/* $OpenBSD: kroute.c,v 1.2 2015/10/21 03:48:09 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -1525,7 +1525,6 @@ rtmsg_process_route(struct rt_msghdr *rtm, struct sockaddr *rti_info[RTAX_MAX]) kr.flags |= F_DYNAMIC; kr.priority = rtm->rtm_priority; - if (rtm->rtm_type == RTM_CHANGE) { /* * The kernel doesn't allow RTM_CHANGE for multipath routes. diff --git a/usr.sbin/eigrpd/rde.c b/usr.sbin/eigrpd/rde.c index 6cc10589ad5..d20d29821d2 100644 --- a/usr.sbin/eigrpd/rde.c +++ b/usr.sbin/eigrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.4 2015/10/10 05:12:33 renato Exp $ */ +/* $OpenBSD: rde.c,v 1.5 2015/10/21 03:48:09 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -452,7 +452,7 @@ rde_dispatch_parent(int fd, short event, void *bula) void rde_instance_init(struct eigrp *eigrp) { - struct rde_nbr nbr; + struct rde_nbr nbr; memset(&nbr, 0, sizeof(nbr)); nbr.flags = F_RDE_NBR_SELF | F_RDE_NBR_REDIST; diff --git a/usr.sbin/eigrpd/rde.h b/usr.sbin/eigrpd/rde.h index 47adebb642f..a010f0ae38e 100644 --- a/usr.sbin/eigrpd/rde.h +++ b/usr.sbin/eigrpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.2 2015/10/05 01:59:33 renato Exp $ */ +/* $OpenBSD: rde.h,v 1.3 2015/10/21 03:48:09 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -171,7 +171,6 @@ void rt_set_successor(struct rt_node *, struct eigrp_route *); struct eigrp_route *rt_get_successor_fc(struct rt_node *); -void rde_send_ack(struct rde_nbr *); void rde_send_update(struct eigrp_iface *, struct rinfo *); void rde_send_update_all(struct rt_node *, struct rinfo *); void rde_send_query(struct eigrp_iface *, struct rinfo *, @@ -189,8 +188,7 @@ void rde_check_link_down_rn(struct rde_nbr *, struct rt_node *, struct eigrp_route *); void rde_check_link_down_nbr(struct rde_nbr *); void rde_check_link_down(unsigned int); -struct eigrp_interface; void rde_check_link_cost_change(struct rde_nbr *, - struct eigrp_interface *); + struct eigrp_iface *); #endif /* _RDE_H_ */ diff --git a/usr.sbin/eigrpd/rde_dual.c b/usr.sbin/eigrpd/rde_dual.c index f2b782e8df2..ad7e32b584b 100644 --- a/usr.sbin/eigrpd/rde_dual.c +++ b/usr.sbin/eigrpd/rde_dual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_dual.c,v 1.5 2015/10/20 11:26:40 jsg Exp $ */ +/* $OpenBSD: rde_dual.c,v 1.6 2015/10/21 03:48:09 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -556,23 +556,6 @@ rinfo_fill_infinite(struct rt_node *rn, enum route_type type, struct rinfo *ri) memcpy(&ri->prefix, &rn->prefix, sizeof(ri->prefix)); ri->prefixlen = rn->prefixlen; ri->metric.delay = EIGRP_INFINITE_METRIC; - ri->metric.bandwidth = 0; - ri->metric.mtu[0] = 0; - ri->metric.mtu[1] = 0; - ri->metric.mtu[2] = 0; - ri->metric.hop_count = 0; - ri->metric.reliability = 0; - ri->metric.load = 0; - ri->metric.tag = 0; - ri->metric.flags = 0; - if (ri->type == EIGRP_ROUTE_EXTERNAL) { - ri->emetric.routerid = 0; - ri->emetric.as = 0; - ri->emetric.tag = 0; - ri->emetric.metric = 0; - ri->emetric.protocol = 0; - ri->emetric.flags = 0; - } } void @@ -1196,7 +1179,7 @@ rde_check_link_down(unsigned int ifindex) } void -rde_check_link_cost_change(struct rde_nbr *nbr, struct eigrp_interface *ei) +rde_check_link_cost_change(struct rde_nbr *nbr, struct eigrp_iface *ei) { } diff --git a/usr.sbin/eigrpd/rtp.c b/usr.sbin/eigrpd/rtp.c index a11cbaf20a5..5a5f3bdc139 100644 --- a/usr.sbin/eigrpd/rtp.c +++ b/usr.sbin/eigrpd/rtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtp.c,v 1.2 2015/10/05 01:59:33 renato Exp $ */ +/* $OpenBSD: rtp.c,v 1.3 2015/10/21 03:48:09 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -228,16 +228,15 @@ rtp_send_ack(struct nbr *nbr) fatal("rtp_send_ack"); /* EIGRP header */ - if (gen_eigrp_hdr(buf, EIGRP_OPC_HELLO, 0, 0, eigrp->as)) - goto fail; + if (gen_eigrp_hdr(buf, EIGRP_OPC_HELLO, 0, 0, eigrp->as)) { + log_warnx("%s: failed to send message", __func__); + ibuf_free(buf); + return; + } /* send unreliably */ send_packet(nbr->ei, nbr, 0, buf); ibuf_free(buf); - return; -fail: - log_warnx("%s: failed to send message", __func__); - ibuf_free(buf); } /* timers */ diff --git a/usr.sbin/eigrpd/tlv.c b/usr.sbin/eigrpd/tlv.c index 54953366378..a5225cae466 100644 --- a/usr.sbin/eigrpd/tlv.c +++ b/usr.sbin/eigrpd/tlv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tlv.c,v 1.4 2015/10/05 01:59:33 renato Exp $ */ +/* $OpenBSD: tlv.c,v 1.5 2015/10/21 03:48:09 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -260,7 +260,7 @@ gen_route_tlv(struct ibuf *buf, struct rinfo *ri) /* adjust tlv length */ if ((tlvp = ibuf_seek(buf, original_size, sizeof(*tlvp))) == NULL) - fatalx("gen_ipv4_internal_tlv: buf_seek failed"); + fatalx("gen_route_tlv: buf_seek failed"); tlvp->length = htons(tlvlen); return (0); -- 2.20.1