diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2021-10-14 12:12:37 -0300 |
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2023-04-19 09:15:01 -0300 |
| commit | c262df828b2475632f590c256db677b424d868c7 (patch) | |
| tree | 85a8ab1e5ff016e9cdc28e18f91d263a207c8d32 /ripd/ripd.c | |
| parent | fec51f2e2be021108dc1de4dd1ea89516082eaf7 (diff) | |
ripd: support BFD integration
Implement RIP peer monitoring with BFD.
RFC 5882 Generic Application of Bidirectional Forwarding Detection
(BFD), Section 10.3 Interactions with RIP.
Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'ripd/ripd.c')
| -rw-r--r-- | ripd/ripd.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/ripd/ripd.c b/ripd/ripd.c index fb3d574aaa..48f266a94c 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -1123,7 +1123,7 @@ static void rip_response_process(struct rip_packet *packet, int size, if (from->sin_port != htons(RIP_PORT_DEFAULT)) { zlog_info("response doesn't come from RIP port: %d", from->sin_port); - rip_peer_bad_packet(rip, from); + rip_peer_bad_packet(rip, ri, from); return; } @@ -1137,7 +1137,7 @@ static void rip_response_process(struct rip_packet *packet, int size, zlog_info( "This datagram doesn't come from a valid neighbor: %pI4", &from->sin_addr); - rip_peer_bad_packet(rip, from); + rip_peer_bad_packet(rip, ri, from); return; } @@ -1147,7 +1147,7 @@ static void rip_response_process(struct rip_packet *packet, int size, ; /* Alredy done in rip_read () */ /* Update RIP peer. */ - rip_peer_update(rip, from, packet->version); + rip_peer_update(rip, ri, from, packet->version); /* Set RTE pointer. */ rte = packet->rte; @@ -1176,7 +1176,7 @@ static void rip_response_process(struct rip_packet *packet, int size, if (!rip_destination_check(rte->prefix)) { zlog_info( "Network is net 0 or net 127 or it is not unicast network"); - rip_peer_bad_route(rip, from); + rip_peer_bad_route(rip, ri, from); continue; } @@ -1186,7 +1186,7 @@ static void rip_response_process(struct rip_packet *packet, int size, /* - is the metric valid (i.e., between 1 and 16, inclusive) */ if (!(rte->metric >= 1 && rte->metric <= 16)) { zlog_info("Route's metric is not in the 1-16 range."); - rip_peer_bad_route(rip, from); + rip_peer_bad_route(rip, ri, from); continue; } @@ -1195,7 +1195,7 @@ static void rip_response_process(struct rip_packet *packet, int size, && rte->nexthop.s_addr != INADDR_ANY) { zlog_info("RIPv1 packet with nexthop value %pI4", &rte->nexthop); - rip_peer_bad_route(rip, from); + rip_peer_bad_route(rip, ri, from); continue; } @@ -1326,7 +1326,7 @@ static void rip_response_process(struct rip_packet *packet, int size, zlog_warn( "RIPv2 address %pI4 is not mask /%d applied one", &rte->prefix, ip_masklen(rte->mask)); - rip_peer_bad_route(rip, from); + rip_peer_bad_route(rip, ri, from); continue; } @@ -1643,7 +1643,7 @@ static void rip_request_process(struct rip_packet *packet, int size, return; /* RIP peer update. */ - rip_peer_update(rip, from, packet->version); + rip_peer_update(rip, ri, from, packet->version); lim = ((caddr_t)packet) + size; rte = packet->rte; @@ -1711,7 +1711,7 @@ static void rip_read(struct event *t) socklen_t fromlen; struct interface *ifp = NULL; struct connected *ifc; - struct rip_interface *ri; + struct rip_interface *ri = NULL; struct prefix p; /* Fetch socket then register myself. */ @@ -1743,8 +1743,10 @@ static void rip_read(struct event *t) /* Which interface is this packet comes from. */ ifc = if_lookup_address((void *)&from.sin_addr, AF_INET, rip->vrf->vrf_id); - if (ifc) + if (ifc) { ifp = ifc->ifp; + ri = ifp->info; + } /* RIP packet received */ if (IS_RIP_DEBUG_EVENT) @@ -1753,7 +1755,7 @@ static void rip_read(struct event *t) ifp ? ifp->name : "unknown", rip->vrf_name); /* If this packet come from unknown interface, ignore it. */ - if (ifp == NULL) { + if (ifp == NULL || ri == NULL) { zlog_info( "%s: cannot find interface for packet from %pI4 port %d (VRF %s)", __func__, &from.sin_addr, ntohs(from.sin_port), @@ -1779,13 +1781,13 @@ static void rip_read(struct event *t) if (len < RIP_PACKET_MINSIZ) { zlog_warn("packet size %d is smaller than minimum size %d", len, RIP_PACKET_MINSIZ); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } if (len > RIP_PACKET_MAXSIZ) { zlog_warn("packet size %d is larger than max size %d", len, RIP_PACKET_MAXSIZ); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } @@ -1793,7 +1795,7 @@ static void rip_read(struct event *t) if ((len - RIP_PACKET_MINSIZ) % 20) { zlog_warn("packet size %d is wrong for RIP packet alignment", len); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } @@ -1807,7 +1809,7 @@ static void rip_read(struct event *t) if (packet->version == 0) { zlog_info("version 0 with command %d received.", packet->command); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } @@ -1823,12 +1825,11 @@ static void rip_read(struct event *t) packet->version = RIPv2; /* Is RIP running or is this RIP neighbor ?*/ - ri = ifp->info; if (!ri->running && !rip_neighbor_lookup(rip, &from)) { if (IS_RIP_DEBUG_EVENT) zlog_debug("RIP is not enabled on interface %s.", ifp->name); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } @@ -1842,7 +1843,7 @@ static void rip_read(struct event *t) zlog_debug( " packet's v%d doesn't fit to if version spec", packet->version); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } @@ -1857,7 +1858,7 @@ static void rip_read(struct event *t) "packet RIPv%d is dropped because authentication disabled", packet->version); ripd_notif_send_auth_type_failure(ifp->name); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } @@ -1893,7 +1894,7 @@ static void rip_read(struct event *t) zlog_debug( "RIPv1 dropped because authentication enabled"); ripd_notif_send_auth_type_failure(ifp->name); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } } else if (ri->auth_type != RIP_NO_AUTH) { @@ -1906,7 +1907,7 @@ static void rip_read(struct event *t) zlog_debug( "RIPv2 authentication failed: no auth RTE in packet"); ripd_notif_send_auth_type_failure(ifp->name); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } @@ -1916,7 +1917,7 @@ static void rip_read(struct event *t) zlog_debug( "RIPv2 dropped because authentication enabled"); ripd_notif_send_auth_type_failure(ifp->name); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } @@ -1952,7 +1953,7 @@ static void rip_read(struct event *t) zlog_debug("RIPv2 %s authentication failure", auth_desc); ripd_notif_send_auth_failure(ifp->name); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); return; } } @@ -1971,16 +1972,16 @@ static void rip_read(struct event *t) zlog_info( "Obsolete command %s received, please sent it to routed", lookup_msg(rip_msg, packet->command, NULL)); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); break; case RIP_POLL_ENTRY: zlog_info("Obsolete command %s received", lookup_msg(rip_msg, packet->command, NULL)); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); break; default: zlog_info("Unknown RIP command %d received", packet->command); - rip_peer_bad_packet(rip, &from); + rip_peer_bad_packet(rip, ri, &from); break; } } @@ -3339,6 +3340,7 @@ void rip_clean(struct rip *rip) route_table_finish(rip->distance_table); RB_REMOVE(rip_instance_head, &rip_instances, rip); + XFREE(MTYPE_TMP, rip->default_bfd_profile); XFREE(MTYPE_RIP_VRF_NAME, rip->vrf_name); XFREE(MTYPE_RIP, rip); } |
