Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eigrpd: Replace inet_ntoa with %pI4 #7360

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions eigrpd/eigrp_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ void eigrp_ip_header_dump(struct ip *iph)
zlog_debug("ip_ttl %u", iph->ip_ttl);
zlog_debug("ip_p %u", iph->ip_p);
zlog_debug("ip_sum 0x%x", (uint32_t)iph->ip_sum);
zlog_debug("ip_src %s", inet_ntoa(iph->ip_src));
zlog_debug("ip_dst %s", inet_ntoa(iph->ip_dst));
zlog_debug("ip_src %pI4", &iph->ip_src);
zlog_debug("ip_dst %pI4", &iph->ip_dst);
}

/*
Expand Down Expand Up @@ -204,8 +204,7 @@ void show_ip_eigrp_neighbor_sub(struct vty *vty, struct eigrp_neighbor *nbr,
int detail)
{

vty_out(vty, "%-3u %-17s %-21s", 0, eigrp_neigh_ip_string(nbr),
IF_NAME(nbr->ei));
vty_out(vty, "%-3u %-17pI4 %-21s", 0, &nbr->src, IF_NAME(nbr->ei));
if (nbr->t_holddown)
vty_out(vty, "%-7lu",
thread_timer_remain_second(nbr->t_holddown));
Expand All @@ -231,8 +230,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)
{
vty_out(vty, "\nEIGRP Topology Table for AS(%d)/ID(%s)\n\n", eigrp->AS,
inet_ntoa(eigrp->router_id));
vty_out(vty, "\nEIGRP Topology Table for AS(%d)/ID(%pI4)\n\n",
eigrp->AS, &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 Expand Up @@ -269,8 +268,8 @@ void show_ip_eigrp_nexthop_entry(struct vty *vty, struct eigrp *eigrp,
vty_out(vty, "%-7s%s, %s\n", " ", "via Connected",
IF_NAME(te->ei));
else {
vty_out(vty, "%-7s%s%s (%u/%u), %s\n", " ", "via ",
inet_ntoa(te->adv_router->src), te->distance,
vty_out(vty, "%-7s%s%pI4 (%u/%u), %s\n", " ", "via ",
&te->adv_router->src, te->distance,
te->reported_distance, IF_NAME(te->ei));
}
}
Expand Down
15 changes: 0 additions & 15 deletions eigrpd/eigrp_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,6 @@ extern unsigned long term_debug_eigrp_zebra;

/* Prototypes. */
extern const char *eigrp_if_name_string(struct eigrp_interface *);
static inline const char
*eigrp_topology_ip_string(struct eigrp_prefix_entry *tn)
{
return inet_ntoa(tn->destination->u.prefix4);
}

static inline const char *eigrp_if_ip_string(struct eigrp_interface *ei)
{
return ei ? inet_ntoa(ei->address.u.prefix4) : "inactive";
}

static inline const char *eigrp_neigh_ip_string(struct eigrp_neighbor *nbr)
{
return inet_ntoa(nbr->src);
}

extern void eigrp_ip_header_dump(struct ip *);
extern void eigrp_header_dump(struct eigrp_header *);
Expand Down
4 changes: 2 additions & 2 deletions eigrpd/eigrp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ int eigrp_fsm_event(struct eigrp_fsm_action_message *msg)
enum eigrp_fsm_events event = eigrp_get_fsm_event(msg);

zlog_info(
"EIGRP AS: %d State: %s Event: %s Network: %s Packet Type: %s Reply RIJ Count: %d change: %s",
"EIGRP AS: %d State: %s Event: %s Network: %pI4 Packet Type: %s Reply RIJ Count: %d change: %s",
msg->eigrp->AS, prefix_state2str(msg->prefix->state),
fsm_state2str(event), eigrp_topology_ip_string(msg->prefix),
fsm_state2str(event), &msg->prefix->destination->u.prefix4,
packet_type2str(msg->packet_type), msg->prefix->rij->count,
change2str(msg->change));
(*(NSM[msg->prefix->state][event].func))(msg);
Expand Down
36 changes: 18 additions & 18 deletions eigrpd/eigrp_hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ eigrp_hello_parameter_decode(struct eigrp_neighbor *nbr,
&& (eigrp->k_values[4] == nbr->K5)) {

if (eigrp_nbr_state_get(nbr) == EIGRP_NEIGHBOR_DOWN) {
zlog_info("Neighbor %s (%s) is pending: new adjacency",
inet_ntoa(nbr->src),
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));
zlog_info(
"Neighbor %pI4 (%s) is pending: new adjacency",
&nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));

