From fa9307852e20616ec4508d97dbf7c3acc43cd374 Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Mon, 10 Apr 2023 11:04:47 +0800 Subject: [PATCH 1/2] ripd: Correct one debug log Correct one debug log, which wrongly mixed address and port. Before: ``` ripd[469497]: [NDAGH-Z85V7] rip_send_packet 3.3.3.4 > 224.0.0.9 (enp1s0) ripd[469497]: [VEJY5-67P5X] SEND to 224.0.0.9520 ``` After: ``` ripd[471330]: [NDAGH-Z85V7] rip_send_packet 3.3.3.4 > 224.0.0.9 (enp1s0) ripd[471330]: [T8DFR-P09JH] SEND to 224.0.0.9 port 520 ``` Signed-off-by: anlan_cs --- ripd/ripd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ripd/ripd.c b/ripd/ripd.c index ae4d93b4f5..15e058a744 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -1500,7 +1500,7 @@ static int rip_send_packet(uint8_t *buf, int size, struct sockaddr_in *to, ret = sendmsg(rip->sock, &msg, 0); if (IS_RIP_DEBUG_EVENT) - zlog_debug("SEND to %pI4%d", &sin.sin_addr, + zlog_debug("SEND to %pI4 port %d", &sin.sin_addr, ntohs(sin.sin_port)); if (ret < 0) From b769fdc88b2445cb6965ac70ffb87a87af26a79d Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Mon, 10 Apr 2023 15:20:43 +0800 Subject: [PATCH 2/2] ripd: Simplify code for distance Simplify the code for `rip_distance_apply()`. Signed-off-by: anlan_cs --- ripd/ripd.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ripd/ripd.c b/ripd/ripd.c index 15e058a744..7dbe2bbccf 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -2836,16 +2836,11 @@ uint8_t rip_distance_apply(struct rip *rip, struct rip_info *rinfo) if (access_list_apply(alist, &rinfo->rp->p) == FILTER_DENY) return 0; - - return rdistance->distance; - } else - return rdistance->distance; + } + return rdistance->distance; } - if (rip->distance) - return rip->distance; - - return 0; + return rip->distance; } static void rip_distance_show(struct vty *vty, struct rip *rip)