Skip to content

Commit

Permalink
eigrpd: eigrp usage of uint32_t to struct in_addr for router_id data
Browse files Browse the repository at this point in the history
In eigrp we were using a uint32_t to hold the `struct in_addr` data
for the router id values.  This caused us to do unnecessary conversions
pre and post for in/out.  Let's just use the standard `struct in_addr`

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Dec 31, 2018
1 parent e7c0d8c commit 900e2d4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
5 changes: 1 addition & 4 deletions eigrpd/eigrp_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,8 @@ void show_ip_eigrp_neighbor_sub(struct vty *vty, struct eigrp_neighbor *nbr,
*/
void show_ip_eigrp_topology_header(struct vty *vty, struct eigrp *eigrp)
{
struct in_addr router_id;
router_id.s_addr = eigrp->router_id;

vty_out(vty, "\nEIGRP Topology Table for AS(%d)/ID(%s)\n\n", eigrp->AS,
inet_ntoa(router_id));
inet_ntoa(eigrp->router_id));
vty_out(vty,
"Codes: P - Passive, A - Active, U - Update, Q - Query, "
"R - Reply\n r - reply Status, s - sia Status\n\n");
Expand Down
4 changes: 2 additions & 2 deletions eigrpd/eigrp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)
rn->info = (void *)pref;

/* Schedule Router ID Update. */
if (eigrp->router_id == 0)
if (eigrp->router_id.s_addr == 0)
eigrp_router_id_update(eigrp);
/* Run network config now. */
/* Get target interface. */
Expand Down Expand Up @@ -293,7 +293,7 @@ void eigrp_if_update(struct interface *ifp)
*/
for (ALL_LIST_ELEMENTS(eigrp_om->eigrp, node, nnode, eigrp)) {
/* EIGRP must be on and Router-ID must be configured. */
if (!eigrp || eigrp->router_id == 0)
if (!eigrp || eigrp->router_id.s_addr == 0)
continue;

/* Run each network for this interface. */
Expand Down
4 changes: 2 additions & 2 deletions eigrpd/eigrp_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ struct eigrp {
char *name;

/* EIGRP Router ID. */
uint32_t router_id; /* Configured automatically. */
uint32_t router_id_static; /* Configured manually. */
struct in_addr router_id; /* Configured automatically. */
struct in_addr router_id_static; /* Configured manually. */

struct list *eiflist; /* eigrp interfaces */
uint8_t passive_interface_default; /* passive-interface default */
Expand Down
6 changes: 2 additions & 4 deletions eigrpd/eigrp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,9 @@ static int config_write_eigrp_router(struct vty *vty, struct eigrp *eigrp)
write++;

/* Router ID print. */
if (eigrp->router_id_static != 0) {
struct in_addr router_id_static;
router_id_static.s_addr = htonl(eigrp->router_id_static);
if (eigrp->router_id_static.s_addr != 0) {
vty_out(vty, " eigrp router-id %s\n",
inet_ntoa(router_id_static));
inet_ntoa(eigrp->router_id_static));
}

/* Network area print. */
Expand Down
14 changes: 7 additions & 7 deletions eigrpd/eigrpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,21 @@ void eigrp_router_id_update(struct eigrp *eigrp)
{
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
uint32_t router_id, router_id_old;
struct in_addr router_id, router_id_old;

router_id_old = eigrp->router_id;

if (eigrp->router_id_static != 0)
if (eigrp->router_id_static.s_addr != 0)
router_id = eigrp->router_id_static;

else if (eigrp->router_id != 0)
else if (eigrp->router_id.s_addr != 0)
router_id = eigrp->router_id;

else
router_id = router_id_zebra.s_addr;
router_id = router_id_zebra;

eigrp->router_id = router_id;
if (router_id_old != router_id) {
if (router_id_old.s_addr != router_id.s_addr) {
// if (IS_DEBUG_EIGRP_EVENT)
// zlog_debug("Router-ID[NEW:%s]: Update",
// inet_ntoa(eigrp->router_id));
Expand Down Expand Up @@ -142,8 +142,8 @@ static struct eigrp *eigrp_new(const char *AS)
/* init information relevant to peers */
eigrp->vrid = 0;
eigrp->AS = atoi(AS);
eigrp->router_id = 0L;
eigrp->router_id_static = 0L;
eigrp->router_id.s_addr = 0;
eigrp->router_id_static.s_addr = 0;
eigrp->sequence_number = 1;

/*Configure default K Values for EIGRP Process*/
Expand Down

0 comments on commit 900e2d4

Please sign in to comment.