X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=pimd%2Fpim_mroute.c;h=2859d26ebad0f3ef93f363e07ca1a332fbeab994;hb=e5af9432cbfc5e9179a01e29f84288ada4d22175;hp=2bdec12cd1a8f26e84efe823a0ba065e512d2ba7;hpb=a12bb225a6681b7e7eb0aac105cbc8b745675131;p=mirror_frr.git diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index 2bdec12cd..2859d26eb 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -57,7 +57,7 @@ static int pim_mroute_set(struct pim_instance *pim, int enable) * We need to create the VRF table for the pim mroute_socket */ if (pim->vrf_id != VRF_DEFAULT) { - frr_elevate_privs(&pimd_privs) { + frr_with_privs(&pimd_privs) { data = pim->vrf->data.l.table_id; err = setsockopt(pim->mroute_socket, IPPROTO_IP, @@ -75,7 +75,7 @@ static int pim_mroute_set(struct pim_instance *pim, int enable) } } - frr_elevate_privs(&pimd_privs) { + frr_with_privs(&pimd_privs) { opt = enable ? MRT_INIT : MRT_DONE; /* * *BSD *cares* about what value we pass down @@ -147,7 +147,7 @@ static int pim_mroute_set(struct pim_instance *pim, int enable) return 0; } -static const char *igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = { +static const char *const igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = { "", "NOCACHE", "WRONGVIF", "WHOLEPKT", "WRVIFWHOLE"}; static int pim_mroute_msg_nocache(int fd, struct interface *ifp, @@ -190,8 +190,6 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp, sg.grp = msg->im_dst; if (!(PIM_I_am_DR(pim_ifp))) { - struct channel_oil *c_oil; - if (PIM_DEBUG_MROUTE_DETAIL) zlog_debug("%s: Interface is not the DR blackholing incoming traffic for %s", __PRETTY_FUNCTION__, pim_str_sg_dump(&sg)); @@ -201,25 +199,21 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp, * Let's blackhole those packets for the moment * As that they will be coming up to the cpu * and causing us to consider them. + * + * This *will* create a dangling channel_oil + * that I see no way to get rid of. Just noting + * this for future reference. */ - c_oil = pim_channel_oil_add(pim_ifp->pim, &sg, - pim_ifp->mroute_vif_index, - __PRETTY_FUNCTION__); - pim_mroute_add(c_oil, __PRETTY_FUNCTION__); + up = pim_upstream_find_or_add( + &sg, ifp, PIM_UPSTREAM_FLAG_MASK_SRC_NOCACHE, + __PRETTY_FUNCTION__); + pim_mroute_add(up->channel_oil, __PRETTY_FUNCTION__); return 0; } up = pim_upstream_find_or_add(&sg, ifp, PIM_UPSTREAM_FLAG_MASK_FHR, __PRETTY_FUNCTION__); - if (!up) { - if (PIM_DEBUG_MROUTE) { - zlog_debug( - "%s: Failure to add upstream information for %s", - __PRETTY_FUNCTION__, pim_str_sg_dump(&sg)); - } - return 0; - } /* * I moved this debug till after the actual add because @@ -242,7 +236,8 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp, vif_index = pim_if_find_vifindex_by_ifindex( pim_ifp->pim, up->rpf.source_nexthop.interface->ifindex); - up->channel_oil->oil.mfcc_parent = vif_index; + pim_channel_oil_change_iif(pim_ifp->pim, up->channel_oil, + vif_index, __PRETTY_FUNCTION__); } pim_register_join(up); @@ -305,7 +300,7 @@ static int pim_mroute_msg_wholepkt(int fd, struct interface *ifp, } if (!up->rpf.source_nexthop.interface) { - if (PIM_DEBUG_TRACE) + if (PIM_DEBUG_PIM_TRACE) zlog_debug("%s: up %s RPF is not present", __PRETTY_FUNCTION__, up->sg_str); return 0; @@ -457,7 +452,6 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, struct pim_upstream *up; struct prefix_sg star_g; struct prefix_sg sg; - struct channel_oil *oil; pim_ifp = ifp->info; @@ -521,11 +515,7 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, up->upstream_register); up->sptbit = PIM_UPSTREAM_SPTBIT_TRUE; } - if (!up->channel_oil) - up->channel_oil = pim_channel_oil_add( - pim_ifp->pim, &sg, - pim_ifp->mroute_vif_index, - __PRETTY_FUNCTION__); + pim_upstream_inherited_olist(pim_ifp->pim, up); if (!up->channel_oil->installed) pim_mroute_add(up->channel_oil, @@ -550,10 +540,6 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, } pim_ifp = ifp->info; - oil = pim_channel_oil_add(pim_ifp->pim, &sg, pim_ifp->mroute_vif_index, - __PRETTY_FUNCTION__); - if (!oil->installed) - pim_mroute_add(oil, __PRETTY_FUNCTION__); if (pim_if_connected_to_source(ifp, sg.src)) { up = pim_upstream_add(pim_ifp->pim, &sg, ifp, PIM_UPSTREAM_FLAG_MASK_FHR, @@ -568,13 +554,18 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, PIM_UPSTREAM_FLAG_SET_SRC_STREAM(up->flags); pim_upstream_keep_alive_timer_start( up, pim_ifp->pim->keep_alive_time); - up->channel_oil = oil; up->channel_oil->cc.pktcnt++; pim_register_join(up); pim_upstream_inherited_olist(pim_ifp->pim, up); // Send the packet to the RP pim_mroute_msg_wholepkt(fd, ifp, buf); + } else { + up = pim_upstream_add(pim_ifp->pim, &sg, ifp, + PIM_UPSTREAM_FLAG_MASK_SRC_NOCACHE, + __PRETTY_FUNCTION__, NULL); + if (!up->channel_oil->installed) + pim_mroute_add(up->channel_oil, __PRETTY_FUNCTION__); } return 0; @@ -620,7 +611,7 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf, pim_inet4_dump("", ip_hdr->ip_dst, ip_dst_str, sizeof(ip_dst_str)); - zlog_warn( + zlog_debug( "%s(%s): igmp kernel upcall on %s(%p) for %s -> %s", __PRETTY_FUNCTION__, pim->vrf->name, ifp->name, igmp, ip_src_str, ip_dst_str); @@ -652,7 +643,7 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf, sizeof(src_str)); pim_inet4_dump("", msg->im_dst, grp_str, sizeof(grp_str)); - zlog_warn( + zlog_debug( "%s: pim kernel upcall %s type=%d ip_p=%d from fd=%d for (S,G)=(%s,%s) on %s vifi=%d size=%d", __PRETTY_FUNCTION__, igmpmsgtype2str[msg->im_msgtype], @@ -707,12 +698,9 @@ static int mroute_read(struct thread *t) if (errno == EWOULDBLOCK || errno == EAGAIN) break; - if (PIM_DEBUG_MROUTE) - zlog_warn( - "%s: failure reading rd=%d: fd=%d: errno=%d: %s", - __PRETTY_FUNCTION__, rd, - pim->mroute_socket, errno, - safe_strerror(errno)); + zlog_warn("%s: failure reading rd=%d: fd=%d: errno=%d: %s", + __PRETTY_FUNCTION__, rd, pim->mroute_socket, + errno, safe_strerror(errno)); goto done; } @@ -744,7 +732,7 @@ int pim_mroute_socket_enable(struct pim_instance *pim) { int fd; - frr_elevate_privs(&pimd_privs) { + frr_with_privs(&pimd_privs) { fd = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP); @@ -1094,18 +1082,14 @@ void pim_mroute_update_counters(struct channel_oil *c_oil) pim_zlookup_sg_statistics(c_oil); if (ioctl(pim->mroute_socket, SIOCGETSGCNT, &sgreq)) { - if (PIM_DEBUG_MROUTE) { - struct prefix_sg sg; + struct prefix_sg sg; - sg.src = c_oil->oil.mfcc_origin; - sg.grp = c_oil->oil.mfcc_mcastgrp; + sg.src = c_oil->oil.mfcc_origin; + sg.grp = c_oil->oil.mfcc_mcastgrp; - zlog_warn( - "ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=%s: errno=%d: %s", - (unsigned long)SIOCGETSGCNT, - pim_str_sg_dump(&sg), errno, - safe_strerror(errno)); - } + zlog_warn("ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=%s: errno=%d: %s", + (unsigned long)SIOCGETSGCNT, pim_str_sg_dump(&sg), + errno, safe_strerror(errno)); return; }