/* Expedited hello sent */
eigrp_hello_send(nbr->ei, EIGRP_HELLO_NORMAL, NULL);
Expand All @@ -164,16 +165,16 @@ eigrp_hello_parameter_decode(struct eigrp_neighbor *nbr,
& param->K5)
== 255) {
zlog_info(
"Neighbor %s (%s) is down: Interface PEER-TERMINATION received",
inet_ntoa(nbr->src),
"Neighbor %pI4 (%s) is down: Interface PEER-TERMINATION received",
&nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));
eigrp_nbr_delete(nbr);
return NULL;
} else {
zlog_info(
"Neighbor %s (%s) going down: Kvalue mismatch",
inet_ntoa(nbr->src),
"Neighbor %pI4 (%s) going down: Kvalue mismatch",
&nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex,
eigrp->vrf_id));
eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_DOWN);
Expand Down Expand Up @@ -253,9 +254,10 @@ static void eigrp_peer_termination_decode(struct eigrp_neighbor *nbr,
uint32_t received_ip = param->neighbor_ip;

if (my_ip == received_ip) {
zlog_info("Neighbor %s (%s) is down: Peer Termination received",
inet_ntoa(nbr->src),
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
zlog_info(
"Neighbor %pI4 (%s) is down: Peer Termination received",
&nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
/* set neighbor to DOWN */
nbr->state = EIGRP_NEIGHBOR_DOWN;
/* delete neighbor */
Expand Down Expand Up @@ -330,9 +332,9 @@ void eigrp_hello_receive(struct eigrp *eigrp, struct ip *iph,
assert(nbr);

if (IS_DEBUG_EIGRP_PACKET(eigrph->opcode - 1, RECV))
zlog_debug("Processing Hello size[%u] int(%s) nbr(%s)", size,
zlog_debug("Processing Hello size[%u] int(%s) nbr(%pI4)", size,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id),
inet_ntoa(nbr->src));
&nbr->src);

size -= EIGRP_HEADER_LEN;
if (size < 0)
Expand Down Expand Up @@ -403,8 +405,7 @@ void eigrp_hello_receive(struct eigrp *eigrp, struct ip *iph,
}

if (IS_DEBUG_EIGRP_PACKET(0, RECV))
zlog_debug("Hello Packet received from %s",
inet_ntoa(nbr->src));
zlog_debug("Hello Packet received from %pI4", &nbr->src);
}

uint32_t FRR_MAJOR;
Expand Down Expand Up @@ -708,9 +709,8 @@ void eigrp_hello_send_ack(struct eigrp_neighbor *nbr)

if (ep) {
if (IS_DEBUG_EIGRP_PACKET(0, SEND))
zlog_debug("Queueing [Hello] Ack Seq [%u] nbr [%s]",
nbr->recv_sequence_number,
inet_ntoa(nbr->src));
zlog_debug("Queueing [Hello] Ack Seq [%u] nbr [%pI4]",
nbr->recv_sequence_number, &nbr->src);

/* Add packet to the top of the interface output queue*/
eigrp_fifo_push(nbr->ei->obuf, ep);
Expand Down
14 changes: 4 additions & 10 deletions eigrpd/eigrp_neighbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ static struct eigrp_neighbor *eigrp_nbr_add(struct eigrp_interface *ei,
nbr = eigrp_nbr_new(ei);
nbr->src = iph->ip_src;

// if (IS_DEBUG_EIGRP_EVENT)
// zlog_debug("NSM[%s:%s]: start", IF_NAME (nbr->oi),
// inet_ntoa (nbr->router_id));

return nbr;
}

Expand Down Expand Up @@ -197,8 +193,7 @@ int holddown_timer_expired(struct thread *thread)
struct eigrp_neighbor *nbr = THREAD_ARG(thread);
struct eigrp *eigrp = nbr->ei->eigrp;

zlog_info("Neighbor %s (%s) is down: holding time expired",
inet_ntoa(nbr->src),
zlog_info("Neighbor %pI4 (%s) is down: holding time expired", &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
nbr->state = EIGRP_NEIGHBOR_DOWN;
eigrp_nbr_delete(nbr);
Expand Down Expand Up @@ -330,13 +325,12 @@ void eigrp_nbr_hard_restart(struct eigrp_neighbor *nbr, struct vty *vty)
{
struct eigrp *eigrp = nbr->ei->eigrp;

zlog_debug("Neighbor %s (%s) is down: manually cleared",
inet_ntoa(nbr->src),
zlog_debug("Neighbor %pI4 (%s) is down: manually cleared", &nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
if (vty != NULL) {
vty_time_print(vty, 0);
vty_out(vty, "Neighbor %s (%s) is down: manually cleared\n",
inet_ntoa(nbr->src),
vty_out(vty, "Neighbor %pI4 (%s) is down: manually cleared\n",
&nbr->src,
ifindex2ifname(nbr->ei->ifp->ifindex, eigrp->vrf_id));
}

Expand Down
23 changes: 10 additions & 13 deletions eigrpd/eigrp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ int eigrp_if_ipmulticast(struct eigrp *top, struct prefix *p,
ret = setsockopt_ipv4_multicast_if(top->fd, p->u.prefix4, ifindex);
if (ret < 0)
zlog_warn(
"can't setsockopt IP_MULTICAST_IF (fd %d, addr %s, ifindex %u): %s",
top->fd, inet_ntoa(p->u.prefix4), ifindex,
safe_strerror(errno));
"can't setsockopt IP_MULTICAST_IF (fd %d, addr %pI4, ifindex %u): %s",
top->fd, &p->u.prefix4, ifindex, safe_strerror(errno));

return ret;
}
Expand All @@ -178,12 +177,11 @@ int eigrp_if_add_allspfrouters(struct eigrp *top, struct prefix *p,
htonl(EIGRP_MULTICAST_ADDRESS), ifindex);
if (ret < 0)
zlog_warn(
"can't setsockopt IP_ADD_MEMBERSHIP (fd %d, addr %s, ifindex %u, AllSPFRouters): %s; perhaps a kernel limit on # of multicast group memberships has been exceeded?",
top->fd, inet_ntoa(p->u.prefix4), ifindex,
safe_strerror(errno));
"can't setsockopt IP_ADD_MEMBERSHIP (fd %d, addr %pI4, ifindex %u, AllSPFRouters): %s; perhaps a kernel limit on # of multicast group memberships has been exceeded?",
top->fd, &p->u.prefix4, ifindex, safe_strerror(errno));
else
zlog_debug("interface %s [%u] join EIGRP Multicast group.",
inet_ntoa(p->u.prefix4), ifindex);
zlog_debug("interface %pI4 [%u] join EIGRP Multicast group.",
&p->u.prefix4, ifindex);

return ret;
}
Expand All @@ -198,12 +196,11 @@ int eigrp_if_drop_allspfrouters(struct eigrp *top, struct prefix *p,
htonl(EIGRP_MULTICAST_ADDRESS), ifindex);
if (ret < 0)
zlog_warn(
"can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %s, ifindex %u, AllSPFRouters): %s",
top->fd, inet_ntoa(p->u.prefix4), ifindex,
safe_strerror(errno));
"can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %pI4, ifindex %u, AllSPFRouters): %s",
top->fd, &p->u.prefix4, ifindex, safe_strerror(errno));
else
zlog_debug("interface %s [%u] leave EIGRP Multicast group.",
inet_ntoa(p->u.prefix4), ifindex);
zlog_debug("interface %pI4 [%u] leave EIGRP Multicast group.",
&p->u.prefix4, ifindex);

return ret;
}
Expand Down
44 changes: 20 additions & 24 deletions eigrpd/eigrp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,17 +442,16 @@ int eigrp_write(struct thread *thread)
if (IS_DEBUG_EIGRP_TRANSMIT(0, SEND)) {
eigrph = (struct eigrp_header *)STREAM_DATA(ep->s);
zlog_debug(
"Sending [%s][%d/%d] to [%s] via [%s] ret [%d].",
"Sending [%s][%d/%d] to [%pI4] via [%s] ret [%d].",
lookup_msg(eigrp_packet_type_str, eigrph->opcode, NULL),
seqno, ack, inet_ntoa(ep->dst), IF_NAME(ei), ret);
seqno, ack, &ep->dst, IF_NAME(ei), ret);
}

if (ret < 0)
zlog_warn(
"*** sendmsg in eigrp_write failed to %s, id %d, off %d, len %d, interface %s, mtu %u: %s",
inet_ntoa(iph.ip_dst), iph.ip_id, iph.ip_off,
iph.ip_len, ei->ifp->name, ei->ifp->mtu,
safe_strerror(errno));
"*** sendmsg in eigrp_write failed to %pI4, id %d, off %d, len %d, interface %s, mtu %u: %s",
&iph.ip_dst, iph.ip_id, iph.ip_off, iph.ip_len,
ei->ifp->name, ei->ifp->mtu, safe_strerror(errno));

/* Now delete packet from queue. */
eigrp_packet_delete(ei);
Expand Down Expand Up @@ -552,8 +551,8 @@ int eigrp_read(struct thread *thread)
|| (IPV4_ADDR_SAME(&srcaddr, &ei->address.u.prefix4))) {
if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV))
zlog_debug(
"eigrp_read[%s]: Dropping self-originated packet",
inet_ntoa(srcaddr));
"eigrp_read[%pI4]: Dropping self-originated packet",
&srcaddr);
return 0;
}

