diff options
| author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2024-08-29 00:10:36 -0500 |
|---|---|---|
| committer | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2024-09-09 13:27:49 -0500 |
| commit | d97bea338de84b8ed33a0f1372ca6b8b56fb7d1d (patch) | |
| tree | 859b88978571b8b15991d432f39c8b66b3775827 /pimd/pim_bsm.c | |
| parent | 865bae9657249ab2b956debca49157b0c7d1cc92 (diff) | |
pimd: refactor pim_sock_read to be used with unicast bsr msgs
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Diffstat (limited to 'pimd/pim_bsm.c')
| -rw-r--r-- | pimd/pim_bsm.c | 59 |
1 files changed, 2 insertions, 57 deletions
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c index e742e9888a..115aec8933 100644 --- a/pimd/pim_bsm.c +++ b/pimd/pim_bsm.c @@ -258,66 +258,11 @@ static inline void pim_bs_timer_restart(struct bsm_scope *scope, int bs_timeout) static void bsm_unicast_sock_read(struct event *t) { struct bsm_scope *scope = EVENT_ARG(t); - struct sockaddr_storage from; - struct sockaddr_storage to; - socklen_t fromlen = sizeof(from); - socklen_t tolen = sizeof(to); - ifindex_t ifindex = 0; - struct interface *ifp; - uint8_t buf[PIM_PIM_BUFSIZE_READ]; - int len, i; + + pim_sock_read_helper(scope->unicast_sock, scope->pim, false); event_add_read(router->master, bsm_unicast_sock_read, scope, scope->unicast_sock, &scope->unicast_read); - - for (i = 0; i < router->packet_process; i++) { - pim_sgaddr sg; - - len = pim_socket_recvfromto(scope->unicast_sock, buf, - sizeof(buf), &from, &fromlen, &to, - &tolen, &ifindex); - if (len < 0) { - if (errno == EINTR) - continue; - if (errno == EWOULDBLOCK || errno == EAGAIN) - break; - - if (PIM_DEBUG_PIM_PACKETS) - zlog_debug("Received errno: %d %s", errno, - safe_strerror(errno)); - break; - } - -#if PIM_IPV == 4 - sg.src = ((struct sockaddr_in *)&from)->sin_addr; - sg.grp = ((struct sockaddr_in *)&to)->sin_addr; -#else - sg.src = ((struct sockaddr_in6 *)&from)->sin6_addr; - sg.grp = ((struct sockaddr_in6 *)&to)->sin6_addr; -#endif - - /* - * What? So with vrf's the incoming packet is received - * on the vrf interface but recvfromto above returns - * the right ifindex, so just use it. We know - * it's the right interface because we bind to it - */ - ifp = if_lookup_by_index(ifindex, scope->pim->vrf->vrf_id); - if (!ifp) { - zlog_warn("Received incoming PIM packet on unknown ifindex %d", - ifindex); - break; - } - - int fail = pim_pim_packet(ifp, buf, len, sg, false); - - if (fail) { - if (PIM_DEBUG_PIM_PACKETS) - zlog_debug("%s: pim_pim_packet() return=%d", - __func__, fail); - break; - } - } } void pim_bsm_proc_init(struct pim_instance *pim) |
