Lines Matching refs:ipnet
32 * The ipnet device defined here provides access to packets at the IP layer. To
39 * Management of the devices in /dev/ipnet/ is handled by the devname
42 * taken down etc. the ipnet module is notified and its view of the interfaces
73 #include <inet/ipnet.h>
80 "ipnet", /* mi_idname */
205 "STREAMS ipnet driver",
269 if ((ipnet_major = ddi_name_to_major("ipnet")) == (major_t)-1)
280 ipnet_taskq = ddi_taskq_create(NULL, "ipnet", 1, TASKQ_DEFAULTPRI, 0);
368 ips->ips_kstatp = net_kstat_create(netid, "ipnet", 0, "ipnet_stats",
380 "ipnet", "ipnet_stats", "misc");
387 * for IPv6, although there is only one ipnet interface for both IPv4
510 ipnet_t *ipnet;
531 if ((ipnet = kmem_zalloc(sizeof (*ipnet), KM_NOSLEEP)) == NULL)
537 rq->q_ptr = WR(rq)->q_ptr = ipnet;
538 ipnet->ipnet_rq = rq;
539 ipnet->ipnet_minor = (minor_t)id_alloc(ipnet_minor_space);
540 ipnet->ipnet_zoneid = zoneid;
541 ipnet->ipnet_dlstate = DL_UNBOUND;
542 ipnet->ipnet_ns = ns;
551 ipnet->ipnet_flags |= IPNET_LOMODE;
552 ipnet->ipnet_acceptfn = ipnet_loaccept;
554 ipnet->ipnet_acceptfn = ipnet_accept;
555 ipnet->ipnet_if = ipnetif_getby_dev(*dev, ips);
556 if (ipnet->ipnet_if == NULL ||
557 !ipnetif_in_zone(ipnet->ipnet_if, zoneid, ips)) {
566 list_insert_head(&ips->ips_str_list, ipnet);
567 *dev = makedevice(getmajor(*dev), ipnet->ipnet_minor);
582 id_free(ipnet_minor_space, ipnet->ipnet_minor);
583 if (ipnet->ipnet_if != NULL)
584 ipnetif_refrele(ipnet->ipnet_if);
585 kmem_free(ipnet, sizeof (*ipnet));
593 ipnet_t *ipnet = rq->q_ptr;
594 ipnet_stack_t *ips = ipnet->ipnet_ns->netstack_ipnet;
596 if (ipnet->ipnet_flags & IPNET_PROMISC_PHYS)
597 ipnet_leave_allmulti(ipnet->ipnet_if, ips);
598 if (ipnet->ipnet_flags & IPNET_PROMISC_MULTI)
599 ipnet_leave_allmulti(ipnet->ipnet_if, ips);
607 list_remove(&ips->ips_str_list, ipnet);
608 if (ipnet->ipnet_if != NULL)
609 ipnetif_refrele(ipnet->ipnet_if);
610 id_free(ipnet_minor_space, ipnet->ipnet_minor);
617 kmem_free(ipnet, sizeof (*ipnet));
698 ipnet_t *ipnet = q->q_ptr;
703 ipnet->ipnet_flags |= IPNET_INFO;
705 ipnet->ipnet_flags &= ~IPNET_INFO;
777 ipnet_t *ipnet = q->q_ptr;
786 ipnet->ipnet_family = AF_UNSPEC;
789 ipnet->ipnet_family = AF_INET;
792 ipnet->ipnet_family = AF_INET6;
800 ipnet->ipnet_dlstate = DL_IDLE;
807 ipnet_t *ipnet = q->q_ptr;
814 if (ipnet->ipnet_dlstate != DL_IDLE) {
817 ipnet->ipnet_dlstate = DL_UNBOUND;
818 ipnet->ipnet_family = AF_UNSPEC;
826 ipnet_t *ipnet = q->q_ptr;
835 if (ipnet->ipnet_flags & IPNET_LOMODE) {
842 if ((err = ipnet_join_allmulti(ipnet->ipnet_if,
843 ipnet->ipnet_ns->netstack_ipnet)) != 0) {
851 ipnet->ipnet_flags |= IPNET_PROMISC_PHYS;
854 ipnet->ipnet_flags |= IPNET_PROMISC_SAP;
857 ipnet->ipnet_flags |= IPNET_PROMISC_MULTI;
870 ipnet_t *ipnet = q->q_ptr;
872 uint16_t orig_ipnet_flags = ipnet->ipnet_flags;
879 if (ipnet->ipnet_flags & IPNET_LOMODE) {
887 if (ipnet->ipnet_flags & IPNET_PROMISC_PHYS)
888 ipnet->ipnet_flags &= ~IPNET_PROMISC_PHYS;
891 if (ipnet->ipnet_flags & IPNET_PROMISC_SAP)
892 ipnet->ipnet_flags &= ~IPNET_PROMISC_SAP;
895 if (ipnet->ipnet_flags & IPNET_PROMISC_MULTI)
896 ipnet->ipnet_flags &= ~IPNET_PROMISC_MULTI;
903 if (orig_ipnet_flags == ipnet->ipnet_flags) {
909 ipnet_leave_allmulti(ipnet->ipnet_if,
910 ipnet->ipnet_ns->netstack_ipnet);
1007 ipnet_get_addrtype(ipnet_t *ipnet, ipnet_addrp_t *addr)
1010 ipnetif_t *ipnetif = ipnet->ipnet_if;
1041 if (ipnet->ipnet_zoneid != GLOBAL_ZONEID &&
1042 ipnet->ipnet_zoneid != ifaddr->ifa_zone)
1067 * ipnet client stream.
1070 ipnet_accept(ipnet_t *ipnet, hook_pkt_observe_t *hdr, ipnet_addrp_t *src,
1074 uint64_t ifindex = ipnet->ipnet_if->if_index;
1078 srctype = ipnet_get_addrtype(ipnet, src);
1079 dsttype = ipnet_get_addrtype(ipnet, dst);
1095 * Do not allow an ipnet stream to see packets that are not from or to
1101 if (ipnet->ipnet_zoneid != GLOBAL_ZONEID &&
1103 if (ipnet->ipnet_zoneid != ntohl(hdr->hpo_zsrc) &&
1104 ipnet->ipnet_zoneid != ntohl(hdr->hpo_zdst))
1112 if (!(ipnet->ipnet_flags & IPNET_PROMISC_SAP) &&
1113 ipnet->ipnet_family != hdr->hpo_family)
1125 if (ipnet->ipnet_flags & IPNET_PROMISC_PHYS) {
1141 * Verify if the packet contained in hdr should be passed up to the ipnet
1146 ipnet_loaccept(ipnet_t *ipnet, hook_pkt_observe_t *hdr, ipnet_addrp_t *src,
1153 if (ipnet->ipnet_if == NULL)
1158 * An ipnet stream must not see packets that are not from/to its zone.
1160 if (ipnet->ipnet_zoneid != GLOBAL_ZONEID) {
1161 if (ipnet->ipnet_zoneid != ntohl(hdr->hpo_zsrc) &&
1162 ipnet->ipnet_zoneid != ntohl(hdr->hpo_zdst))
1166 return (ipnet->ipnet_family == AF_UNSPEC ||
1167 ipnet->ipnet_family == hdr->hpo_family);
1175 ipnet_t *ipnet;
1199 for (ipnet = list_head(list); ipnet != NULL;
1200 ipnet = list_next(list, ipnet)) {
1201 if (!(*ipnet->ipnet_acceptfn)(ipnet, hdr, &src, &dst)) {
1207 if (list_next(list, ipnet) == NULL) {
1218 if (ipnet->ipnet_flags & IPNET_INFO) {
1225 if (ipnet->ipnet_rq->q_first == NULL &&
1226 canputnext(ipnet->ipnet_rq)) {
1227 putnext(ipnet->ipnet_rq, netmp);
1229 } else if (canput(ipnet->ipnet_rq)) {
1230 (void) putq(ipnet->ipnet_rq, netmp);
1327 ipnet_t *ipnet;
1331 for (ipnet = list_head(&ips->ips_str_list); ipnet != NULL;
1332 ipnet = list_next(&ips->ips_str_list, ipnet)) {
1333 if (ipnet->ipnet_if == ipnetif)
1334 (void) putnextctl(ipnet->ipnet_rq, M_HANGUP);
1809 ipnet_t *ipnet;
1812 for (ipnet = list_head(strlist); ipnet != NULL;
1813 ipnet = list_next(strlist, ipnet)) {
1814 if (ipnet->ipnet_if != ipnetif)
1816 if (!ipnetif_in_zone(ipnetif, ipnet->ipnet_zoneid, ips))
1817 (void) putnextctl(ipnet->ipnet_rq, M_HANGUP);
1833 * in /dev/ipnet.
2042 * The list of interfaces available via ipnet is private for each zone,
2098 * working with the ipnet interfaces and hence the ips_event_lock is held.
2100 * in ipnet, and thus ipnet holds the ips_event_lock. Thus the datalink id
2138 * Strictly speaking, there is no such thing as a "client" in ipnet, like
2164 * from ipnet.
2183 ipnet_t *ipnet;
2199 ipnet = kmem_zalloc(sizeof (*ipnet), KM_SLEEP);
2200 ipnet->ipnet_if = ifp;
2201 ipnet->ipnet_ns = ns;
2202 ipnet->ipnet_flags = flags;
2205 ipnet->ipnet_acceptfn = ipnet_loaccept;
2207 ipnet->ipnet_acceptfn = ipnet_accept;
2214 HOOK_INIT(ipnet->ipnet_hook, ipnet_bpf_bounce, "", ipnet);
2216 (void *)ipnet->ipnet_hook);
2217 ipnet->ipnet_hook->h_name = strdup(name);
2218 ipnet->ipnet_data = data;
2219 ipnet->ipnet_zoneid = ifp->if_zoneid;
2224 ipnet->ipnet_hook);
2229 ipnet->ipnet_hook);
2232 NH_OBSERVE, ipnet->ipnet_hook);
2236 *mhandle = (uintptr_t)ipnet;
2243 strfree(ipnet->ipnet_hook->h_name);
2244 hook_free(ipnet->ipnet_hook);
2253 ipnet_t *ipnet;
2256 ipnet = data;
2257 ipst = ipnet->ipnet_ns->netstack_ip;
2258 hook = ipnet->ipnet_hook;
2270 kmem_free(ipnet, sizeof (*ipnet));
2290 ipnet_t *ipnet;
2296 ipnet = (ipnet_t *)arg;
2311 if (!(*ipnet->ipnet_acceptfn)(ipnet, hdr, &src, &dst)) {
2317 ipnet_itap(ipnet->ipnet_data, mp,
2331 * shared instance zones, this means the ipnet driver needs to detect