Lines Matching +full:ring +full:- +full:disable +full:- +full:pullup

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
53 * and PIM-SMv2 and PIM-DM support, advanced API support,
130 #define VIFI_INVALID ((vifi_t) -1)
176 VNET_DEFINE_STATIC(u_char *, nexpire); /* 0..mfchashsize-1 */
207 * Pending upcalls are stored in a ring which is flushed when
231 "Disable IGMP_WHOLEPKT notifications if rendezvous point is unspecified");
380 if (in_hosteq(rt->mfc_origin, *o) && in mfc_find()
381 in_hosteq(rt->mfc_mcastgrp, *g) && in mfc_find()
382 buf_ring_empty(rt->mfc_stall_ring)) in mfc_find()
397 rt->mfc_stall_ring = buf_ring_alloc(MAX_UPQ, M_MRTABLE, in mfc_alloc()
399 if (rt->mfc_stall_ring == NULL) { in mfc_alloc()
420 if (so != V_ip_mrouter && sopt->sopt_name != MRT_INIT) in X_ip_mrouter_set()
424 switch (sopt->sopt_name) { in X_ip_mrouter_set()
451 if (sopt->sopt_name == MRT_ADD_MFC && in X_ip_mrouter_set()
459 sizeof(mfc) - sizeof(struct mfcctl)); in X_ip_mrouter_set()
463 if (sopt->sopt_name == MRT_ADD_MFC) in X_ip_mrouter_set()
490 if (sopt->sopt_name == MRT_ADD_BW_UPCALL) in X_ip_mrouter_set()
511 switch (sopt->sopt_name) { in X_ip_mrouter_get()
568 * returns the packet, byte, rpf-failure count for the source group provided
576 rt = mfc_find(&req->src, &req->grp); in get_sg_cnt()
579 req->pktcnt = req->bytecnt = req->wrong_if = 0xffffffff; in get_sg_cnt()
582 req->pktcnt = rt->mfc_pkt_cnt; in get_sg_cnt()
583 req->bytecnt = rt->mfc_byte_cnt; in get_sg_cnt()
584 req->wrong_if = rt->mfc_wrong_if; in get_sg_cnt()
595 vifi_t vifi = req->vifi; in get_vif_cnt()
604 req->icount = V_viftable[vifi].v_pkt_in; in get_vif_cnt()
605 req->ocount = V_viftable[vifi].v_pkt_out; in get_vif_cnt()
606 req->ibytes = V_viftable[vifi].v_bytes_in; in get_vif_cnt()
607 req->obytes = V_viftable[vifi].v_bytes_out; in get_vif_cnt()
634 * 4. Free vif state. This should disable ALLMULTI on the interface. in if_detached_event()
644 if (rt->mfc_parent == vifi) { in if_detached_event()
714 /* Create upcall ring */ in ip_mrouter_init()
746 * Disable multicast forwarding.
761 * Detach/disable hooks to the reset of the system. in X_ip_mrouter_done()
784 /* Destroy upcall ring */ in X_ip_mrouter_done()
792 * For each phyint in use, prepare to disable promiscuous reception in X_ip_mrouter_done()
796 * a non-sleepable lock. in X_ip_mrouter_done()
872 * - there are no vifs installed in set_api_config()
873 * - pim_assert is not enabled in set_api_config()
874 * - the MFC table is empty in set_api_config()
909 struct vif *vifp = V_viftable + vifcp->vifc_vifi; in add_vif()
915 if (vifcp->vifc_vifi >= MAXVIFS) in add_vif()
918 if (vifcp->vifc_rate_limit != 0) { in add_vif()
923 if (in_nullhost(vifcp->vifc_lcl_addr)) in add_vif()
927 if (vifcp->vifc_flags & VIFF_REGISTER) { in add_vif()
937 sin.sin_addr = vifcp->vifc_lcl_addr; in add_vif()
944 ifp = ifa->ifa_ifp; in add_vif()
949 if ((vifcp->vifc_flags & VIFF_TUNNEL) != 0) { in add_vif()
952 } else if (vifcp->vifc_flags & VIFF_REGISTER) { in add_vif()
957 V_reg_vif_num = vifcp->vifc_vifi; in add_vif()
960 if ((ifp->if_flags & IFF_MULTICAST) == 0) in add_vif()
971 if (!in_nullhost(vifp->v_lcl_addr)) { in add_vif()
980 vifp->v_flags = vifcp->vifc_flags; in add_vif()
981 vifp->v_threshold = vifcp->vifc_threshold; in add_vif()
982 vifp->v_lcl_addr = vifcp->vifc_lcl_addr; in add_vif()
983 vifp->v_rmt_addr = vifcp->vifc_rmt_addr; in add_vif()
984 vifp->v_ifp = ifp; in add_vif()
986 vifp->v_pkt_in = 0; in add_vif()
987 vifp->v_pkt_out = 0; in add_vif()
988 vifp->v_bytes_in = 0; in add_vif()
989 vifp->v_bytes_out = 0; in add_vif()
990 sprintf(vifp->v_spin_name, "BM[%d] spin", vifcp->vifc_vifi); in add_vif()
991 mtx_init(&vifp->v_spin, vifp->v_spin_name, NULL, MTX_SPIN); in add_vif()
994 if (V_numvifs <= vifcp->vifc_vifi) in add_vif()
995 V_numvifs = vifcp->vifc_vifi + 1; in add_vif()
1000 (int)vifcp->vifc_vifi, ntohl(vifcp->vifc_lcl_addr.s_addr), in add_vif()
1001 (int)vifcp->vifc_threshold); in add_vif()
1023 if (in_nullhost(vifp->v_lcl_addr)) { in del_vif_locked()
1027 if (!(vifp->v_flags & (VIFF_TUNNEL | VIFF_REGISTER))) in del_vif_locked()
1028 *ifp_multi_leave = vifp->v_ifp; in del_vif_locked()
1030 if (vifp->v_flags & VIFF_REGISTER) { in del_vif_locked()
1032 if (vifp->v_ifp) { in del_vif_locked()
1033 if (vifp->v_ifp == V_multicast_register_if) in del_vif_locked()
1035 *ifp_free = vifp->v_ifp; in del_vif_locked()
1039 mtx_destroy(&vifp->v_spin); in del_vif_locked()
1046 for (vifi = V_numvifs; vifi > 0; vifi--) in del_vif_locked()
1047 if (!in_nullhost(V_viftable[vifi-1].v_lcl_addr)) in del_vif_locked()
1081 rt->mfc_parent = mfccp->mfcc_parent; in update_mfc_params()
1083 rt->mfc_ttls[i] = mfccp->mfcc_ttls[i]; in update_mfc_params()
1084 rt->mfc_flags[i] = mfccp->mfcc_flags[i] & V_mrt_api_config & in update_mfc_params()
1089 rt->mfc_rp = mfccp->mfcc_rp; in update_mfc_params()
1091 rt->mfc_rp.s_addr = INADDR_ANY; in update_mfc_params()
1100 rt->mfc_origin = mfccp->mfcc_origin; in init_mfc_params()
1101 rt->mfc_mcastgrp = mfccp->mfcc_mcastgrp; in init_mfc_params()
1105 /* initialize pkt counters per src-grp */ in init_mfc_params()
1106 rt->mfc_pkt_cnt = 0; in init_mfc_params()
1107 rt->mfc_byte_cnt = 0; in init_mfc_params()
1108 rt->mfc_wrong_if = 0; in init_mfc_params()
1109 timevalclear(&rt->mfc_last_assert); in init_mfc_params()
1119 free_bw_list(rt->mfc_bw_meter_leq); in expire_mfc()
1120 free_bw_list(rt->mfc_bw_meter_geq); in expire_mfc()
1122 while (!buf_ring_empty(rt->mfc_stall_ring)) { in expire_mfc()
1123 rte = buf_ring_dequeue_mc(rt->mfc_stall_ring); in expire_mfc()
1125 m_freem(rte->m); in expire_mfc()
1129 buf_ring_free(rt->mfc_stall_ring, M_MRTABLE); in expire_mfc()
1148 rt = mfc_find(&mfccp->mfcc_origin, &mfccp->mfcc_mcastgrp); in add_mfc()
1153 __func__, ntohl(mfccp->mfcc_origin.s_addr), in add_mfc()
1154 (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), in add_mfc()
1155 mfccp->mfcc_parent); in add_mfc()
1165 hash = MFCHASH(mfccp->mfcc_origin, mfccp->mfcc_mcastgrp); in add_mfc()
1168 if (in_hosteq(rt->mfc_origin, mfccp->mfcc_origin) && in add_mfc()
1169 in_hosteq(rt->mfc_mcastgrp, mfccp->mfcc_mcastgrp) && in add_mfc()
1170 !buf_ring_empty(rt->mfc_stall_ring)) { in add_mfc()
1173 __func__, ntohl(mfccp->mfcc_origin.s_addr), in add_mfc()
1174 (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), in add_mfc()
1175 mfccp->mfcc_parent, in add_mfc()
1176 rt->mfc_stall_ring); in add_mfc()
1181 rt->mfc_expire = 0; /* Don't clean this guy up */ in add_mfc()
1182 V_nexpire[hash]--; in add_mfc()
1185 while (!buf_ring_empty(rt->mfc_stall_ring)) { in add_mfc()
1186 rte = buf_ring_dequeue_mc(rt->mfc_stall_ring); in add_mfc()
1187 if (rte->ifp != NULL) in add_mfc()
1188 ip_mdq(rte->m, rte->ifp, rt, -1); in add_mfc()
1189 m_freem(rte->m); in add_mfc()
1202 if (in_hosteq(rt->mfc_origin, mfccp->mfcc_origin) && in add_mfc()
1203 in_hosteq(rt->mfc_mcastgrp, mfccp->mfcc_mcastgrp)) { in add_mfc()
1205 if (rt->mfc_expire) in add_mfc()
1206 V_nexpire[hash]--; in add_mfc()
1207 rt->mfc_expire = 0; in add_mfc()
1221 rt->mfc_expire = 0; in add_mfc()
1222 rt->mfc_bw_meter_leq = NULL; in add_mfc()
1223 rt->mfc_bw_meter_geq = NULL; in add_mfc()
1245 origin = mfccp->mfcc_origin; in del_mfc()
1246 mcastgrp = mfccp->mfcc_mcastgrp; in del_mfc()
1254 if (in_hosteq(rt->mfc_origin, origin) && in del_mfc()
1255 in_hosteq(rt->mfc_mcastgrp, mcastgrp)) in del_mfc()
1277 SOCKBUF_LOCK(&s->so_rcv); in socket_send()
1278 if (sbappendaddr_locked(&s->so_rcv, (struct sockaddr *)src, mm, in socket_send()
1286 return -1; in socket_send()
1296 * erroneous, in which case a non-zero return value tells the caller to
1317 ntohl(ip->ip_src.s_addr), (u_long)ntohl(ip->ip_dst.s_addr), ifp); in X_ip_mforward()
1319 if (ip->ip_hl < (sizeof(struct ip) + TUNNEL_LEN) >> 2 || in X_ip_mforward()
1327 * Packet arrived through a source-route tunnel. in X_ip_mforward()
1328 * Source-route tunnels are no longer supported. in X_ip_mforward()
1337 if (imo && ((vifi = imo->imo_multicast_vif) < V_numvifs)) { in X_ip_mforward()
1338 if (ip->ip_ttl < MAXTTL) in X_ip_mforward()
1339 ip->ip_ttl++; /* compensate for -1 in *_send routines */ in X_ip_mforward()
1346 * Don't forward a packet with time-to-live of zero or one, in X_ip_mforward()
1347 * or a packet destined to a local-only group. in X_ip_mforward()
1349 if (ip->ip_ttl <= 1 || IN_LOCAL_GROUP(ntohl(ip->ip_dst.s_addr))) { in X_ip_mforward()
1359 rt = mfc_find(&ip->ip_src, &ip->ip_dst); in X_ip_mforward()
1363 error = ip_mdq(m, ifp, rt, -1); in X_ip_mforward()
1384 hlen = ip->ip_hl << 2; in X_ip_mforward()
1389 ntohl(ip->ip_src.s_addr), (u_long)ntohl(ip->ip_dst.s_addr)); in X_ip_mforward()
1393 * just going to fail anyway. Make sure to pullup the header so in X_ip_mforward()
1403 if (mb0 && (!M_WRITABLE(mb0) || mb0->m_len < hlen)) in X_ip_mforward()
1412 hash = MFCHASH(ip->ip_src, ip->ip_dst); in X_ip_mforward()
1415 if (in_hosteq(ip->ip_src, rt->mfc_origin) && in X_ip_mforward()
1416 in_hosteq(ip->ip_dst, rt->mfc_mcastgrp) && in X_ip_mforward()
1417 !buf_ring_empty(rt->mfc_stall_ring)) in X_ip_mforward()
1453 im->im_msgtype = IGMPMSG_NOCACHE; in X_ip_mforward()
1454 im->im_mbz = 0; in X_ip_mforward()
1455 im->im_vif = vifi; in X_ip_mforward()
1459 k_igmpsrc.sin_addr = ip->ip_src; in X_ip_mforward()
1471 rt->mfc_origin.s_addr = ip->ip_src.s_addr; in X_ip_mforward()
1472 rt->mfc_mcastgrp.s_addr = ip->ip_dst.s_addr; in X_ip_mforward()
1473 rt->mfc_expire = UPCALL_EXPIRE; in X_ip_mforward()
1476 rt->mfc_ttls[i] = 0; in X_ip_mforward()
1477 rt->mfc_flags[i] = 0; in X_ip_mforward()
1479 rt->mfc_parent = -1; in X_ip_mforward()
1482 rt->mfc_rp.s_addr = INADDR_ANY; in X_ip_mforward()
1483 rt->mfc_bw_meter_leq = NULL; in X_ip_mforward()
1484 rt->mfc_bw_meter_geq = NULL; in X_ip_mforward()
1486 /* initialize pkt counters per src-grp */ in X_ip_mforward()
1487 rt->mfc_pkt_cnt = 0; in X_ip_mforward()
1488 rt->mfc_byte_cnt = 0; in X_ip_mforward()
1489 rt->mfc_wrong_if = 0; in X_ip_mforward()
1490 timevalclear(&rt->mfc_last_assert); in X_ip_mforward()
1492 buf_ring_enqueue(rt->mfc_stall_ring, rte); in X_ip_mforward()
1498 if (buf_ring_full(rt->mfc_stall_ring)) { in X_ip_mforward()
1506 buf_ring_enqueue(rt->mfc_stall_ring, rte); in X_ip_mforward()
1509 rte->m = mb0; in X_ip_mforward()
1510 rte->ifp = ifp; in X_ip_mforward()
1536 if (buf_ring_empty(rt->mfc_stall_ring)) in expire_upcalls()
1539 if (rt->mfc_expire == 0 || --rt->mfc_expire > 0) in expire_upcalls()
1544 (u_long)ntohl(rt->mfc_origin.s_addr), in expire_upcalls()
1545 (u_long)ntohl(rt->mfc_mcastgrp.s_addr)); in expire_upcalls()
1565 int plen = ntohs(ip->ip_len); in ip_mdq()
1572 * If xmt_vif is not -1, send on only the requested vif. in ip_mdq()
1574 * (since vifi_t is u_short, -1 becomes MAXUSHORT, which > numvifs.) in ip_mdq()
1587 vifi = rt->mfc_parent; in ip_mdq()
1592 ++rt->mfc_wrong_if; in ip_mdq()
1597 * XXX: A PIM-SM router needs the WRONGVIF detection so it in ip_mdq()
1612 if (rt->mfc_flags[vifi] & MRT_MFC_FLAGS_DISABLE_WRONGVIF) in ip_mdq()
1615 if (ratecheck(&rt->mfc_last_assert, &pim_assert_interval)) { in ip_mdq()
1618 int hlen = ip->ip_hl << 2; in ip_mdq()
1621 if (mm && (!M_WRITABLE(mm) || mm->m_len < hlen)) in ip_mdq()
1627 im->im_msgtype = IGMPMSG_WRONGVIF; in ip_mdq()
1628 im->im_mbz = 0; in ip_mdq()
1629 im->im_vif = vifi; in ip_mdq()
1633 k_igmpsrc.sin_addr = im->im_src; in ip_mdq()
1646 if (in_hosteq(ip->ip_src, V_viftable[vifi].v_lcl_addr)) { in ip_mdq()
1655 rt->mfc_pkt_cnt++; in ip_mdq()
1656 rt->mfc_byte_cnt += plen; in ip_mdq()
1661 * - the ttl exceeds the vif's threshold in ip_mdq()
1662 * - there are group members downstream on interface in ip_mdq()
1665 if ((rt->mfc_ttls[vifi] > 0) && (ip->ip_ttl > rt->mfc_ttls[vifi])) { in ip_mdq()
1675 * Perform upcall-related bw measuring. in ip_mdq()
1677 if ((rt->mfc_bw_meter_geq != NULL) || (rt->mfc_bw_meter_leq != NULL)) { in ip_mdq()
1682 /* Process meters for Greater-or-EQual case */ in ip_mdq()
1683 for (x = rt->mfc_bw_meter_geq; x != NULL; x = x->bm_mfc_next) in ip_mdq()
1686 /* Process meters for Lower-or-EQual case */ in ip_mdq()
1687 for (x = rt->mfc_bw_meter_leq; x != NULL; x = x->bm_mfc_next) { in ip_mdq()
1694 mtx_lock_spin(&x->bm_spin); in ip_mdq()
1695 x->bm_measured.b_packets++; in ip_mdq()
1696 x->bm_measured.b_bytes += plen; in ip_mdq()
1697 mtx_unlock_spin(&x->bm_spin); in ip_mdq()
1748 int hlen = ip->ip_hl << 2; in phyint_send()
1759 if (mb_copy && (!M_WRITABLE(mb_copy) || mb_copy->m_len < hlen)) in phyint_send()
1776 imo.imo_multicast_ifp = vifp->v_ifp; in send_packet()
1777 imo.imo_multicast_ttl = mtod(m, struct ip *)->ip_ttl - 1; in send_packet()
1779 imo.imo_multicast_vif = -1; in send_packet()
1783 * Re-entrancy should not be a problem here, because in send_packet()
1790 (ptrdiff_t)(vifp - V_viftable), error); in send_packet()
1827 * Define common interface for timeval-related methods
1838 if (req->bu_flags & BW_UPCALL_UNIT_PACKETS) in compute_bw_meter_flags()
1840 if (req->bu_flags & BW_UPCALL_UNIT_BYTES) in compute_bw_meter_flags()
1842 if (req->bu_flags & BW_UPCALL_GEQ) in compute_bw_meter_flags()
1844 if (req->bu_flags & BW_UPCALL_LEQ) in compute_bw_meter_flags()
1860 CURVNET_SET((struct vnet *)x->arg); in expire_bw_meter_leq()
1867 if (((x->bm_flags & BW_METER_UNIT_PACKETS) && in expire_bw_meter_leq()
1868 (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || in expire_bw_meter_leq()
1869 ((x->bm_flags & BW_METER_UNIT_BYTES) && in expire_bw_meter_leq()
1870 (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { in expire_bw_meter_leq()
1879 x->bm_start_time = now; in expire_bw_meter_leq()
1883 mtx_lock_spin(&x->bm_spin); in expire_bw_meter_leq()
1884 x->bm_measured.b_bytes = 0; in expire_bw_meter_leq()
1885 x->bm_measured.b_packets = 0; in expire_bw_meter_leq()
1886 mtx_unlock_spin(&x->bm_spin); in expire_bw_meter_leq()
1888 callout_schedule(&x->bm_meter_callout, tvtohz(&x->bm_threshold.b_time)); in expire_bw_meter_leq()
1910 if (!(req->bu_flags & (BW_UPCALL_UNIT_PACKETS | BW_UPCALL_UNIT_BYTES))) in add_bw_upcall()
1912 if (!(req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ))) in add_bw_upcall()
1914 if ((req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) == (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) in add_bw_upcall()
1918 if (BW_TIMEVALCMP(&req->bu_threshold.b_time, &delta, <)) in add_bw_upcall()
1927 mfc = mfc_find(&req->bu_src, &req->bu_dst); in add_bw_upcall()
1934 if (req->bu_flags & BW_UPCALL_GEQ) in add_bw_upcall()
1935 bwm_ptr = &mfc->mfc_bw_meter_geq; in add_bw_upcall()
1937 bwm_ptr = &mfc->mfc_bw_meter_leq; in add_bw_upcall()
1939 for (x = *bwm_ptr; x != NULL; x = x->bm_mfc_next) { in add_bw_upcall()
1940 if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, in add_bw_upcall()
1941 &req->bu_threshold.b_time, ==)) in add_bw_upcall()
1942 && (x->bm_threshold.b_packets in add_bw_upcall()
1943 == req->bu_threshold.b_packets) in add_bw_upcall()
1944 && (x->bm_threshold.b_bytes in add_bw_upcall()
1945 == req->bu_threshold.b_bytes) in add_bw_upcall()
1946 && (x->bm_flags & BW_METER_USER_FLAGS) in add_bw_upcall()
1961 x->bm_threshold.b_time = req->bu_threshold.b_time; in add_bw_upcall()
1963 x->bm_start_time = now; in add_bw_upcall()
1964 x->bm_threshold.b_packets = req->bu_threshold.b_packets; in add_bw_upcall()
1965 x->bm_threshold.b_bytes = req->bu_threshold.b_bytes; in add_bw_upcall()
1966 x->bm_measured.b_packets = 0; in add_bw_upcall()
1967 x->bm_measured.b_bytes = 0; in add_bw_upcall()
1968 x->bm_flags = flags; in add_bw_upcall()
1969 x->bm_time_next = NULL; in add_bw_upcall()
1970 x->bm_mfc = mfc; in add_bw_upcall()
1971 x->arg = curvnet; in add_bw_upcall()
1972 sprintf(x->bm_spin_name, "BM spin %p", x); in add_bw_upcall()
1973 mtx_init(&x->bm_spin, x->bm_spin_name, NULL, MTX_SPIN); in add_bw_upcall()
1976 if (req->bu_flags & BW_UPCALL_LEQ) { in add_bw_upcall()
1977 callout_init_rw(&x->bm_meter_callout, &mrouter_lock, CALLOUT_SHAREDLOCK); in add_bw_upcall()
1978 callout_reset(&x->bm_meter_callout, tvtohz(&x->bm_threshold.b_time), in add_bw_upcall()
1983 x->bm_mfc_next = *bwm_ptr; in add_bw_upcall()
1998 if (x->bm_flags & BW_METER_LEQ) { in free_bw_list()
1999 callout_drain(&x->bm_meter_callout); in free_bw_list()
2000 mtx_destroy(&x->bm_spin); in free_bw_list()
2003 list = list->bm_mfc_next; in free_bw_list()
2023 mfc = mfc_find(&req->bu_src, &req->bu_dst); in del_bw_upcall()
2027 } else if (req->bu_flags & BW_UPCALL_DELETE_ALL) { in del_bw_upcall()
2034 list = mfc->mfc_bw_meter_leq; in del_bw_upcall()
2035 mfc->mfc_bw_meter_leq = NULL; in del_bw_upcall()
2039 list = mfc->mfc_bw_meter_geq; in del_bw_upcall()
2040 mfc->mfc_bw_meter_geq = NULL; in del_bw_upcall()
2051 if (req->bu_flags & BW_UPCALL_GEQ) in del_bw_upcall()
2052 bwm_ptr = &mfc->mfc_bw_meter_geq; in del_bw_upcall()
2054 bwm_ptr = &mfc->mfc_bw_meter_leq; in del_bw_upcall()
2058 prev = x, x = x->bm_mfc_next) { in del_bw_upcall()
2059 if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, &req->bu_threshold.b_time, ==)) && in del_bw_upcall()
2060 (x->bm_threshold.b_packets == req->bu_threshold.b_packets) && in del_bw_upcall()
2061 (x->bm_threshold.b_bytes == req->bu_threshold.b_bytes) && in del_bw_upcall()
2062 (x->bm_flags & BW_METER_USER_FLAGS) == flags) in del_bw_upcall()
2067 prev->bm_mfc_next = x->bm_mfc_next; /* remove from middle*/ in del_bw_upcall()
2069 *bwm_ptr = x->bm_mfc_next;/* new head of list */ in del_bw_upcall()
2071 if (req->bu_flags & BW_UPCALL_LEQ) in del_bw_upcall()
2072 callout_stop(&x->bm_meter_callout); in del_bw_upcall()
2097 BW_TIMEVALDECR(&delta, &x->bm_start_time); in bw_meter_geq_receive_packet()
2104 if (BW_TIMEVALCMP(&delta, &x->bm_threshold.b_time, >)) { in bw_meter_geq_receive_packet()
2106 x->bm_start_time = *nowp; in bw_meter_geq_receive_packet()
2107 x->bm_measured.b_packets = 0; in bw_meter_geq_receive_packet()
2108 x->bm_measured.b_bytes = 0; in bw_meter_geq_receive_packet()
2109 x->bm_flags &= ~BW_METER_UPCALL_DELIVERED; in bw_meter_geq_receive_packet()
2113 x->bm_measured.b_packets++; in bw_meter_geq_receive_packet()
2114 x->bm_measured.b_bytes += plen; in bw_meter_geq_receive_packet()
2119 if (!(x->bm_flags & BW_METER_UPCALL_DELIVERED)) { in bw_meter_geq_receive_packet()
2120 if (((x->bm_flags & BW_METER_UNIT_PACKETS) && in bw_meter_geq_receive_packet()
2121 (x->bm_measured.b_packets >= x->bm_threshold.b_packets)) || in bw_meter_geq_receive_packet()
2122 ((x->bm_flags & BW_METER_UNIT_BYTES) && in bw_meter_geq_receive_packet()
2123 (x->bm_measured.b_bytes >= x->bm_threshold.b_bytes))) { in bw_meter_geq_receive_packet()
2126 x->bm_flags |= BW_METER_UPCALL_DELIVERED; in bw_meter_geq_receive_packet()
2132 * Prepare a bandwidth-related upcall
2146 BW_TIMEVALDECR(&delta, &x->bm_start_time); in bw_meter_prepare_upcall()
2156 u->bu_src = x->bm_mfc->mfc_origin; in bw_meter_prepare_upcall()
2157 u->bu_dst = x->bm_mfc->mfc_mcastgrp; in bw_meter_prepare_upcall()
2158 u->bu_threshold.b_time = x->bm_threshold.b_time; in bw_meter_prepare_upcall()
2159 u->bu_threshold.b_packets = x->bm_threshold.b_packets; in bw_meter_prepare_upcall()
2160 u->bu_threshold.b_bytes = x->bm_threshold.b_bytes; in bw_meter_prepare_upcall()
2161 u->bu_measured.b_time = delta; in bw_meter_prepare_upcall()
2162 u->bu_measured.b_packets = x->bm_measured.b_packets; in bw_meter_prepare_upcall()
2163 u->bu_measured.b_bytes = x->bm_measured.b_bytes; in bw_meter_prepare_upcall()
2164 u->bu_flags = 0; in bw_meter_prepare_upcall()
2165 if (x->bm_flags & BW_METER_UNIT_PACKETS) in bw_meter_prepare_upcall()
2166 u->bu_flags |= BW_UPCALL_UNIT_PACKETS; in bw_meter_prepare_upcall()
2167 if (x->bm_flags & BW_METER_UNIT_BYTES) in bw_meter_prepare_upcall()
2168 u->bu_flags |= BW_UPCALL_UNIT_BYTES; in bw_meter_prepare_upcall()
2169 if (x->bm_flags & BW_METER_GEQ) in bw_meter_prepare_upcall()
2170 u->bu_flags |= BW_UPCALL_GEQ; in bw_meter_prepare_upcall()
2171 if (x->bm_flags & BW_METER_LEQ) in bw_meter_prepare_upcall()
2172 u->bu_flags |= BW_UPCALL_LEQ; in bw_meter_prepare_upcall()
2181 * Send the pending bandwidth-related upcalls
2271 in_nullhost(rt->mfc_rp)) in pim_register_send()
2283 mb_copy = mm->m_nextpkt; in pim_register_send()
2284 mm->m_nextpkt = 0; in pim_register_send()
2288 if ((V_mrt_api_config & MRT_MFC_RP) && !in_nullhost(rt->mfc_rp)) { in pim_register_send()
2311 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { in pim_register_prepare()
2313 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; in pim_register_prepare()
2317 * Copy the old packet & pullup its IP header into the in pim_register_prepare()
2323 mb_copy = m_pullup(mb_copy, ip->ip_hl << 2); in pim_register_prepare()
2329 --ip->ip_ttl; in pim_register_prepare()
2332 mtu = 0xffff - sizeof(pim_encap_iphdr) - sizeof(pim_encap_pimhdr); in pim_register_prepare()
2334 if (ntohs(ip->ip_len) <= mtu) { in pim_register_prepare()
2336 ip->ip_sum = 0; in pim_register_prepare()
2337 ip->ip_sum = in_cksum(mb_copy, ip->ip_hl << 2); in pim_register_prepare()
2340 mb_copy->m_pkthdr.csum_flags |= CSUM_IP; in pim_register_prepare()
2350 * Send an upcall with the data packet to the user-level process.
2357 int len = ntohs(ip->ip_len); in pim_register_send_upcall()
2371 mb_first->m_data += max_linkhdr; in pim_register_send_upcall()
2372 mb_first->m_pkthdr.len = len + sizeof(struct igmpmsg); in pim_register_send_upcall()
2373 mb_first->m_len = sizeof(struct igmpmsg); in pim_register_send_upcall()
2374 mb_first->m_next = mb_copy; in pim_register_send_upcall()
2378 im->im_msgtype = IGMPMSG_WHOLEPKT; in pim_register_send_upcall()
2379 im->im_mbz = 0; in pim_register_send_upcall()
2380 im->im_vif = vifp - V_viftable; in pim_register_send_upcall()
2381 im->im_src = ip->ip_src; in pim_register_send_upcall()
2382 im->im_dst = ip->ip_dst; in pim_register_send_upcall()
2384 k_igmpsrc.sin_addr = ip->ip_src; in pim_register_send_upcall()
2411 int len = ntohs(ip->ip_len); in pim_register_send_rp()
2412 vifi_t vifi = rt->mfc_parent; in pim_register_send_rp()
2429 mb_first->m_data += max_linkhdr; in pim_register_send_rp()
2430 mb_first->m_len = sizeof(pim_encap_iphdr) + sizeof(pim_encap_pimhdr); in pim_register_send_rp()
2431 mb_first->m_next = mb_copy; in pim_register_send_rp()
2433 mb_first->m_pkthdr.len = len + mb_first->m_len; in pim_register_send_rp()
2440 ip_outer->ip_len = htons(len + sizeof(pim_encap_iphdr) + in pim_register_send_rp()
2442 ip_outer->ip_src = V_viftable[vifi].v_lcl_addr; in pim_register_send_rp()
2443 ip_outer->ip_dst = rt->mfc_rp; in pim_register_send_rp()
2448 ip_outer->ip_tos = ip->ip_tos; in pim_register_send_rp()
2449 if (ip->ip_off & htons(IP_DF)) in pim_register_send_rp()
2450 ip_outer->ip_off |= htons(IP_DF); in pim_register_send_rp()
2455 /* If the iif crosses a border, set the Border-bit */ in pim_register_send_rp()
2456 if (rt->mfc_flags[vifi] & MRT_MFC_FLAGS_BORDER_VIF & V_mrt_api_config) in pim_register_send_rp()
2457 pimhdr->flags |= htonl(PIM_BORDER_REGISTER); in pim_register_send_rp()
2459 mb_first->m_data += sizeof(pim_encap_iphdr); in pim_register_send_rp()
2460 pimhdr->pim.pim_cksum = in_cksum(mb_first, sizeof(pim_encap_pimhdr)); in pim_register_send_rp()
2461 mb_first->m_data -= sizeof(pim_encap_iphdr); in pim_register_send_rp()
2487 * PIM-SMv2 and PIM-DM messages processing.
2491 * (used by PIM-SM): the PIM header is stripped off, and the inner packet
2501 int datalen = ntohs(ip->ip_len) - iphlen; in pim_input()
2514 __func__, datalen, ntohl(ip->ip_src.s_addr)); in pim_input()
2532 if (m->m_len < minlen && (m = m_pullup(m, minlen)) == NULL) { in pim_input()
2539 ip_tos = ip->ip_tos; in pim_input()
2542 m->m_data += iphlen; in pim_input()
2543 m->m_len -= iphlen; in pim_input()
2553 if (PIM_VT_T(pim->pim_vt) == PIM_REGISTER && in_cksum(m, PIM_MINLEN) == 0) { in pim_input()
2563 if (PIM_VT_V(pim->pim_vt) < PIM_VERSION) { in pim_input()
2566 (int)PIM_VT_V(pim->pim_vt), PIM_VERSION); in pim_input()
2572 m->m_data -= iphlen; in pim_input()
2573 m->m_len += iphlen; in pim_input()
2575 if (PIM_VT_T(pim->pim_vt) == PIM_REGISTER) { in pim_input()
2614 __func__, ntohl(encap_ip->ip_src.s_addr), in pim_input()
2615 ntohs(encap_ip->ip_len)); in pim_input()
2618 if (encap_ip->ip_v != IPVERSION) { in pim_input()
2626 if (!IN_MULTICAST(ntohl(encap_ip->ip_dst.s_addr))) { in pim_input()
2629 ntohl(encap_ip->ip_dst.s_addr)); in pim_input()
2641 if (encap_ip->ip_tos != ip_tos) { in pim_input()
2642 /* Outer TOS -> inner TOS */ in pim_input()
2643 encap_ip->ip_tos = ip_tos; in pim_input()
2647 m->m_data += (iphlen + PIM_MINLEN); in pim_input()
2648 m->m_len -= (iphlen + PIM_MINLEN); in pim_input()
2650 encap_ip->ip_sum = 0; in pim_input()
2651 encap_ip->ip_sum = in_cksum(m, encap_ip->ip_hl << 2); in pim_input()
2654 m->m_data -= (iphlen + PIM_MINLEN); in pim_input()
2655 m->m_len += (iphlen + PIM_MINLEN); in pim_input()
2664 * XXX: here m->m_data points to the outer IP header. in pim_input()
2676 PIMSTAT_ADD(pims_rcv_registers_bytes, ntohs(encap_ip->ip_len)); in pim_input()
2686 (u_long)ntohl(encap_ip->ip_src.s_addr), in pim_input()
2687 (u_long)ntohl(encap_ip->ip_dst.s_addr), in pim_input()
2701 * outer IP header, PIM header, PIM-Register header and the in pim_input()
2715 if (req->newptr) in sysctl_mfctable()
2746 if (req->newptr) in sysctl_viflist()
2755 /* Copy out user-visible portion of vif entry. */ in sysctl_viflist()
2847 * Typically module unload happens after the user-level in ip_mroute_modevent()