Expand Down Expand Up @@ -596,8 +595,9 @@ int eigrp_read(struct thread *thread)
*/
else if (ei->ifp != ifp) {
if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV))
zlog_warn("Packet from [%s] received on wrong link %s",
inet_ntoa(iph->ip_src), ifp->name);
zlog_warn(
"Packet from [%pI4] received on wrong link %s",
&iph->ip_src, ifp->name);
return 0;
}

Expand All @@ -606,26 +606,21 @@ int eigrp_read(struct thread *thread)
if (ret < 0) {
if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV))
zlog_debug(
"eigrp_read[%s]: Header check failed, dropping.",
inet_ntoa(iph->ip_src));
"eigrp_read[%pI4]: Header check failed, dropping.",
&iph->ip_src);
return ret;
}

/* calcualte the eigrp packet length, and move the pounter to the
start of the eigrp TLVs */
opcode = eigrph->opcode;

if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV)) {
char src[PREFIX_STRLEN], dst[PREFIX_STRLEN];

strlcpy(src, inet_ntoa(iph->ip_src), sizeof(src));
strlcpy(dst, inet_ntoa(iph->ip_dst), sizeof(dst));
if (IS_DEBUG_EIGRP_TRANSMIT(0, RECV))
zlog_debug(
"Received [%s][%d/%d] length [%u] via [%s] src [%s] dst [%s]",
"Received [%s][%d/%d] length [%u] via [%s] src [%pI4] dst [%pI4]",
lookup_msg(eigrp_packet_type_str, opcode, NULL),
ntohl(eigrph->sequence), ntohl(eigrph->ack), length,
IF_NAME(ei), src, dst);
}
IF_NAME(ei), &iph->ip_src, &iph->ip_dst);

/* Read rest of the packet and call each sort of packet routine. */
stream_forward_getp(ibuf, EIGRP_HEADER_LEN);
Expand All @@ -648,8 +643,9 @@ int eigrp_read(struct thread *thread)
&& (ntohl(eigrph->ack)
== nbr->init_sequence_number)) {
eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_UP);
zlog_info("Neighbor(%s) adjacency became full",
inet_ntoa(nbr->src));
zlog_info(
"Neighbor(%pI4) adjacency became full",
&nbr->src);
nbr->init_sequence_number = 0;
nbr->recv_sequence_number =
ntohl(eigrph->sequence);
Expand Down Expand Up @@ -957,8 +953,8 @@ static int eigrp_verify_header(struct stream *ibuf, struct eigrp_interface *ei,
/* Check network mask, Silently discarded. */
if (!eigrp_check_network_mask(ei, iph->ip_src)) {
zlog_warn(
"interface %s: eigrp_read network address is not same [%s]",
IF_NAME(ei), inet_ntoa(iph->ip_src));
"interface %s: eigrp_read network address is not same [%pI4]",
IF_NAME(ei), &iph->ip_src);
return -1;
}
//
Expand Down
Loading