Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/ip6_mroute.c
| Show First 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | |||||
| * Hash function for a source, group entry | * Hash function for a source, group entry | ||||
| */ | */ | ||||
| #define MF6CHASH(a, g) MF6CHASHMOD((a).s6_addr32[0] ^ (a).s6_addr32[1] ^ \ | #define MF6CHASH(a, g) MF6CHASHMOD((a).s6_addr32[0] ^ (a).s6_addr32[1] ^ \ | ||||
| (a).s6_addr32[2] ^ (a).s6_addr32[3] ^ \ | (a).s6_addr32[2] ^ (a).s6_addr32[3] ^ \ | ||||
| (g).s6_addr32[0] ^ (g).s6_addr32[1] ^ \ | (g).s6_addr32[0] ^ (g).s6_addr32[1] ^ \ | ||||
| (g).s6_addr32[2] ^ (g).s6_addr32[3]) | (g).s6_addr32[2] ^ (g).s6_addr32[3]) | ||||
| /* | /* | ||||
| * Find a route for a given origin IPv6 address and Multicast group address. | |||||
| */ | |||||
| #define MF6CFIND(o, g, rt) do { \ | |||||
| struct mf6c *_rt = mf6ctable[MF6CHASH(o,g)]; \ | |||||
| rt = NULL; \ | |||||
| while (_rt) { \ | |||||
| if (IN6_ARE_ADDR_EQUAL(&_rt->mf6c_origin.sin6_addr, &(o)) && \ | |||||
| IN6_ARE_ADDR_EQUAL(&_rt->mf6c_mcastgrp.sin6_addr, &(g)) && \ | |||||
| (_rt->mf6c_stall == NULL)) { \ | |||||
| rt = _rt; \ | |||||
| break; \ | |||||
| } \ | |||||
| _rt = _rt->mf6c_next; \ | |||||
| } \ | |||||
| if (rt == NULL) { \ | |||||
| MRT6STAT_INC(mrt6s_mfc_misses); \ | |||||
| } \ | |||||
| } while (/*CONSTCOND*/ 0) | |||||
| /* | |||||
| * Macros to compute elapsed time efficiently | * Macros to compute elapsed time efficiently | ||||
| * Borrowed from Van Jacobson's scheduling code | * Borrowed from Van Jacobson's scheduling code | ||||
| * XXX: replace with timersub() ? | * XXX: replace with timersub() ? | ||||
| */ | */ | ||||
| #define TV_DELTA(a, b, delta) do { \ | #define TV_DELTA(a, b, delta) do { \ | ||||
| int xxs; \ | int xxs; \ | ||||
| \ | \ | ||||
| delta = (a).tv_usec - (b).tv_usec; \ | delta = (a).tv_usec - (b).tv_usec; \ | ||||
| Show All 33 Lines | |||||
| static struct callout expire_upcalls_ch; | static struct callout expire_upcalls_ch; | ||||
| static int X_ip6_mforward(struct ip6_hdr *, struct ifnet *, struct mbuf *); | static int X_ip6_mforward(struct ip6_hdr *, struct ifnet *, struct mbuf *); | ||||
| static int X_ip6_mrouter_done(void); | static int X_ip6_mrouter_done(void); | ||||
| static int X_ip6_mrouter_set(struct socket *, struct sockopt *); | static int X_ip6_mrouter_set(struct socket *, struct sockopt *); | ||||
| static int X_ip6_mrouter_get(struct socket *, struct sockopt *); | static int X_ip6_mrouter_get(struct socket *, struct sockopt *); | ||||
| static int X_mrt6_ioctl(u_long, caddr_t); | static int X_mrt6_ioctl(u_long, caddr_t); | ||||
| static struct mf6c * | |||||
| mf6c_find(const struct in6_addr *origin, const struct in6_addr *group) | |||||
glebius: I'd suggest to use more meaningful names like `origin` and `group`, or `orig` and `grp`. | |||||
Done Inline ActionsSure, I made the change locally. markj: Sure, I made the change locally. | |||||
| { | |||||
| MFC6_LOCK_ASSERT(); | |||||
| for (struct mf6c *rt = mf6ctable[MF6CHASH(*origin, *group)]; rt != NULL; | |||||
| rt = rt->mf6c_next) { | |||||
| if (IN6_ARE_ADDR_EQUAL(&rt->mf6c_origin.sin6_addr, origin) && | |||||
| IN6_ARE_ADDR_EQUAL(&rt->mf6c_mcastgrp.sin6_addr, group) && | |||||
| rt->mf6c_stall == NULL) | |||||
| return (rt); | |||||
| } | |||||
| MRT6STAT_INC(mrt6s_mfc_misses); | |||||
| return (NULL); | |||||
| } | |||||
| /* | /* | ||||
| * Handle MRT setsockopt commands to modify the multicast routing tables. | * Handle MRT setsockopt commands to modify the multicast routing tables. | ||||
| */ | */ | ||||
| static int | static int | ||||
| X_ip6_mrouter_set(struct socket *so, struct sockopt *sopt) | X_ip6_mrouter_set(struct socket *so, struct sockopt *sopt) | ||||
| { | { | ||||
| int error = 0; | int error = 0; | ||||
| int optval; | int optval; | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| struct mf6c *rt; | struct mf6c *rt; | ||||
| int ret; | int ret; | ||||
| ret = 0; | ret = 0; | ||||
| MFC6_LOCK(); | MFC6_LOCK(); | ||||
| MF6CFIND(req->src.sin6_addr, req->grp.sin6_addr, rt); | rt = mf6c_find(&req->src.sin6_addr, &req->grp.sin6_addr); | ||||
| if (rt == NULL) { | if (rt == NULL) { | ||||
| ret = ESRCH; | ret = ESRCH; | ||||
| } else { | } else { | ||||
| req->pktcnt = rt->mf6c_pkt_cnt; | req->pktcnt = rt->mf6c_pkt_cnt; | ||||
| req->bytecnt = rt->mf6c_byte_cnt; | req->bytecnt = rt->mf6c_byte_cnt; | ||||
| req->wrong_if = rt->mf6c_wrong_if; | req->wrong_if = rt->mf6c_wrong_if; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | add_m6fc(struct mf6cctl *mfccp) | ||||
| struct mf6c *rt; | struct mf6c *rt; | ||||
| u_long hash; | u_long hash; | ||||
| struct rtdetq *rte; | struct rtdetq *rte; | ||||
| u_short nstl; | u_short nstl; | ||||
| char ip6bufo[INET6_ADDRSTRLEN], ip6bufg[INET6_ADDRSTRLEN]; | char ip6bufo[INET6_ADDRSTRLEN], ip6bufg[INET6_ADDRSTRLEN]; | ||||
| MFC6_LOCK(); | MFC6_LOCK(); | ||||
| MF6CFIND(mfccp->mf6cc_origin.sin6_addr, | rt = mf6c_find(&mfccp->mf6cc_origin.sin6_addr, | ||||
| mfccp->mf6cc_mcastgrp.sin6_addr, rt); | &mfccp->mf6cc_mcastgrp.sin6_addr); | ||||
| /* If an entry already exists, just update the fields */ | /* If an entry already exists, just update the fields */ | ||||
| if (rt) { | if (rt) { | ||||
| MRT6_DLOG(DEBUG_MFC, "no upcall o %s g %s p %x", | MRT6_DLOG(DEBUG_MFC, "no upcall o %s g %s p %x", | ||||
| ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr), | ip6_sprintf(ip6bufo, &mfccp->mf6cc_origin.sin6_addr), | ||||
| ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr), | ip6_sprintf(ip6bufg, &mfccp->mf6cc_mcastgrp.sin6_addr), | ||||
| mfccp->mf6cc_parent); | mfccp->mf6cc_parent); | ||||
| rt->mf6c_parent = mfccp->mf6cc_parent; | rt->mf6c_parent = mfccp->mf6cc_parent; | ||||
| ▲ Show 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) { | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| MFC6_LOCK(); | MFC6_LOCK(); | ||||
| /* | /* | ||||
| * Determine forwarding mifs from the forwarding cache table | * Determine forwarding mifs from the forwarding cache table | ||||
| */ | */ | ||||
| MF6CFIND(ip6->ip6_src, ip6->ip6_dst, rt); | rt = mf6c_find(&ip6->ip6_src, &ip6->ip6_dst); | ||||
| MRT6STAT_INC(mrt6s_mfc_lookups); | MRT6STAT_INC(mrt6s_mfc_lookups); | ||||
| /* Entry exists, so forward if necessary */ | /* Entry exists, so forward if necessary */ | ||||
| if (rt) { | if (rt) { | ||||
| MFC6_UNLOCK(); | MFC6_UNLOCK(); | ||||
| return (ip6_mdq(m, ifp, rt)); | return (ip6_mdq(m, ifp, rt)); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 822 Lines • Show Last 20 Lines | |||||
I'd suggest to use more meaningful names like origin and group, or orig and grp.